speed optimization of multiplication routine

This commit is contained in:
FeralChild64 committed 2020-02-27 18:48:34 +01:00
1 parent a40b419b1f
commit 6afae69a31
2 files changed
+18 -3

No files matched your search

+17 -2
View File
@@ -7,13 +7,20 @@
// - https://codebase64.org/doku.php?id=base:8bit_multiplication_16bit_product_fast_no_tables
//
// input: .A, INDEX+3
// output: .X (high byte), .A and INDEX+2 (low byte), carry always clear
// output: .X (high byte), .A (low byte), carry always clear
//
mul_FAC2_FAC1_8x8:
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)
@@ -62,6 +69,14 @@ mul_FAC2_FAC1_8x8:
tax
lda INDEX+2
clc
clc
rts
mul_FAC2_FAC1_8x8_zero:
lda #$00
tax
clc
rts