This commit is contained in:
Brooke Vibber 2022-12-30 18:25:43 -08:00
parent 2d67cdc498
commit 5605cc4652

View file

@ -9,34 +9,6 @@ FRX = $ec
.export start .export start
.macro sext16to32 arg
.local plus
.local minus
lda arg+1
asl ; sign -> carry
lda #$ff
bcc plus
lda #$00
plus:
sta arg+2
sta arg+3
.endmacro
.macro copy bytes, arg1, arg2
.repeat 2, byte
lda arg1+byte
sta arg2+byte
.endrepeat
.endmacro
.macro copy16 arg1, arg2
copy 2, arg1, arg2
.endmacro
.macro copy32 arg1, arg2
copy 4, arg1, arg2
.endmacro
; 2 + 8 * byte cycles ; 2 + 8 * byte cycles
.macro neg bytes, arg .macro neg bytes, arg
sec ; 2 cyc sec ; 2 cyc
@ -57,64 +29,7 @@ plus:
neg 4, arg neg 4, arg
.endmacro .endmacro
; 2 + 9 * bytes cycles ; inner loop for imul16
.macro add bytes, arg1, arg2
clc ; 2 cyc
.repeat bytes, byte
lda arg1+byte ; 3 cyc
adc arg2+byte ; 3 cyc
sta arg1+byte ; 3 cyc
.endrepeat
.endmacro
; 20 cycles
.macro add16 arg1, arg2
add 2, arg1, arg2
.endmacro
; 38 cycles
.macro add32 arg1, arg2
add 4, arg1, arg2
.endmacro
.macro shl bytes, arg
asl arg
.repeat bytes-1, byte
rol arg+byte+1
.endrepeat
.endmacro
.macro shl16 arg
shl 2, arg
.endmacro
.macro shl24 arg
shl 3, arg
.endmacro
.macro shl32 arg
shl 4, arg
.endmacro
.macro shr bytes, arg
lsr arg
.repeat bytes-1, byte
ror arg+byte+1
.endrepeat
.endmacro
.macro shr16 arg
shr 2, arg
.endmacro
.macro shr24 arg
shr 3, arg
.endmacro
.macro shr32 arg
shr 4, arg
.endmacro
; 24 to 44 cycles ; 24 to 44 cycles
.macro bitmul16 arg1, arg2, result, bitnum .macro bitmul16 arg1, arg2, result, bitnum
.local next .local next