From adc211e39957b4dba3f9c695f4c7f745b4cbd586 Mon Sep 17 00:00:00 2001 From: hugova Date: Fri, 1 Aug 2025 20:13:07 +0200 Subject: [PATCH] rewrite arithmatic tests. --- host/src/routines/arithmatic/div_test.s | 16 +++++-- host/src/routines/arithmatic/div_test_zero.s | 18 ------- host/src/routines/arithmatic/mult_test.s | 13 +++++- host/src/test.s | 49 -------------------- 4 files changed, 23 insertions(+), 73 deletions(-) delete mode 100644 host/src/routines/arithmatic/div_test_zero.s delete mode 100644 host/src/test.s diff --git a/host/src/routines/arithmatic/div_test.s b/host/src/routines/arithmatic/div_test.s index d904295..fc29dbb 100644 --- a/host/src/routines/arithmatic/div_test.s +++ b/host/src/routines/arithmatic/div_test.s @@ -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 diff --git a/host/src/routines/arithmatic/div_test_zero.s b/host/src/routines/arithmatic/div_test_zero.s deleted file mode 100644 index 870a5d8..0000000 --- a/host/src/routines/arithmatic/div_test_zero.s +++ /dev/null @@ -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 diff --git a/host/src/routines/arithmatic/mult_test.s b/host/src/routines/arithmatic/mult_test.s index 8c4d682..3ada2dc 100644 --- a/host/src/routines/arithmatic/mult_test.s +++ b/host/src/routines/arithmatic/mult_test.s @@ -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 diff --git a/host/src/test.s b/host/src/test.s deleted file mode 100644 index 467ca40..0000000 --- a/host/src/test.s +++ /dev/null @@ -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"