<<< BSWAP Instruction Swap Bytes | Index | Sign Extending Signed Value >>> |
Since moving data between registers of different sizes is illegal, you must sign-extend integers to convert signed data to a larger size.
Sign-extending means copying the sign bit of the unextended operand to all bits of the operand's next larger size.
This widens the operand while maintaining its sign and value.
The four instructions presented below act only on the accumulator register (AL, AX, or EAX), as shown:
Instruction | Sign-extend |
---|---|
CBW (convert byte to word) | AL to AX |
CWD (convert word to doubleword) | AX to DX:AX |
CWDE (convert word to doubleword extended) | AX to EAX |
CDQ (convert doubleword to quadword) | EAX to EDX:EAX |
<<< BSWAP Instruction Swap Bytes | Index | Sign Extending Signed Value >>> |