Isn't PTR redundant in this instruction : CALL DWORD PTR [XXXXXXXX]
Isn't PTR redundant in this instruction CALL DWORD PTR [XXXXXXXX]
. If the instruction was CALL DWORD [XXXXXXXX]
This also says, Call th开发者_运维百科e DWORD length value located at the address XXXXXXXX.
Why PTR then?
If i remember right, the "PTR" operator is there because in MASM, there are times when you can have an expression that looks like a regular value but is actually a pointer.
If both statements work for you, all i can say is, assemble them both and make sure they both generate the same bytes. They ought to be the same thing, considering the "xxxxxxxx" in [xxxxxxxx]
is by definition a pointer, but it's been a while since i last coded in MASM. (NASM, which i tend to favor, is far less confusing about such things.)
In masm parlance, DWORD PTR is a pointer override, IOW what you would usually call a cast. It basically means, "consider address XXXXXXXX as a DWORD pointer".
masm actually types its data items. So if XXXXXXXX has previously been defined as
XXXXXXXX DWORD SomeAddress ; Presumably a function entry point.
then
CALL XXXXXXXX
is enough and will generate the same code as
CALL DWORD PTR XXXXXXXX
OTOH, if for some reason, XXXXXXXX were instead defined as
XXXXXXXX WORD ?
WORD ?
then the only way to get MASM to assemble a call to XXXXXXXX without generating a mams error would be
CALL DWORD PTR XXXXXXXX
The square brackets [ ] don't bring anything to the plate in this case, BTW. For some other assemblers, they indicates indirection. In the examples above, masm doesn't require them. In other contexts (base + index expressions), they are used to bracket the index registers and/or values.
Oh, and btw:
CALL DWORD [XXXXXXXX]
is today an unusual masm syntax (per masm 6 documentation books and their examples), and probably a compatibility allowance corresponding to some older masm syntax.
精彩评论