fix test that test most multiplications. Also fix multiplication 0*0 bugg.

This commit is contained in:
hugova 2025-07-31 21:53:55 +02:00
parent 0f80ba10ef
commit 0e3ebe487c
2 changed files with 36 additions and 7 deletions

View file

@ -11,8 +11,13 @@
.include "arithmatic.inc" .include "arithmatic.inc"
LDA #$00 LDA #$00 ;; A = value to return.
JMP start
;; 0 * 0 will never terminate so we need to fix this.
LDX VAL_A
BNE start
;; Now we have 0 * something. Instead of handeling [something = 0] we are more general and always return 0.
RTS ;; returning A = 0.
loop: loop:
ASL VAL_B ASL VAL_B
start: start:

View file

@ -1,10 +1,34 @@
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- ;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
;;Calculates $11 * $0E = $EE ;;Calculates $11 * $0E = $EE
.scope mult_test .scope mult_test
A_temp = $4043
B_temp = $4046
.include "arithmatic.inc" .include "arithmatic.inc"
LDA #$0F .repeat $0F, i ;; $15 = floor(sqrt($255))
STA VAL_A ;; now i * j_max = $FF --> j_max = $FF/i
LDA #$07 .repeat $0F, j
STA VAL_B INC $400D ;; print number of iterations on screen.
JSR mult; A = $69 if it works as it should LDX #i
STX VAL_A
STX A_temp
LDY #j
STY VAL_B
STY B_temp
JSR mult; A = VAL_A * VAL_B, clobers X.
CMP #i*j
BEQ :+
jmp error
:
.endrepeat
.endrepeat
jmp end
error:
;; Error make screen read
;; X * Y has the result in A that is wrong.
LDX #$02
STX $D020
end:
LDX A_temp
LDY B_temp
.endscope .endscope