background image

22-32 Vol. 3B

ARCHITECTURE COMPATIBILITY

22.31.3  Fault Handling Effects on the Stack 

During the handling of certain instructions, such as CALL and PUSHA, faults may occur in different sequences for 
the different processors. For example, during far calls, the Intel486 processor pushes the old CS and EIP before a 
possible branch fault is resolved. A branch fault is a fault from a branch instruction occurring from a segment limit 
or access rights violation. If a branch fault is taken, the Intel486 and P6 family processors will have corrupted 
memory below the stack pointer. However, the ESP register is backed up to make the instruction restartable. The 
P6 family processors issue the branch before the pushes. Therefore, if a branch fault does occur, these processors 
do not corrupt memory below the stack pointer. This implementation difference, however, does not constitute a 
compatibility problem, as only values at or above the stack pointer are considered to be valid. Other operations that 
encounter faults may also corrupt memory below the stack pointer and this behavior may vary on different imple-
mentations.

22.31.4  Interlevel RET/IRET From a 16-Bit Interrupt or Call Gate

If a call or interrupt is made from a 32-bit stack environment through a 16-bit gate, only 16 bits of the old ESP can 
be pushed onto the stack. On the subsequent RET/IRET, the 16-bit ESP is popped but the full 32-bit ESP is updated 
since control is being resumed in a 32-bit stack environment. The Intel486 processor writes the SS selector into the 
upper 16 bits of ESP. The P6 family and Pentium processors write zeros into the upper 16 bits.     

22.32  MIXING 16- AND 32-BIT SEGMENTS

The features of the 16-bit Intel 286 processor are an object-code compatible subset of those of the 32-bit IA-32 
processors. The D (default operation size) flag in segment descriptors indicates whether the processor treats a 
code or data segment as a 16-bit or 32-bit segment; the B (default stack size) flag in segment descriptors indicates 
whether the processor treats a stack segment as a 16-bit or 32-bit segment.
The segment descriptors used by the Intel 286 processor are supported by the 32-bit IA-32 processors if the Intel-
reserved word (highest word) of the descriptor is clear. On the 32-bit IA-32 processors, this word includes the 
upper bits of the base address and the segment limit.
The segment descriptors for data segments, code segments, local descriptor tables (there are no descriptors for 
global descriptor tables), and task gates are the same for the 16- and 32-bit processors. Other 16-bit descriptors 
(TSS segment, call gate, interrupt gate, and trap gate) are supported by the 32-bit processors. 
The 32-bit processors also have descriptors for TSS segments, call gates, interrupt gates, and trap gates that 
support the 32-bit architecture. Both kinds of descriptors can be used in the same system.
For those segment descriptors common to both 16- and 32-bit processors, clear bits in the reserved word cause the 
32-bit processors to interpret these descriptors exactly as an Intel 286 processor does, that is:

Base Address — The upper 8 bits of the 32-bit base address are clear, which limits base addresses to 24 bits.

Limit — The upper 4 bits of the limit field are clear, restricting the value of the limit field to 64 KBytes.

Granularity bit — The G (granularity) flag is clear, indicating the value of the 16-bit limit is interpreted in units 
of 1 byte.

Big bit — In a data-segment descriptor, the B flag is clear in the segment descriptor used by the 32-bit 
processors, indicating the segment is no larger than 64 KBytes.

Default bit — In a code-segment descriptor, the D flag is clear, indicating 16-bit addressing and operands are 
the default. In a stack-segment descriptor, the D flag is clear, indicating use of the SP register (instead of the 
ESP register) and a 64-KByte maximum segment limit.

For information on mixing 16- and 32-bit code in applications, see Chapter 21, “Mixing 16-Bit and 32-Bit Code.”

22.33  SEGMENT AND ADDRESS WRAPAROUND

This section discusses differences in segment and address wraparound between the P6 family, Pentium, Intel486, 
Intel386, Intel 286, and 8086 processors.