Use the MOVZX
instruction:
movzx ecx, al ; move byte to doubleword, zero-extension
There's also MOVSX
if you want the value in al
to be treated as signed.
Zero-extention means the upper bits of the destination operand will be set to zero, while sign-extension means the upper bits of the destination operand will be set to the sign bit of the source operand. Some examples:
mov al,0x7F
movzx ebx,al ; ebx = 0x0000007F
movsx ebx,al ; ebx = 0x0000007F
mov al,0x80
movzx ebx,al ; ebx = 0x00000080
movsx ebx,al ; ebx = 0xFFFFFF80
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…