xref: /csrg-svn/lib/libc/tahoe/fpe/cvtfl.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 */
1029510Ssam
1136829Sbostic#if defined(SYSLIBC_SCCS) && !defined(lint)
12*61181Sbostic	.asciz "@(#)cvtfl.s	8.1 (Berkeley) 06/04/93"
1336829Sbostic#endif /* SYSLIBC_SCCS and not lint */
1436829Sbostic
1529510Ssam#include <tahoemath/fp.h>
1629510Ssam#include "DEFS.h"
1729510Ssam
1829510SsamXENTRY(cvtfu, R2|R3|R4|R5)
1929510Ssam	jbr	1f
2029510Ssam
2129510SsamXENTRY(cvtfl, R2|R3|R4|R5)
2229510Ssam #
2329510Ssam #Some initializations:
2429510Ssam #
2529510Ssam1:
2629510Ssam	movl	4(fp),r0	# fetch operand.
2729510Ssam	clrl	r3		# r3 - negative flag.
2829510Ssam #
2929510Ssam #get exponent
3029510Ssam #
3129510Ssam	andl3	$EXPMASK,r0,r2	# r2 will hold the exponent.
3229510Ssam	jeql	is_reserved	# check for reserved operand.
3329510Ssam	cmpl	$ONE_EXP,r2	# if exponent is less then 1,return zero.
3429510Ssam	jgtr	retzero
3529510Ssam	andl2	$0!EXPSIGN,r2	# turn off biased exponent sign
3629510Ssam	shrl	$EXPSHIFT,r2,r2
3729510Ssam #
3829510Ssam #get fraction
3929510Ssam #
4029510Ssam	bbc	$31,r0,positive	# if negative remember it.
4129510Ssam	incl	r3
4229510Ssampositive:
4329510Ssam				# clear the non fraction parts.
4429510Ssam	andl2	$(0!(EXPMASK | SIGNBIT)),r0
4529510Ssam				# add the hidden bit.
4629510Ssam	orl2	$(0!CLEARHID),r0
4729510Ssam	subl2	$24,r2		# compute the shift.
4829510Ssam	jgtr	shift_left
4929510Ssam	mnegl	r2,r2
5029510Ssam	shrl	r2,r0,r0	# shift right.
5129510Ssam	jmp	shifted
5229510Ssamshift_left:
5329510Ssam	cmpl	r2,$7
5429510Ssam	jgtr	overflow
5529510Ssamgo_on:	shll	r2,r0,r0	# shift right.
5629510Ssamshifted:
5729510Ssam	bbc	$0,r3,done	# check for negative
5829510Ssam	mnegl	r0,r0
5929510Ssamdone:
6029510Ssam	ret
6129510Ssam
6229510Ssamretzero:
6329510Ssam	clrl	r0
6429510Ssam	ret
6529510Ssamoverflow:
6629510Ssam	callf	$4,sfpover
6729510Ssam	jmp	go_on
6829510Ssam
6929510Ssamis_reserved:
7029510Ssam	bbc	$31,r0,retzero
7129510Ssam
7229510Ssam	callf	$4,sfpresop
7329510Ssam	ret
74