Reputation: 407
Back at it with another assembly question. I am having a hard time seeing what is the difference between square brackets and ptr in assembly.
mov dword ptr eax, 1234 ; this should write 1234 to the memory address stored at eax right?
mov dword ptr [eax], 1234; this writes to the memory address that is stored at the memory address that is stored in eax?
mov [eax], 1234 ; this does the same as the first one right? it writes 1234 to the memory address that is stored in eax?
Can anyone please shed some light on this topic?
Upvotes: 0
Views: 327
Reputation: 58467
dword PTR
is just a size specifier for what follows. Since the size of eax
is known, the dword PTR
is redundant in the first case.
That is, mov dword ptr eax, 1234
is the same as just writing mov eax, 1234
.
mov dword ptr [eax], 1234
means write 1234 to the doubleword in memory at the address given by eax
.
mov [eax], 1234
is ambigous and shouldn't even assemble. The assembler has no way of knowing if you intended to store a word or a doubleword.
Upvotes: 4