This commit is contained in:
Brooke Vibber 2023-01-04 19:52:56 -08:00
parent 9682b4a6b3
commit fa599be775

View file

@ -32,7 +32,8 @@ FRX = $ec
; inner loop for imul16 ; inner loop for imul16
; 24 to 44 cycles ; 24 to 44 cycles
.macro bitmul16 arg1, arg2, result, bitnum .macro bitmul16 arg1, arg2, result, bitnum
.local next .local one
.local zero
; does 16-bit adds ; does 16-bit adds
; arg1 must be 0 or positive ; arg1 must be 0 or positive
@ -49,8 +50,9 @@ FRX = $ec
lda arg1 + 1 ; 3 cyc lda arg1 + 1 ; 3 cyc
and #(1 << (bitnum - 8)) ; 2 cyc and #(1 << (bitnum - 8)) ; 2 cyc
.endif .endif
beq next ; 2 cyc beq zero ; 2 cyc
one:
; 16-bit add on the top bits ; 16-bit add on the top bits
lda result + 2 ; 3 cyc lda result + 2 ; 3 cyc
adc arg2 ; 3 cyc adc arg2 ; 3 cyc
@ -59,11 +61,13 @@ FRX = $ec
adc arg2 + 1 ; 3 cyc adc arg2 + 1 ; 3 cyc
ror a ; 2 cyc - get a jump on the shift ror a ; 2 cyc - get a jump on the shift
sta result + 3 ; 3 cyc sta result + 3 ; 3 cyc
jmp oneb ; 3 cyc
; Shift the 32-bit result down by one bit, ; Shift the 32-bit result down by one bit,
; saving the previous carry. ; saving the previous carry.
zero:
ror result + 3 ; 5 cyc ror result + 3 ; 5 cyc
next: oneb:
ror result + 2 ; 5 cyc ror result + 2 ; 5 cyc
ror result + 1 ; 5 cyc ror result + 1 ; 5 cyc
.if bitnum >= 8 .if bitnum >= 8