2.9
[glibc/nacl-glibc.git] / sysdeps / i386 / fpu / s_remquol.S
blob65240adbe47f60146a9041dfacc8ed369fe4c51e
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  */
7 #include <machine/asm.h>
8 #include "bp-sym.h"
9 #include "bp-asm.h"
11 #define PARMS   LINKAGE         /* no space for saved regs */
12 #define DVDND   PARMS
13 #define DVSOR   DVDND+12
14 #define QUOP    DVSOR+12
16         .text
17 ENTRY (BP_SYM (__remquol))
18         ENTER
20         fldt    DVSOR(%esp)
21         fldt    DVDND(%esp)
22 1:      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+8(%esp), %edx
41         xorl    DVSOR+8(%esp), %edx
42         testl   $0x8000, %edx
43         jz      1f
44         negl    %eax
45 1:      movl    %eax, (%ecx)
47         LEAVE
48         ret
49 END (BP_SYM (__remquol))
50 weak_alias (BP_SYM (__remquol), BP_SYM (remquol))