INC and DEC Instructions


The instruction adds 1 to a single operand, and the instruction subtracts 1 from a single operand.

INC — Increment

Usage: INC dest

Flag O D I S Z A P C
Result *     * * * *  

Adds one to destination unsigned binary operand.

Clocks
Operand 286 386 486 Size Bytes
reg8 2 2 1 2
reg16/32 2 2 1 1
mem 7 6 3 2-4

DEC — Decrement

Usage: DEC dest

Flag O D I S Z A P C
Result *     * * * *  

Unsigned binary subtraction of one from the destination.

Clocks
Operand 286 386 486 Size Bytes
reg8 2 2 1 2
reg16/32 2 2 1 1
mem 7 6 3 2-4


INC X+1 ADD X+1, 1 DEC [OFFSET X]
 INCLUDE Irvine32.inc
 .data
  X   WORD  1234h
 .code
 main PROC
  inc    X+1
  movzx  eax, X
  call   WriteHex
  exit
 main ENDP
 END main
 INCLUDE Irvine32.inc
 .data
  X   WORD  1234h
 .code
 main PROC
  add    X+1, 1
  movzx  eax, X
  call   WriteHex
  exit
 main ENDP
 END main
 INCLUDE Irvine32.inc
 .data
  X   WORD  1234h
 .code
 main PROC
  mov    ebx, OFFSET X
  dec    [ebx]
  movzx  eax, X
  call   WriteHex
  exit
 main ENDP
 END main
Output Output Output

 

 

 

 

 

 






      “I’m not arguing, I’m just explaining why I’m right.”    
      ― Unknown