If this bit is zero, then memory is addressed byte by byte? And if it is 1, then memory is addressed 4Kb by 4Kb?
So for example, if this bit was set to 0, and i addressed memory location a000h, then i would be addressing the byte at that location right? And if i addressed the next location a001h, then that would be the next byte up in memory right?
But if this bit was 1, will i be addressing 4Kb chunks?
So would addressing a000h give me a 4Kb chunk, and a001 the next 4Kb up in memory?
The answer by kbzombie is almost correct. Various resources on the internet make the same mistake actually, likely because one copies the other.
When the granularity bit is set, the limit is indeed shifted left by 12 bits, but it's important to note that one-bits are inserted. So 0xfffff results in a limit of 0xffffffff, and 0x00000 results in a limit of 0x00000fff.
The 80386 Programmer's Reference Manual has this to say:
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With