1/* 2 * Copyright (c) 1986 Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Computer Consoles Inc. 7 * 8 * Redistribution and use in source and binary forms are permitted 9 * provided that the above copyright notice and this paragraph are 10 * duplicated in all such forms and that any documentation, 11 * advertising materials, and other materials related to such 12 * distribution and use acknowledge that the software was developed 13 * by the University of California, Berkeley. The name of the 14 * University may not be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 */ 20 21#if defined(SYSLIBC_SCCS) && !defined(lint) 22 .asciz "@(#)sfnorm.s 1.2 (Berkeley) 02/17/89" 23#endif /* SYSLIBC_SCCS and not lint */ 24 25#include <tahoemath/fp.h> 26#include "DEFS.h" 27 28XENTRY(sfnorm, R2|R3|R4|R5|R6) 29 clrl r1 30 movl r0,r4 /* copy to temporary. */ 31 jeql retzero 32 clrl r3 /* r3 - pos of m.s.b */ 33inr00: ffs r4,r6 34 incl r6 35 addl2 r6,r3 36 shrl r6,r4,r4 37 jneq inr00 38 39cmpshift: 40 /* compute the shift (r4). */ 41 subl3 r3,$HID_POS,r4 42 jlss shiftr /* if less then zero we shift right. */ 43 shll r4,r0,r0 /* else we shift left. */ 44 subl2 r4,r2 /* uodate exponent. */ 45 jleq underflow /* if less then 0 (biased) it is underflow. */ 46 jmp combine /* go to combine exponent and fraction. */ 47shiftr: 48 mnegl r4,r4 49 shrl r4,r0,r0 /* shift right. */ 50 addl2 r4,r2 /* update exponent */ 51 cmpl r2,$256 52 jgeq overflow /* check for overflow. */ 53combine: 54 andl2 $CLEARHID,r0 /* clear the hidden bit. */ 55 shal $EXPSHIFT,r2,r2 /* shift the exponent to its proper place. */ 56 orl2 r2,r0 57 ret 58 59underflow: 60 callf $4,sfpunder 61 ret 62 63overflow: 64 callf $4,sfpover 65 ret 66retzero: 67 clrl r0 68 ret 69