Merytsetesh wrote:[...] why use [SBC]?
If you do the sign inversion
in the same context as done in BALLPING (i.e. a given zero page address as source and target), for both methods you'll arrive at (DX := $F9):
Code: Select all
; ** using SBC:
SEC
LDA #$00
SBC $F9
STA $F9
7 bytes, 10 cycles
Code: Select all
; ** using EOR #$FF and 2s-complement:
CLC
LDA $F9
EOR #$FF
ADC #$01
STA $F9
9 bytes, 12 cycles
So there ...
(Also, using SBC has the charme it's
independent of the way signed integers are represented)
When the value already is in the Accumulator, then using 2s-complement is shorter and faster - and it can even spare the CLC instruction when the state of the carry flag is known at that point, doing either
EOR #$FF/ADC #$01 when C is known clear or
EOR #$FF/ADC #$00 when C is known set. See
here.