近与远与巨大指针 [英] near vs. far vs. huge pointers

查看:80
本文介绍了近与远与巨大指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


Hi,
What is the difference between "near", "far" and "huge" pointers?

推荐答案

这些区别仅与16位[1] intel体系结构有关,已停止在15年前就具有重要意义.

简而言之,Intel x86芯片上的虚拟地址包含两个组件-选择器和偏移量.选择器是基地址表[2]的索引,并且偏移量被添加到该基地址上.它旨在让处理器访问20位(在8086/8、186上),30位(286)或46位(386及更高版本)的虚拟地址空间,而无需那么大的寄存器.

所以...

近"指针没有选择器-它们具有隐式选择器.他们可以在286和更早版本的虚拟地址空间上访问64k,在386或更高版本上的地址空间访问4Gb.

远"指针具有显式选择器.但是,当您对它们执行指针算术运算时,不会修改选择器.

巨大"的指针有一个显式的选择器.当您对它们进行指针算术运算时,尽管选择器可以更改.

基于"指针...哦,您没有问过它们.

基本上忽略这一点.除非您是考古学家,否则不值得花时间去学习.

干杯,



[1]好的,现代intel处理器仍然保留所有旧的分段式信息,但OS倾向于先设置一次选择器,然后再忽略它们.

[2]在实模式下,没有基址表,该地址只是选择器乘以16.
The differences are only relevant on 16 bit [1] intel architectures and stopped being significant about 15 years ago.

In a nutshell virtual addresses on an Intel x86 chip have two components - a selector and an offset. The selector is an index into a table of base addresses [2] and the offset is added onto that base address. This was designed to let the processor access 20 bit (on a 8086/8, 186), 30 bit (286) or 46 bit (386 and later) virtual address spaces without needing registers that big.

So...

''near'' pointers don''t have a selector - they have an implied selector. They can access 64k off the virtual address space on a 286 and earlier and 4Gb of the addresss space on a 386 or later.

''far'' pointers have an explicit selector. However when you do pointer arithmetic on them the selector isn''t modified.

''huge'' pointers have an explicit selector. When you do pointer arithmetic on them though the selector can change.

''based'' pointers... oh, you didn''t ask about them.

Basically ignore this. It''s not worth the hassle to learn about unless you''re an archaeologist.

Cheers,

Ash

[1] Okay, modern intel processors have all the old segmented guff still hanging about but the OS tends to set the selectors once and then forget about them.

[2] In real mode there is no table of base addresses, the address is just the selector multipled by 16.



这篇关于近与远与巨大指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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