BigEd wrote:
So with XBA, TCD and TDC, emulation mode has access to a further two bytes of register?
Correct.
XBA is particularly useful in emulation mode, as you effectively have two accumulators at your disposal. It's just a matter of keeping track of which accumulator is holding what, and remembering that a
PHA only pushes the A-accumulator.
Even in native mode,
XBA is very useful. Consider, for example, a SCSI driver that is setting up a command descriptor block (CDB). Data transfer sizes in CDBs are written in big-endian format, but the 65C816 processes in little-endian. So if a data transfer size has been computed and is presently loaded in the 16-bit accumulator, it will be in little-endian format. Prior to writing the size value into the CDB, an
XBA would reverse endianess.
Interesting aside:
XBA counter-intuitively affects the
N and
Z flags in
SR according to the value transferred into the A-accumulator, regardless of the current
m bit setting in
SR. Hence the following code would set
N and clear
Z:
Code:
rep #%00100000 ;16 bit accumulator
lda #$8000 ;.C = $8000
xba ;.C = $0080
brk
On the other hand:
Code:
rep #%00100000 ;16 bit accumulator
lda #$8000 ;.C = $8000
and #$ff00 ;.C = $8000
brk
would also set
N and clear
Z, as all arithmetic and Boolean operations on the 16 bit accumulator condition
N according to the value of bit 15, not bit 7.