sdivsi3.S revision 1.7.2.2 1 1.7.2.2 elad /* $NetBSD: sdivsi3.S,v 1.7.2.2 2006/05/11 23:31:08 elad Exp $ */
2 1.7.2.2 elad
3 1.7.2.2 elad /*-
4 1.7.2.2 elad * Copyright (c) 1990 The Regents of the University of California.
5 1.7.2.2 elad * All rights reserved.
6 1.7.2.2 elad *
7 1.7.2.2 elad * This code is derived from software contributed to Berkeley by
8 1.7.2.2 elad * William Jolitz.
9 1.7.2.2 elad *
10 1.7.2.2 elad * Redistribution and use in source and binary forms, with or without
11 1.7.2.2 elad * modification, are permitted provided that the following conditions
12 1.7.2.2 elad * are met:
13 1.7.2.2 elad * 1. Redistributions of source code must retain the above copyright
14 1.7.2.2 elad * notice, this list of conditions and the following disclaimer.
15 1.7.2.2 elad * 2. Redistributions in binary form must reproduce the above copyright
16 1.7.2.2 elad * notice, this list of conditions and the following disclaimer in the
17 1.7.2.2 elad * documentation and/or other materials provided with the distribution.
18 1.7.2.2 elad * 3. Neither the name of the University nor the names of its contributors
19 1.7.2.2 elad * may be used to endorse or promote products derived from this software
20 1.7.2.2 elad * without specific prior written permission.
21 1.7.2.2 elad *
22 1.7.2.2 elad * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 1.7.2.2 elad * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 1.7.2.2 elad * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 1.7.2.2 elad * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 1.7.2.2 elad * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 1.7.2.2 elad * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 1.7.2.2 elad * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 1.7.2.2 elad * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 1.7.2.2 elad * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 1.7.2.2 elad * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 1.7.2.2 elad * SUCH DAMAGE.
33 1.7.2.2 elad *
34 1.7.2.2 elad * from: @(#)udivsi3.s 5.1 (Berkeley) 5/15/90
35 1.7.2.2 elad */
36 1.7.2.2 elad
37 1.7.2.2 elad #include <machine/asm.h>
38 1.7.2.2 elad #if defined(LIBC_SCCS)
39 1.7.2.2 elad RCSID("$NetBSD: sdivsi3.S,v 1.7.2.2 2006/05/11 23:31:08 elad Exp $")
40 1.7.2.2 elad #endif
41 1.7.2.2 elad
42 1.7.2.2 elad #ifdef PIC /* XXX: uwe */
43 1.7.2.2 elad .hidden __sdivsi3
44 1.7.2.2 elad #endif
45 1.7.2.2 elad
46 1.7.2.2 elad /* r0 <= r4 / r5 */
47 1.7.2.2 elad NENTRY(__sdivsi3)
48 1.7.2.2 elad mov r4, r0
49 1.7.2.2 elad mov r5, r1
50 1.7.2.2 elad
51 1.7.2.2 elad tst r1, r1
52 1.7.2.2 elad bt div_by_zero
53 1.7.2.2 elad
54 1.7.2.2 elad mov #0, r2
55 1.7.2.2 elad div0s r2, r0
56 1.7.2.2 elad subc r3, r3
57 1.7.2.2 elad subc r2, r0
58 1.7.2.2 elad div0s r1, r3
59 1.7.2.2 elad #define DIVSTEP rotcl r0; div1 r1, r3
60 1.7.2.2 elad /* repeat 32 times */
61 1.7.2.2 elad DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP;
62 1.7.2.2 elad DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP;
63 1.7.2.2 elad DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP;
64 1.7.2.2 elad DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP;
65 1.7.2.2 elad #undef DIVSTEP
66 1.7.2.2 elad rotcl r0
67 1.7.2.2 elad
68 1.7.2.2 elad rts
69 1.7.2.2 elad addc r2, r0
70 1.7.2.2 elad
71 1.7.2.2 elad div_by_zero:
72 1.7.2.2 elad #ifdef _KERNEL
73 1.7.2.2 elad rts
74 1.7.2.2 elad mov #0, r0
75 1.7.2.2 elad #else
76 1.7.2.2 elad mov.l r14, @-r15
77 1.7.2.2 elad sts.l pr, @-r15
78 1.7.2.2 elad mov r15, r14
79 1.7.2.2 elad
80 1.7.2.2 elad mov.l L_raise, r1
81 1.7.2.2 elad #ifdef PIC
82 1.7.2.2 elad 1: bsrf r1
83 1.7.2.2 elad #else
84 1.7.2.2 elad jsr @r1
85 1.7.2.2 elad #endif
86 1.7.2.2 elad mov #8, r4 /* delay slot. 8 <- SIGFPE. */
87 1.7.2.2 elad mov #0, r0
88 1.7.2.2 elad
89 1.7.2.2 elad lds.l @r15+, pr
90 1.7.2.2 elad rts
91 1.7.2.2 elad mov.l @r15+, r14
92 1.7.2.2 elad
93 1.7.2.2 elad .align 2
94 1.7.2.2 elad L_raise:
95 1.7.2.2 elad #ifdef PIC
96 1.7.2.2 elad .long _C_LABEL(raise)-(1b+4)
97 1.7.2.2 elad #else
98 1.7.2.2 elad .long _C_LABEL(raise)
99 1.7.2.2 elad #endif
100 1.7.2.2 elad #endif
101