"PTR"和"NEAR PTR"有什么区别? [英] What is the difference between “PTR” and “NEAR PTR”?

查看:171
本文介绍了"PTR"和"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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆