Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4973 right-hear 1
/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
2
#include
3
	.text
4
MK_C_SYM(powi)
5
	/* double powi(double x, int iy) = x^iy */
6
 
7
	fldl	4(%esp)			/* x2p = x; */
8
	movl	12(%esp), %eax
9
 
10
	testl	%eax, %eax		/* if (iy < 0) { */
11
	jge	Endif1
12
	negl	%eax			/*	  iy = -iy; */
13
	fld1				/*	  x = 1./x; */
14
	/* Should be fdivrp %st, %st(1) (gas bug) */
15
	.byte	0xDE, 0xF1
16
Endif1:					/* } */
17
 
18
	fld1				/* result = 1.; */
19
	fxch	%st(1)
20
 
21
	jmp	Test
22
	.balign 16,,7
23
Loop:
24
	testb	$1, %al			/*	  if (iy & 1) result *= x2p; */
25
	je	Endif2
26
	fmul	%st, %st(1)
27
Endif2:
28
	shrl	$1, %eax		/*	  (unsigned) iy >>= 1; */
29
	fmul	%st(0), %st		/*	  x2p *= x2p; */
30
Test:
31
	testl	%eax, %eax		/* } */
32
	jne	Loop
33
	fstp	%st(0)
34
	ret				/* return result; */