gpt4 book ai didi

c++ - 24 位地址和 24 位算术与具有 16 位地址算术的 24 位地址之间的区别?

转载 作者:行者123 更新时间:2023-12-02 10:02:22 27 4
gpt4 key购买 nike

我在 c167 文档中找到了关于指针算术的注释。
有两个宏_huge 和_shuge。

来自 Doku 的引用:

_huge or _shuge. Huge data may be anywhere in memory and you can

also reference it using a 24 bit address. However, address arithmetic is

done using the complete address (24 bit). Shuge data may also be

anywhere in memory and you can also reference it using a 24 bit address.

However, address arithmetic is done using a 16 bit address.



那么_huge和_shuge的用法有什么区别呢?
在我的理解中,指针的算术是使用起始地址的偏移量

到目前为止我所理解的示例:

&a[0] + 1 where one element of a is int32 &a[0] gives me the address of the first element thi s would be equal to 0x1234211 + 32Bit for example.**



考虑到上面的注释是否有区别,_huge 和 _shuge 有什么区别?

此致

最佳答案

在此 PDF 的第 17 页(标记为第 7 页)上有斜向说明:https://www.tasking.com/support/c166/c166_user_guide_v4.0.pdf

By default all __far pointer arithmetic is 14-bit. This implies that comparison of __far pointers is also done in 14-bit. For __shuge the same is true, but then with 16-bit arithmetic.This saves code significantly, but has the following implications:

• Comparing pointers to different objects is not reliable. It is only reliable when it is known that these objects are located in the same page.

• Comparing with NULL is not reliable. Objects that are located in another page at offset 0x0000 have the low 14 bits (the page offset) zero and will also be evaluated as NULL.



换句话说, _shuge指针的最低 16 位以上的位将被忽略,除非取消引用它们。您可能还注意到 _shuge指针有 16 位对齐,这意味着它们的最低 4 位始终为零,因此在比较或减法时只需要考虑 12 位。

关于c++ - 24 位地址和 24 位算术与具有 16 位地址算术的 24 位地址之间的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62001929/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com