"PTR"和"NEAR PTR"有什么区别? [英] What is the difference between “PTR” and “NEAR PTR”?
问题描述
我正在查找包含"NEAR PTR"的示例,但可以轻松地用"PTR"替换它们.使用"NEAR PTR"有什么好处吗?
I was looking up examples containing "NEAR PTR", but they were easily replaceable with "PTR". Is there any advantage for using "NEAR PTR"?
推荐答案
NEAR是16位过去的遗留物.假设您的代码是32位或64位,则它们是相同的.
NEAR is a legacy from 16-bit past. Assuming your code is 32-bit or 64-bit, they are the same.
这与内存段有关(Wikipedia链接至x86 32位并指向 64位).
This is about memory segments (Wikipedia link to x86 32-bit and to 64-bit).
在 LABEL语句中 PTR和NEAR PTR都只存储一个32/64位的内存地址,没有段.
In LABEL statement both PTR and NEAR PTR just store a 32/64 bit memory address without segment.
如果在64位MASM下编译下一个代码:
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
并在Visual Studio调试器下检查大小:
and check under Visual Studio debugger the sizes:
?justPtrSize
8
?nearPtrSize
8
独立PTR占用8字节(64位),与NEAR PTR相同.
Indeed PTR occupies 8-byte (64 bit), same way as NEAR PTR does.
这篇关于"PTR"和"NEAR PTR"有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!