rewrite arithmatic tests.

This commit is contained in:
hugova 2025-08-01 20:13:07 +02:00
parent eff01e5411
commit adc211e399
4 changed files with 23 additions and 73 deletions

View file

@ -6,21 +6,29 @@
.scope div_test
A_temp = $4043
.include "arithmatic.inc"
.repeat $16, i
.repeat $16, j
.repeat $17, i
.repeat $17, j
;INC $400D ;; print number of iterations on screen.
LDX #i
STX VAL_A
STX A_temp
LDY #(j+1)
LDY #j
STY VAL_B
JSR div ; A = VAL_A / VAL_B, clobers X.
CMP #i/(j+1)
.if j <> 0 ;; This is undefined, should not get stuck in loop, dont care about result!
CMP #i/j
BEQ :+
jmp error
:
.endif
.endrepeat
.endrepeat
no_error:
;; All good make screen green.
;; If not red or green, then we have infinate loop in mult.
LDX #$05
STX $D020
jmp end
error:
;; Error make screen read

View file

@ -1,18 +0,0 @@
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
;; Test if division with 0 is not stuck in infinate loop.
.scope div_test_zero
.include "arithmatic.inc"
.repeat $FF, i
INC $400D ;; print number of iterations on screen.
LDX #i
STX VAL_A
LDA #$00
STA VAL_B
JSR div ; A = VAL_A / VAL_B, clobers X.
.endrepeat
paint:
;; Done, make screen green
LDA #$05
STA $D020
.endscope

View file

@ -6,8 +6,8 @@
A_temp = $4043
B_temp = $4046
.include "arithmatic.inc"
.repeat $0F, i
.repeat $0F, j
.repeat $13, i
.repeat $13, j
INC $400D ;; print number of iterations on screen.
LDX #i
STX VAL_A
@ -17,12 +17,21 @@
STY B_temp
JSR mult; A = VAL_A * VAL_B, clobers X.
.if i*j <= $ff ;; we will not check correct behaviour if overflow.
CMP #i*j
BEQ :+
jmp error
:
.endif
.endrepeat
.endrepeat
no_error:
;; All good make screen green.
;; If not red or green, then we have infinate loop in mult.
LDX #$05
STX $D020
jmp end
error:
;; Error make screen read

View file

@ -1,49 +0,0 @@
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
.debuginfo + ; Generate debug info
.org $080D
;;Macros
.include "macros/16aritmatic.s"
;;inc files
.include "routines/memory/mem.inc"
;;Code to run
.include "STARTUP.s"
;; WIP, do not use.
;.include "dubbel_buffer/raster_irqs.s"
mainsetup:
;; Note that arithmetic tests may use upp all the memory and the compiler don't complain!
;.include "routines/arithmatic/mult_test.s"
;.include "routines/arithmatic/div_test.s"
;.include "routines/arithmatic/div_test_zero.s"
.include "routines/circle/circle_test.s"
.include "routines/circle/circle_test_size.s"
.include "routines/circle/circle_test_position.s"
;.include "routines/line/line_test.s"
;.include "routines/line/line_test_extensive.s"
;.include "routines/text/char_draw_test.s"
;.include "routines/pixel/pixel_test.s"
;.include "routines/memory/memcpy_test.s"
;.include "routines/memory/memset_test.s"
;.include "routines/triangle/triangle_test.s"
exit:
JMP exit
.include "public.inc"
;.include "routines/line/line.s"
.include "routines/circle/circle.s"
;.include "routines/triangle/triangle.s"
.include "routines/pixel/pixel_draw.s"
.include "routines/pixel/pixel_calc.s"
;.include "routines/pixel/misc_pixel.s"
;.include "routines/text/char_draw.s"
.include "routines/memory/memset.s"
.include "routines/memory/clear_screen.s"
;.include "routines/memory/memcpy.s"
;.include "routines/arithmatic/mult.s"
.include "routines/arithmatic/div.s"
.include "lookup_tables.s"
.include "END.s"