Add inv_FAC1_mantissa

This commit is contained in:
Rikard Nordgren committed 2025-03-03 20:08:06 +01:00
1 parent b521241636
commit 0b90926c09
9 files changed
+65 -5

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
This is an important floating point math routine, documented in many places.
XXX - try to find real-life example
+36
View File
@@ -0,0 +1,36 @@
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000
;; #LAYOUT# * BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
;
; Math package - invert FAC1 mantissa
;
; See also:
; - [CM64] Computes Mapping the Commodore 64 - page 113
; - https://www.c64-wiki.com/wiki/BASIC-ROM
; - https://sta.c64.org/cbm64basconv.html
;
; 2-complement the FAC1 mantissa
; The 4 byte mantissa is treated as an integer in big endian form
inv_FAC1_mantissa:
ldx #3
@1: lda FAC1_mantissa,X
eor #$FF
sta FAC1_mantissa,X
dex
bpl @1
inc FAC1_mantissa+3
bne @2
inc FAC1_mantissa+2
bne @2
inc FAC1_mantissa+1
bne @2
inc FAC1_mantissa
@2: rts