1/*
2 * Written by Ulrich Drepper <drepper@cygnus.com>.
3 * Based on e_remainder by J.T. Conklin <jtc@netbsd.org>.
4 * Public domain.
5 */
6
7#include <machine/asm.h>
8#include "bp-sym.h"
9#include "bp-asm.h"
10
11#define PARMS	LINKAGE		/* no space for saved regs */
12#define DVDND	PARMS
13#define DVSOR	DVDND+8
14#define QUOP	DVSOR+8
15
16	.text
17ENTRY (BP_SYM (__remquo))
18	ENTER
19
20	fldl	DVSOR(%esp)
21	fldl	DVDND(%esp)
221:	fprem1
23	fstsw	%ax
24	sahf
25	jp	1b
26	fstp	%st(1)
27	/* Compute the congruent of the quotient.  */
28	movl	%eax, %ecx
29	shrl	$8, %eax
30	shrl	$12, %ecx
31	andl	$4, %ecx
32	andl	$3, %eax
33	orl	%eax, %ecx
34	leal	(%ecx,%ecx,2),%ecx
35	movl	$0xef2a60, %eax
36	shrl	%cl, %eax
37	andl	$7, %eax
38	movl	QUOP(%esp), %ecx
39	CHECK_BOUNDS_BOTH_WIDE (%ecx, QUOP(%esp), $4)
40	movl	DVDND+4(%esp), %edx
41	xorl	DVSOR+4(%esp), %edx
42	testl	$0x80000000, %edx
43	jz	1f
44	negl	%eax
451:	movl	%eax, (%ecx)
46
47	LEAVE
48	ret
49END (BP_SYM (__remquo))
50weak_alias (BP_SYM (__remquo), BP_SYM (remquo))
51