Remove unused math helpers
This commit is contained in:
1 parent
1ec43e8cd7
commit
6ea0dc74be
4 files changed
-198
No files matched your search
@@ -1,68 +0,0 @@
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
;
|
||||
; Math package - denormalize FAC1 mantissa and adapt its exponent accordingly for division
|
||||
;
|
||||
|
||||
div_FAC1_denorm:
|
||||
|
||||
; Set FACOV to 0, no need for increased precision here
|
||||
|
||||
lda #$00
|
||||
sta FACOV
|
||||
|
||||
; Start by moving whole bytes, if possible
|
||||
|
||||
lda FAC1_mantissa+3
|
||||
bne div_FAC1_denorm_by_bit ; branch if last byte of mantissa is non-zero
|
||||
|
||||
lda FAC1_exponent
|
||||
cmp #$08
|
||||
bcc div_FAC1_denorm_by_bit ; branch if not suitable to increment exponent by 8
|
||||
|
||||
; Increment exponent
|
||||
|
||||
sbc #$08 ; Carry already sec
|
||||
sta FAC1_exponent
|
||||
|
||||
; Move mantissa bytes
|
||||
|
||||
lda FAC1_mantissa+2
|
||||
sta FAC1_mantissa+3
|
||||
lda FAC1_mantissa+1
|
||||
sta FAC1_mantissa+2
|
||||
lda FAC1_mantissa+0
|
||||
sta FAC1_mantissa+1
|
||||
lda #$00
|
||||
sta FAC1_mantissa+0
|
||||
|
||||
beq div_FAC1_denorm ; branch always
|
||||
|
||||
div_FAC1_denorm_by_bit:
|
||||
|
||||
lda FAC1_mantissa+3
|
||||
and #$01
|
||||
bne div_FAC1_denorm_done ; branch if lowest bit of mantissa is already 1
|
||||
|
||||
lda FAC1_exponent
|
||||
beq div_FAC1_denorm_done ; branch if not suitable to decrement exponent
|
||||
|
||||
; Decrement exponent
|
||||
|
||||
dec FAC1_exponent
|
||||
|
||||
; Move mantissa bits
|
||||
|
||||
clc
|
||||
ror FAC1_mantissa+0
|
||||
ror FAC1_mantissa+1
|
||||
ror FAC1_mantissa+2
|
||||
ror FAC1_mantissa+3
|
||||
|
||||
bcc div_FAC1_denorm_by_bit ; branch always
|
||||
|
||||
div_FAC1_denorm_done:
|
||||
|
||||
rts
|
||||
@@ -1,84 +0,0 @@
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
; Math package - 32-bit mantissa division, based on code by Verz
|
||||
;
|
||||
; divident: FAC2_mantissa, divisor: FAC1_mantissa (without FACOV), result: FAC2_mantissa, remainder: RESHO
|
||||
; temporary storage: INDEX+0, INDEX+1, INDEX+2, INDEX+3
|
||||
;
|
||||
; RESHO (remainder) should be set to 0 before
|
||||
;
|
||||
; see https://codebase64.org/doku.php?id=base:24bit_division_24-bit_result
|
||||
|
||||
; XXX test this
|
||||
|
||||
div_mantissas:
|
||||
|
||||
ldx #32 ; repeat for each bit
|
||||
|
||||
; FALLTROUGH
|
||||
|
||||
div_mantissas_loop:
|
||||
|
||||
; Multiply divident by 2, msb -> Carry
|
||||
|
||||
asl FAC2_mantissa+3
|
||||
rol FAC2_mantissa+2
|
||||
rol FAC2_mantissa+1
|
||||
rol FAC2_mantissa+0
|
||||
|
||||
; Multiply remainder by 2, lsb <- Carry
|
||||
|
||||
rol RESHO+3
|
||||
rol RESHO+2
|
||||
rol RESHO+1
|
||||
rol RESHO+0
|
||||
|
||||
; Subtract divisor from the remainder, result to INDEX and .Y
|
||||
|
||||
sec
|
||||
lda RESHO+3
|
||||
sbc FAC1_mantissa+3
|
||||
sta INDEX+3
|
||||
|
||||
lda RESHO+2
|
||||
sbc FAC1_mantissa+2
|
||||
sta INDEX+2
|
||||
|
||||
lda RESHO+1
|
||||
sbc FAC1_mantissa+1
|
||||
sta INDEX+1
|
||||
|
||||
lda RESHO+0
|
||||
sbc FAC1_mantissa+0
|
||||
|
||||
bcc div_mantissas_skip ; if Carry is not set then divisor did not fit in remainder yet
|
||||
sta INDEX+0
|
||||
|
||||
; Save subtraction result as new remainder
|
||||
|
||||
lda INDEX+3
|
||||
sta RESHO+3
|
||||
|
||||
lda INDEX+2
|
||||
sta RESHO+2
|
||||
|
||||
lda INDEX+1
|
||||
sta RESHO+1
|
||||
|
||||
lda INDEX+0
|
||||
sta RESHO+0
|
||||
|
||||
; Increment result cause divisor fit in 1 times
|
||||
|
||||
inc FAC2_mantissa+3
|
||||
|
||||
; FALLTROUGH
|
||||
|
||||
div_mantissas_skip:
|
||||
|
||||
dex
|
||||
bne div_mantissas_loop
|
||||
|
||||
rts
|
||||
@@ -1,16 +0,0 @@
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
;
|
||||
; Multiply FAC1 by 2, do not normalize
|
||||
;
|
||||
|
||||
mul10_FAC1_mul2:
|
||||
|
||||
; Increment the exponent
|
||||
|
||||
inc FAC1_exponent
|
||||
+beq overflow_error
|
||||
|
||||
rts
|
||||
@@ -1,30 +0,0 @@
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
;
|
||||
; Math package - helper routines for RESHO manipulation
|
||||
;
|
||||
|
||||
|
||||
muldiv_RESHO_set_0:
|
||||
|
||||
lda #$00
|
||||
sta RESHO+0
|
||||
sta RESHO+1
|
||||
sta RESHO+2
|
||||
sta RESHO+3
|
||||
sta RESHO+4
|
||||
|
||||
rts
|
||||
|
||||
|
||||
muldiv_RESHO_01_add_A:
|
||||
|
||||
clc
|
||||
adc RESHO+0
|
||||
sta RESHO+0
|
||||
bcc @1
|
||||
inc RESHO+1
|
||||
@1:
|
||||
rts
|
||||
Reference in new issue
Block a user