CBW: Convert Byte to Word

For information about interpreting this page, see the help page.
Opcode and MnemonicEncoding16 bit Mode32 bit Mode64 bit ModeDescription
98
CBW
ZOValidValidValidSign extend AL into AX.

Encoding

EncodingOperand
ZONone

Description

The CBW instruction sign extends AL into AX.

This instruction shares its opcode with CWDE (Convert Word to Doubleword). Which one will be used depends on the operating mode of the processor (CBW in 16 bit mode and CWDE in 32 bit mode). To force the use of the other one (i.e. CBW in 32 bit mode and CWDE in 16 bit mode), prefix this instruction with OPSIZE (0x66).

Operation

This pseudo-code uses C# syntax. A list of the types used is available here.
public void CBW()
{
  AX = SignExtend(AL);
}

Flags Affected

CF (carry flag)
Unmodified.
PF (parity flag)
Unmodified.
AF (auxiliary flag)
Unmodified.
ZF (zero flag)
Unmodified.
SF (sign flag)
Unmodified.
OF (overflow flag)
Unmodified.

Exceptions

Protected Mode

#UD
If the LOCK prefix is used.

Real-Address Mode

#UD
If the LOCK prefix is used.

Virtual-8086 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.