various multiplication fixes

This commit is contained in:
FeralChild64 committed 2020-02-27 18:28:57 +01:00
1 parent 55f1a1ae8a
commit a40b419b1f
5 files changed
+83 -75

No files matched your search

+67
View File
@@ -0,0 +1,67 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// 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
// output: .X (high byte), .A and INDEX+2 (low byte), carry always clear
//
mul_FAC2_FAC1_8x8:
sta INDEX+2
lda #$00
dec INDEX+3 // decrement because we will be adding with carry set for speed (an extra one)
ror INDEX+2
bcc !+
adc INDEX+3
!:
ror
ror INDEX+2
bcc !+
adc INDEX+3
!:
ror
ror INDEX+2
bcc !+
adc INDEX+3
!:
ror
ror INDEX+2
bcc !+
adc INDEX+3
!:
ror
ror INDEX+2
bcc !+
adc INDEX+3
!:
ror
ror INDEX+2
bcc !+
adc INDEX+3
!:
ror
ror INDEX+2
bcc !+
adc INDEX+3
!:
ror
ror INDEX+2
bcc !+
adc INDEX+3
!:
ror
ror INDEX+2
inc INDEX+3
tax
lda INDEX+2
clc
rts