Decrement

Decrement by one a register or a memory location

The decrement instructions add one to either a register or a memory location.

Unlike subtracting 1 with ADC, these instructions does not use the Carry flag in any way. You can test for wraparound only by testing after every decrement to see if the result is zero or negative.

The d flag does not affect these instructions. The decrement is always in binary mode.

For all processors, the decrement is an 8-bit operation unless m=0 on the 65816 in which case the decrement is 16-bit.

DEC - Decrement

Decrement by 1 the contents of the memory location or accumulator.

DEX - Decrement Index Register X

Decrement by 1 the X index register.

DEY - Decrement Index Register Y

Decrement by 1 the Y index register.

Flags Affected
Flags
n-----z-
nSet if most significant bit of the result is set
zSet if result is zero
Instructions
SyntaxOpcode Available on: # of # of Addressing Mode
(hex) 6502 65C02 65816 bytes cycles
DEC A3A x x 1 2 Accumulator
DEC addrCE x x x 3 61 Absolute
DEC dpC6 x x x 2 51, 2 Direct Page
DEC addr,XDE x x x 3 71, 3 Absolute Indexed X
DEC dp,XD6 x x x 2 61, 2 Direct Page Indexed X
DEX CA x x x 1 2 Implied
DEY 88 x x x 1 2 Implied

Notes:

  1. 65816: Add 2 cycles if m=0 (16-bit memory/accumulator)
  2. 65816: Add 1 cycle if low byte of Direct Page register is not 0
  3. 65C02: Subtract 1 cycle if no page boundary is crossed

Last modified November 5, 2021: Add instruction categories (6b74ff9)