XBA - Exchanges B with A


XBA swaps the values of the two 8-bit accumulators A and B. It should be noted that A and B don't swap position - it's only their values that exchange. If they swapped positions that would add a lot of confusion.

Extended Notes

It bears repeating that the 65c816 does not literally have a 16-bit accumulator. It actually has two 8-bit accumulator registers named A and B, respectively. When the M flag is unset and Native Mode is active, one can think of them as combining together into a 16-bit accumulator called C. A and B respectively make up the low and high bytes of the C accumulator.

The letter "C" can be found in many register transfer instructions such as TDC and TSC. This serves as a visual reminder that certain instructions work with the full C accumulator in all of the 65c816's modes. That includes Emulation Mode and the M flag being set in Native Mode.

Programmers of the 6502 might have expected to see mnemonics like TDA or TSA instead. It's worth noting that the instructions that feature the letter "C" all interchange with registers that are not variable in width (S and D).

To generalize even further, both A and B are alive and well in each of the 65c816's modes of operation. This contrasts sharply with the X and Y registers, whose 16-bit upper halves are destroyed during some changes of processor state.