no diff using different temp

This commit is contained in:
Brooke Vibber 2023-02-11 15:47:58 -08:00
commit 99197bb7b2
3 changed files with 86 additions and 8 deletions

View file

@ -417,6 +417,9 @@ positive_result:
; Adapted from https://everything2.com/title/Fast+6502+multiplication
.macro imul8 dest, arg1, arg2
.local under256
.local next
.local small_product
.scope
mul_factor_a = arg1
mul_factor_x = arg2
@ -468,6 +471,7 @@ positive_result:
arg1 = FR0 ; 16-bit arg (clobbered)
arg2 = FR1 ; 16-bit arg (clobbered)
result = FR2 ; 32-bit result
inter = temp2
ldy #0 ; 2 cyc
; counts the number of sign bits in Y
@ -480,18 +484,18 @@ positive_result:
sta result + 2
sta result + 3
imul8 temp, arg1, arg2
add16 result, result, temp
imul8 inter, arg1, arg2
add16 result, result, inter
imul8 temp, arg1 + 1, arg2
add16 result + 1, result + 1, temp
imul8 inter, arg1 + 1, arg2
add16 result + 1, result + 1, inter
imul8 temp, arg1, arg2 + 1
add16 result + 1, result + 1, temp
imul8 inter, arg1, arg2 + 1
add16 result + 1, result + 1, inter
add_carry result + 3
imul8 temp, arg1 + 1, arg2 + 1
add16 result + 2, result + 2, temp
imul8 inter, arg1 + 1, arg2 + 1
add16 result + 2, result + 2, inter
; In case of mixed input signs, return a negative result.
cpy #1 ; 2 cyc