INX Instruction (Increment Index Register X)
Increments the value of index register X.
INX Overloads
| Opcode | Syntax | Addressing Mode | Bytes | Cycles | Notes |
|---|---|---|---|---|---|
| E8 | INX | Imp. | 1 | 2 |
Flags Affected
n-----z-
n: Set to the MSB of the incremented result
z: Set if the incremented result is 0
Examples
A loop that fills memory
; fill 32 bytes from $7E:2000 with $FF (A is 8-bit, X is 16-bit)
LDA.b #$FF
LDX.w #$0000
.loop
STA.l $7E2000,X
INX
CPX.w #$0020
BNE .loop
When processing a table of 16-bit values in order, use two INX instructions in a row to advance 2 bytes at a time.
See also
DEC instruction
DEX instruction
DEY instruction
INC instruction
INY instruction