mathhardalib.s

来自「vxworks源码源码解读是学习vxworks的最佳途径」· S 代码 · 共 916 行 · 第 1/2 页

S
916
字号
	je	powZeroX		/* if (x == 0) */	jb	powNegX			/* if (x < 0) */	fldl	DARG2(%ebp)		/* x > 0 */	fldl	DARG1(%ebp)		/* x**y = 2**(y * log2(x)) */	fyl2x	call	_powerOftwo	jmp	powExitpowZeroX:				/* x == 0 */	fldz	fldl	DARG2(%ebp)	fcompp	fstsw	%ax	sahf	ja	powNan			/* if (y > 0),  (0**y = 0) */	je	powOne			/* if (y == 0), (0**0 = 1) */	fldl	mathHardInfinity0	/* if (y < 0),  (0**y = HUGE_VALUE */	fldl2t	fmulp	%st, %st(1)	call	_powerOftwo	jmp	powErrExitpowOne:	fld1	jmp	powErrExitpowNan:	fldz	jmp	powErrExitpowNegX:				/* x < 0 */	fldl	DARG2(%ebp)	frndint	fcompl	DARG2(%ebp)	fstsw	%ax	sahf	jne	powNan			/* if (y != int(y)), (x**y = 0) */	fldl	DARG2(%ebp)		/* x**y = 2**(y * log2(|x|)) */	fldl	DARG1(%ebp)	fabs	fyl2x	call	_powerOftwo	fld1				/* if ((y % 2) != 0)              */	fld1				/*   x**y = -(%st)                */	faddp				/* else                           */	fldl	DARG2(%ebp)             /*   x**y = %st	                  */	fprem	fldz	fcompp	fstsw	%ax	sahf	je	powExit0	fcomp	%st			/* pop, fincstp + ffree might work */	fchs				/* x**y = -(%st) */	jmp	powExitpowExit0:	fcomp	%st			/* pop, fincstp + ffree might work */	jmp	powExitpowErrExit:powExit:	leave	ret/********************************************************************************* mathHardSin - ANSI-compatable hardware floating-point sine** RETURNS: The floating-point sine of dblParam.** SEE ALSO: *   floatLib (1), cos (2), tan (2), *   "The C Programming Language - Second Edition"** double mathHardSin (dblParam)*     double dblParam;	/* angle in radians ***/	.align 4,0x90_mathHardSin:	pushl	%ebp	movl	%esp,%ebp	fldl	DARG1(%ebp)	fsin	leave	ret/********************************************************************************* mathHardSqrt - ANSI-compatable hardware floating-point square root** RETURNS: The floating-point square root of dblParam.** SEE ALSO: floatLib(1), pow (2)** double mathHardSqrt (dblParam)*     double dblParam;	/* argument ***/	.align 4,0x90_mathHardSqrt:	pushl	%ebp	movl	%esp,%ebp	fldl	DARG1(%ebp)	fsqrt	leave	ret/********************************************************************************* mathHardTan - ANSI-compatable hardware floating-point tangent** RETURNS: Floating-point tangent of dblParam.** SEE ALSO: floatLib (1), cos (2), sin (2),* "The C Programming Language - Second Edition"** double mathHardTan (dblParam)*     double dblParam;	/* angle in radians ***/	.align 4,0x90_mathHardTan:	pushl	%ebp	movl	%esp,%ebp	fldl	DARG1(%ebp)	fptan	fstp	%st	leave	ret/********************************************************************************* mathHardSincos - simultaneous hardware floating-point sine and cosine** RETURNS:* The simultaeous floating point results of sine and cosine of the * radian argument  The dblParam must be in range of -1.0 to +1.0.** CAVEAT:* Supported for the HD648132 only.** SEE ALSO: floatLib (1), "HD648132 Floating-Point User's Manual"** void mathHardSincos (dblParam, sinResult, cosResult)*     double dblParam;		/* angle in radians **     double *sinResult;	/* sine result buffer **     double *cosResult;	/* cosine result buffer ***/	.align 4,0x90_mathHardSincos:	pushl	%ebp	movl	%esp,%ebp	fldl	DARG1(%ebp)	fsincos	movl	DARG2L(%ebp),%eax	fstpl	(%eax)	movl	DARG2(%ebp),%edx	fstpl	(%edx)	leave	ret/********************************************************************************* mathHardFmod - ANSI-compatable hardware floating-point modulus ** RETURNS: * Floating-point modulus of (dblParam / dblDivisor) with the sign of dblParam.  ** SEE ALSO: * floatLib (1), "The C Programming Language - Second Edition"** double mathHardFmod (dblParam, dblDivisor)*     double dblParam;		/* argument **     double dblDivisor;	/* divisor ***/	.align 4,0x90_mathHardFmod:	pushl	%ebp	movl	%esp,%ebp	fldl	DARG2(%ebp)	fldl	DARG1(%ebp)	fprem			/* XXX fprem1 for IEEE */	fstp	%st(1)	leave	ret/********************************************************************************* mathHardFloor - ANSI-compatable hardware floating-point floor** Performs a 'round-to-negative-infinity'.** RETURNS: * The largest integral value less than or equal to dblParam,* result is returned in double precision.** SEE ALSO: * floatLib (1), "The C Programming Language - Second Edition"*** double mathHardFloor (dblParam)*     double dblParam;	/* argument ***/	.align 4,0x90_mathHardFloor:	pushl	%ebp	movl	%esp,%ebp	subl	$8,%esp	fstcw	-4(%ebp)	fwait	movw	-4(%ebp),%ax	andw	$ FPP_ROUND_MASK,%ax	orw	$ FPP_ROUND_DOWN,%ax	movw	%ax,-8(%ebp)	fldcw	-8(%ebp)	fldl	DARG1(%ebp)	frndint	fldcw	-4(%ebp)	addl	$8,%esp	leave	ret/********************************************************************************* mathHardCeil - ANSI-compatable hardware floating-point ceiling** Performs a 'round-to-positive-infinity'** RETURNS: * The least integral value greater than or equal to dblParam,* result is returned in double precision.** SEE ALSO: * floatLib (1), "The C Programming Language - Second Edition"** double mathHardCeil (dblParam)*     double dblParam;	/* argument ***/	.align 4,0x90_mathHardCeil:	pushl	%ebp	movl	%esp,%ebp	subl	$8,%esp	fstcw	-4(%ebp)	fwait	movw	-4(%ebp),%ax	andw	$ FPP_ROUND_MASK,%ax	orw	$ FPP_ROUND_UP,%ax	movw	%ax,-8(%ebp)	fldcw	-8(%ebp)	fldl	DARG1(%ebp)	frndint	fldcw	-4(%ebp)	addl	$8,%esp	leave	ret/********************************************************************************* mathHardTrunc - hardware floating-point truncation** Performs FINTRZ.** RETURNS:* The integer portion of a double-precision number,* result is in double-precision.** SEE ALSO: floatLib (1)** double mathHardTrunc (dblParam)*     double dblParam;	/* argument ***/	.align 4,0x90_mathHardTrunc:	pushl	%ebp	movl	%esp,%ebp	subl	$8,%esp	fstcw	-4(%ebp)	fwait	movw	-4(%ebp),%ax	andw	$ FPP_ROUND_MASK,%ax	orw	$ FPP_ROUND_ZERO,%ax	movw	%ax,-8(%ebp)	fldcw	-8(%ebp)	fldl	DARG1(%ebp)	frndint	fldcw	-4(%ebp)	addl	$8,%esp	leave	ret/********************************************************************************* mathHardRound - hardware floating-point rounding** Performs a 'round-to-nearest'.** SEE ALSO: floatLib (1)** double mathHardRound (dblParam)*     double dblParam;	/* argument ***/	.align 4,0x90_mathHardRound:	pushl	%ebp	movl	%esp,%ebp	subl	$8,%esp	fstcw	-4(%ebp)	fwait	movw	-4(%ebp),%ax	andw	$ FPP_ROUND_MASK,%ax	orw	$ FPP_ROUND_NEAREST,%ax	movw	%ax,-8(%ebp)	fldcw	-8(%ebp)	fldl	DARG1(%ebp)	frndint	fldcw	-4(%ebp)	addl	$8,%esp	leave	ret/********************************************************************************* mathHardIround - hardware floating-point rounding to nearest integer** Performs a 'round-to-nearest' function.** NOTE:* If dblParam is spaced evenly between two integers,* then the  even integer will be returned.** int mathHardIround (dblParam)*     double dblParam;	/* argument ***/	.align 4,0x90_mathHardIround:	pushl	%ebp	movl	%esp,%ebp	subl	$8,%esp	fstcw	-4(%ebp)	fwait	movw	-4(%ebp),%ax	andw	$0xf3ff,%ax	orw	$0x0,%ax	movw	%ax,-8(%ebp)	fldcw	-8(%ebp)	fldl	DARG1(%ebp)	frndint	fistpl	DARG1(%ebp)	fwait	movl	DARG1(%ebp),%eax	fldcw	-4(%ebp)	addl	$8,%esp	leave	ret/********************************************************************************* mathHardIrint - hardware floating-point double to integer conversion** Convert dblParam to an integer using the selected IEEE* rounding direction.** CAVEAT:* The rounding direction is not pre-selectable* and is fixed for 'round-to-the-nearest'.** SEE ALSO: floatLib (1)* * int mathHardIrint (dblParam)*     double dblParam;	/* argument ***/ 	.align 4,0x90_mathHardIrint:	pushl	%ebp	movl	%esp,%ebp	fldl	DARG1(%ebp)	frndint	fistpl	DARG1(%ebp)	fwait	movl	DARG1(%ebp),%eax	leave	ret/********************************************************************************* mathHardInfinity - hardware floating-point return of a very large double** SEE ALSO: floatLib(1)* * double mathHardInfinity ()**/ 	.align 4mathHardInfinity0:	.double 0d4.09600000000000000000e+03	.align 4_mathHardInfinity:			/* 10**4096 = 2**(4096 * log2(10)) */	pushl	%ebp	movl	%esp,%ebp	fldl	mathHardInfinity0	fldl2t	fmulp	%st,%st(1)	call	_powerOftwo	leave	ret

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?