任何人都可以解释一下c中的远指针吗?有什么用? [英] can any one explain me about far pointer in c? what is the use of it?

查看:58
本文介绍了任何人都可以解释一下c中的远指针吗?有什么用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

char far * scr;

char far * arr [10];

以上语句中far的用法是什么?

char far *scr;
char far *arr[10];
what is the usage of far in above statements?

推荐答案

PIEBALDconsult的答案已经足够了。这是远端指针的一些额外背景。



DOS最初运行在英特尔的8088和8086处理器上。这些处理器具有16位寄存器和20位地址总线(1兆字节)。由于20位地址总线比寄存器可容纳的位数多4位,因此可以选择高达64千字节的存储区 - 在16字节边界(称为段落)上。程序代码,数据和堆栈可以分开(中型和大型)或全部重叠(小型号)。



只要您的所有数据 - 包括堆栈空间 - 适合64 kb内部,没有必要混淆数据的远指针。只要你的代码也适合64kb,就没有必要为函数指针提供远指针。



但是,一旦你做出了单独的堆栈和数据的决定空间,或大于64 kb的数据空间,或者你的运行代码超过64 kb段,你需要从简单的16位近指针切换到32位远指针。
PIEBALDconsult's answer is quite sufficient. Here's some additional background on far pointers.

DOS originally ran on Intel's 8088 and 8086 processors. These processors had 16 bit registers and a 20 bit address bus (one megabyte). Since the 20 bit address bus was 4 bits more than what a register could hold, banks of up to 64 kilobytes of memory could be selected - on 16 byte boundaries (called paragraphs). Program code, data, and stack could be made separate (medium and large models) or all overlapping (small model).

As long as all of your data - including stack space - fit inside 64 kb, there was no need to mess with far pointers for data. As long as your code also fit inside 64kb, there was no need for far pointers for function pointers.

However, once you made the decision to have separate stack and data space, or data space larger than 64 kb, or your running code outgrew a 64 kb segment, you needed to switch from simple 16 bit near pointers to 32 bit far pointers.


这篇关于任何人都可以解释一下c中的远指针吗?有什么用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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