divsi3.S revision 1.3
11.3Srin/* $NetBSD: divsi3.S,v 1.3 2020/04/22 11:58:26 rin Exp $ */ 21.1Sfredette 31.1Sfredette/*- 41.3Srin * Copyright (c) 1990 The Regents of the University of California. 51.1Sfredette * All rights reserved. 61.1Sfredette * 71.3Srin * This code is derived from software contributed to Berkeley by 81.3Srin * the Systems Programming Group of the University of Utah Computer 91.3Srin * Science Department. 101.1Sfredette * 111.1Sfredette * Redistribution and use in source and binary forms, with or without 121.1Sfredette * modification, are permitted provided that the following conditions 131.1Sfredette * are met: 141.1Sfredette * 1. Redistributions of source code must retain the above copyright 151.1Sfredette * notice, this list of conditions and the following disclaimer. 161.1Sfredette * 2. Redistributions in binary form must reproduce the above copyright 171.1Sfredette * notice, this list of conditions and the following disclaimer in the 181.1Sfredette * documentation and/or other materials provided with the distribution. 191.3Srin * 3. Neither the name of the University nor the names of its contributors 201.3Srin * may be used to endorse or promote products derived from this software 211.3Srin * without specific prior written permission. 221.1Sfredette * 231.3Srin * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 241.3Srin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 251.3Srin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 261.3Srin * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 271.3Srin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 281.3Srin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 291.3Srin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 301.3Srin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 311.3Srin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 321.3Srin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 331.3Srin * SUCH DAMAGE. 341.1Sfredette */ 351.1Sfredette 361.1Sfredette#include <machine/asm.h> 371.1Sfredette 381.1Sfredette#if defined(LIBC_SCCS) && !defined(lint) 391.3Srin#if 0 401.3Srin RCSID("from: @(#)divsi3.s 5.1 (Berkeley) 6/7/90") 411.3Srin#else 421.3Srin RCSID("$NetBSD: divsi3.S,v 1.3 2020/04/22 11:58:26 rin Exp $") 431.3Srin#endif 441.1Sfredette#endif /* LIBC_SCCS and not lint */ 451.1Sfredette 461.3Srin/* int / int */ 471.3Srin#ifndef __mc68010__ 481.3Srin#error 491.3SrinENTRY(__divsi3) 501.3Srin movel 4(%sp),%d0 511.3Srin divsl 8(%sp),%d0 521.3Srin rts 531.3SrinEND(__divsi3) 541.3Srin#else 551.1SfredetteENTRY(__divsi3) 561.1Sfredette| NB: this requires that __udivsi3 preserve %a0: 571.3Srin movel 4(%sp), %d1 | load the dividend 581.1Sfredette bpl 1f 591.3Srin negl 4(%sp) | store abs(dividend) 601.3Srin1: movel 8(%sp), %d0 | load the divisor 611.1Sfredette bpl 2f 621.3Srin negl 8(%sp) | store abs(divisor) 631.1Sfredette2: eorl %d1, %d0 641.1Sfredette bpl 3f | branch if sgn(divisor) == sgn(dividend) 651.3Srin movel (%sp)+, %a0 | pop return address 661.3Srin pea (.Lret,%pc) | push our return address 671.1Sfredette3: jmp _C_LABEL(__udivsi3) 681.3Srin.Lret: negl %d0 | negate quotient 691.3Srin jmp (%a0) 701.3SrinEND(__divsi3) 711.3Srin#endif /* __mc68010__ */ 72