gpt4 book ai didi

assembly - GDT 的粒度位对于寻址内存到底有什么变化?

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

如果该位为零,那么内存是逐字节寻址的?如果是1,那么内存是按4Kb×4Kb寻址的?

例如,如果该位设置为 0,并且我寻址内存位置 a000h,那么我将寻址该字节在那个位置对吧?如果我寻址下一个位置a001h,那么这将是内存中的下一个字节,对吗?

但如果该位为 1,我会寻址 4Kb block 吗?

那么寻址 a000h 会给我一个 4Kb block ,而 a001内存中的下一个 4Kb?

最佳答案

kbzombie的回答几乎是正确的。互联网上的各种资源实际上都犯了同样的错误,可能是因为一个复制了另一个。

设置粒度位后,限制确实左移 12 位,但需要注意的是插入了一位。因此,0xfffff 会导致 0xffffffff 的限制,0x00000 会导致 0x00000fff 的限制。

The 80386 Programmer's Reference Manual有这样说:

6.3.1.2 LIMIT CHECKING

The limit field of a segment descriptor is used by the processor to prevent programs from addressing outside the segment. The processor's interpretation of the limit depends on the setting of the G (granularity) bit. For data segments, the processor's interpretation of the limit depends also on the E-bit (expansion-direction bit) and the B-bit (big bit) (refer to Table 6-2).

When G= 0, the actual limit is the value of the 20-bit limit field as it appears in the descriptor. In this case, the limit may range from 0 to 0FFFFFH (220 - 1 or 1 megabyte). When G= 1, the processor appends 12 low-order one-bits to the value in the limit field. In this case the actual limit may range from 0FFFH (212 - 1 or 4 kilobytes) to 0FFFFFFFFH (232 - 1 or 4 gigabytes).

Table 6-2

关于assembly - GDT 的粒度位对于寻址内存到底有什么变化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26577692/

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