background image

Vol. 3B 22-31

ARCHITECTURE COMPATIBILITY

22.30.3  Enabling and Disabling Paging

Paging is enabled and disabled by loading a value into control register CR0 that modifies the PG flag. For backward 
and forward compatibility with all IA-32 processors, Intel recommends that the following operations be performed 
when enabling or disabling paging:
1. Execute a MOV CR0, REG instruction to either set (enable paging) or clear (disable paging) the PG flag. 
2. Execute a near JMP instruction.
The sequence bounded by the MOV and JMP instructions should be identity mapped (that is, the instructions should 
reside on a page whose linear and physical addresses are identical).
For the P6 family processors, the MOV CR0, REG instruction is serializing, so the jump operation is not required. 
However, for backwards compatibility, the JMP instruction should still be included.

22.31 STACK 

OPERATIONS

This section identifies the differences in the stack mechanism for the various IA-32 processors.

22.31.1  Selector Pushes and Pops

When pushing a segment selector onto the stack, the Pentium 4, Intel Xeon, P6 family, and Intel486 processors 
decrement the ESP register by the operand size and then write 2 bytes. If the operand size is 32-bits, the upper 
two bytes of the write are not modified. The Pentium processor decrements the ESP register by the operand size 
and determines the size of the write by the operand size. If the operand size is 32-bits, the upper two bytes are 
written as 0s. 
When popping a segment selector from the stack, the Pentium 4, Intel Xeon, P6 family, and Intel486 processors 
read 2 bytes and increment the ESP register by the operand size of the instruction. The Pentium processor deter-
mines the size of the read from the operand size and increments the ESP register by the operand size.
It is possible to align a 32-bit selector push or pop such that the operation generates an exception on a Pentium 
processor and not on an Pentium 4, Intel Xeon, P6 family, or Intel486 processor. This could occur if the third and/or 
fourth byte of the operation lies beyond the limit of the segment or if the third and/or fourth byte of the operation 
is locate on a non-present or inaccessible page.
For a POP-to-memory instruction that meets the following conditions:

The stack segment size is 16-bit.

Any 32-bit addressing form with the SIB byte specifying ESP as the base register.

The initial stack pointer is FFFCH (32-bit operand) or FFFEH (16-bit operand) and will wrap around to 0H as a 
result of the POP operation.

The result of the memory write is implementation-specific. For example, in P6 family processors, the result of the 
memory write is SS:0H plus any scaled index and displacement. In Pentium processors, the result of the memory 
write may be either a stack fault (real mode or protected mode with stack segment size of 64 KByte), or write to 
SS:10000H plus any scaled index and displacement (protected mode and stack segment size exceeds 64 KByte).

22.31.2  Error Code Pushes

The Intel486 processor implements the error code pushed on the stack as a 16-bit value. When pushed onto a 32-
bit stack, the Intel486 processor only pushes 2 bytes and updates ESP by 4. The P6 family and Pentium processors’ 
error code is a full 32 bits with the upper 16 bits set to zero. The P6 family and Pentium processors, therefore, push 
4 bytes and update ESP by 4. Any code that relies on the state of the upper 16 bits may produce inconsistent 
results.