/* libgcc1 routines for 68000 w/o floating-point hardware.1Copyright (C) 1994, 1996, 1997, 1998 Free Software Foundation, Inc.23This file is part of GNU CC.45GNU CC is free software; you can redistribute it and/or modify it6under the terms of the GNU General Public License as published by the7Free Software Foundation; either version 2, or (at your option) any8later version.910In addition to the permissions in the GNU General Public License, the11Free Software Foundation gives you unlimited permission to link the12compiled version of this file with other programs, and to distribute13those programs without any restriction coming from the use of this14file. (The General Public License restrictions do apply in other15respects; for example, they cover modification of the file, and16distribution when not linked into another program.)1718This file is distributed in the hope that it will be useful, but19WITHOUT ANY WARRANTY; without even the implied warranty of20MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU21General Public License for more details.2223You should have received a copy of the GNU General Public License24along with this program; see the file COPYING. If not, write to25the Free Software Foundation, 59 Temple Place - Suite 330,26Boston, MA 02111-1307, USA. */2728/* As a special exception, if you link this library with files29compiled with GCC to produce an executable, this does not cause30the resulting executable to be covered by the GNU General Public License.31This exception does not however invalidate any other reasons why32the executable file might be covered by the GNU General Public License. */3334/* Use this one for any 680x0; assumes no floating point hardware.35The trailing " '" appearing on some lines is for ANSI preprocessors. Yuk.36Some of this code comes from MINIX, via the folks at ericsson.37D. V. Henkel-Wallace ([email protected]) Fete Bastille, 199238*/3940/* These are predefined by new versions of GNU cpp. */4142#ifndef __USER_LABEL_PREFIX__43#define __USER_LABEL_PREFIX__ _44#endif4546#ifndef __REGISTER_PREFIX__47#define __REGISTER_PREFIX__48#endif4950#ifndef __IMMEDIATE_PREFIX__51#define __IMMEDIATE_PREFIX__ #52#endif5354/* ANSI concatenation macros. */5556#define CONCAT1(a, b) CONCAT2(a, b)57#define CONCAT2(a, b) a ## b5859/* Use the right prefix for global labels. */6061#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x)6263/* Use the right prefix for registers. */6465#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x)6667/* Use the right prefix for immediate values. */6869#define IMM(x) CONCAT1 (__IMMEDIATE_PREFIX__, x)7071#define d0 REG (d0)72#define d1 REG (d1)73#define d2 REG (d2)74#define d3 REG (d3)75#define d4 REG (d4)76#define d5 REG (d5)77#define d6 REG (d6)78#define d7 REG (d7)79#define a0 REG (a0)80#define a1 REG (a1)81#define a2 REG (a2)82#define a3 REG (a3)83#define a4 REG (a4)84#define a5 REG (a5)85#define a6 REG (a6)86#define fp REG (fp)87#define sp REG (sp)8889.text90.proc91.globl SYM (__divsi3)92SYM (__divsi3):93movel d2, sp@-9495moveq IMM (1), d2 /* sign of result stored in d2 (=1 or =-1) */96movel sp@(12), d1 /* d1 = divisor */97jpl L198negl d199#if !(defined(__mcf5200__) || defined(__mcoldfire__))100negb d2 /* change sign because divisor <0 */101#else102negl d2 /* change sign because divisor <0 */103#endif104L1: movel sp@(8), d0 /* d0 = dividend */105jpl L2106negl d0107#if !(defined(__mcf5200__) || defined(__mcoldfire__))108negb d2109#else110negl d2111#endif112113L2: movel d1, sp@-114movel d0, sp@-115jbsr SYM (__udivsi3) /* divide abs(dividend) by abs(divisor) */116addql IMM (8), sp117118tstb d2119jpl L3120negl d0121122L3: movel sp@+, d2123rts124125126127