1*a347db52Sbostic/*- 2*a347db52Sbostic * Copyright (c) 1985 The Regents of the University of California. 3*a347db52Sbostic * All rights reserved. 4*a347db52Sbostic * 5*a347db52Sbostic * This code is derived from software contributed to Berkeley by 6*a347db52Sbostic * Computer Consoles Inc. 7*a347db52Sbostic * 8*a347db52Sbostic * %sccs.include.redist.c% 9*a347db52Sbostic * 10*a347db52Sbostic * @(#)Ksfnorm.s 7.1 (Berkeley) 12/06/90 11*a347db52Sbostic */ 12771ba0f9Ssam 13698bcaa9Sbostic#include "../math/fp.h" 14698bcaa9Sbostic#include "../math/Kfp.h" 15905fa82eSsam#include "../tahoe/SYS.h" 16771ba0f9Ssam 17dadb24d9Ssam/* 18dadb24d9Ssam * Ksfnorm(hfs) 19dadb24d9Ssam */ 20771ba0f9Ssam .text 21dadb24d9SsamENTRY(Ksfnorm, R6|R5|R4|R3|R2) 22771ba0f9Ssam clrl r1 23771ba0f9Ssam movl r0,r4 /* copy to temporary. */ 24771ba0f9Ssam jeql retzero 25771ba0f9Ssam clrl r3 /* r3 - pos of m.s.b */ 26771ba0f9Ssaminr00: ffs r4,r6 27771ba0f9Ssam incl r6 28771ba0f9Ssam addl2 r6,r3 29771ba0f9Ssam shrl r6,r4,r4 30771ba0f9Ssam jneq inr00 31771ba0f9Ssam 32771ba0f9Ssamcmpshift: 33771ba0f9Ssam /* compute the shift (r4). */ 34771ba0f9Ssam subl3 r3,$HID_POS,r4 35771ba0f9Ssam jlss shiftr /* if less then zero we shift right. */ 36771ba0f9Ssam shll r4,r0,r0 /* else we shift left. */ 37771ba0f9Ssam subl2 r4,r2 /* uodate exponent. */ 38771ba0f9Ssam jleq underflow /* if less then 0 (biased) it is underflow. */ 39771ba0f9Ssam jmp combine /* go to combine exponent and fraction. */ 40771ba0f9Ssamshiftr: 41771ba0f9Ssam mnegl r4,r4 42771ba0f9Ssam shrl r4,r0,r0 /* shift right. */ 43771ba0f9Ssam addl2 r4,r2 /* update exponent */ 44771ba0f9Ssam cmpl r2,$256 45771ba0f9Ssam jgeq overflow /* check for overflow. */ 46771ba0f9Ssamcombine: 47771ba0f9Ssam andl2 $CLEARHID,r0 /* clear the hidden bit. */ 48771ba0f9Ssam shal $EXPSHIFT,r2,r2 /* shift the exponent to its proper place. */ 49771ba0f9Ssam orl2 r2,r0 50771ba0f9Ssam ret 51771ba0f9Ssam 52771ba0f9Ssamunderflow: 53771ba0f9Ssam orl2 $HFS_UNDF,*4(fp) 54771ba0f9Ssam ret 55771ba0f9Ssam 56771ba0f9Ssamoverflow: 57771ba0f9Ssam orl2 $HFS_OVF,*4(fp) 58771ba0f9Ssam ret 59771ba0f9Ssamretzero: 60771ba0f9Ssam clrl r0 61771ba0f9Ssam ret 62