Update mov_FAC1_FAC2 to match the original implementation
This commit is contained in:
1 parent
0e6e0a5fc4
commit
ee3c8cb11d
11 files changed
+110
-71
No files matched your search
@@ -3,13 +3,19 @@
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
; This file is under the MIT license, it contains code released by Microsoft Corporation.
|
||||
; See LICENSE for more information.
|
||||
|
||||
;
|
||||
; Math package - round and move FAC1 to FAC2
|
||||
;
|
||||
; This is identical to the original Microsoft implementation where it was named MOVAF.
|
||||
;
|
||||
; Output:
|
||||
; - .A - FAC1 exponent
|
||||
;
|
||||
; See also:
|
||||
; - https://github.com/microsoft/BASIC-M6502/blob/7460af2c03ae19c0e60ff327489229d2005b9357/m6502.asm#L5540C1-L5548C12
|
||||
; - [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
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
; Just a compatibility jump - our routine is longer than original one
|
||||
|
||||
jmp mov_FAC1_FAC2
|
||||
@@ -0,0 +1,41 @@
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
; This file is under the MIT license, it contains code released by Microsoft Corporation.
|
||||
; See LICENSE for more information.
|
||||
|
||||
;
|
||||
; Math package - move FAC1 to FAC2
|
||||
;
|
||||
; This is verified to be identical to the original Microsoft implementation where it was named MOVEF.
|
||||
;
|
||||
; Output:
|
||||
; - .A - FAC1 exponent
|
||||
; - .X - always 0
|
||||
|
||||
; Preserves:
|
||||
; - .Y
|
||||
;
|
||||
; Note:
|
||||
; - Always clears FACOV, not sure why
|
||||
;
|
||||
; See also:
|
||||
; - https://github.com/microsoft/BASIC-M6502/blob/7460af2c03ae19c0e60ff327489229d2005b9357/m6502.asm#L5540C1-L5548C12
|
||||
; - [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
|
||||
;
|
||||
|
||||
mov_FAC1_FAC2:
|
||||
|
||||
ldx #6
|
||||
|
||||
@1
|
||||
lda FAC1_exponent - 1,X
|
||||
sta FAC2_exponent - 1,X
|
||||
dex
|
||||
bne @1
|
||||
stx FACOV ; Always zero
|
||||
rts
|
||||
@@ -1,51 +0,0 @@
|
||||
;; #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
|
||||
;
|
||||
|
||||
mov_FAC1_FAC2:
|
||||
|
||||
; Copy the exponent
|
||||
lda FAC1_exponent
|
||||
sta FAC2_exponent
|
||||
beq @1 ; 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
|
||||
@1:
|
||||
; Duplicate the original ROM behaviour
|
||||
ldx #$00
|
||||
stx FACOV
|
||||
|
||||
rts
|
||||
Reference in new issue
Block a user