Accumulator

Optimising use of the A register

Setting the Accumulator to 0

When dealing with loading 0 into the Accumulator, there's several ways to do it.

3E00LDA,0Traditional way to set A to 0
AFXORAAnything xor itself is 0
97SUBAA-A=0

The downside to the above options is that they also affect the flags. However, they are only 1 byte long not 2 and are both 3 T-states faster.

Inverting A

If inverting A, i.e. swapping each bit from 1 to 0 and vis-versa then instead of XOR 0xFF use CPL instead. It's both faster, 1 byte and that's all that instruction does.

EEFFXOR0xFFA=A XOR 0xff
2FCPLThis instruction does exactly the same thing and nothing else!

The downside is that CPL does not affect the flags whilst XOR does.


Last modified November 16, 2021: Optimise optimisation pages (b7101cb)