implemented 2 more simple math routines

This commit is contained in:
FeralChild64 committed 2020-02-01 20:52:00 +01:00
1 parent 51064f6b70
commit a2cd07a94c
10 files changed
+78 -12

No files matched your search

+51
View File
@@ -0,0 +1,51 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Math package - move FAC1 to FAC2
//
// Output (all found by experimentation):
// - .A - FAC1 exponent
// - .X - always 0
//
// Preserves (found by experimentation):
// - .Y
//
// Note:
// - observed that original ROM always clears FACOV, not sure why
//
// See also:
// - [CM64] Computes Mapping the Commodore 64 - page 115
// - https://www.c64-wiki.com/wiki/BASIC-ROM
// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic
//
MOVFA:
// Copy the exponent
lda FAC1_exponent
sta FAC2_exponent
beq !+ // for 0 no need to copy mantissa and sign
// Copy the mantissa
lda FAC1_mantissa+0
sta FAC2_mantissa+0
lda FAC1_mantissa+1
sta FAC2_mantissa+1
lda FAC1_mantissa+2
sta FAC2_mantissa+2
lda FAC1_mantissa+3
sta FAC2_mantissa+3
// Copy the sign
lda FAC1_sign
sta FAC2_sign
lda FAC1_exponent
!:
// Duplicate the original ROM behaviour
ldx #$00
stx FACOV
rts
+1 -1
View File
@@ -21,7 +21,7 @@
// XXX test this
MOVMF:
MOVFM:
// Checked in the available documentation:
// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic
+1 -1
View File
@@ -43,7 +43,7 @@ ROUND:
inc FAC1_exponent
bne round_zero_FACOV
// If w are here, it means the exponent wrapped around to $00; put it back to $FF
// If we are here, it means the exponent wrapped around to $00; put it back to $FF
dec FAC1_exponent
+1 -1
View File
@@ -4,4 +4,4 @@
// Just a compatibility jump - our routine is longer than original one
jmp MOVMF
jmp MOVFM
+22
View File
@@ -0,0 +1,22 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Math package - round and move FAC1 to FAC2
//
// Output:
// - .A - FAC1 exponent
//
// See also:
// - [CM64] Computes Mapping the Commodore 64 - page 115
// - https://www.c64-wiki.com/wiki/BASIC-ROM
// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic
//
MOVAF:
// First round FAC1
jsr ROUND
// FALLTROUGH to MOVFA
+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
+7
View File
@@ -0,0 +1,7 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
// Just a compatibility jump - our routine is longer than original one
jmp MOVFA
+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