View Single Post
Old 29th May 2019, 6:10 am   #9
julie_m
Dekatron
 
Join Date: May 2008
Location: Derby, UK.
Posts: 7,399
Default Re: Fun with 6502 Assembler

On the 6502, there isn't a "Branch Never" instruction (on the early ARM processors, by contrast, every instruction is conditional!), but you can do something like this:
Code:
 
         .entry1
A9 00    LDA #0
CC       EQUB &CC
         .entry2
A9 FF    LDA #255
         \ rest of stuff
60       RTS
Now if we jump to entry1, once we have placed 0 in the accumulator, the next byte EQUB CC followed by LDA #255 actually looks like CPY &FFA9, which will not affect the accumulator; so after 4 cycles, we carry on with A=0. But if we jumped to entry2, we see just the LDA #255 instruction.

This is only one byte shorter than a branch around the "unwanted" instruction, so probably only needed in extreme circumstances.
__________________
If I have seen further than others, it is because I was standing on a pile of failed experiments.
julie_m is online now   Reply With Quote