Increment
Increment by one a register or a memory location
The increment instructions add one to either a register or a memory location.
Unlike adding 1 with ADC, these instructions does not use the Carry flag in any way. You can test for wraparound only by testing after every increment to see if the result is zero or positive.
The d flag does not affect these instructions. The increment is always in binary mode.
For all processors, the increment is an 8-bit operation unless m=0 on the 65816 in which case the increment is 16-bit.
INC - Increment
Increment by 1 the contents of the memory location or accumulator.
INX - Increment Index Register X
Increment by 1 the X index register.
INY - Increment Index Register Y
Increment by 1 the Y index register.
Flags Affected
Flags |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
n | Set if most significant bit of the result is set | ||||||||
z | Set if result is zero |
Instructions
Syntax | Opcode | Available on: | # of | # of | Addressing Mode | ||
---|---|---|---|---|---|---|---|
(hex) | 6502 | 65C02 | 65816 | bytes | cycles | ||
INC A | 1A | x | x | 1 | 2 | Accumulator | |
INC addr | EE | x | x | x | 3 | 61 | Absolute |
INC dp | E6 | x | x | x | 2 | 51, 2 | Direct Page |
INC addr,X | FE | x | x | x | 3 | 71, 3 | Absolute Indexed X |
INC dp,X | F6 | x | x | x | 2 | 61, 2 | Direct Page Indexed X |
INX | E8 | x | x | x | 1 | 2 | Implied |
INY | C8 | x | x | x | 1 | 2 | Implied |
Notes:
- 65816: Add 2 cycles if m=0 (16-bit memory/accumulator)
- 65816: Add 1 cycle if low byte of Direct Page register is not 0
- 65C02: Subtract 1 cycle if no page boundary is crossed
Last modified November 5, 2021: Add instruction categories (6b74ff9)