1/*- 2 * Copyright (c) 1985 The 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 * %sccs.include.redist.c% 9 * 10 * @(#)Ksfnorm.s 7.1 (Berkeley) 12/06/90 11 */ 12 13#include "../math/fp.h" 14#include "../math/Kfp.h" 15#include "../tahoe/SYS.h" 16 17/* 18 * Ksfnorm(hfs) 19 */ 20 .text 21ENTRY(Ksfnorm, R6|R5|R4|R3|R2) 22 clrl r1 23 movl r0,r4 /* copy to temporary. */ 24 jeql retzero 25 clrl r3 /* r3 - pos of m.s.b */ 26inr00: ffs r4,r6 27 incl r6 28 addl2 r6,r3 29 shrl r6,r4,r4 30 jneq inr00 31 32cmpshift: 33 /* compute the shift (r4). */ 34 subl3 r3,$HID_POS,r4 35 jlss shiftr /* if less then zero we shift right. */ 36 shll r4,r0,r0 /* else we shift left. */ 37 subl2 r4,r2 /* uodate exponent. */ 38 jleq underflow /* if less then 0 (biased) it is underflow. */ 39 jmp combine /* go to combine exponent and fraction. */ 40shiftr: 41 mnegl r4,r4 42 shrl r4,r0,r0 /* shift right. */ 43 addl2 r4,r2 /* update exponent */ 44 cmpl r2,$256 45 jgeq overflow /* check for overflow. */ 46combine: 47 andl2 $CLEARHID,r0 /* clear the hidden bit. */ 48 shal $EXPSHIFT,r2,r2 /* shift the exponent to its proper place. */ 49 orl2 r2,r0 50 ret 51 52underflow: 53 orl2 $HFS_UNDF,*4(fp) 54 ret 55 56overflow: 57 orl2 $HFS_OVF,*4(fp) 58 ret 59retzero: 60 clrl r0 61 ret 62