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 W. Metzenthen, 22 Parker St, Ormond, 9 * Vic 3163, Australia. 10 * E-mail apm233m@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 operating system. Any other use is not permitted 16 * 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 51/*---------------------------------------------------------------------------+ 52 | unsigned long div_small(unsigned long long *x, unsigned long y) | 53 +---------------------------------------------------------------------------*/ 54 55#include "fpu_asm.h" 56 57.text 58 .align 2,144 59 60.globl _div_small 61 62_div_small: 63 pushl %ebp 64 movl %esp,%ebp 65 66 pushl %esi 67 68 movl PARAM1,%esi /* pointer to num */ 69 movl PARAM2,%ecx /* The denominator */ 70 71 movl 4(%esi),%eax /* Get the current num msw */ 72 xorl %edx,%edx 73 divl %ecx 74 75 movl %eax,4(%esi) 76 77 movl (%esi),%eax /* Get the num lsw */ 78 divl %ecx 79 80 movl %eax,(%esi) 81 82 movl %edx,%eax /* Return the remainder in eax */ 83 84 popl %esi 85 86 leave 87 ret 88 89