Professional Documents
Culture Documents
Tech No Locus CBWCWD Instructions 2727140
Tech No Locus CBWCWD Instructions 2727140
The CBW instruction fill upper-byte or word with copies of sign bit of
lower bit. This operation is called sign extension of byte to word. No flag is affected by this
instruction. This operation is done with AL register and the result is stored in AX register,
so no operand is required. In the demonstration given below we've first cleared AX and
then enter 9Bh in AL. The signed number is negative. That means most significant bit is 1.
-A 100
448A:0100 MOV AX,0
448A:0103 MOV AL,9B
448A:0105 CBW
448A:0106
-R IP
IP 0103
:100
-P
Now, after we execute the instruction CBW, AH is filled up with the most significant bit of
the content of AL and that makes the content of AH register FFh, all 1s.
The instruction CWD fills upper word or double word with sign bit of lower word. This
instruction is just an extended form of the CBW instruction.This instruction results in sign
extension of AX register to DX:AX. To demonstrate it we first clear both AX and DX and
then move a number F01Ah to register AX. Then we execute CWD.
-A 100
448A:0100 MOV AX,0
448A:0103 MOV DX,0
448A:0106 MOV AX,F01A
448A:0109 CWD
448A:010A
-R IP
IP 0109
:100
-G 10A
The right most bit of the content of AX, i.e. the sign bit is 1 signifying a negative number.
Thus the DX register is totally filled up with 1s and that makes it FFFFh.