a1eff2bbaf88f8e77a92bdabf140206f422528f7
[dragonfly.git] / sys / i386 / gnu / fpemul / div_small.s
1         .file   "div_small.S"
2 /*
3  *  div_small.S
4  *
5  * Divide a 64 bit integer by a 32 bit integer & return remainder.
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/div_small.s,v 1.8 1999/08/28 00:42:48 peter Exp $
61  * $DragonFly: src/sys/i386/gnu/fpemul/Attic/div_small.s,v 1.3 2003/08/07 21:17:20 dillon Exp $
62  *
63  */
64
65 /*---------------------------------------------------------------------------+
66  |    unsigned long div_small(unsigned long long *x, unsigned long y)        |
67  +---------------------------------------------------------------------------*/
68
69 #include "fpu_asm.h"
70
71 .text
72 ENTRY(div_small)
73         pushl   %ebp
74         movl    %esp,%ebp
75
76         pushl   %esi
77
78         movl    PARAM1,%esi     /* pointer to num */
79         movl    PARAM2,%ecx     /* The denominator */
80
81         movl    4(%esi),%eax    /* Get the current num msw */
82         xorl    %edx,%edx
83         divl    %ecx
84
85         movl    %eax,4(%esi)
86
87         movl    (%esi),%eax     /* Get the num lsw */
88         divl    %ecx
89
90         movl    %eax,(%esi)
91
92         movl    %edx,%eax       /* Return the remainder in eax */
93
94         popl    %esi
95
96         leave
97         ret
98