Opcode | Encoding | 16-bit | 32-bit | 64-bit | Description |
---|---|---|---|---|---|
FE /1 DEC r/m8 | m | Valid | Valid | Valid | Decrement r/m8. |
REX FE /1 DEC r/m8* | m | N/E | N/E | Valid | Decrement r/m8. This uses the alterate gpr8 encoding. |
FF /1 DEC r/m16 | m | Valid | Valid | Valid | Decrement r/m16. |
FF /1 DEC r/m32 | m | Valid | Valid | Valid | Decrement r/m32. |
REX.W FF /1 DEC r/m64 | m | N/E | N/E | Valid | Decrement r/m64. |
48+rw DEC r16 | o | Valid | Valid | N/E | Decrement r16. |
48+rd DEC r32 | o | Valid | Valid | N/E | Decrement r32. |
Encoding
Encoding | Operand |
---|---|
m | ModRM.r/m[rw] |
o | opcode(0..2) |
Description
The DEC
instruction decrements the operand by one. It is equivalent to a SUB
instruction with an operand of 1
, but without touching the EFLAGS.CF
flag.
The opcode forms (bytes 0x48..0x4F
) were repurposed in Long Mode for the REX prefix. As such, they are only encodable outside of Long Mode. If they are encountered in Long Mode, they will be mistakenly interpretted as REX prefixes for the following byte.
This instruction can be used with the LOCK
prefix to allow atomic exectution.
Operation
public void DEC(ref U8 arg)
{
arg--;
}
public void DEC(ref U16 arg)
{
arg--;
}
public void DEC(ref U32 arg)
{
arg--;
}
public void DEC(ref U64 arg)
{
arg--;
}
Flags Affected
CF
(carry flag)- Unmodified.
PF
(parity flag)- Set according to the result.
AF
(auxiliary flag)- Set according to the result.
ZF
(zero flag)- Set according to the result.
SF
(sign flag)- Set according to the result.
OF
(overflow flag)- Set according to the result.
Exceptions
Real-Address Mode
#UD
- If the
LOCK
- prefix is used, but the destination is not a memory operand.
#SS(0)
- If a memory operand using the
SS
- segment has an effective address that is outside the
SS
- segment's limit.
#GP(0)
- If a memory operand (using a segment other than
SS
- ) has an effective address that is outside the segment's limit.
Virtual-8086 Mode
#UD
- If the
LOCK
- prefix is used, but the destination is not a memory operand.
#SS(0)
- If a memory operand using the
SS
- segment has an effective address that is outside the
SS
- segment's limit.
#GP(0)
- If a memory operand (using a segment other than
SS
- ) has an effective address that is outside the segment's limit.
#PF(fc)
- If a page fault occurs.
#AC(0)
- If alignment checking is enabled while the current privilege level is 3 and an unaligned memory access is made.
Protected Mode
#UD
- If the
LOCK
- prefix is used, but the destination is not a memory operand.
#SS(0)
- If a memory operand using the
SS
- segment has an effective address that is outside the
SS
- segment's limit.
#GP(0)
- If the destination is located in a non-writable segment.
- If a memory operand uses a segment containing a
NULL
selector. - If a memory operand (using a segment other than
SS
) has an effective address that is outside the segment's limit.
#PF(fc)
- If a page fault occurs.
#AC(0)
- If alignment checking is enabled while the current privilege level is 3 and an unaligned memory access is made.
Compatibility Mode
#UD
- If the
LOCK
- prefix is used, but the destination is not a memory operand.
#SS(0)
- If a memory operand using the
SS
- segment has an effective address that is outside the
SS
- segment's limit.
#GP(0)
- If the destination is located in a non-writable segment.
- If a memory operand uses a segment containing a
NULL
selector. - If a memory operand (using a segment other than
SS
) has an effective address that is outside the segment's limit.
#PF(fc)
- If a page fault occurs.
#AC(0)
- If alignment checking is enabled while the current privilege level is 3 and an unaligned memory access is made.
Long Mode
#UD
- If the
LOCK
- prefix is used, but the destination is not a memory operand.
#SS(0)
- If a memory operand using the
SS
segment is in non-canonical form. - If a memory operand using the
SS
segment has an effective address that is outside theSS
segment's limit.
#GP(0)
- If a memory operand (using a segment other than
SS
) is in non-canonical form. - If the destination is located in a non-writable segment.
- If a memory operand uses a segment containing a
NULL
selector. - If a memory operand (using a segment other than
SS
) has an effective address that is outside the segment's limit.
#PF(fc)
- If a page fault occurs.
#AC(0)
- If alignment checking is enabled while the current privilege level is 3 and an unaligned memory access is made.