xref: /csrg-svn/lib/libc/tahoe/fpe/sfnorm.s (revision 61181)
136829Sbostic/*
2*61181Sbostic * Copyright (c) 1986, 1993
3*61181Sbostic *	The Regents of the University of California.  All rights reserved.
436829Sbostic *
536829Sbostic * This code is derived from software contributed to Berkeley by
636829Sbostic * Computer Consoles Inc.
736829Sbostic *
842637Sbostic * %sccs.include.redist.c%
936829Sbostic */
1029518Ssam
1136829Sbostic#if defined(SYSLIBC_SCCS) && !defined(lint)
12*61181Sbostic	.asciz "@(#)sfnorm.s	8.1 (Berkeley) 06/04/93"
1336829Sbostic#endif /* SYSLIBC_SCCS and not lint */
1436829Sbostic
1529518Ssam#include <tahoemath/fp.h>
1629518Ssam#include "DEFS.h"
1729518Ssam
1829518SsamXENTRY(sfnorm, R2|R3|R4|R5|R6)
1929518Ssam	clrl	r1
2029518Ssam	movl	r0,r4		/* copy to temporary. */
2129518Ssam	jeql	retzero
2229518Ssam	clrl	r3		/* r3 - pos of m.s.b */
2329518Ssaminr00:	ffs	r4,r6
2429518Ssam	incl	r6
2529518Ssam	addl2	r6,r3
2629518Ssam	shrl	r6,r4,r4
2729518Ssam	jneq	inr00
2829518Ssam
2929518Ssamcmpshift:
3029518Ssam				/* compute the shift (r4). */
3129518Ssam	subl3	r3,$HID_POS,r4
3229518Ssam	jlss	shiftr		/* if less then zero we shift right. */
3329518Ssam	shll	r4,r0,r0	/* else we shift left. */
3429518Ssam	subl2	r4,r2		/* uodate exponent. */
3529518Ssam	jleq	underflow	/* if less then 0 (biased) it is underflow. */
3629518Ssam	jmp	combine		/* go to combine exponent and fraction. */
3729518Ssamshiftr:
3829518Ssam	mnegl	r4,r4
3929518Ssam	shrl	r4,r0,r0	/* shift right. */
4029518Ssam	addl2	r4,r2		/* update exponent */
4129518Ssam	cmpl	r2,$256
4229518Ssam	jgeq	overflow	/* check for overflow. */
4329518Ssamcombine:
4429518Ssam	andl2	$CLEARHID,r0	/* clear the hidden bit. */
4529518Ssam	shal	$EXPSHIFT,r2,r2	/* shift the exponent to its proper place. */
4629518Ssam	orl2	r2,r0
4729518Ssam	ret
4829518Ssam
4929518Ssamunderflow:
5029518Ssam	callf	$4,sfpunder
5129518Ssam	ret
5229518Ssam
5329518Ssamoverflow:
5429518Ssam	callf 	$4,sfpover
5529518Ssam	ret
5629518Ssamretzero:
5729518Ssam	clrl	r0
5829518Ssam	ret
59