Friday 26 May 2017

assembly MOV instruction operands

name db 'zara ali' is just a shorthand for


name db 'z', 'a', 'r', 'a', ' ', 'a','l','i'

that is another shorthand for


name db 'z'
db 'a'
db 'r'
db 'a'
db ' '
db 'a'
db 'l'
db 'i'

thus that's a sequence of bytes, the address of the first one is given the name name.


MOV ecx, name has different semantics in different assemblers.
In NASM it doesn't read the variable name it stores the value of the symbol name in ecx - it is equivalent to the TASM/MASM notation


mov ecx, OFFSET name
lea ecx, name ;This is an abuse of notation but valid in TASM

In MASM/TASM it reads the DWORD (implied by the use of a DWORD register like ecx) at the address name, thus reading the first four bytes (zara).
It is equivalent of mov ecx, [name] or mov ecx, DWORD [name] in NASM.

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...