1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*---------------------------------------------------------------------------+
5 | Copyright (C) 1992,1993,1994,1995,1997 |
6 | W. Metzenthen, 22 Parker St, Ormond, Vic 3163, |
7 | Australia. E-mail billm@suburbia.net |
9 | Normalize the value in a FPU_REG. |
12 | int FPU_normalize(FPU_REG *n) |
14 | int FPU_normalize_nuo(FPU_REG *n) |
16 | Return value is the tag of the answer, or-ed with FPU_Exception if |
17 | one was raised, or -1 on internal error. |
19 +---------------------------------------------------------------------------*/
25 SYM_FUNC_START(FPU_normalize)
35 orl %edx,%edx /* ms bits */
36 js L_done /* Already normalized */
37 jnz L_shift_1 /* Shift left 1 - 31 bits */
40 jz L_zero /* The contents are zero */
44 subw $32,EXP(%ebx) /* This can cause an underflow */
46 /* We need to shift left by 1 - 31 bits */
48 bsrl %edx,%ecx /* get the required shift in %ecx */
53 subw %cx,EXP(%ebx) /* This can cause an underflow */
59 cmpw EXP_OVER,EXP(%ebx)
62 cmpw EXP_UNDER,EXP(%ebx)
68 /* Convert the exponent to 80x87 form. */
69 addw EXTENDED_Ebias,EXP(%ebx)
70 andw $0x7fff,EXP(%ebx)
84 /* Convert the exponent to 80x87 form. */
85 addw EXTENDED_Ebias,EXP(%ebx)
92 /* Convert the exponent to 80x87 form. */
93 addw EXTENDED_Ebias,EXP(%ebx)
98 SYM_FUNC_END(FPU_normalize)
102 /* Normalise without reporting underflow or overflow */
103 SYM_FUNC_START(FPU_normalize_nuo)
113 orl %edx,%edx /* ms bits */
114 js L_exit_nuo_valid /* Already normalized */
115 jnz L_nuo_shift_1 /* Shift left 1 - 31 bits */
118 jz L_exit_nuo_zero /* The contents are zero */
122 subw $32,EXP(%ebx) /* This can cause an underflow */
124 /* We need to shift left by 1 - 31 bits */
126 bsrl %edx,%ecx /* get the required shift in %ecx */
131 subw %cx,EXP(%ebx) /* This can cause an underflow */
145 movw EXP_UNDER,EXP(%ebx)
150 SYM_FUNC_END(FPU_normalize_nuo)