4 ms·
But part of the bizarre genius of the 6502 is that you can't do the same thing. OK, sure, so you could do this, and it does indeed EOR the accumulator with its
by to3m 10y ago
But part of the bizarre genius of the 6502 is that you can't do the same thing.
OK, sure, so you could do this, and it does indeed EOR the accumulator with itself.
STA $70 ; 2 3
EOR $70 ; 4 6
But that's stupid, because nobody would waste a zero page byte like that. Perhaps you have heard of this thing called "best practice"? With that in mind, here is some self-modifying code.
STA L+1 ; 3 4
L:
EOR #$FF ; 5 6
Much better. The accumulator is EORed with itself just the same, and this time nobody can accuse you of being unprofessional.
Of course, if the latter approach is less stupid, that's only in relative terms. Because you could also do this.
LDA #0 ; 2 2
- SixSigma 10y agoThe bizarre "genius" of x86 is that exactly that thing gets done in microcode as a special case.