fix testing for divition and add doc.. for mult..
This commit is contained in:
parent
4cddb13ba8
commit
f647c68edf
3 changed files with 58 additions and 9 deletions
|
@ -1,10 +1,37 @@
|
||||||
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||||
;;Calculates $EE /$05 = $33
|
|
||||||
|
;; Note that the compile dont understand if its out of mem.
|
||||||
|
;; Please run without linking other stuff. thats also why some code is commented out.
|
||||||
|
;; Add it back in for debugging!
|
||||||
.scope div_test
|
.scope div_test
|
||||||
|
A_temp = $4043
|
||||||
.include "arithmatic.inc"
|
.include "arithmatic.inc"
|
||||||
LDA #$05
|
.repeat $16, i
|
||||||
STA VAL_A
|
.repeat $16, j
|
||||||
LDA #$02
|
;INC $400D ;; print number of iterations on screen.
|
||||||
STA VAL_B
|
LDX #i
|
||||||
JSR div; X = $02 if it works as it should
|
STX VAL_A
|
||||||
|
STX A_temp
|
||||||
|
LDY #(j+1)
|
||||||
|
STY VAL_B
|
||||||
|
JSR div ; A = VAL_A / VAL_B, clobers X.
|
||||||
|
CPX #i/(j+1)
|
||||||
|
BEQ :+
|
||||||
|
jmp error
|
||||||
|
:
|
||||||
|
.endrepeat
|
||||||
|
.endrepeat
|
||||||
|
TXA
|
||||||
|
jmp end
|
||||||
|
error:
|
||||||
|
TXA
|
||||||
|
;; Error make screen read
|
||||||
|
;; X * Y has the result in A that is wrong.
|
||||||
|
LDX #$02
|
||||||
|
STX $D020
|
||||||
|
end:
|
||||||
|
LDX A_temp
|
||||||
|
; X = VAL_A
|
||||||
|
; Y = VAL_B
|
||||||
|
; A = awnser.
|
||||||
.endscope
|
.endscope
|
||||||
|
|
18
host/src/routines/arithmatic/div_test_zero.s
Normal file
18
host/src/routines/arithmatic/div_test_zero.s
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
;;; -*- 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:
|
||||||
|
;; Donw make screen green
|
||||||
|
LDA #$13
|
||||||
|
STA $D020
|
||||||
|
.endscope
|
|
@ -1,11 +1,12 @@
|
||||||
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||||
;;Calculates $11 * $0E = $EE
|
|
||||||
|
;; Note that the compile dont understand if its out of mem.
|
||||||
|
;; Please run without linking other stuff. thats also why some code is commented out.
|
||||||
.scope mult_test
|
.scope mult_test
|
||||||
A_temp = $4043
|
A_temp = $4043
|
||||||
B_temp = $4046
|
B_temp = $4046
|
||||||
.include "arithmatic.inc"
|
.include "arithmatic.inc"
|
||||||
.repeat $0F, i ;; $15 = floor(sqrt($255))
|
.repeat $0F, i
|
||||||
;; now i * j_max = $FF --> j_max = $FF/i
|
|
||||||
.repeat $0F, j
|
.repeat $0F, j
|
||||||
INC $400D ;; print number of iterations on screen.
|
INC $400D ;; print number of iterations on screen.
|
||||||
LDX #i
|
LDX #i
|
||||||
|
@ -31,4 +32,7 @@ error:
|
||||||
end:
|
end:
|
||||||
LDX A_temp
|
LDX A_temp
|
||||||
LDY B_temp
|
LDY B_temp
|
||||||
|
; X = VAL_A
|
||||||
|
; Y = VAL_B
|
||||||
|
; A = awnser.
|
||||||
.endscope
|
.endscope
|
||||||
|
|
Loading…
Add table
Reference in a new issue