up: Chapter 17 -- 80386 Instruction Set
prev: CALL Call Procedure
next: CLC Clear Carry Flag


CBW/CWDE -- Convert Byte to Word/Convert Word to Doubleword

Opcode    Instruction     Clocks          Description

98        CBW             3               AX := sign-extend of AL
98        CWDE            3               EAX := sign-extend of AX

Operation

IF OperandSize = 16 (* instruction = CBW *)
THEN AX := SignExtend(AL);
ELSE (* OperandSize = 32, instruction = CWDE *)
   EAX := SignExtend(AX);
FI;

Description

CBW converts the signed byte in AL to a signed word in AX by extending the most significant bit of AL (the sign bit) into all of the bits of AH. CWDE converts the signed word in AX to a doubleword in EAX by extending the most significant bit of AX into the two most significant bytes of EAX. Note that CWDE is different from CWD. CWD uses DX:AX rather than EAX as a destination.

Flags Affected

None

Protected Mode Exceptions

None

Real Address Mode Exceptions

None

Virtual 8086 Mode Exceptions

None


up: Chapter 17 -- 80386 Instruction Set
prev: CALL Call Procedure
next: CLC Clear Carry Flag