DEC Variable

Function
Decrement value of Variable by one.

Explanation
The DEC instruction subtracts one from the specified variable. If the variable holds zero it will roll over to its maximum value (255 for bytes, 65535 for words) after DEC.

flags           VAR     Byte(2)
result          VAR     Word

Main:
  flags(0) = 0
  DEC flags(0)                                  ' flags(0) = flags(0) - 1

  result = $0000
  DEC result                                    ' result is now $FFFF

Related Instruction: INC and DJNZ