For the first part you need some experience and a lot of patience, but for the second part you need sometimes some inspirations.
I would like to start some threads about a few recurring tasks and hope that some people would like to share their ideas and comments about that. Would there be any interest in something like that?
Just as a little appetizer, I thought of something like that:
How to toggle a flag
Code: Select all
InitialiseFlag:
lda #0
sta onoff
ToggleFlagV1:
inc onoff
lda onoff
and #$01
sta onoff
(11 bytes, assuming onoff not ZP)
ToggleFlagV2:
sec
lda #$01
sbc onoff
sta onoff
(9 bytes, assuming onoff not ZP)
ToggleFlagV3:
lda onoff
eor #$01
sta onoff
(8 bytes, assuming onoff not ZP)
Flag will be 0 for off or 1 for on.
----------------------------------------------------
InitialiseFlag:
lda #$55
sta onoff
rts
ToggleFlagV4:
ror onoff
(3 bytes, assuming onoff not ZP)
Flag will be $55 or $AA
check with
bit adr
bmi / bpl for on/off