Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Лаб2012 / 25366517.pdf
Скачиваний:
65
Добавлен:
02.02.2015
Размер:
3.33 Mб
Скачать

PROGRAMMING WITH THE X87 FPU

8.1.9.1Fopcode Compatibility Sub-mode

Beginning with the Pentium 4 and Intel Xeon processors, the IA-32 architecture provides program control over the storing of the last instruction opcode (sometimes referred to as the fopcode). Here, bit 2 of the IA32_MISC_ENABLE MSR enables (set) or disables (clear) the fopcode compatibility mode.

If FOP code compatibility mode is enabled, the FOP is defined as it has always been in previous IA32 implementations (always defined as the FOP of the last non-transparent FP instruction executed before a FSAVE/FSTENV/FXSAVE). If FOP code compatibility mode is disabled (default), FOP is only valid if the last non-transparent FP instruction executed before a FSAVE/FSTENV/FXSAVE had an unmasked exception.

 

1st Instruction Byte

 

2nd Instruction Byte

 

7

2

0

7

0

 

10

8 7

0

 

 

 

x87 FPU Opcode Register

 

Figure 8-8. Contents of x87 FPU Opcode Registers

The fopcode compatibility mode should be enabled only when x87 FPU floating-point exception handlers are designed to use the fopcode to analyze program performance or restart a program after an exception has been handled.

8.1.10Saving the x87 FPU’s State with FSTENV/FNSTENV and FSAVE/FNSAVE

The FSTENV/FNSTENV and FSAVE/FNSAVE instructions store x87 FPU state information in memory for use by exception handlers and other system and application software. The FSTENV/FNSTENV instruction saves the contents of the status, control, tag, x87 FPU instruction pointer, x87 FPU operand pointer, and opcode registers. The FSAVE/FNSAVE instruction stores that information plus the contents of the x87 FPU data registers. Note that the FSAVE/FNSAVE instruction also initializes the x87 FPU to default values (just as the FINIT/FNINIT instruction does) after it has saved the original state of the x87 FPU.

8-14 Vol. 1

PROGRAMMING WITH THE X87 FPU

The manner in which this information is stored in memory depends on the operating mode of the processor (protected mode or real-address mode) and on the operand-size attribute in effect (32-bit or 16-bit). See Figures 8-9 through 8-12. In virtual-8086 mode or SMM, the real-address mode formats shown in Figure 8-12 is used. See “Using the FPU in SMM” in Chapter 13 of the

IA-32 Intel Architecture Software Developer’s Manual, Volume 3, for special considerations for using the x87 FPU while in SMM.

The FLDENV and FRSTOR instructions allow x87 FPU state information to be loaded from memory into the x87 FPU. Here, the FLDENV instruction loads only the status, control, tag, x87 FPU instruction pointer, x87 FPU operand pointer, and opcode registers, and the FRSTOR instruction loads all the x87 FPU registers, including the x87 FPU stack registers.

 

 

 

 

32-Bit Protected Mode Format

 

 

 

31

 

16

15

 

0

 

 

 

 

 

 

 

 

 

Control Word

 

 

0

 

 

 

 

 

 

 

 

Status Word

 

 

4

 

 

 

 

 

 

 

 

Tag Word

 

 

8

 

 

 

 

FPU Instruction Pointer Offset

 

 

12

 

 

0 0 0 0 0

Opcode 10...00

FPU Instruction Pointer Selector

 

 

16

 

 

 

 

FPU Operand Pointer Offset

 

 

20

 

 

 

 

 

FPU Operand Pointer Selector

 

 

24

 

 

For instructions that also store x87 FPU data registers, the eight 80-

 

 

 

 

 

bit registers (R0-R7) follow the above structure in sequence.

 

 

 

 

 

 

 

 

 

 

 

 

 

Figure 8-9. Protected Mode x87 FPU State Image in Memory, 32-Bit Format

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

32-Bit Real-Address Mode Format

 

 

 

31

 

16

15

 

 

 

0

 

 

 

 

 

 

 

 

 

Control Word

 

 

0

 

 

 

 

 

 

 

 

Status Word

 

 

4

 

 

 

 

 

 

 

 

Tag Word

 

 

8

 

 

 

 

 

FPU Instruction Pointer 15...00

 

 

12

 

 

 

 

 

 

0

 

 

 

 

 

 

 

0 0 0 0

 

FPU Instruction Pointer 31...16

 

Opcode 10...00

 

 

16

 

 

 

 

 

FPU Operand Pointer 15...00

 

 

20

 

 

0 0 0 0

 

FPU Operand Pointer 31...16

 

0 0 0 0 0 0 0 0 0 0 0 0

 

 

24

 

 

For instructions that also store x87 FPU data registers, the eight 80-

 

 

 

 

 

bit registers (R0-R7) follow the above structure in sequence.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Figure 8-10. Real Mode x87 FPU State Image in Memory, 32-Bit Format

Vol. 1 8-15

Соседние файлы в папке Лаб2012