c64-livecoding/wip-hugo/macros/16aritmatic.s
hugova 4d12f20a6e A Fix for D that gets the wrong initial value and the branch logic in line_* checked for the wrong value.
A new proc, line.s that can chose whitch line_* to use
A small test program in source.s
Wrote a smal test program in source.s  (all looks good exept line_up_inv)
2025-03-03 22:08:00 +01:00

42 lines
928 B
ArmAsm
Executable file

.macro Add_16 a_low, a_hi, b_low, b_hi ; a = a + b
CLC
LDA b_low
ADC a_low
STA a_low
LDA b_hi
ADC a_hi
STA a_hi
.endmacro
.macro Sub_16 a_low, a_hi, b_low, b_hi ; a = a - b
SEC
LDA a_low
SBC b_low
STA a_low
LDA a_hi
SBC b_hi
STA a_hi
.endmacro
.macro mult_16 low_, hi_ ; [low, hi] = [low, hi]*2
CLC
ROL low_
ROL hi_
.endmacro
;;Se below for some fast 16bit logic
;;http://6502.org/tutorials/compare_beyond.html
;; exampel 4.1.1
;;Larger then operation. IF a < b then jump to label
.macro Lag_16 a_low, a_hi, b_low, b_hi, label ; [low, hi] = [low, hi]*2
LDA a_hi ; compare high bytes
CMP b_hi
BCC label ; if NUM1H < NUM2H then NUM1 < NUM2
BNE LABEL ; if NUM1H <> NUM2H then NUM1 > NUM2 (so NUM1 >= NUM2)
LDA a_low ; compare low bytes
CMP b_low
BCC label ; if NUM1L < NUM2L then NUM1 < NUM2
LABEL:
.endmacro