Initial import from FreeBSD RELENG_4:
[dragonfly.git] / sys / i386 / gnu / fpemul / poly_div.s
1         .file   "poly_div.S"
2 /*
3  *  poly_div.S
4  *
5  * A set of functions to divide 64 bit integers by fixed numbers.
6  *
7  *
8  * Copyright (C) 1992,1993,1994
9  *                       W. Metzenthen, 22 Parker St, Ormond, Vic 3163,
10  *                       Australia.  E-mail   billm@vaxc.cc.monash.edu.au
11  * All rights reserved.
12  *
13  * This copyright notice covers the redistribution and use of the
14  * FPU emulator developed by W. Metzenthen. It covers only its use
15  * in the 386BSD, FreeBSD and NetBSD operating systems. Any other
16  * use is not permitted under this copyright.
17  *
18  * Redistribution and use in source and binary forms, with or without
19  * modification, are permitted provided that the following conditions
20  * are met:
21  * 1. Redistributions of source code must retain the above copyright
22  *    notice, this list of conditions and the following disclaimer.
23  * 2. Redistributions in binary form must include information specifying
24  *    that source code for the emulator is freely available and include
25  *    either:
26  *      a) an offer to provide the source code for a nominal distribution
27  *         fee, or
28  *      b) list at least two alternative methods whereby the source
29  *         can be obtained, e.g. a publically accessible bulletin board
30  *         and an anonymous ftp site from which the software can be
31  *         downloaded.
32  * 3. All advertising materials specifically mentioning features or use of
33  *    this emulator must acknowledge that it was developed by W. Metzenthen.
34  * 4. The name of W. Metzenthen may not be used to endorse or promote
35  *    products derived from this software without specific prior written
36  *    permission.
37  *
38  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
39  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
40  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
41  * W. METZENTHEN BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
42  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
43  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
44  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
45  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
46  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
47  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48  *
49  *
50  * The purpose of this copyright, based upon the Berkeley copyright, is to
51  * ensure that the covered software remains freely available to everyone.
52  *
53  * The software (with necessary differences) is also available, but under
54  * the terms of the GNU copyleft, for the Linux operating system and for
55  * the djgpp ms-dos extender.
56  *
57  * W. Metzenthen   June 1994.
58  *
59  *
60  * $FreeBSD: src/sys/gnu/i386/fpemul/poly_div.s,v 1.8 1999/08/28 00:42:53 peter Exp $
61  *
62  */
63
64 #include <gnu/i386/fpemul/fpu_asm.h>
65
66 .text
67
68 /*---------------------------------------------------------------------------*/
69 ENTRY(poly_div2)
70         pushl %ebp
71         movl %esp,%ebp
72
73         movl PARAM1,%ecx
74         movw (%ecx),%ax
75
76         shrl $1,4(%ecx)
77         rcrl $1,(%ecx)
78
79         testw $1,%ax
80         je poly_div2_exit
81
82         addl $1,(%ecx)
83         adcl $0,4(%ecx)
84 poly_div2_exit:
85
86         leave
87         ret
88 /*---------------------------------------------------------------------------*/
89 ENTRY(poly_div4)
90         pushl %ebp
91         movl %esp,%ebp
92
93         movl PARAM1,%ecx
94         movw (%ecx),%ax
95
96         movl 4(%ecx),%edx
97         shll $30,%edx
98
99         shrl $2,4(%ecx)
100         shrl $2,(%ecx)
101
102         orl %edx,(%ecx)
103
104         testw $2,%ax
105         je poly_div4_exit
106
107         addl $1,(%ecx)
108         adcl $0,4(%ecx)
109 poly_div4_exit:
110
111         leave
112         ret
113 /*---------------------------------------------------------------------------*/
114 ENTRY(poly_div16)
115         pushl %ebp
116         movl %esp,%ebp
117
118         movl PARAM1,%ecx
119         movw (%ecx),%ax
120
121         movl 4(%ecx),%edx
122         shll $28,%edx
123
124         shrl $4,4(%ecx)
125         shrl $4,(%ecx)
126
127         orl %edx,(%ecx)
128
129         testw $8,%ax
130         je poly_div16_exit
131
132         addl $1,(%ecx)
133         adcl $0,4(%ecx)
134 poly_div16_exit:
135
136         leave
137         ret
138 /*---------------------------------------------------------------------------*/