The 8051 Instruction Set
1-35 Atmel 8051 Microcontrollers Hardware Manual
4316B–8051–02/04
1.14.13 DECbyte
Function: Decrement
Description: DEC byte decrements the variable indicated by 1. An original value of 00H underflows to 0FFH. No flags are
affected. Four operand addressing modes are allowed: accumulator, register, direct, or register-indirect.
Note: When this instruction is used to modify an output port, the value used as the original port data will be read
from the output data latch, not the input pins.
Example: Register 0 contains 7FH (01111111B). Internal RAM locations 7EH and 7FH contain 00H and 40H, respectively.
The following instruction sequence,
DEC @R0
DEC R0
DEC @R0
leaves register 0 set to 7EH and internal RAM locations 7EH and 7FH set to 0FFH and 3FH.
DEC A
Bytes: 1
Cycles: 1
Encoding: 00010100
Operation: DEC
(A) ← (A) - 1
DEC R
n
Bytes: 1
Cycles: 1
Encoding: 00011r r r
Operation: DEC
(R
n
) ← (R
n
) - 1
DEC direct
Bytes: 2
Cycles: 1
Encoding: 00010101 direct address
Operation: DEC
(direct) ← (direct) - 1
DEC @R
i
Bytes: 1
Cycles: 1
Encoding: 0001011 i
Operation: DEC
((R
i
)) ← ((R
i
)) - 1