TXA Instruction (Transfer Index Register X to Accumulator)
Transfers the value of index register X to the accumulator.
TXA Overload
| Opcode | Syntax | Addressing mode | Byte count | Execution cycles | Note |
|---|---|---|---|---|---|
| 8A | TXA | Imp. | 1 | 2 |
Status flag changes
n-----z-
n: Receives the MSB of the transferred value.
z: Set if the transferred value is 0; cleared otherwise.
Explanation
The TXA instruction transfers the value of index register X to the accumulator.
Index register X is not cleared, and the value that was in the accumulator before TXA executed is discarded.
For register-to-register transfer instructions, the number of bytes transferred changes according to the status flags as follows.
| Source | Destination | Status flags | Transfer width | Note |
|---|---|---|---|---|
| 8-bit accumulator | 8-bit index register | m = 1, x = 1 | 8-bit | |
| 8-bit accumulator | 16-bit index register | m = 1, x = 0 | 16-bit | 1 |
| 16-bit accumulator | 8-bit index register | m = 0, x = 1 | 8-bit | 2 |
| 16-bit accumulator | 16-bit index register | m = 0, x = 0 | 16-bit | |
| 8-bit index register | 16-bit accumulator | m = 0, x = 1 | 16-bit | 3 |
| 16-bit index register | 8-bit accumulator | m = 1, x = 0 | 8-bit | 4 |
| 16-bit stack pointer | 8-bit index register | x = 1 | 8-bit | 5 |
| 8-bit index register | 16-bit stack pointer | x = 1 | 16-bit | 6 |
Note
- The unused high byte of the accumulator is transferred to the high byte of the index register.
- Only the low byte of the accumulator is transferred to the index register.
- 16 bits are transferred, but the high byte of the accumulator is always set to 0.
- Only the low byte of the index register is transferred; the unused high byte of the accumulator is not changed.
- Only the low byte of the stack pointer is transferred.
- 16 bits are transferred, but the high byte of the stack pointer is always set to 0.
Examples
Doing arithmetic on an index
TXA ; move the index into A to do arithmetic
CLC
ADC.w #$0010
TAX
When X is 16-bit and A is 8-bit, only the low byte is transferred and the high byte of A is left as is.
See also
TAX instruction
TAY instruction
TYA instruction
TSX instruction
TXS instruction
TXY instruction
TYX instruction
TCD instruction
TDC instruction
TCS instruction
TSC instruction
XBA instruction