xref: /original-bsd/sys/tahoe/math/Kfrexpf.s (revision a425a1c9)
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 *	@(#)Kfrexpf.s	7.1 (Berkeley) 12/06/90
11 */
12
13#include "../tahoe/SYS.h"
14
15	.text
16ENTRY(Kfrexpf, 0)
17	subl3	$60,fp,sp
18	clrl	-60(fp)		# j=0;
19	clrl	-56(fp)		# neg=0;
20	tstl	4(fp)		# if(x<0){
21	jgeq	1f
22	lnd	4(fp)
23	std	4(fp)		# x = -x;
24	movl	$1,-56(fp)	# neg=1;}
251:
26	cmpd2	4(fp),one	# if (x>1){
27	jleq	1f
282:
29	cmpd2	4(fp),one	# while(x>1){
30	jleq	3f
31	addl2	$1,-60(fp)	# j=j+1;
32	pushl	16(fp)		# hfs
33	ldd	two
34	pushd
35	ldd	4(fp)
36	pushd
37	callf	$24,_Kdivd
38	ldd	r0
39	std	4(fp)		# x= x/2;
40	jbr	2b
411:
42	cmpd2	4(fp),half	# if(x<0.5){
43	jlss	2f
44	jbr	3f
450:
46	subl2	$1,-60(fp)	# j = j-1;
47	pushl	16(fp)		# hfs
48	ldd	4(fp)
49	pushd
50	ldd	two
51	pushd
52	callf	$24,_Kmuld
53	ldd	r0
54	std	4(fp)		# x = 2*x;
552:
56	cmpd2	4(fp),half	# while (x<0.5){
57	jlss	0b
583:
59	movl	-60(fp),*12(fp)	# *i=j;
60	tstl	-56(fp)		# if (neg)
61	jeql	1f
62	lnd	4(fp)
63	std	4(fp)
641:
65	ldd	4(fp)
66	cvdf
67	stf	r0
68	ret
69
70	.data
71	.align	2
72one:	.long	0x40800000, 0x00000000 # .double 1
73two:	.long	0x41000000, 0x00000000 # .double 2
74half:	.long	0x40000000, 0x00000000 # .double .5
75