问题
Im trying to move edx into al but i get this error
lib/io/print.asm:50: error: invalid combination of opcode and operands
this is the code
mov edx, 0x41
mov al, edx
thanks in advance
回答1:
The problem is the second line:
mov al, edx
The edx register is 32-bits, but al is 8-bit, so you can't directly move one into the other. If you want to move the low 8 bits of edx into dl, do this:
mov al, dl
Or perhaps you want to move all of edx into eax, like this:
mov eax, edx
The difference is the first option leaves the high 24 bits of eax unchanged, while the second option sets them to the same as the corresponding bits of edx.
If you don't care about the high 24 bits, e.g., because you aren't going to use them, or because you know they are zero in either case, the second option may be slightly faster because it breaks the dependency on the previous value of eax, so it can execute as soon as edx is ready, regardless of what happened to eax before.
来源:https://stackoverflow.com/questions/57531562/move-32bit-register-into-a-8-bit-register