APPLICATION ARCHITECTURE

REGISTER STACK

79

78

64

63

± EXPONENTSIGNIFICAND

CONTROL REGISTER

STATUS REGISTER

Figure 2-3. Numeric Coprocessor Registers

2.2 Memory and logical Addressing

80386 application programs use logical addresses to specify the locations of operands in a 4- gigabyte physical address space. The processor automatically translates these logical addresses to the physical addresses that it emits on the system bus. As discussed more fully in Chapter 3, an 80386 operating system can tailor an appli- cation program's view of its logical address space. For example, an operating system can define the logical address space as it is defined by many architectures, as a simple array of 232 bytes. Alternatively, an 80386 operating system can organize the logical address space as a collection of variable-length segments. An operating system can define many segments or just a few, as appropriate to its view of logical memory; the 80386 does not dictate the use of segments, but rather allows them to be used as they support application needs. When reading the following sections, bear in mind that the extent to which an

application program actively uses segments de- pends on the framework established by the operating system.

2.2.1 Segments

As just mentioned, an operating system can define the 80386 logical address space as one or more segments. Segments are logical units that map well to programming structures, which are inherently variable in length. For example, a l5l6-byte procedure fits exactly into a 1516-byte segment, as an 8-megabyte array (for example, a 1028x1028x8 display buffer) fits exactly into a segment of the same size. By providing architec- tural support for segments (for example, segments can be individually protected, and can be shared selectively between tasks), the 80386 improves the performance of systems that choose segments as a structuring mechanism. (Pages, which are described in Chapter 3, are fixed-size; they do not map well to programming constructs, but, on the other hand, are better-suited to operating system functions such as swapping.)

An 80386 segment can be any size from 1 byte to 4 gigabytes. For every segment, the operating system maintains an architecture-defined descrip- tor that specifies the attributes of the segment. Segment attributes include a 32-bit base address and limit (length), and protection information that can guard a segment against incorrect use. Because descriptors are maintained by operating systems, fuller coverage of them is deferred to Chapter 3. Application programs deal only indirectly with descriptors, referring to segments by means of logical addresses.

2.2.2 Logical Addresses

Because a program may potentially refer to multiple segments, an 80386 logical address must identify a segment. Therefore, an 80386 logical address consists of two parts, a 16-bit segment selector and a 32-bit offset into the selected segment (see Figure 2-4). The selector part of a

2-3

Page 16
Image 16
Intel 80386 manual Memory and logical Addressing