Microsoft KB Archive/120069

= Real and Protected Mode Segment Size =

Article ID: 120069

Article Last Modified on 2/11/2004

-

APPLIES TO


 * Microsoft Macro Assembler 6.1 Standard Edition
 * Microsoft Macro Assembler 6.11 Standard Edition

-



This article was previously published under Q120069



In real mode on an x86 machine, a physical segment can be up to 64K in size. A segment does not have to be 64K. Typically, your program segments will not be a full 64K. The size of the segment depends on what you and/or the assembler put in it.

With a real mode application, even though a segment may be less than 64K, you can still access beyond the end of the segment up to the 64K limit. Therefore, if you unintentionally write beyond the end of the segment in real mode, there is no warning given by the operating system.

In protected mode, each segment has a descriptor that describes the segment. One of the characteristics the descriptor contains is a segment limit. The CPU uses the segment limit to determine if you have accessed beyond the end of the segment. Unintentionally accessing beyond the segment boundary causes an interrupt called a "general protection fault" to occur.

With 286 processors, the limit field is 16-bits in length, which limits segments to 64K of memory.

With 386 processors and higher, you can create segments larger than 64K. The limit field is 20-bits in length, which allows the addressing of 1M items. The granularity bit of the descriptor determines if each item is 1 byte or 1 page (4K on an x86 machine). Therefore, page granularity provides a segment limit of 4G of memory. The segment limit will nearly always be set to less than the full 4G.

Additional query words: 6.00 6.10

Keywords: KB120069

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.