Merge pull request #98 from rikardn/div10_fix

Fix broken div10_FAC1
This commit is contained in:
FeralChild64 authored and GitHub committed 2025-04-06 13:10:24 +00:00
commit 7563da19ab
5 files changed
+120 -9

No files matched your search

+6 -9
View File
@@ -7,7 +7,7 @@
; Math package - divide FAC1 by 10, result is always positive
;
; Notes:
; - shifts FAC1 to FAC2, loads FAC1 with the constant 10, falls through to the division routine
; - moves FAC1 to FAC2, loads FAC1 with the constant 10, jumps to the division routine
;
; See also:
@@ -16,14 +16,11 @@
; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics
;
; XXX test this
div10_FAC1_p:
lda #$00
sta FAC1_sign
jsr mov_FAC1_FAC2
ldy #>const_TEN
lda #<const_TEN
jsr mov_MEM_FAC1
ldy #>const_TEN
lda #<const_TEN
jmp div_MEM_FAC1
jmp div_FAC2_FAC1
+1
View File
@@ -0,0 +1 @@
The floating point constant 10.0 + fragment
+3
View File
@@ -0,0 +1,3 @@
$BBA2 + JMP $BB12
Fragment of well known floating point function address + JMP to other well known floating point function
+3
View File
@@ -0,0 +1,3 @@
TAY + JMP $B3A2 + JMP fragment
Fragments + jump to well known floating point function
+107
View File
@@ -552,5 +552,112 @@ print "COMPARE"
compare $61 $61 $1001
print "END"
print "TEST: div FAC2 FAC1 0.0 / 1.0 = 0.0"
fill $61 $66 81 80 00 00 00 00
fill $70 $70 00
fill $69 $6E 00 FF FF FF FF 00
r PC=$BB12
ret
print "COMPARE"
compare $61 $61 $69
compare $70 $70 $6E ; FACOV = 0
print "END"
print "TEST: div FAC2 FAC1 1.0 / 1.0 = 1.0"
fill $61 $66 81 80 00 00 00 00
fill $70 $70 00
fill $69 $6E 81 80 00 00 00 00
r PC=$BB12
ret
fill $1001 $1006 81 80 00 00 00 00
print "COMPARE"
compare $61 $66 $1001
compare $70 $70 $6E ; FACOV = 0
print "END"
print "TEST: div FAC2 FAC1 -1.0 / 1.0 = -1.0"
fill $61 $66 81 80 00 00 00 80
fill $70 $70 00
fill $69 $6E 81 80 00 00 00 00
r PC=$BB12
ret
fill $1001 $1006 81 80 00 00 00 80
print "COMPARE"
compare $61 $66 $1001
compare $70 $70 $1003 ; FACOV = 0
print "END"
print "TEST: div FAC2 FAC1 1.0 / -1.0 = -1.0"
fill $61 $66 81 80 00 00 00 00
fill $70 $70 00
fill $69 $6E 81 80 00 00 00 80
r PC=$BB12
ret
fill $1001 $1006 81 80 00 00 00 80
print "COMPARE"
compare $61 $66 $1001
compare $70 $70 $1003 ; FACOV = 0
print "END"
print "TEST: div FAC2 FAC1 1.0 / 2.0 = 0.5"
fill $61 $66 82 80 00 00 00 00
fill $70 $70 00
fill $69 $6E 81 80 00 00 00 00
r PC=$BB12
ret
fill $1001 $1006 80 80 00 00 00 00
print "COMPARE"
compare $61 $66 $1001
compare $70 $70 $1003 ; FACOV = 0
print "END"
print "TEST: div FAC2 FAC1 2.0 / 0.5 = 4.0"
fill $61 $66 80 80 00 00 00 00
fill $70 $70 00
fill $69 $6E 82 80 00 00 00 00
r PC=$BB12
ret
fill $1001 $1006 83 80 00 00 00 00
print "COMPARE"
compare $61 $66 $1001
compare $70 $70 $1003 ; FACOV = 0
print "END"
print "TEST: div FAC2 FAC1 3.0 / 0.5 = 6.0"
fill $61 $66 80 80 00 00 00 00
fill $70 $70 00
fill $69 $6E 82 C0 00 00 00 00
r PC=$BB12
ret
fill $1001 $1006 83 C0 00 00 00 00
print "COMPARE"
compare $61 $66 $1001
compare $70 $70 $1003 ; FACOV = 0
print "END"
print "TEST: div FAC2 FAC1 1.0 / 10.0 = 0.1"
fill $61 $66 84 A0 00 00 00 00
fill $70 $70 00
fill $69 $6E 81 80 00 00 00 00
r PC=$BB12
ret
# Slight rounding error here. Should be CC at the end
fill $1001 $1006 7D CC CC CC C8 00
print "COMPARE"
compare $61 $66 $1001
compare $70 $70 $1006 ; FACOV = 0
print "END"
print "TEST: div10_FAC1 1.0 = 0.1"
fill $61 $66 81 80 00 00 00 00
fill $70 $70 00
r PC=$BAFE
ret
# Slight rounding error here. Should be CC at the end
fill $1001 $1007 7D CC CC CC C8 20 00
print "COMPARE"
compare $61 $66 $1001
compare $70 $70 $1007 ; FACOV = 0
print "END"
q