NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: dalfonso01 on July 24, 2014, 08:50:00 AM
-
Hi,
As far as I can understand the instructions:
mov dword [HexStr], 'G'
mov [HexStr], dword 'G'
mov dword [HexStr], dword 'G'
work and do the same.
Are this corrects ? And what could the better representing (the 3rd is just to overload more)
I checked and they will end up to the very same opcode:
29 00000011 C705[00000000]4700- mov dword [HexStr], 'G'
30 00000019 0000
Thanks
-
Yeah, they're all the same. I tend to default to:
mov dword [eax], 'G'
But I was discussing this question with someone around here, and we observed that in:
movzx eax, byte [ebx]
the size specifier has to come second, so perhaps it would be better to standardize on putting it second. I haven't changed my habits, but you can develop better ones if you want. :)
Why in the world you want to treat 'G' as a dword is a different question. :)
Best,
Frank
-
Hi,
that was just playing with the fact that you are 'altering' more than you are actually putting, so that size specifier has a reason to be there.
Thanks
Fabio D'Alfonso
-
Hi,
I was now wondering why the two are different, but in this case the point is that the
movzx byte eax, [ebx]
is not different but actually and error, because we are applying a size specifier to a register that has its own implicit size getting a warning, and being ignored, while the other which is a location in memory has no one.
But there is something more I would need to think about this, because
mov byte eax, [ebx]
only fires the warning.
Any way, as of my minimal knowledge, if the destination is a register, you are using the register size to tell how much you are storing. That works for mov while is the opposite for movzx where there is a need to put the size specifier before the source operand, where in mov is an error.