Assembly x86程序集中mov命令的有效性

Assembly x86程序集中mov命令的有效性,assembly,x86,mov,Assembly,X86,Mov,我在课堂上了解到,将16位寄存器移到8位寄存器不是有效的指令。例如,此命令无效: mov al,bx 但有没有这样的指示: mov bx,al 或者两个寄存器的大小必须相等?如下所示: mov al,bl mov bx,ax 我可以写命令吗:mov bx,al 不,但是你可以 movsx bx,al ; sign-extend al into bx ; the upper half of bx will be filled with the mo

我在课堂上了解到,将16位寄存器移到8位寄存器不是有效的指令。例如,此命令无效:

mov al,bx
但有没有这样的指示:

mov bx,al
或者两个寄存器的大小必须相等?如下所示:

mov al,bl        
mov bx,ax
我可以写命令吗:mov bx,al

不,但是你可以

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. 


同样,从16位通用寄存器到32位通用寄存器

我可以写命令吗:mov bx,al

不,但是你可以

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. 



同样,从16位通用寄存器到32位通用寄存器。

所以,如果我理解我不能写move bx,al,mov al,bxRight,你会怎么说。您可以使用sx/zx变体进行加宽移动。但是没有收缩移动,所以必须使用
mov al,bl
而不是
mov al,bx
(假设您想要
bx
)的下8位。所以如果我知道我不能写move bx,al,mov al,bx,你会怎么说。您可以使用sx/zx变体进行加宽移动。但是没有收缩移动,因此必须使用
mov-al,bl
而不是
mov-al,bx
(假设您需要
bx
的低8位)。