Reputation: 21625
Both brackets and PTR
imply the following value (memory address or register value) is dereferenced, is it really necessary to have both of them to appear at the same time from language design perspective?
Upvotes: 1
Views: 859
Reputation: 102296
is it really necessary to have both of them to appear at the same time from language design perspective?
Usually not. While you do have to specifically indicate you want the value (and the not the address) of a symbolic, using both is neither required nor prohibited.
Using the bracket is just a convention many folks use to indicate they are using the value, and not the address or pointer. Sometimes you will hear it called "contents".
If you want to see an example of both of them being required, then see Addressing variables (or, what is ML64 generating?). But this is not a language requirement per se. Rather, both are required because the same source is used for both MASM/ML and MASM64/ML64.
Under MASM64/ML64, the assembler does not appear to handle symbolic defines and fastcall properly, so both are needed due to the <symbolic name> EQU <register>
. Or, maybe the code was written so the assembler could not handle it...
If you look closely, you will see MASM uses base relative addressing (everything is accessed via EBP
), while MASM64 has dirrent requirements due to fastacll
, where the first two args are available via registers (ECX
and EDX
).
Both brackets and PTR imply the following value (memory address or register value)
You probably know this already, but in case someone else finds it useful ...
In C, you always deal with the value and have to do special things to get the address:
int value = 1;
In your C code, you would always use 1
unless you take the address of the variable.
In ASM, the opposite is in effect. When you declare a variable and symbolically refer to it:
LOCAL value:QWORD
You are always working with the address unless you take special steps to work with the value. To get the value, you would use QWORD PTR value
or [value]
. Or you can use both QWORD PTR [value]
, which is harmless.
Upvotes: 1