Opcode | Encoding | 16-bit | 32-bit | 64-bit | Description |
---|---|---|---|---|---|
99 CWD | zo | Valid | Valid | Valid | Sign extend AX into DX . |
99 CDQ | zo | Valid | Valid | Valid | Sign extend EAX into EDX . |
REX.W 99 CQO | zo | N/E | N/E | Valid | Sign extend RAX into RDX . |
Encoding
Encoding | Operand |
---|---|
zo | None |
Description
The CWD/CDQ/CQO
instructions sign extend the accumulator into the data register (rDX
). This essentially sets every bit of the data register to that of the accumulator.
This instruction is similar to CBW/CWDE/CDQE
(Sign Extend Accumulator), but working into the data register.
Operation
public void CWD()
{
// DX:AX = SignExtend(AX)
DX = AX.Bit[15] ? 0xFFFF : 0;
}
public void CDQ()
{
// EDX:EAX = SignExtend(EAX)
EDX = EAX.Bit[31] ? 0xFFFFFFFF : 0;
}
public void CQO()
{
// RDX:RAX = SignExtend(RAX)
RDX = RAX.Bit[63] ? 0xFFFFFFFFFFFFFFFF : 0;
}
Flags Affected
None.Exceptions
Real-Address Mode
#UD
- If the
LOCK
- prefix is used.
Virtual-8086 Mode
#UD
- If the
LOCK
- prefix is used.
Protected Mode
#UD
- If the
LOCK
- prefix is used.
Compatibility Mode
#UD
- If the
LOCK
- prefix is used.
Long Mode
#UD
- If the
LOCK
- prefix is used.