this repo has no description
1
2/*
3 * by Ian Ollmann
4 *
5 * Copyright � 2005 Apple Computer Inc. All Rights Reserved.
6 *
7 */
8
9
10#include <machine/asm.h>
11#include "abi.h"
12
13
14#if defined( __LP64__ )
15 #define DEST_P %rdi
16 #define LOAD_DEST_P
17#else
18 #define DEST_P %ecx
19 #define LOAD_DEST_P mov THIRD_ARG_OFFSET(STACKP), DEST_P
20#endif
21
22
23PRIVATE_ENTRY(__remquol) //private interface used by single and double precision remquo
24#if ! defined( BUILDING_FOR_CARBONCORE_LEGACY )
25ENTRY(remquol)
26#endif
27 //load data
28 fldt SECOND_ARG_OFFSET(STACKP) // { d }
29 fldt FIRST_ARG_OFFSET(STACKP) // { n, d }
30
311: fprem1 // { r, d }
32 fstsw %ax
33 btw $10,%ax
34 jc 1b
35 fstp %st(1)
36
37 //Calculate quo.
38 //Alas, the bits in fstat are all scrambled up.
39 //It seems like there should be an easy way to do this,
40 //but I don't see the magic instruction. So....
41 movl %eax, %ecx
42 movl %eax, %edx
43 ror $6, %eax
44 ror $9, %ecx
45 ror $13, %edx
46 and $0x4, %eax
47 and $0x1, %ecx
48 and $0x2, %edx
49 or %ecx, %eax
50 or %eax, %edx
51
52 //set the sign appropriately according to the sign of n/d
53 movw (FIRST_ARG_OFFSET+8)(STACKP), %cx
54 movw (SECOND_ARG_OFFSET+8)(STACKP), %ax
55 xor %ecx, %eax
56 LOAD_DEST_P //Get the destination pointer
57 cwde
58 sar $15, %eax
59 xor %eax, %edx
60 sub %eax, %edx
61
62 //store out quo and return
63 movl %edx, (DEST_P)
64 ret
65