162306a36Sopenharmony_ci/* libgcc1 routines for 68000 w/o floating-point hardware.
262306a36Sopenharmony_ci   Copyright (C) 1994, 1996, 1997, 1998 Free Software Foundation, Inc.
362306a36Sopenharmony_ci
462306a36Sopenharmony_ciThis file is part of GNU CC.
562306a36Sopenharmony_ci
662306a36Sopenharmony_ciGNU CC is free software; you can redistribute it and/or modify it
762306a36Sopenharmony_ciunder the terms of the GNU General Public License as published by the
862306a36Sopenharmony_ciFree Software Foundation; either version 2, or (at your option) any
962306a36Sopenharmony_cilater version.
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ciIn addition to the permissions in the GNU General Public License, the
1262306a36Sopenharmony_ciFree Software Foundation gives you unlimited permission to link the
1362306a36Sopenharmony_cicompiled version of this file with other programs, and to distribute
1462306a36Sopenharmony_cithose programs without any restriction coming from the use of this
1562306a36Sopenharmony_cifile.  (The General Public License restrictions do apply in other
1662306a36Sopenharmony_cirespects; for example, they cover modification of the file, and
1762306a36Sopenharmony_cidistribution when not linked into another program.)
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ciThis file is distributed in the hope that it will be useful, but
2062306a36Sopenharmony_ciWITHOUT ANY WARRANTY; without even the implied warranty of
2162306a36Sopenharmony_ciMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2262306a36Sopenharmony_ciGeneral Public License for more details. */
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci/* As a special exception, if you link this library with files
2562306a36Sopenharmony_ci   compiled with GCC to produce an executable, this does not cause
2662306a36Sopenharmony_ci   the resulting executable to be covered by the GNU General Public License.
2762306a36Sopenharmony_ci   This exception does not however invalidate any other reasons why
2862306a36Sopenharmony_ci   the executable file might be covered by the GNU General Public License.  */
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci/* Use this one for any 680x0; assumes no floating point hardware.
3162306a36Sopenharmony_ci   The trailing " '" appearing on some lines is for ANSI preprocessors.  Yuk.
3262306a36Sopenharmony_ci   Some of this code comes from MINIX, via the folks at ericsson.
3362306a36Sopenharmony_ci   D. V. Henkel-Wallace (gumby@cygnus.com) Fete Bastille, 1992
3462306a36Sopenharmony_ci*/
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci#include <linux/export.h>
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci/* These are predefined by new versions of GNU cpp.  */
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci#ifndef __USER_LABEL_PREFIX__
4162306a36Sopenharmony_ci#define __USER_LABEL_PREFIX__ _
4262306a36Sopenharmony_ci#endif
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci#ifndef __REGISTER_PREFIX__
4562306a36Sopenharmony_ci#define __REGISTER_PREFIX__
4662306a36Sopenharmony_ci#endif
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci#ifndef __IMMEDIATE_PREFIX__
4962306a36Sopenharmony_ci#define __IMMEDIATE_PREFIX__ #
5062306a36Sopenharmony_ci#endif
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci/* ANSI concatenation macros.  */
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci#define CONCAT1(a, b) CONCAT2(a, b)
5562306a36Sopenharmony_ci#define CONCAT2(a, b) a ## b
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci/* Use the right prefix for global labels.  */
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x)
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci/* Use the right prefix for registers.  */
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x)
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci/* Use the right prefix for immediate values.  */
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci#define IMM(x) CONCAT1 (__IMMEDIATE_PREFIX__, x)
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ci#define d0 REG (d0)
7062306a36Sopenharmony_ci#define d1 REG (d1)
7162306a36Sopenharmony_ci#define d2 REG (d2)
7262306a36Sopenharmony_ci#define d3 REG (d3)
7362306a36Sopenharmony_ci#define d4 REG (d4)
7462306a36Sopenharmony_ci#define d5 REG (d5)
7562306a36Sopenharmony_ci#define d6 REG (d6)
7662306a36Sopenharmony_ci#define d7 REG (d7)
7762306a36Sopenharmony_ci#define a0 REG (a0)
7862306a36Sopenharmony_ci#define a1 REG (a1)
7962306a36Sopenharmony_ci#define a2 REG (a2)
8062306a36Sopenharmony_ci#define a3 REG (a3)
8162306a36Sopenharmony_ci#define a4 REG (a4)
8262306a36Sopenharmony_ci#define a5 REG (a5)
8362306a36Sopenharmony_ci#define a6 REG (a6)
8462306a36Sopenharmony_ci#define fp REG (fp)
8562306a36Sopenharmony_ci#define sp REG (sp)
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci	.text
8862306a36Sopenharmony_ci	.proc
8962306a36Sopenharmony_ci	.globl	SYM (__modsi3)
9062306a36Sopenharmony_ciSYM (__modsi3):
9162306a36Sopenharmony_ci	movel	sp@(8), d1	/* d1 = divisor */
9262306a36Sopenharmony_ci	movel	sp@(4), d0	/* d0 = dividend */
9362306a36Sopenharmony_ci	movel	d1, sp@-
9462306a36Sopenharmony_ci	movel	d0, sp@-
9562306a36Sopenharmony_ci	jbsr	SYM (__divsi3)
9662306a36Sopenharmony_ci	addql	IMM (8), sp
9762306a36Sopenharmony_ci	movel	sp@(8), d1	/* d1 = divisor */
9862306a36Sopenharmony_ci#if !(defined(__mcf5200__) || defined(__mcoldfire__))
9962306a36Sopenharmony_ci	movel	d1, sp@-
10062306a36Sopenharmony_ci	movel	d0, sp@-
10162306a36Sopenharmony_ci	jbsr	SYM (__mulsi3)	/* d0 = (a/b)*b */
10262306a36Sopenharmony_ci	addql	IMM (8), sp
10362306a36Sopenharmony_ci#else
10462306a36Sopenharmony_ci	mulsl	d1,d0
10562306a36Sopenharmony_ci#endif
10662306a36Sopenharmony_ci	movel	sp@(4), d1	/* d1 = dividend */
10762306a36Sopenharmony_ci	subl	d0, d1		/* d1 = a - (a/b)*b */
10862306a36Sopenharmony_ci	movel	d1, d0
10962306a36Sopenharmony_ci	rts
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_ci	EXPORT_SYMBOL(__modsi3)
112