1 /*---------------------------------------------------------------------------+
4 | Copyright (C) 1992,1993,1994,1995,1997 |
5 | W. Metzenthen, 22 Parker St, Ormond, Vic 3163, |
6 | Australia. E-mail billm@suburbia.net |
8 | Normalize the value in a FPU_REG. |
11 | int FPU_normalize(FPU_REG *n) |
13 | int FPU_normalize_nuo(FPU_REG *n) |
15 | Return value is the tag of the answer, or-ed with FPU_Exception if |
16 | one was raised, or -1 on internal error. |
18 +---------------------------------------------------------------------------*/
34 orl %edx,%edx /* ms bits */
35 js L_done /* Already normalized */
36 jnz L_shift_1 /* Shift left 1 - 31 bits */
39 jz L_zero /* The contents are zero */
43 subw $32,EXP(%ebx) /* This can cause an underflow */
45 /* We need to shift left by 1 - 31 bits */
47 bsrl %edx,%ecx /* get the required shift in %ecx */
52 subw %cx,EXP(%ebx) /* This can cause an underflow */
58 cmpw EXP_OVER,EXP(%ebx)
61 cmpw EXP_UNDER,EXP(%ebx)
67 /* Convert the exponent to 80x87 form. */
68 addw EXTENDED_Ebias,EXP(%ebx)
69 andw $0x7fff,EXP(%ebx)
83 /* Convert the exponent to 80x87 form. */
84 addw EXTENDED_Ebias,EXP(%ebx)
91 /* Convert the exponent to 80x87 form. */
92 addw EXTENDED_Ebias,EXP(%ebx)
100 /* Normalise without reporting underflow or overflow */
101 ENTRY(FPU_normalize_nuo)
111 orl %edx,%edx /* ms bits */
112 js L_exit_nuo_valid /* Already normalized */
113 jnz L_nuo_shift_1 /* Shift left 1 - 31 bits */
116 jz L_exit_nuo_zero /* The contents are zero */
120 subw $32,EXP(%ebx) /* This can cause an underflow */
122 /* We need to shift left by 1 - 31 bits */
124 bsrl %edx,%ecx /* get the required shift in %ecx */
129 subw %cx,EXP(%ebx) /* This can cause an underflow */
143 movw EXP_UNDER,EXP(%ebx)