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

boa*_*oid 1 x86 assembly mov

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

mov al,bx
Run Code Online (Sandbox Code Playgroud)

但是有这样的指示:

mov bx,al
Run Code Online (Sandbox Code Playgroud)

或者2个寄存器的大小必须相等?如下所示:

mov al,bl        
mov bx,ax
Run Code Online (Sandbox Code Playgroud)

Mic*_*ael 6

我可以写命令: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. 
Run Code Online (Sandbox Code Playgroud)

要么

movzx bx,al  ; zero-extend al into bx
             ; the upper half of bx will be filled with zeroes 
Run Code Online (Sandbox Code Playgroud)


类似地,从16位通用寄存器到32位通用寄存器.