The inc
and dec
instructions use the following syntax:
inc(mem/reg
); dec(mem/reg
);
The single operand can be any legal 8-bit, 16-bit, or 32-bit register or memory operand. The inc
instruction will add 1 to the specified operand, and the dec
instruction will subtract 1 from the specified operand.
These two instructions are slightly shorter than the corresponding add
or sub
instructions (that is, their encoding uses fewer bytes). There is also one slight difference between these two instructions and the corresponding add
or sub
instructions: They do not affect the carry flag.
As an example of the inc
instruction, consider the example from the previous section, recoded to use inc
rather than add
:
mem.alloc( 128 ); for( mov( 0, ebx ); ebx < 128; inc( ebx ) ) do mov( 0, (type byte [eax+ebx]) ); endfor;