4 * Normalize the value in a FPU_REG.
7 * void normalize(FPU_REG *n)
9 * void normalize_nuo(FPU_REG *n)
12 * Copyright (C) 1992,1993,1994
13 * W. Metzenthen, 22 Parker St, Ormond, Vic 3163,
14 * Australia. E-mail billm@vaxc.cc.monash.edu.au
15 * All rights reserved.
17 * This copyright notice covers the redistribution and use of the
18 * FPU emulator developed by W. Metzenthen. It covers only its use
19 * in the 386BSD, FreeBSD and NetBSD operating systems. Any other
20 * use is not permitted under this copyright.
22 * Redistribution and use in source and binary forms, with or without
23 * modification, are permitted provided that the following conditions
25 * 1. Redistributions of source code must retain the above copyright
26 * notice, this list of conditions and the following disclaimer.
27 * 2. Redistributions in binary form must include information specifying
28 * that source code for the emulator is freely available and include
30 * a) an offer to provide the source code for a nominal distribution
32 * b) list at least two alternative methods whereby the source
33 * can be obtained, e.g. a publically accessible bulletin board
34 * and an anonymous ftp site from which the software can be
36 * 3. All advertising materials specifically mentioning features or use of
37 * this emulator must acknowledge that it was developed by W. Metzenthen.
38 * 4. The name of W. Metzenthen may not be used to endorse or promote
39 * products derived from this software without specific prior written
42 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
43 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
44 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
45 * W. METZENTHEN BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
46 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
47 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
48 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
49 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
50 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
51 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 * The purpose of this copyright, based upon the Berkeley copyright, is to
55 * ensure that the covered software remains freely available to everyone.
57 * The software (with necessary differences) is also available, but under
58 * the terms of the GNU copyleft, for the Linux operating system and for
59 * the djgpp ms-dos extender.
61 * W. Metzenthen June 1994.
64 * $FreeBSD: src/sys/gnu/i386/fpemul/reg_norm.s,v 1.8 1999/08/28 00:42:57 peter Exp $
65 * $DragonFly: src/sys/i386/gnu/fpemul/Attic/reg_norm.s,v 1.4 2003/08/07 21:17:20 dillon Exp $
85 orl %edx,%edx /* ms bits */
86 js L_done /* Already normalized */
87 jnz L_shift_1 /* Shift left 1 - 31 bits */
90 jz L_zero /* The contents are zero */
95 subl $32,EXP(%ebx) /* This can cause an underflow */
97 /* We need to shift left by 1 - 31 bits */
99 bsrl %edx,%ecx /* get the required shift in %ecx */
104 subl %ecx,EXP(%ebx) /* This can cause an underflow */
110 cmpl EXP_OVER,EXP(%ebx)
113 cmpl EXP_UNDER,EXP(%ebx)
123 movl EXP_UNDER,EXP(%ebx)
124 movb TW_Zero,TAG(%ebx)
141 /* Normalise without reporting underflow or overflow */
152 orl %edx,%edx /* ms bits */
153 js L_exit /* Already normalized */
154 jnz L_nuo_shift_1 /* Shift left 1 - 31 bits */
157 jz L_zero /* The contents are zero */
159 /* L_nuo_shift_32: */
162 subl $32,EXP(%ebx) /* This can cause an underflow */
164 /* We need to shift left by 1 - 31 bits */
166 bsrl %edx,%ecx /* get the required shift in %ecx */
171 subl %ecx,EXP(%ebx) /* This can cause an underflow */