Tue Oct 10 23:08:53 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
[glibc.git] / sysdeps / alpha / divrem.m4
blobd2f36383cbe5f8d3f1febb22b73516561127f5fe
1 /* For each N divided by D, we do:
2       result = (double) N / (double) D
3    Then, for each N mod D, we do:
4       result = N - (D * divMODE (N, D))
6    FIXME:
7    The q and qu versions won't deal with operands > 50 bits.  We also
8    don't check for divide by zero.  */
10 #include "DEFS.h"
11 #if 0
12 /* We do not handle div by zero yet.  */
13 #include <machine/pal.h>
14 #endif
15 #include <sysdep.h>
17 /* Avoid the definition of ret that we set in the alpha sysdep.h.  */
18 #undef ret
20 define(path, `SYSDEP_DIR/macros.m4')dnl
21 include(path)
23 FUNC__(OP)
24         /* First set up the dividend.  */
25         EXTEND(t10)
26         stq t10,0(sp)
27         ldt $f10,0(sp)
28         cvtqt $f10,$f10
29         ADJQU($f10)
31         /* Then set up the divisor.  */
32         EXTEND(t11)
33         stq t11,0(sp)
34         ldt $f1,0(sp)
35         cvtqt $f1,$f1
36         ADJQU($f1)
38         /* Do the division.  */
39         divt $f10,$f1,$f10
40         cvttqc $f10,$f10
42         /* Put the result in t12.  */
43         stt $f10,0(sp)
44         ldq t12,0(sp)
45         FULLEXTEND(t12)
47         DOREM
49         lda sp,16(sp)
50         ret zero,(t9),1
51         .end NAME__(OP)