implemented 2 more simple math routines
This commit is contained in:
1 parent
51064f6b70
commit
a2cd07a94c
10 files changed
+78
-12
No files matched your search
@@ -193,9 +193,10 @@ Floating point mathematical routines - not official, but well known and broadly
|
||||
| `$BB0F` | `FDIV` | PARTIAL | needs `FDIVT` |
|
||||
| `$BB12` | `FDIVT` | NOT DONE | divide FAC2 by FAC1, ignores sign |
|
||||
| `$BBA2` | `MOVFM` | PARTIAL | not fully tested yet |
|
||||
| `$BBD4` | `MOVMF` | NOT DONE | copy FAC1 to memory location, rounds if asked |
|
||||
| `$BBD4` | `MOVFM2` | NOT DONE | copy FAC1 to memory location, rounds if asked |
|
||||
| `$BBFC` | `MOVEF` | NOT DONE | copy FAC2 to FAC1 |
|
||||
| `$BC0F` | `MOVFA` | NOT DONE | copy FAC1 to FAC2, skips rounding |
|
||||
| `$BC0C` | `MOVAF` | PARTIAL | not fully tested |
|
||||
| `$BC0F` | `MOVFA` | DONE | |
|
||||
| `$BC1B` | `ROUND` | PARTIAL | not tested |
|
||||
| `$BC2B` | `SIGN` | NOT DONE | evaluate FAC1 sign |
|
||||
| `$BC39` | `SGN` | NOT DONE | evaluate FAC1 sign, to FAC1 |
|
||||
|
||||
@@ -14,12 +14,11 @@
|
||||
// - .A - FAC1 exponent
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
||||
// XXX provide implementation
|
||||
|
||||
MOVFM:
|
||||
MOVFM2:
|
||||
STUB_IMPLEMENTATION()
|
||||
@@ -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
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
// XXX test this
|
||||
|
||||
MOVMF:
|
||||
MOVFM:
|
||||
|
||||
// Checked in the available documentation:
|
||||
// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -4,4 +4,4 @@
|
||||
|
||||
// Just a compatibility jump - our routine is longer than original one
|
||||
|
||||
jmp MOVMF
|
||||
jmp MOVFM
|
||||
@@ -3,15 +3,20 @@
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Math package - copy FAC1 to FAC2, skips rounding
|
||||
// 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
|
||||
// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics
|
||||
//
|
||||
|
||||
// XXX provide implementation
|
||||
MOVAF:
|
||||
|
||||
MOVFA:
|
||||
STUB_IMPLEMENTATION()
|
||||
// First round FAC1
|
||||
jsr ROUND
|
||||
|
||||
// FALLTROUGH to MOVFA
|
||||
File renamed without changes.
@@ -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
|
||||
@@ -0,0 +1,3 @@
|
||||
This is an important floating point math routine, documented in many places.
|
||||
|
||||
XXX - try to find real-life example
|
||||
Reference in new issue
Block a user