about summary refs log tree commit diff
path: root/sysdeps/i386/fpu/s_remquo.S
blob: 4857b98ab4be913b4e9bf1df156a99ef212b7c49 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 * Written by Ulrich Drepper <drepper@cygnus.com>.
 * Based on e_remainder by J.T. Conklin <jtc@netbsd.org>.
 * Public domain.
 */

#include <machine/asm.h>
#include "bp-sym.h"
#include "bp-asm.h"

#define PARMS	LINKAGE		/* no space for saved regs */
#define DVDND	PARMS
#define DVSOR	DVDND+8
#define QUOP	DVSOR+8

	.text
ENTRY (BP_SYM (__remquo))
	ENTER

	fldl	DVSOR(%esp)
	fldl	DVDND(%esp)
1:	fprem1
	fstsw	%ax
	sahf
	jp	1b
	fstp	%st(1)
	/* Compute the congruent of the quotient.  */
	movl	%eax, %ecx
	shrl	$8, %eax
	shrl	$12, %ecx
	andl	$4, %ecx
	andl	$3, %eax
	orl	%eax, %ecx
	movl	$0xef2960, %eax
	shrl	%cl, %eax
	andl	$3, %eax
	movl	QUOP(%esp), %ecx
	CHECK_BOUNDS_BOTH_WIDE (%ecx, QUOP(%esp), $4)
	movl	DVDND+4(%esp), %edx
	xorl	DVSOR+4(%esp), %edx
	testl	$0x80000000, %edx
	jz	1f
	negl	%eax
1:	movl	%eax, (%ecx)

	LEAVE
	ret
END (BP_SYM (__remquo))
weak_alias (BP_SYM (__remquo), BP_SYM (remquo))