Update mov_FAC2_FAC1 to match the original implementation
This commit is contained in:
1 parent
ee3c8cb11d
commit
c9e4a09594
4 files changed
+43
-53
No files matched your search
@@ -227,7 +227,7 @@ Floating point mathematical routines - not official, but well known and broadly
|
||||
| `$BBCA` | `mov_r_FAC1_TMP1` | PARTIAL | not fully tested yet |
|
||||
| `$BBD0` | `mov_r_FAC1_VAR` | PARTIAL | not fully tested yet |
|
||||
| `$BBD4` | `mov_r_FAC1_MEM` | PARTIAL | not fully tested yet |
|
||||
| `$BBFC` | `mov_FAC2_FAC1` | DONE | |
|
||||
| `$BBFC` | `mov_FAC2_FAC1` | DONE | From the Microsoft BASIC, original name: MOVFA |
|
||||
| `$BC0C` | `mov_r_FAC1_FAC2` | DONE | From the Microsoft BASIC, original name: MOVAF |
|
||||
| `$BC0F` | `mov_FAC1_FAC2` | DONE | From the Microsoft BASIC, original name: MOVEF |
|
||||
| `$BC1B` | `round_FAC1` | PARTIAL | not fully tested yet |
|
||||
|
||||
@@ -3,6 +3,45 @@
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
; Just a compatibility jump - our routine is longer than original one
|
||||
; This file is under the MIT license, it contains code released by Microsoft Corporation.
|
||||
; See LICENSE for more information.
|
||||
|
||||
jmp mov_FAC2_FAC1
|
||||
; Math package - Copy FAC2 to FAC1
|
||||
;
|
||||
; This is verified to be identical to the original Microsoft implementation where it was named MOVFA.
|
||||
;
|
||||
; It has an alternative entry point at mov_FAC2_FAC1_sign (original: MOVFA1) that instead of copying the sign uses A for the copied sign.
|
||||
;
|
||||
; Output (found by experimentation):
|
||||
; - .A - FAC1 exponent
|
||||
; - .X - always 0
|
||||
;
|
||||
; Preserves:
|
||||
; - .Y
|
||||
;
|
||||
; See also:
|
||||
; - [CM64] Computes Mapping the Commodore 64 - page 115
|
||||
; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic
|
||||
; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics
|
||||
;
|
||||
|
||||
|
||||
mov_FAC2_FAC1:
|
||||
; Copy the sign
|
||||
|
||||
lda FAC2_sign
|
||||
|
||||
mov_FAC2_FAC1_sign:
|
||||
sta FAC2_sign
|
||||
|
||||
; Copy the mantissa and the exponent
|
||||
|
||||
ldx #5
|
||||
|
||||
@1
|
||||
lda FAC2_exponent - 1,X
|
||||
sta FAC1_exponent - 1,X
|
||||
dex
|
||||
bne @1
|
||||
stx FACOV ; Always 0
|
||||
rts
|
||||
@@ -1,49 +0,0 @@
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
;
|
||||
; Math package - copy FAC2 to FAC1
|
||||
;
|
||||
; Output (found by experimentation):
|
||||
; - .A - FAC1 exponent
|
||||
; - .X - always 0
|
||||
;
|
||||
; Preserves:
|
||||
; - .Y
|
||||
;
|
||||
; See also:
|
||||
; - [CM64] Computes Mapping the Commodore 64 - page 115
|
||||
; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic
|
||||
; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics
|
||||
;
|
||||
|
||||
mov_FAC2_FAC1:
|
||||
|
||||
; Copy the mantissa
|
||||
|
||||
lda FAC2_mantissa+3
|
||||
sta FAC1_mantissa+3
|
||||
lda FAC2_mantissa+2
|
||||
sta FAC1_mantissa+2
|
||||
lda FAC2_mantissa+1
|
||||
sta FAC1_mantissa+1
|
||||
lda FAC2_mantissa+0
|
||||
sta FAC1_mantissa+0
|
||||
|
||||
; Copy the sign
|
||||
|
||||
lda FAC2_sign
|
||||
sta FAC1_sign
|
||||
|
||||
; Copy the exponent
|
||||
|
||||
lda FAC2_exponent
|
||||
sta FAC1_exponent
|
||||
|
||||
; Clear FACOV
|
||||
|
||||
ldx #$00
|
||||
stx FACOV
|
||||
|
||||
rts
|
||||
+1
-1
@@ -22,7 +22,7 @@ int phase_mask[MAX_SIZE+MAX_SIZE];
|
||||
|
||||
#define NUM_CHUNKS 1
|
||||
// Pairs of start, end memory addresses of known exact similarity with the open source Microsoft BASIC
|
||||
unsigned short microsoft_basic_chunks[NUM_CHUNKS * 2] = {0xBC0C, 0xBC1A};
|
||||
unsigned short microsoft_basic_chunks[NUM_CHUNKS * 2] = {0xBBFC, 0xBC1A};
|
||||
|
||||
|
||||
int main(int argc,char **argv)
|
||||
|
||||
Reference in new issue
Block a user