Can I do this in assembly mov eax, [ax] or must I specify the size mov eax, dword [ax].
Can I do this in assembly mov eax, [ax] or must I specify the
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
[ax]is not a valid 16-bit addressing mode. Change it tomov ebx, [bx]and you could do it. Theebxdetermines the size of the operation, so you wouldn’t need to saydword. In 32-bit mode,[bx]is unlikely to be a “useful” address, but it’s “valid” code. In 32-bit mode,mov al, [eax],mov ax, [eax]andmov eax, [eax]are all valid, and the sizes are determined by the size of the destination register, but you might want to say “byte”, “word”, or “dword” for clarity. In this(!) case, the sizes do not have to match.FWIW, it is possible to use 32-bit instructions – and 32-bit addressing modes – in 16-bit code. The entire address needs to be within the segment limit – usually 64k – but
mov eax, [eax + ecx * 4]is valid code. Nasm (or other “competent” assembler) will generate the required “operand size override prefix” and “address size override prefix” (0x66 and 0x67).Don’t be afraid to try these things… although it may not be clear WHY Nasm is refusing, and if Nasm DOES accept it that doesn’t mean it will do what you intend…