I am writing NASM assembly code, and have to do some indexed addressing. I have the index stored in $al, but x86 won\'t let you use $al as an index register, and I\'m alread
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