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
See Question&Answers more detail:osIm 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
See Question&Answers more detail:osThe 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.
movzx eax, dl
MOVZX has the same benefit of avoiding a false-dependency on the AL destination, while only taking one byte from EDX and zero-extending it. The byte you want is in AL.
If you want a different byte of the source EDX, you can move and shift, or movzx eax, dh
.