xref: /original-bsd/sys/tahoe/math/Kcvtdl.s (revision 7c3db03c)
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 *	@(#)Kcvtdl.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	.text
19	.globl	_Kcvtdl
20	.globl	_Kcvtdu
21_Kcvtdu:
22_Kcvtdl:
23	.word	R5|R4|R3|R2
24
25 #
26 #Some initializations:
27 #
28	clrl	r3		# r3 - negative flag.
29	movl	4(fp),r0	# fetch operand.
30	movl	8(fp),r1
31 #
32 #get exponent
33 #
34	andl3	$EXPMASK,r0,r2	# r2 will hold the exponent.
35	jeql	retzero
36	cmpl	$TWO_EXP,r2	# if exponent is less then -2,return zero.
37	jgtr	retzero
38	andl2	$0!EXPSIGN,r2	# turn off biased exponent sign
39	shrl	$EXPSHIFT,r2,r2
40 #
41 #get fraction
42 #
43	bbc	$31,r0,positive	# if negative remember it.
44	incl	r3
45positive:
46				# clear the non fraction parts.
47	andl2	$(0!(EXPMASK | SIGNBIT)),r0
48				# add the hidden bit.
49	orl2	$(0!CLEARHID),r0
50	subl2	$24,r2		# compute the shift.
51	jgtr	shift_left
52	mnegl	r2,r2
53	shrl	r2,r0,r0	# shift right.
54	jmp	shifted
55shift_left:
56	cmpl	r2,$7
57	jgtr	overflow
58go_on:	shlq	r2,r0,r0	# shift right.
59shifted:
60	bbc	$0,r3,done	# check for negative
61	mnegl	r0,r0
62done:
63	ret
64
65retzero:
66	clrl	r0
67	ret
68overflow:
69	ret
70