fix test that test most multiplications. Also fix multiplication 0*0 bugg.
This commit is contained in:
parent
0f80ba10ef
commit
0e3ebe487c
2 changed files with 36 additions and 7 deletions
|
@ -11,8 +11,13 @@
|
|||
|
||||
.include "arithmatic.inc"
|
||||
|
||||
LDA #$00
|
||||
JMP start
|
||||
LDA #$00 ;; A = value to return.
|
||||
|
||||
;; 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:
|
||||
ASL VAL_B
|
||||
start:
|
||||
|
|
|
@ -1,10 +1,34 @@
|
|||
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||
;;Calculates $11 * $0E = $EE
|
||||
.scope mult_test
|
||||
A_temp = $4043
|
||||
B_temp = $4046
|
||||
.include "arithmatic.inc"
|
||||
LDA #$0F
|
||||
STA VAL_A
|
||||
LDA #$07
|
||||
STA VAL_B
|
||||
JSR mult; A = $69 if it works as it should
|
||||
.repeat $0F, i ;; $15 = floor(sqrt($255))
|
||||
;; now i * j_max = $FF --> j_max = $FF/i
|
||||
.repeat $0F, j
|
||||
INC $400D ;; print number of iterations on screen.
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue