Merge from vendor branch OPENSSL:
[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  * $DragonFly: src/sys/i386/gnu/fpemul/Attic/poly_div.s,v 1.3 2003/08/07 21:17:20 dillon Exp $
62  *
63  */
64
65 #include "fpu_asm.h"
66
67 .text
68
69 /*---------------------------------------------------------------------------*/
70 ENTRY(poly_div2)
71         pushl %ebp
72         movl %esp,%ebp
73
74         movl PARAM1,%ecx
75         movw (%ecx),%ax
76
77         shrl $1,4(%ecx)
78         rcrl $1,(%ecx)
79
80         testw $1,%ax
81         je poly_div2_exit
82
83         addl $1,(%ecx)
84         adcl $0,4(%ecx)
85 poly_div2_exit:
86
87         leave
88         ret
89 /*---------------------------------------------------------------------------*/
90 ENTRY(poly_div4)
91         pushl %ebp
92         movl %esp,%ebp
93
94         movl PARAM1,%ecx
95         movw (%ecx),%ax
96
97         movl 4(%ecx),%edx
98         shll $30,%edx
99
100         shrl $2,4(%ecx)
101         shrl $2,(%ecx)
102
103         orl %edx,(%ecx)
104
105         testw $2,%ax
106         je poly_div4_exit
107
108         addl $1,(%ecx)
109         adcl $0,4(%ecx)
110 poly_div4_exit:
111
112         leave
113         ret
114 /*---------------------------------------------------------------------------*/
115 ENTRY(poly_div16)
116         pushl %ebp
117         movl %esp,%ebp
118
119         movl PARAM1,%ecx
120         movw (%ecx),%ax
121
122         movl 4(%ecx),%edx
123         shll $28,%edx
124
125         shrl $4,4(%ecx)
126         shrl $4,(%ecx)
127
128         orl %edx,(%ecx)
129
130         testw $8,%ax
131         je poly_div16_exit
132
133         addl $1,(%ecx)
134         adcl $0,4(%ecx)
135 poly_div16_exit:
136
137         leave
138         ret
139 /*---------------------------------------------------------------------------*/