Reputation: 1395
I was looking up examples containing “NEAR PTR”, but they were easily replaceable with “PTR”. Is there any advantage for using “NEAR PTR”?
Upvotes: 2
Views: 1039
Reputation: 8962
NEAR is a legacy from 16-bit past. Assuming your code is 32-bit or 64-bit, they are the same.
This is about memory segments (Wikipedia link to x86 32-bit and to 64-bit).
In LABEL statement both PTR and NEAR PTR just store a 32/64 bit memory address without segment.
If compile next code under 64-bit MASM:
_DATA SEGMENT
justPtr LABEL PTR db
nearPtr LABEL NEAR PTR db
justPtrSize dd SIZEOF justPtr
nearPtrSize dd SIZEOF nearPtr
_DATA ENDS
and check under Visual Studio debugger the sizes:
?justPtrSize
8
?nearPtrSize
8
Indeed PTR occupies 8-byte (64 bit), same way as NEAR PTR does.
Upvotes: 2