Subversion Repositories Kolibri OS

Rev

Rev 4973 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4973 Rev 5098
1
/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
1
/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
2
#include
2
#include
3
 
3
 
4
NaN:
4
NaN:
5
	.long	  0x00000000, 0xFFF80000
5
	.long	  0x00000000, 0xFFF80000
6
 
6
 
7
MK_C_SYM(sincos)
7
MK_C_SYM(sincos)
8
 
8
 
9
	/* void sincos(double *cosine, double *sine, double x); */
9
	/* void sincos(double x, double *sine, double *cosine); */
10
 
10
 
11
	movl	16(%esp), %ecx
11
	movl	8(%esp), %ecx
12
 
12
 
13
	movl	4(%esp), %eax		/* Point to cosine. */
13
	movl	16(%esp), %eax		/* Point to cosine. */
14
	movl	8(%esp), %edx		/* Point to sine. */
14
	movl	12(%esp), %edx		/* Point to sine. */
15
 
15
 
16
	andl	$0x7FF00000, %ecx	/* Examine exponent of x. */
16
	andl	$0x7FF00000, %ecx	/* Examine exponent of x. */
17
	cmpl	$0x43E00000, %ecx	/* |x| >= 2^63 */
17
	cmpl	$0x43E00000, %ecx	/* |x| >= 2^63 */
18
	jae	bigarg
18
	jae	bigarg
19
 
19
 
20
	fldl	12(%esp)
20
	fldl	4(%esp)
21
	fsincos
21
	fsincos
22
	fstpl	(%eax)			/* cos */
22
	fstpl	(%eax)			/* cos */
23
	fstpl	(%edx)			/* sin */
23
	fstpl	(%edx)			/* sin */
24
	ret
24
	ret
25
 
25
 
26
bigarg:
26
bigarg:
27
	cmpl	$0x7FF00000, %ecx	/* x is INF or NaN. */
27
	cmpl	$0x7FF00000, %ecx	/* x is INF or NaN. */
28
	jb	finite
28
	jb	finite
29
	movl	NaN, %ecx		/* Return -NaN */
29
	movl	NaN, %ecx		/* Return -NaN */
30
	movl	%ecx, (%eax)
30
	movl	%ecx, (%eax)
31
	movl	%ecx, (%edx)
31
	movl	%ecx, (%edx)
32
	movl	NaN+4, %ecx
32
	movl	NaN+4, %ecx
33
	movl	%ecx, 4(%eax)
33
	movl	%ecx, 4(%eax)
34
	movl	%ecx, 4(%edx)
34
	movl	%ecx, 4(%edx)
35
	movl	$1, C_SYM(errno)
35
	movl	$1, C_SYM(errno)
36
	ret
36
	ret
37
 
37
 
38
finite:
38
finite:
39
	fld1
39
	fld1
40
	fstpl	(%eax)			/* cos = 1. */
40
	fstpl	(%eax)			/* cos = 1. */
41
	fldz
41
	fldz
42
	fstpl	(%edx)			/* sin = 0. */
42
	fstpl	(%edx)			/* sin = 0. */
43
	ret
43
	ret