Update mov_MEM_FAC2 and get_FAC2_via_INDEX

This commit is contained in:
Rikard Nordgren authored and FeralChild64 committed 2026-03-29 21:45:24 +02:00
1 parent 135522352a
commit 061440c7e1
4 files changed
+39 -40

No files matched your search

+8 -3
View File
@@ -2,7 +2,10 @@
;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000
;; #LAYOUT# * BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
;
; This file is under the MIT license, it contains code released by Microsoft Corporation.
; See LICENSE for more information.
; Math package - fetch FAC2 from memory location
;
; Input:
@@ -16,6 +19,8 @@
; Preserves:
; - .X - (experimentation with original ROM)
;
; This is verified to be identical to the original Microsoft implementation where it was named CONUPK.
;
; See also:
; - [CM64] Computes Mapping the Commodore 64 - page 114
; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic
@@ -24,7 +29,7 @@
mov_MEM_FAC2:
sty INDEX+1
sta INDEX+0
sta INDEX+0
sty INDEX+1
; FALLTHROUGH to get_FAC2_via_INDEX
+27 -34
View File
@@ -3,9 +3,13 @@
;; #LAYOUT# * BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
;
; This file is under the MIT license, it contains code released by Microsoft Corporation.
; See LICENSE for more information.
; Math package - Mov MEM to FAC2 with address in INDEX zero page register
;
; This is verified to be identical to the original Microsoft implementation where it was named CONUPK (partial).
;
; See also:
; - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True
;
@@ -14,36 +18,25 @@
get_FAC2_via_INDEX:
; 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
; Copy the mantissa
ldy #$04
lda (INDEX), y
sta FAC2_mantissa+3
dey
lda (INDEX), y
sta FAC2_mantissa+2
dey
lda (INDEX), y
sta FAC2_mantissa+1
dey
lda (INDEX), y
sta FAC2_sign
ora #$80 ; clear the sign bit
sta FAC2_mantissa+0
; Copy the exponent
dey
lda (INDEX), y
sta FAC2_exponent
; Return the FAC1 exponent
lda FAC1_exponent
rts
ldy #4
lda (INDEX),Y
sta FAC2_mantissa+3
dey
lda (INDEX),Y
sta FAC2_mantissa+2
dey
lda (INDEX),Y
sta FAC2_mantissa+1
dey
lda (INDEX),Y
sta FAC2_sign
eor FAC1_sign ; Set sign for multiplication/division
sta ARISGN
lda FAC2_sign
ora #$80 ; Set mantissa high bit
sta FAC2_mantissa+0
dey
lda (INDEX),Y
sta FAC2_exponent
lda FAC1_exponent ; Set flags from FAC1_exponent
rts