关于 cbw 指令及其相关指令:
CBW, CWD, CDQInstructions
The CBW (convert byte to word) instruction extend s the sign bit of AL into the AH register. This preserves the number 's sign:
.DATA
byte_val SBYTE -101
.CODE
mov al, byte_val ; AL = 9Bh
cbw ; AX = FF9Bh
Note that both 9Bh and FF9Bh both equal decimal -101, the only difference is the storage size.
The CWD (convert word to doubleword) instruction extends the sign bit of AX into the DX register:
.DATA
word_val SWORD -101 ; FF9Bh
.CODE
mov ax, word_val ; AX = FF9Bh
cwd ; DX:AX = FFFFh:FF9Bh
The CDQ (convert doubleword to quadword) instruction extends the sign bit of EAX into the EDXregister:
.data
dword_val SDWORD -101
.code
mov eax, dword_val ; EAX = FFFFFF9Bh
cdq ; EDX:EAX = FFFFFFFh:FFFFFFF9Bh