Update MUL10
This commit is contained in:
1 parent
582ecedbd1
commit
76d30af5cd
3 files changed
+20
-27
No files matched your search
@@ -3,9 +3,13 @@
|
||||
;; #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 - multiply FAC1 by 10
|
||||
;
|
||||
; This is verified to be identical to the original Microsoft implementation where it was named MUL10
|
||||
;
|
||||
; See also:
|
||||
; - [CM64] Computes Mapping the Commodore 64 - page 114
|
||||
; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic
|
||||
@@ -14,28 +18,17 @@
|
||||
|
||||
mul10_FAC1:
|
||||
|
||||
; Handle special case of FAC1 equal 0
|
||||
MUL10:
|
||||
|
||||
lda FAC1_exponent
|
||||
beq mul10_FAC1_done
|
||||
|
||||
; Start by multiplying FAC1 by 2
|
||||
|
||||
jsr mul10_FAC1_mul2
|
||||
|
||||
; Move FAC1 to FAC2, so that FAC1 = FAC2 = 2 * initial
|
||||
|
||||
jsr mov_FAC1_FAC2
|
||||
|
||||
; Multiply FAC1 by 4
|
||||
|
||||
jsr mul10_FAC1_mul2
|
||||
jsr mul10_FAC1_mul2
|
||||
|
||||
; Now we have FAC1 = 8 * initial and FAC2 = 2 * initial; so just add these 2 values
|
||||
|
||||
jmp add_FAC2_FAC1
|
||||
|
||||
mul10_FAC1_done:
|
||||
|
||||
rts
|
||||
jsr mov_r_FAC1_FAC2
|
||||
tax
|
||||
beq MUL10R
|
||||
clc
|
||||
adc #2
|
||||
bcs GOOVER ; Closest jmp to overflow
|
||||
FINML6: ldx #0
|
||||
stx ARISGN
|
||||
jsr FADDC
|
||||
inc FAC1_exponent
|
||||
beq GOOVER
|
||||
MUL10R: rts
|
||||
Reference in new issue
Block a user