Question

I learned in my class that it's not a valid instruction to move a 16-bit register to a 8-bit register. For example this command is not valid:

mov al,bx

But is there an instruction like this:

mov bx,al

Or must the sizes of the 2 registers be equal? As in below:

mov al,bl        
mov bx,ax
Was it helpful?

Solution

can i write command : mov bx,al

No, but you can do

movsx bx,al  ; sign-extend al into bx
             ; the upper half of bx will be filled with the most significant
             ; bit of al. For example 0x40 becomes 0x0040, while 0xC0
             ; becomes 0xFFC0. 

or

movzx bx,al  ; zero-extend al into bx
             ; the upper half of bx will be filled with zeroes 


and similarly from 16-bit general purpose registers to 32-bit general purpose registers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top