Add get_FAC2_via_INDEX

This commit is contained in:
Rikard Nordgren committed 2025-03-04 21:04:21 +01:00
1 parent b521241636
commit a67e6432a0
13 files changed
+85 -49

No files matched your search

+1 -1
View File
@@ -216,7 +216,7 @@ Floating point mathematical routines - not official, but well known and broadly
| `$BA28` | `mul_MEM_FAC1` | DONE | | | `$BA28` | `mul_MEM_FAC1` | DONE | |
| `$BA2B` | `mul_FAC2_FAC1` | DONE | | | `$BA2B` | `mul_FAC2_FAC1` | DONE | |
| `$BA8C` | `mov_MEM_FAC2` | DONE | | | `$BA8C` | `mov_MEM_FAC2` | DONE | |
| `$BA90` | `get_FAC2_via_INDEX` | NOT DONE | | | `$BA90` | `get_FAC2_via_INDEX` | DONE | |
| `$BAE2` | `mul10_FAC1` | DONE | | | `$BAE2` | `mul10_FAC1` | DONE | |
| `$BAFE` | `div10_FAC1_p` | DONE | | | `$BAFE` | `div10_FAC1_p` | DONE | |
| `$BB0F` | `div_MEM_FAC1` | DONE | | | `$BB0F` | `div_MEM_FAC1` | DONE | |
@@ -1,17 +0,0 @@
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000
;; #LAYOUT# * BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
;
; Math package - XXX
;
; See also:
; - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True
;
; XXX implement, test
get_FAC2_via_INDEX:
+STUB_IMPLEMENTATION
-8
View File
@@ -1,8 +0,0 @@
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000
;; #LAYOUT# * BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
; Just a compatibility jump - our routine is longer than original one
jmp mov_MEM_FAC2
File renamed without changes.
+30
View File
@@ -0,0 +1,30 @@
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000
;; #LAYOUT# * BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
;
; Math package - fetch FAC2 from memory location
;
; Input:
; - .A - address low byte
; - .Y - address high byte
;
; Output:
; - .A - FAC1 exponent (yes, really - Codebase64 is right)
; - .Y - 0 (experimentation with original ROM)
;
; Preserves:
; - .X - (experimentation with original ROM)
;
; See also:
; - [CM64] Computes Mapping the Commodore 64 - page 114
; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic
; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics
;
mov_MEM_FAC2:
sty INDEX+1
sta INDEX+0
; FALLTHROUGH to get_FAC2_via_INDEX
@@ -1,36 +1,18 @@
;; #LAYOUT# STD * #TAKE ;; #LAYOUT# STD * #TAKE
;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000
;; #LAYOUT# * BASIC_0 #TAKE ;; #LAYOUT# * BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE ;; #LAYOUT# * * #IGNORE
; ;
; Math package - fetch FAC2 from memory location ; Math package - Mov MEM to FAC2 with address in INDEX zero page register
;
; Input:
; - .A - address low byte
; - .Y - address high byte
;
; Output:
; - .A - FAC1 exponent (yes, really - Codebase64 is right)
; - .Y - 0 (experimentation with original ROM)
;
; Preserves:
; - .X - (experimentation with original ROM)
; ;
; See also: ; See also:
; - [CM64] Computes Mapping the Commodore 64 - page 114 ; - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True
; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic
; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics
; ;
; XXX test this ; XXX implement, test
mov_MEM_FAC2: get_FAC2_via_INDEX:
; Original routines use $22/$23 location for a vector too, see here:
; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics
sty INDEX+1
sta INDEX+0
; Now copy the data from RAM to FAC2, for the format description see: ; Now copy the data from RAM to FAC2, for the format description see:
; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic#Representation_in_the_C-64 ; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic#Representation_in_the_C-64
File renamed without changes.
+3
View File
@@ -0,0 +1,3 @@
JSR $BA8C + LDA fragment
Call to well known floating point function + fragment
+3
View File
@@ -0,0 +1,3 @@
$3C + JSR $BA8C
Fragment and call to well known floating point function.
+5
View File
@@ -0,0 +1,5 @@
4C 67 B8 20 8C BA A5 66 49 FF 85 66
JMP $B867 + JSR $BA8C + LDA $66 + EOR #$FF + STA $66
Call two well known floating point functions and invert sign of FAC1
+3
View File
@@ -0,0 +1,3 @@
ror $63 + ror $64 + ror $65 + ror $70 + rts
Shifting of 32 bit value of the FAC1 mantissa in the zero page
+3
View File
@@ -0,0 +1,3 @@
$BC + LDA #$00 + STA fragment
Fragment of clearing variable in zero page
+32
View File
@@ -145,6 +145,38 @@ compare $61 $66 $1001
compare $70 $70 $1003 ; FACOV = 0 compare $70 $70 $1003 ; FACOV = 0
print "END" print "END"
print "TEST: mov MEM FAC2 const 1.0"
fill $69 $6E FF FF FF FF FF AA
r A=$BC
r Y=$B9
r PC=$BA8C
ret
fill $1001 $1006 81 80 00 00 00 00
print "COMPARE"
compare $69 $6E $1001
print "END"
print "TEST: mov MEM FAC2 const -0.5"
fill $69 $6E FF FF FF FF FF AA
r A=$E0
r Y=$B9
r PC=$BA8C
ret
fill $1001 $1006 80 80 00 00 00 FF
print "COMPARE"
compare $69 $6E $1001
print "END"
print "TEST: get_FAC2_via_INDEX -0.5"
fill $69 $6E FF FF FF FF FF AA
fill $22 $23 E0 B9
r PC=$BA90
ret
fill $1001 $1006 80 80 00 00 00 FF
print "COMPARE"
compare $69 $6E $1001
print "END"
print "TEST: FCOMP 1.0 == 1.0" print "TEST: FCOMP 1.0 == 1.0"
r A=$BC r A=$BC
r Y=$B9 r Y=$B9