divsi3.S revision 1.1
11.1Sfredette/* $NetBSD: divsi3.S,v 1.1 2002/03/26 22:49:32 fredette Exp $ */ 21.1Sfredette 31.1Sfredette/*- 41.1Sfredette * Copyright (c) 2002 The NetBSD Foundation, Inc. 51.1Sfredette * All rights reserved. 61.1Sfredette * 71.1Sfredette * This code is derived from software contributed to The NetBSD Foundation 81.1Sfredette * by Matthew Fredette. 91.1Sfredette * 101.1Sfredette * Redistribution and use in source and binary forms, with or without 111.1Sfredette * modification, are permitted provided that the following conditions 121.1Sfredette * are met: 131.1Sfredette * 1. Redistributions of source code must retain the above copyright 141.1Sfredette * notice, this list of conditions and the following disclaimer. 151.1Sfredette * 2. Redistributions in binary form must reproduce the above copyright 161.1Sfredette * notice, this list of conditions and the following disclaimer in the 171.1Sfredette * documentation and/or other materials provided with the distribution. 181.1Sfredette * 3. All advertising materials mentioning features or use of this software 191.1Sfredette * must display the following acknowledgement: 201.1Sfredette * This product includes software developed by the NetBSD 211.1Sfredette * Foundation, Inc. and its contributors. 221.1Sfredette * 4. Neither the name of The NetBSD Foundation nor the names of its 231.1Sfredette * contributors may be used to endorse or promote products derived 241.1Sfredette * from this software without specific prior written permission. 251.1Sfredette * 261.1Sfredette * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 271.1Sfredette * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 281.1Sfredette * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 291.1Sfredette * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 301.1Sfredette * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 311.1Sfredette * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 321.1Sfredette * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 331.1Sfredette * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 341.1Sfredette * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 351.1Sfredette * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 361.1Sfredette * POSSIBILITY OF SUCH DAMAGE. 371.1Sfredette */ 381.1Sfredette 391.1Sfredette#include <machine/asm.h> 401.1Sfredette 411.1Sfredette#if defined(LIBC_SCCS) && !defined(lint) 421.1Sfredette RCSID("$NetBSD: divsi3.S,v 1.1 2002/03/26 22:49:32 fredette Exp $"); 431.1Sfredette#endif /* LIBC_SCCS and not lint */ 441.1Sfredette 451.1SfredetteENTRY(__divsi3) 461.1Sfredette| NB: this requires that __udivsi3 preserve %a0: 471.1Sfredette movel %sp@(4), %d1 | load the dividend 481.1Sfredette bpl 1f 491.1Sfredette negl %sp@(4) | store abs(dividend) 501.1Sfredette1: movel %sp@(8), %d0 | load the divisor 511.1Sfredette bpl 2f 521.1Sfredette negl %sp@(8) | store abs(divisor) 531.1Sfredette2: eorl %d1, %d0 541.1Sfredette bpl 3f | branch if sgn(divisor) == sgn(dividend) 551.1Sfredette movel %sp@+, %a0 | pop return address 561.1Sfredette pea %pc@(Lret) | push our return address 571.1Sfredette3: jmp _C_LABEL(__udivsi3) 581.1SfredetteLret: negl %d0 | negate quotient 591.1Sfredette jmp %a0@ 60