TXA Instruction (Transfer Index Register X to Accumulator)

Transfers the value of index register X to the accumulator.

TXA Overload

OpcodeSyntaxAddressing modeByte countExecution cyclesNote
8ATXAImp.12

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.

SourceDestinationStatus flagsTransfer widthNote
8-bit accumulator8-bit index registerm = 1, x = 18-bit
8-bit accumulator16-bit index registerm = 1, x = 016-bit1
16-bit accumulator8-bit index registerm = 0, x = 18-bit2
16-bit accumulator16-bit index registerm = 0, x = 016-bit
8-bit index register16-bit accumulatorm = 0, x = 116-bit3
16-bit index register8-bit accumulatorm = 1, x = 08-bit4
16-bit stack pointer8-bit index registerx = 18-bit5
8-bit index register16-bit stack pointerx = 116-bit6

Note

  1. The unused high byte of the accumulator is transferred to the high byte of the index register.
  2. Only the low byte of the accumulator is transferred to the index register.
  3. 16 bits are transferred, but the high byte of the accumulator is always set to 0.
  4. Only the low byte of the index register is transferred; the unused high byte of the accumulator is not changed.
  5. Only the low byte of the stack pointer is transferred.
  6. 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