Files
open-roms/src/basic/math_mov/ba90.get_FAC2_via_INDEX.s
T
Rikard Nordgren 5a3f65efa4 Add get_FAC1_via_INDEX
Also change to only use bit 7 as sign in FAC1 and FAC2 (as the original BASIC does) to simplify
implementations.
2025-04-01 19:42:21 +02:00

50 lines
920 B
ArmAsm

;; #LAYOUT# STD * #TAKE
;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000
;; #LAYOUT# * BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
;
; Math package - Mov MEM to FAC2 with address in INDEX zero page register
;
; 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:
; 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