patch-2.1.73 linux/arch/i386/math-emu/reg_norm.S

Next file: linux/arch/i386/math-emu/reg_round.S
Previous file: linux/arch/i386/math-emu/reg_mul.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.72/linux/arch/i386/math-emu/reg_norm.S linux/arch/i386/math-emu/reg_norm.S
@@ -1,16 +1,19 @@
 /*---------------------------------------------------------------------------+
  |  reg_norm.S                                                               |
  |                                                                           |
- | Copyright (C) 1992,1993,1994,1995                                         |
+ | Copyright (C) 1992,1993,1994,1995,1997                                    |
  |                       W. Metzenthen, 22 Parker St, Ormond, Vic 3163,      |
- |                       Australia.  E-mail billm@jacobi.maths.monash.edu.au |
+ |                       Australia.  E-mail billm@suburbia.net               |
  |                                                                           |
  | Normalize the value in a FPU_REG.                                         |
  |                                                                           |
  | Call from C as:                                                           |
- |   void normalize(FPU_REG *n)                                              |
+ |    int FPU_normalize(FPU_REG *n)                                          |
  |                                                                           |
- |   void normalize_nuo(FPU_REG *n)                                          |
+ |    int FPU_normalize_nuo(FPU_REG *n)                                      |
+ |                                                                           |
+ |    Return value is the tag of the answer, or-ed with FPU_Exception if     |
+ |    one was raised, or -1 on internal error.                               |
  |                                                                           |
  +---------------------------------------------------------------------------*/
 
@@ -18,24 +21,13 @@
 
 
 .text
-ENTRY(normalize)
+ENTRY(FPU_normalize)
 	pushl	%ebp
 	movl	%esp,%ebp
 	pushl	%ebx
 
 	movl	PARAM1,%ebx
 
-#ifdef PARANOID
-	cmpb	TW_Valid,TAG(%ebx)
-	je	L_ok
-
-	pushl	$0x220
-	call	SYMBOL_NAME(FPU_exception)
-	addl	$4,%esp
-
-L_ok:
-#endif PARANOID
-
 	movl	SIGH(%ebx),%edx
 	movl	SIGL(%ebx),%eax
 
@@ -48,7 +40,7 @@
 
 	movl	%eax,%edx
 	xorl	%eax,%eax
-	subl	$32,EXP(%ebx)	/* This can cause an underflow */
+	subw	$32,EXP(%ebx)	/* This can cause an underflow */
 
 /* We need to shift left by 1 - 31 bits */
 L_shift_1:
@@ -57,18 +49,25 @@
 	negl	%ecx
 	shld	%cl,%eax,%edx
 	shl	%cl,%eax
-	subl	%ecx,EXP(%ebx)	/* This can cause an underflow */
+	subw	%cx,EXP(%ebx)	/* This can cause an underflow */
 
 	movl	%edx,SIGH(%ebx)
 	movl	%eax,SIGL(%ebx)
 
 L_done:
-	cmpl	EXP_OVER,EXP(%ebx)
+	cmpw	EXP_OVER,EXP(%ebx)
 	jge	L_overflow
 
-	cmpl	EXP_UNDER,EXP(%ebx)
+	cmpw	EXP_UNDER,EXP(%ebx)
 	jle	L_underflow
 
+L_exit_valid:
+	movl	TAG_Valid,%eax
+
+	/* Convert the exponent to 80x87 form. */
+	addw	EXTENDED_Ebias,EXP(%ebx)
+	andw	$0x7fff,EXP(%ebx)
+
 L_exit:
 	popl	%ebx
 	leave
@@ -76,17 +75,21 @@
 
 
 L_zero:
-	movl	EXP_UNDER,EXP(%ebx)
-	movb	TW_Zero,TAG(%ebx)
+	movw	$0,EXP(%ebx)
+	movl	TAG_Zero,%eax
 	jmp	L_exit
 
 L_underflow:
+	/* Convert the exponent to 80x87 form. */
+	addw	EXTENDED_Ebias,EXP(%ebx)
 	push	%ebx
 	call	SYMBOL_NAME(arith_underflow)
 	pop	%ebx
 	jmp	L_exit
 
 L_overflow:
+	/* Convert the exponent to 80x87 form. */
+	addw	EXTENDED_Ebias,EXP(%ebx)
 	push	%ebx
 	call	SYMBOL_NAME(arith_overflow)
 	pop	%ebx
@@ -95,37 +98,26 @@
 
 
 /* Normalise without reporting underflow or overflow */
-ENTRY(normalize_nuo)
+ENTRY(FPU_normalize_nuo)
 	pushl	%ebp
 	movl	%esp,%ebp
 	pushl	%ebx
 
 	movl	PARAM1,%ebx
 
-#ifdef PARANOID
-	cmpb	TW_Valid,TAG(%ebx)
-	je	L_ok_nuo
-
-	pushl	$0x221
-	call	SYMBOL_NAME(FPU_exception)
-	addl	$4,%esp
-
-L_ok_nuo:
-#endif PARANOID
-
 	movl	SIGH(%ebx),%edx
 	movl	SIGL(%ebx),%eax
 
 	orl	%edx,%edx	/* ms bits */
-	js	L_exit		/* Already normalized */
+	js	L_exit_nuo_valid	/* Already normalized */
 	jnz	L_nuo_shift_1	/* Shift left 1 - 31 bits */
 
 	orl	%eax,%eax
-	jz	L_zero		/* The contents are zero */
+	jz	L_exit_nuo_zero		/* The contents are zero */
 
 	movl	%eax,%edx
 	xorl	%eax,%eax
-	subl	$32,EXP(%ebx)	/* This can cause an underflow */
+	subw	$32,EXP(%ebx)	/* This can cause an underflow */
 
 /* We need to shift left by 1 - 31 bits */
 L_nuo_shift_1:
@@ -134,10 +126,22 @@
 	negl	%ecx
 	shld	%cl,%eax,%edx
 	shl	%cl,%eax
-	subl	%ecx,EXP(%ebx)	/* This can cause an underflow */
+	subw	%cx,EXP(%ebx)	/* This can cause an underflow */
 
 	movl	%edx,SIGH(%ebx)
 	movl	%eax,SIGL(%ebx)
-	jmp	L_exit
 
+L_exit_nuo_valid:
+	movl	TAG_Valid,%eax
 
+	popl	%ebx
+	leave
+	ret
+
+L_exit_nuo_zero:
+	movl	TAG_Zero,%eax
+	movw	EXP_UNDER,EXP(%ebx)
+
+	popl	%ebx
+	leave
+	ret

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov