further multiplication fixes

This commit is contained in:
FeralChild64 committed 2020-02-27 19:22:24 +01:00
1 parent 6afae69a31
commit 9f29d058dd
2 files changed
+25 -27

No files matched your search

+21 -18
View File
@@ -97,32 +97,32 @@ mul_FAC2_FAC1_sub_exp_bias:
// XXX maybe we should preserve .X on stack? this will not cost us too much
lda FACOV
jsr mul_by_A
jsr mul_shift_RESHO
jsr mul_FAC2_FAC1_by_A
jsr mul_FAC2_FAC1_shift_RESHO
bcc !+
inc RESHO+0
!:
lda FAC1_mantissa+3
jsr mul_by_A
jsr mul_shift_RESHO
jsr mul_FAC2_FAC1_by_A
jsr mul_FAC2_FAC1_shift_RESHO
bcc !+
inc RESHO+0
!:
lda FAC1_mantissa+2
jsr mul_by_A
jsr mul_shift_RESHO
jsr mul_FAC2_FAC1_by_A
jsr mul_FAC2_FAC1_shift_RESHO
bcc !+
inc RESHO+0
!:
lda FAC1_mantissa+1
jsr mul_by_A
jsr mul_shift_RESHO
jsr mul_FAC2_FAC1_by_A
jsr mul_FAC2_FAC1_shift_RESHO
bcc !+
inc RESHO+0
!:
lda FAC1_mantissa+0
jsr mul_by_A
jsr mul_shift_RESHO
jsr mul_FAC2_FAC1_by_A
jsr mul_FAC2_FAC1_shift_RESHO
bcc !+
inc RESHO+0
!:
@@ -149,11 +149,9 @@ mul_FAC2_FAC1_sub_exp_bias:
jmp normal_FAC1
mul_FAC2_FAC1_by_A:
mul_by_A: // XXX we should probably move this subroutine to a separate file
beq mul_FAC2_FAC1_by_A_done
sta INDEX+3
// Multiply FAC2_mantissa+3
@@ -168,9 +166,9 @@ mul_by_A: // XXX we should probably move this subroutine to a separate file
sta RESHO+3
bcc !+
inc RESHO+2
bcc !+
bne !+
inc RESHO+1
bcc !+
bne !+
inc RESHO+0
!:
// Multiply FAC2_mantissa+2
@@ -185,7 +183,7 @@ mul_by_A: // XXX we should probably move this subroutine to a separate file
sta RESHO+2
bcc !+
inc RESHO+1
bcc !+
bne !+
inc RESHO+0
!:
// Multiply FAC2_mantissa+1
@@ -211,11 +209,16 @@ mul_by_A: // XXX we should probably move this subroutine to a separate file
adc RESHO+0
sta RESHO+0
// FALLTROUGH
mul_FAC2_FAC1_by_A_done:
rts
mul_shift_RESHO: // XXX we should probably move this subroutine to a separate file
mul_FAC2_FAC1_shift_RESHO: // XXX we should probably move this subroutine to a separate file
// Shift RESHO by one byte
+4 -9
View File
@@ -6,21 +6,16 @@
// Helper routine, based on code by djmips from:
// - https://codebase64.org/doku.php?id=base:8bit_multiplication_16bit_product_fast_no_tables
//
// input: .A, INDEX+3
// input: .A (and Zero flag set according to .A), INDEX+3
// output: .X (high byte), .A (low byte), carry always clear
//
mul_FAC2_FAC1_8x8:
// Special case (optimization) - handle 0 in INDEX+2
beq mul_FAC2_FAC1_8x8_zero
sta INDEX+2
// Special case (optimization) - handle 0
lda INDEX+2
beq mul_FAC2_FAC1_8x8_zero
lda INDEX+3
beq mul_FAC2_FAC1_8x8_zero
lda #$00
dec INDEX+3 // decrement because we will be adding with carry set for speed (an extra one)