وو

وحید آنلاین . آرشیو وبلاگ وحیدمی دات آی آر . شرکت بیان. vahidmy.blog.ir

وو

وحید آنلاین . آرشیو وبلاگ وحیدمی دات آی آر . شرکت بیان. vahidmy.blog.ir

FSAVE / FNSAVE

FSAVE / FNSAVE

Usage: FSAVE   dest                                  Modifies flags: See below.

The C0, C1, C2, C3 flags are loaded. Stores the current FPU state (operating environment and register stack) at the specified destination in memory, and then re-initializes the FPU. 

Save/Restore Floating-Point State


FSAVE  mem                    ; 9B DD /6             [8086,FPU]

FNSAVE mem                    ; DD /6                [8086,FPU]


FRSTOR mem                    ; DD /4                [8086,FPU]


FSAVE saves the entire floating-point unit state, including all the information saved by FSTENV plus the contents of all the registers, to a 94 or 108 byte area of memory (depending on the CPU mode). FRSTOR restores the floating-point state from the same area of memory.


FNSAVE does the same as FSAVE, without first waiting for pending floating-point exceptions to clear.


Under 32 Bits OS, the Structure of the 108 Bytes Memory is as follow:

[FPU_STATE: 

 ControlWord: W$ ? Padding1: W$ ?

 StatusWord: W$ ? Padding2: W$ ?

 TagWord: W$ ? Padding3: ?

 IPtr: D$ ?

 CSeg: W$ ? Padding4: W$ ?

 OperandAddress: D$ ?

 DSeg: W$ ? Padding5: W$ ?

 ST0reg: T$ ? ST1reg: T$ ? ST2reg: T$ ?

 ST3reg: T$ ? ST4reg: T$ ? ST5reg: T$ ?

 ST6reg: T$ ? ST7reg: T$ ?]


FPU Flags Affected C1 Set to 0 if stack underflow occurred. Set if result was rounded up; cleared otherwise. C0, C2, C3 Undefined. 


The FSAVE instruction checks for and handles pending unmasked floating-point exceptions before storing the FPU state; the FNSAVE instruction does not. The FPU operating environment consists of the FPU control word, status word, tag word, instruction pointer, data pointer, and last opcode.  The contents of the FPU register stack are stored in the 80 bytes immediately follow the operating environment image. The saved image reflects the state of the FPU after all floating-point instructions preceding the FSAVE/FNSAVE instruction in the instruction stream have been executed.


Example:

fsave Label