📄 fppalib.s
字号:
/* fppALib.s - floating-point coprocessor support assembly language routines *//* Copyright 1984-1998 Wind River Systems, Inc. */ .data .globl _copyright_wind_river .long _copyright_wind_river/*modification history--------------------01g,04apr98,hdn added X86FPU_387, X86FPU_487 macros.01f,21sep95,hdn added support for NS48601e,01nov94,hdn added a check of sysProcessor for Pentium01d,10aug93,hdn changed fppProbeSup().01c,01jun93,hdn updated to 5.1. - fixed #else and #endif - changed VOID to void - changed ASMLANGUAGE to _ASMLANGUAGE - changed copyright notice01b,29sep92,hdn debugged. fixed bugs.01a,07apr92,hdn written based on TRON version.*//*DESCRIPTIONThis library contains routines to support the i80387 floating-point coprocessor. The routines fppSave() and fppRestore() save and restore all the task floating-point context information, which consists of the 16 extended double precision registers and three control registers. Higher-level accessmechanisms are found in fppLib.SEE ALSO: fppLib, i80387 Floating-Point Coprocessor User's Manual*/#define _ASMLANGUAGE#include "vxWorks.h"#include "fppLib.h"#include "asm.h"#include "regs.h"/* The following flag controls the assembly of the fpp instructions. * If TRUE, the fpp instructions are assembled (many assemblers can't handle). * If FALSE, hand-coded machine code equivalents are assembled. */#define FPP_ASSEM FALSE /* internals */ .globl _fppSave .globl _fppRestore .globl _fppDtoDx .globl _fppDxtoD .globl _fppProbeSup .globl _fppR01 /* externals */ .globl _fppFsw .globl _fppFcw .globl _sysCoprocessor .text .align 4/********************************************************************************* fppSave - save the floating-pointing coprocessor context** This routine saves the floating-point coprocessor context.* The context saved is:** - internal state** RETURNS: N/A** SEE ALSO: fppRestore(), i80387 Floating-Point Coprocessor * User's Manual* void fppSave (pFpContext)* FP_CONTEXT *pFpContext; /* where to save context **/_fppSave: pushl %ebp movl %esp,%ebp movl ARG1(%ebp),%eax /* where to save registers */ fnsave (%eax) leave ret/********************************************************************************* fppRestore - restore the floating-point coprocessor context** This routine restores the floating-point coprocessor context.* The context restored is:** - internal** RETURNS: N/A** SEE ALSO: fppSave(), i80387 Floating-Point Coprocessor User's Manual* void fppRestore (pFpContext)* FP_CONTEXT *pFpContext; /* from where to restore context **/ .align 4,0x90_fppRestore: pushl %ebp movl %esp,%ebp movl ARG1(%ebp),%eax /* from where to restore registers */ frstor (%eax) leave ret/********************************************************************************* fppDtoDx - convert double to extended double precision** The FPU uses a special extended double precision format* (10 bytes as opposed to 8 bytes) for internal operations.* The routines fppSave and fppRestore must preserve this precision.** NOMANUAL* void fppDtoDx (pDx, pDouble)* DOUBLEX *pDx; /* where to save result ** double *pDouble; /* ptr to value to convert **/ .align 4,0x90_fppDtoDx: pushl %ebp movl %esp,%ebp movl ARG1(%ebp),%edx /* to Dx */ movl ARG2(%ebp),%ecx /* from D */ subl $16,%esp fstpt (%esp) /* save %st */ fldl (%ecx) fstpt (%edx) fldt (%esp) /* restore %st */ addl $16,%esp leave ret/********************************************************************************* fppDxtoD - convert extended double precisoion to double** The FPU uses a special extended double precision format* (10 bytes as opposed to 8 bytes) for internal operations.* The routines fppSave and fppRestore must preserve this precision.** NOMANUAL* void fppDxtoD (pDouble, pDx)* double *pDouble; /* where to save result ** DOUBLEX *pDx; /* ptr to value to convert **/ .align 4,0x90_fppDxtoD: pushl %ebp movl %esp,%ebp movl ARG1(%ebp),%edx /* to D */ movl ARG2(%ebp),%ecx /* from Dx */ subl $16,%esp fstpt (%esp) /* save %st */ fldt (%ecx) fstpl (%edx) fldt (%esp) /* restore %st */ addl $16,%esp leave ret/********************************************************************************* fppProbeSup - fppProbe support routine** This routine executes some coprocessor instruction which will cause a* bus error if a coprocessor is not present. A handler, viz. fppProbeTrap,* should be installed at that vector. If the coprocessor is present this* routine returns OK.** SEE ALSO: i80387 User's Manual** NOMANUAL* STATUS fppProbeSup ()*/ .align 4,0x90_fppProbeSup: cmpl $ X86CPU_386,_sysProcessor /* is it 386 ? */ jne fppProbe487 /* does it have 387 ? */ fninit movl $_fppFsw,%edx movl $_fppFcw,%ecx fnstsw (%edx) cmpb $0,(%edx) jne fppProbeNo387 fnstcw (%ecx) movw (%ecx),%ax cmpw $0x37f,%ax jne fppProbeNo387 movl %cr0,%eax andl $0xfffffff9,%eax orl $0x00000002,%eax movl %eax,%cr0 /* EM=0, MP=1 */ movl $ X86FPU_387,_sysCoprocessor /* it has 80387 */ xorl %eax,%eax /* set status to OK */ jmp fppProbe0fppProbeNo387: movl %cr0,%eax andl $0xfffffff9,%eax orl $0x00000004,%eax /* EM=1, MP=0 */ movl %eax,%cr0 movl $ ERROR,%eax /* set status to ERROR */ jmp fppProbe0fppProbe487: cmpl $ X86CPU_NS486,_sysProcessor /* is it NS486 ? */ je fppProbeNo487 /* does it have 487 ? */ fninit movl $_fppFcw,%edx fnstcw (%edx) movw (%edx),%ax cmpw $0x37f,%ax jne fppProbeNo487 movl %cr0,%eax andl $0xffffffd9,%eax orl $0x00000002,%eax movl %eax,%cr0 /* NE=0, EM=0, MP=1 */ movl $ X86FPU_487,_sysCoprocessor /* it has 80487 */ xorl %eax,%eax /* set status to OK */ jmp fppProbe0fppProbeNo487: movl %cr0,%eax andl $0xffffffd9,%eax orl $0x00000004,%eax movl %eax,%cr0 /* NE=0, EM=1, MP=0 */ movl $ ERROR,%eax /* set status to ERROR */ jmp fppProbe0fppProbeNS486: movl $ ERROR,%eax /* set status to ERROR */fppProbe0: ret/********************************************************************************* fppR01 - convert the double value in which a return value is held** This routine moves the double value of returns to %eax, %edx.* 386 compilers use st0 as a return value instead of the d0, d1 used* by 68K compilers.** RETURNS: A double in d0, d1.* double fppR01 (doubleArg)* double doubleArg; /* value to convert **/ .align 4,0x90/* XXX should work some day when software floating point lib is supported */_fppR01: ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -