For example, let's do a piece of code which eturns 01 if the thing to test is positive, and $02 else. The "clean" way to do it is :
Code: Select all
lda something_to_test
bmi _else
lda #$01
jmp _endif
_else
lda #$02
_endif
rtsCode: Select all
lda something_to_test
bmi _else
lda #$01
.db $cd (cmp $xxxx opcode)
_else
lda #$02
rtsSince the next instruction (to skip) is always a two byte instruction, the one performing this trick has to be very carefull about the argument of the two byte instruction in question. If the argument is included between $20 and $3f, he has to become carefull. Something as innocent as sta $20 for example would in fact read $2085 (mirror $2005) which normally have no effect, but I'd still avoid reading it. Luckily, no two byte instruction has $7 or $e as their last nyble of their opcode, making reading accidentally $2007 technically impossible (maybe I missed one tough). But something like ldx $20 would read $20a2 (so $2002) and this could possibly affect the PPU during rendering.
Am I correct to worry about such things or am I imaginating things.