?? mathhardalib.s
字號:
/* mathHardALib.s - *//* Copyright 1984-1992 Wind River Systems, Inc. */ .data .globl _copyright_wind_river .long _copyright_wind_river/*modification history--------------------01v,29jun94,tpr added MC68060 cpu support.01u,29oct92,jcf MC68020/MC68040 now both use assembly code. fixed SPR #1422.01t,23aug92,jcf changed bxxx to jxx.01s,26may92,rrr the tree shuffle01r,20apr92,kdl Fixed cut/paste typo in .word version of mathHardIrint (SPR #1422).01q,20jan92,kdl Put in conditional code so 68040 calls emulation library for missing fp instructions; change fp register naming from "fN" to "fpN"; use fp0 (not fp7) as scratch register.01p,04oct91,rrr passed through the ansification filter -fixed #else and #endif -changed VOID to void -changed ASMLANGUAGE to _ASMLANGUAGE -changed copyright notice01o,27aug91,wmd added #include "vxWorks.h".01n,23jul91,gae changed 68k/asm.h to asm.h.01m,13jun91,kdl fixed offset problems when dereferencing multiple double arguments; now uses new "DARGx" symbolic offsets; removed cut/paste artifact "ftanhd" call from mathHardSincos.01l,28jan91,kdl changed name from "mathALib.s" to "mathHardALib.s"; all functions renamed with "mathHard" prefix, to be called via jumps from the new "mathALib.s".01k,27oct90,dnw changed to include "68k/asm.h" explicitly.01j,23sep90,elr Renamed rmod to fmod to conform to ANSI. +mau Added atan2, floor, infinity to conform to ANSI. Removed entier - function was never documented, used, or understood. Included errno.h. Added #else (ifndef) MATH_ASM throughout this module module.01i,14mar90,jdi documentation cleanup.01h,10feb89,gae fixed d1 bug in all functions. +pxm added sincos, rmod, floor, ceil, trunc, round, entier irint & iround.01g,19aug88,gae documentation.01f,28may88,dnw removed extra spaces in .word declarations that may have been screwing up the VMS port.01e,13feb88,dnw added .data before .asciz above, for Intermetrics assembler.01d,04dec87,gae removed most HOST_TYPE dependencies - fp codes hand assembled.01c,23nov87,gae added included asm.h and special HOST_IRIS version.01b,18nov87,jlf documentation and alphabetized01a,16nov87,terry arden + rdc written*//*DESCRIPTIONThis library provides a C interface to the high-level math functionson the MC68881/MC68882 floating-point coprocessor. All angle-relatedparameters and return values are expressed in radians. Functionscapable errors, will set errno upon an error. All functionsincluded in this library whos names correspond to the ANSI C specificationare, indeed, ANSI-compatable. In the spirit of ANSI, HUGE_VAL is nowsupported.WARNINGThis library works only if an MC68881/MC68882 coprocessor is in thesystem! Attempts to use these routines with no coprocessor presentwill result in illegal instruction traps.SEE ALSO:fppLib (1), floatLib (1), The C Programming Language - Second EditionINCLUDE FILE: math.hINTERNALEach routine has the following format: o save register f7 o calculate floating-point function using double parameter o transfer result to parameter storage o store result to d0 and d1 registers o restore old register f7*/#define _ASMLANGUAGE#include "vxWorks.h"#include "asm.h"#include "errno.h"#if (CPU == MC68060)#include "fplsp060Lib.h"#endif /* (CPU == MC68060) */ .text .even .globl _mathHardTanh .globl _mathHardCosh .globl _mathHardSinh .globl _mathHardLog2 .globl _mathHardLog10 .globl _mathHardLog .globl _mathHardExp .globl _mathHardAtan .globl _mathHardAtan2 .globl _mathHardAcos .globl _mathHardAsin .globl _mathHardTan .globl _mathHardCos .globl _mathHardSin .globl _mathHardPow .globl _mathHardSqrt .globl _mathHardFabs .globl _mathHardFmod .globl _mathHardSincos .globl _mathHardFloor .globl _mathHardCeil .globl _mathHardTrunc .globl _mathHardRound .globl _mathHardIround .globl _mathHardIrint .globl _mathHardInfinity/********************************************************************************* mathHardAcos - ANSI-compatable hardware floating-point arc-cosine** RETURNS: The arc-cosine in the range -pi/2 to pi/2 radians.* double mathHardAcos (dblParam)* double dblParam; /* angle in radians ***/_mathHardAcos: link a6,#0 fmovex fp0,sp@-#if (CPU==MC68040 || CPU==MC68060) movel a6@(DARG1L),sp@- movel a6@(DARG1),sp@-#if (CPU == MC68040) jsr __l_facosd /* returns in fp0 */#else /* (CPU == MC68060) */ jsr FPLSP_060__FACOSD_ /* returns in fp0 */#endif /* (CPU == MC68060) */ addql #8,sp#else facosd a6@(DARG1),fp0#endif fmoved fp0,a6@(DARG1) movel a6@(DARG1),d0 movel a6@(DARG1L),d1 fmovex sp@+,fp0 unlk a6 rts/********************************************************************************* mathHardAsin - ANSI-compatable hardware floating-point arc-sine** RETURNS: The arc-sine in the range 0.0 to pi radians.** SEE ALSO:* floatLib (1), "The C Programming Language - Second Edition"* double mathHardAsin (dblParam)* double dblParam; /* angle in radians ***/_mathHardAsin: link a6,#0 fmovex fp0,sp@-#if (CPU==MC68040 || CPU==MC68060) movel a6@(DARG1L),sp@- movel a6@(DARG1),sp@-#if (CPU == MC68040) jsr __l_fasind /* returns in fp0 */#else /* (CPU == MC68060) */ jsr FPLSP_060__FASIND_ /* returns in fp0 */#endif /* (CPU == MC68060) */ addql #8,sp#else fasind a6@(DARG1),fp0#endif fmoved fp0,a6@(DARG1) movel a6@(DARG1),d0 movel a6@(DARG1L),d1 fmovex sp@+,fp0 unlk a6 rts/********************************************************************************* mathHardAtan - ANSI-compatable hardware floating-point arc-tangent** RETURNS: The arc-tangent of dblParam in the range -pi/2 to pi/2.** SEE ALSO: floatLib (1), acos (2), asin (2)* double mathHardAtan (dblParam)* double dblParam; /* angle in radians ***/_mathHardAtan: link a6,#0 fmovex fp0,sp@-#if (CPU==MC68040 || CPU==MC68060) movel a6@(DARG1L),sp@- movel a6@(DARG1),sp@-#if (CPU == MC68040) jsr __l_fatand /* returns in fp0 */#else /* (CPU == MC68060) */ jsr FPLSP_060__FATAND_ /* returns in fp0 */#endif /* (CPU == MC68060) */ addql #8,sp#else fatand a6@(DARG1),fp0#endif fmoved fp0,a6@(DARG1) movel a6@(DARG1),d0 movel a6@(DARG1L),d1 fmovex sp@+,fp0 unlk a6 rts/********************************************************************************* mathHardAtan2 - hardware floating point function for arctangent of (dblY/dblX)** RETURNS:* The arc-tangent of (dblY/dblX) in the range -pi to pi.** SEE ALSO:* floatLib (1), "The C Programming Language - Second Edition"* double mathHardAtan2 (dblY, dblX)* double dblY; /* Y ** double dblX; /* X ***/_mathHardAtan2: link a6, #0 fmoved a6@(DARG1), fp0 /* y */ fmoved a6@(DARG2), fp1 /* x */ fdivx fp1,fp0 /* y/x */ fatanx fp0, fp0 /* atan (y/x) */ ftstx fp1 /* x */ fbge atan2Exit /* x >= 0 */ fmovecr #0, fp1 /* pi */ ftstd a6@(DARG1) /* y */ fblt atan2NegY /* y < 0 ? */atan2PosY: faddx fp1, fp0 /* atan(y/x) + pi */ jra atan2Exitatan2NegY: fsubx fp1, fp0 /* atan(y/x) - pi */atan2Exit: fmoved fp0, a6@(DARG1) /* return result in d0:d1 */ movl a6@(DARG1), d0 movl a6@(DARG1L), d1 unlk a6 rts/********************************************************************************* mathHardCos - ANSI-compatable hardware floating-point cosine** RETURNS: the cosine of the radian argument dblParam** SEE ALSO:* floatLib (1), sin (2), cos (2), tan(2),* "The C Programming Language - Second Edition"* double mathHardCos (dblParam)* double dblParam; /* angle in radians ***/_mathHardCos: link a6,#0 fmovex fp0,sp@-#if (CPU==MC68040 || CPU==MC68060) movel a6@(DARG1L),sp@- movel a6@(DARG1),sp@-#if (CPU == MC68040) jsr __l_fcosd /* returns in fp0 */#else /* (CPU == MC68060) */ jsr FPLSP_060__FCOSD_ /* returns in fp0 */#endif /* (CPU == MC68060) */ addql #8,sp#else fcosd a6@(DARG1),fp0#endif fmoved fp0,a6@(DARG1) movel a6@(DARG1),d0 movel a6@(DARG1L),d1 fmovex sp@+,fp0 unlk a6 rts/********************************************************************************* mathHardCosh - ANSI-compatable hardware floating-point hyperbolic cosine** RETURNS:* The hyperbolic cosine of dblParam if (dblParam > 1.0), or* NaN if (dblParam < 1.0)** SEE ALSO: "The C Programming Language - Second Edition"* double mathHardCosh (dblParam)* double dblParam; /* angle in radians ***/_mathHardCosh: link a6,#0 fmovex fp0,sp@-#if (CPU==MC68040 || CPU==MC68060) movel a6@(DARG1L),sp@- movel a6@(DARG1),sp@-#if (CPU == MC68040) jsr __l_fcoshd /* returns in fp0 */#else /* (CPU == MC68060) */ jsr FPLSP_060__FCOSHD_ /* returns in fp0 */#endif /* (CPU == MC68060) */ addql #8,sp#else fcoshd a6@(DARG1),fp0#endif fmoved fp0,a6@(DARG1) movel a6@(DARG1),d0 movel a6@(DARG1L),d1 fmovex sp@+,fp0 unlk a6 rts/********************************************************************************* mathHardExp - hardware floating-point exponential function** RETURNS:* Floating-point inverse natural logarithm (e ** (dblExponent)).** SEE ALSO:* floatLib (1), "The C Programming Language - Second Edition"* double mathHardExp (dblExponent)* double dblExponent; /* argument ***/_mathHardExp: link a6,#0 fmovex fp0,sp@-#if (CPU==MC68040 || CPU==MC68060) movel a6@(DARG1L),sp@- movel a6@(DARG1),sp@-#if (CPU == MC68040) jsr __l_fetoxd /* returns in fp0 */#else /* (CPU == MC68060) */ jsr FPLSP_060__FETOXD_ /* returns in fp0 */#endif /* (CPU == MC68060) */ addql #8,sp#else fetoxd a6@(DARG1),fp0#endif fmoved fp0,a6@(DARG1) movel a6@(DARG1),d0 movel a6@(DARG1L),d1 fmovex sp@+,fp0 unlk a6 rts/********************************************************************************* mathHardFabs - ANSI-compatable hardware floating-point absolute value** RETURNS: The floating-point absolute value of dblParam.** SEE ALSO:* floatLib (1), "The C Programming Language - Second Edition"* double mathHardFabs (dblParam)* double dblParam; /* argument ***/_mathHardFabs: link a6,#0 fmovex fp0,sp@-#if (CPU==MC68040) movel a6@(DARG1L),sp@- movel a6@(DARG1),sp@- jsr __l_fabsd /* returns in fp0 */ addql #8,sp#else fabsd a6@(DARG1),fp0#endif fmoved fp0,a6@(DARG1) movel a6@(DARG1),d0 movel a6@(DARG1L),d1 fmovex sp@+,fp0 unlk a6 rts/********************************************************************************* mathHardLog - ANSI-compatable hardware floating-point natural logarithm** RETURNS: The natural logarithm of dblParam.** SEE ALSO:* floatLib (1), "The C Programming Language - Second Edition"* double mathHardLog (dblParam)* double dblParam; /* argument ***/_mathHardLog: link a6,#0 fmovex fp0,sp@-#if (CPU==MC68040 || CPU==MC68060) movel a6@(DARG1L),sp@- movel a6@(DARG1),sp@-#if (CPU == MC68040) jsr __l_flognd /* returns in fp0 */#else /* (CPU == MC68060) */ jsr FPLSP_060__FLOGND_ /* returns in fp0 */#endif /* (CPU == MC68060) */ addql #8,sp#else flognd a6@(DARG1),fp0#endif fmoved fp0,a6@(DARG1) movel a6@(DARG1),d0 movel a6@(DARG1L),d1 fmovex sp@+,fp0 unlk a6 rts/********************************************************************************* mathHardLog10 - ANSI-compatable hardware floating-point base 10 logarithm** RETURNS: The logarithm (base 10) of dblParam.** SEE ALSO: floatLib (1), log2 (2)* double mathHardLog10 (dblParam)* double dblParam; /* argument ***/_mathHardLog10: link a6,#0 fmovex fp0,sp@-#if (CPU==MC68040 || CPU==MC68060) movel a6@(DARG1L),sp@- movel a6@(DARG1),sp@-#if (CPU == MC68040) jsr __l_flog10d /* returns in fp0 */#else /* (CPU == MC68060) */ jsr FPLSP_060__FLOG10D_ /* returns in fp0 */#endif /* (CPU == MC68060) */ addql #8,sp#else flog10d a6@(DARG1),fp0#endif fmoved fp0,a6@(DARG1) movel a6@(DARG1),d0 movel a6@(DARG1L),d1 fmovex sp@+,fp0 unlk a6 rts/********************************************************************************* mathHardLog2 - ANSI-compatable hardware floating-point logarithm base 2** RETURNS: The logarithm (base 2) of dblParam.** SEE ALSO: floatLib (1), log10 (2)* double mathHardLog2 (dblParam)* double dblParam; /* argument ***/_mathHardLog2: link a6,#0 fmovex fp0,sp@-#if (CPU==MC68040 || CPU==MC68060) movel a6@(DARG1L),sp@- movel a6@(DARG1),sp@-#if (CPU == MC68040) jsr __l_flog2d /* returns in fp0 */#else /* (CPU == MC68060) */ jsr FPLSP_060__FLOG2D_ /* returns in fp0 */#endif /* (CPU == MC68060) */ addql #8,sp#else flog2d a6@(DARG1),fp0#endif fmoved fp0,a6@(DARG1) movel a6@(DARG1),d0 movel a6@(DARG1L),d1 fmovex sp@+,fp0 unlk a6 rts/********************************************************************************* mathHardPow - ANSI-compatable hardware floating-point power function** RETURNS: The floating-point value of dblX to the power of dblY.** SEE ALSO: floatLib (1), sqrt (2)* double mathHardPow (dblX, dblY)* double dblX; /* X ** double dblY; /* X ***/_mathHardPow: /* pow (x,y) = exp (y * log(x)) */ link a6, #0 fmoved a6@(DARG1), fp0 /* x */ fble powNonPosX /* is (x =< 0) ? */powPosX: /* x > 0 */#if (CPU==MC68040 || CPU==MC68060) fmovex fp0,sp@-#if (CPU == MC68040) jsr __l_flognx /* ln(x) -- returns in fp0 */#else /* (CPU == MC68060) */ jsr FPLSP_060__FLOGNX_ /* ln(x) -- returns in fp0 */#endif /* (CPU == MC68060) */ addql #8,sp fmuld a6@(DARG2), fp0 /* y * ln(x) */ fmovex fp0,sp@-#if (CPU == MC68040) jsr __l_fetoxx /* exp( y * ln(x)) -- returns in fp0 */#else /* (CPU == MC68060) */ jsr FPLSP_060__FETOXX_ /* exp( y * ln(x)) -- returns in fp0 */#endif /* (CPU == MC68060) */ addql #8,sp#else flognx fp0, fp0 /* ln(x) */ fmuld a6@(DARG2), fp0 /* y * ln(x) */ fetoxx fp0, fp0 /* exp( y * ln(x) ) */#endif jra powExit /* finished */powNonPosX: /* x =< 0 */ fbne powNegX /* is (x < 0) ? */powZeroX: /* x == 0 */ ftstd a6@(DARG2) /* y */ fbgt powExit /* if (y>0), 0^(y>0) --> 0 */ fbeq powNaN /* if (y==0), 0^0 --> undefined */ fmovecr #0x3f, fp0 /* if (y<0), --> HUGE_VAL */ jra powErrExitpowNegX:#if (CPU==MC68040) fmovex fp0,sp@- jsr __l_fabsx /* returns in fp0 */ addql #8,sp fmovex fp0,sp@- jsr __l_flognx /* ln (|x|) -- returns in fp0 */ addql #8,sp fmovex fp0,sp@- /* save fp0 temporarily */ movel a6@(DARG2L),sp@-
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -