AngoLinux

80386 Programmer's Reference Manual -- Opcode CWD


CWD/CDQ -- Convert Word to Doubleword/Convert Doubleword to Quadword

OpcodeInstructionClocks DescriptionExample
99cwd 2 DX:AX := sign-extend of AXcwd
99cdq 2 EDX:EAX := sign-extend of EAXcdq

Operation




IF OperandSize = 16 (* CWD instruction *)
THEN
   IF AX < 0 THEN DX := 0FFFFH; ELSE DX := 0; FI;
ELSE (* OperandSize = 32, CDQ instruction *)
   IF EAX < 0 THEN EDX := 0FFFFFFFFH; ELSE EDX := 0; FI;
FI;

Description

CWD converts the signed word in AX to a signed doubleword in DX:AX by extending the most significant bit of AX into all the bits of DX. CDQ converts the signed doubleword in EAX to a signed 64-bit integer in the register pair EDX:EAX by extending the most significant bit of EAX (the sign bit) into all the bits of EDX. Note that CWD is different from CWDE. CWDE uses EAX as a destination, instead of DX:AX.

Flags Affected

None

Protected Mode Exceptions

None

Real Address Mode Exceptions

None

Virtual 8086 Mode Exceptions

None


[Home Page dell'ITIS "Fermi"] [80386 Programmer's Reference Manual Index] [Previous] [Next]