INC
From C64-Wiki
Jump to navigationJump to searchINC (short for "INCrease") is the mnemonic for a machine language instruction which increases the numerical value of the contents of the address specified by one, and "wraps over" when the numerical limits of a byte are exceeded.
- If the byte in question is taken as an unsigned integer, INC "counts" from 0 thru 255/$0 thru $FF. If a byte already containing the value 255/$FF is INCremented, it "wraps over" to the value 0.
- If the byte is taken as a signed integer, INC will "count" from −128 thru +127, or −$80 thru +$7F. If a byte already holding the value 127/$7F is INCremented, it "wraps over" to the value −128/−$80.
Addressing modes[edit | edit source]
Opcode | Addressing mode |
Assembler format |
Length in bytes |
Number of cycles | |
Dec | Hex | ||||
238 | EE | Absolute | INC nnnn | 3 | 6 |
254 | FE | Absolute,X | INC nnnn,X | 3 | 7 |
230 | E6 | Zeropage | INC nn | 2 | 5 |
246 | F6 | Zeropage,X | INC nn,X | 2 | 6 |
INC supports the four different addressing modes shown in the table at right. In the assembler formats listed, nn represents a single-byte (8-bit) figure, and nnnn is a two-byte (16-bit) address.
CPU flags[edit | edit source]
INC affects 2 of the CPU's status flags:
- The negative status flag is set if the result is negative, i.e. has its most significant bit set.
- The zero flag is set if the result is zero, or cleared if it is non-zero.