18c2ecf20Sopenharmony_ci/* libgcc1 routines for 68000 w/o floating-point hardware.
28c2ecf20Sopenharmony_ci   Copyright (C) 1994, 1996, 1997, 1998 Free Software Foundation, Inc.
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ciThis file is part of GNU CC.
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ciGNU CC is free software; you can redistribute it and/or modify it
78c2ecf20Sopenharmony_ciunder the terms of the GNU General Public License as published by the
88c2ecf20Sopenharmony_ciFree Software Foundation; either version 2, or (at your option) any
98c2ecf20Sopenharmony_cilater version.
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ciIn addition to the permissions in the GNU General Public License, the
128c2ecf20Sopenharmony_ciFree Software Foundation gives you unlimited permission to link the
138c2ecf20Sopenharmony_cicompiled version of this file with other programs, and to distribute
148c2ecf20Sopenharmony_cithose programs without any restriction coming from the use of this
158c2ecf20Sopenharmony_cifile.  (The General Public License restrictions do apply in other
168c2ecf20Sopenharmony_cirespects; for example, they cover modification of the file, and
178c2ecf20Sopenharmony_cidistribution when not linked into another program.)
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ciThis file is distributed in the hope that it will be useful, but
208c2ecf20Sopenharmony_ciWITHOUT ANY WARRANTY; without even the implied warranty of
218c2ecf20Sopenharmony_ciMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
228c2ecf20Sopenharmony_ciGeneral Public License for more details. */
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci/* As a special exception, if you link this library with files
258c2ecf20Sopenharmony_ci   compiled with GCC to produce an executable, this does not cause
268c2ecf20Sopenharmony_ci   the resulting executable to be covered by the GNU General Public License.
278c2ecf20Sopenharmony_ci   This exception does not however invalidate any other reasons why
288c2ecf20Sopenharmony_ci   the executable file might be covered by the GNU General Public License.  */
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci/* Use this one for any 680x0; assumes no floating point hardware.
318c2ecf20Sopenharmony_ci   The trailing " '" appearing on some lines is for ANSI preprocessors.  Yuk.
328c2ecf20Sopenharmony_ci   Some of this code comes from MINIX, via the folks at ericsson.
338c2ecf20Sopenharmony_ci   D. V. Henkel-Wallace (gumby@cygnus.com) Fete Bastille, 1992
348c2ecf20Sopenharmony_ci*/
358c2ecf20Sopenharmony_ci#include <asm/export.h>
368c2ecf20Sopenharmony_ci/* These are predefined by new versions of GNU cpp.  */
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci#ifndef __USER_LABEL_PREFIX__
398c2ecf20Sopenharmony_ci#define __USER_LABEL_PREFIX__ _
408c2ecf20Sopenharmony_ci#endif
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci#ifndef __REGISTER_PREFIX__
438c2ecf20Sopenharmony_ci#define __REGISTER_PREFIX__
448c2ecf20Sopenharmony_ci#endif
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci#ifndef __IMMEDIATE_PREFIX__
478c2ecf20Sopenharmony_ci#define __IMMEDIATE_PREFIX__ #
488c2ecf20Sopenharmony_ci#endif
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci/* ANSI concatenation macros.  */
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci#define CONCAT1(a, b) CONCAT2(a, b)
538c2ecf20Sopenharmony_ci#define CONCAT2(a, b) a ## b
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci/* Use the right prefix for global labels.  */
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x)
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci/* Use the right prefix for registers.  */
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x)
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci/* Use the right prefix for immediate values.  */
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci#define IMM(x) CONCAT1 (__IMMEDIATE_PREFIX__, x)
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci#define d0 REG (d0)
688c2ecf20Sopenharmony_ci#define d1 REG (d1)
698c2ecf20Sopenharmony_ci#define d2 REG (d2)
708c2ecf20Sopenharmony_ci#define d3 REG (d3)
718c2ecf20Sopenharmony_ci#define d4 REG (d4)
728c2ecf20Sopenharmony_ci#define d5 REG (d5)
738c2ecf20Sopenharmony_ci#define d6 REG (d6)
748c2ecf20Sopenharmony_ci#define d7 REG (d7)
758c2ecf20Sopenharmony_ci#define a0 REG (a0)
768c2ecf20Sopenharmony_ci#define a1 REG (a1)
778c2ecf20Sopenharmony_ci#define a2 REG (a2)
788c2ecf20Sopenharmony_ci#define a3 REG (a3)
798c2ecf20Sopenharmony_ci#define a4 REG (a4)
808c2ecf20Sopenharmony_ci#define a5 REG (a5)
818c2ecf20Sopenharmony_ci#define a6 REG (a6)
828c2ecf20Sopenharmony_ci#define fp REG (fp)
838c2ecf20Sopenharmony_ci#define sp REG (sp)
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci	.text
868c2ecf20Sopenharmony_ci	.proc
878c2ecf20Sopenharmony_ci	.globl	SYM (__umodsi3)
888c2ecf20Sopenharmony_ciSYM (__umodsi3):
898c2ecf20Sopenharmony_ci	movel	sp@(8), d1	/* d1 = divisor */
908c2ecf20Sopenharmony_ci	movel	sp@(4), d0	/* d0 = dividend */
918c2ecf20Sopenharmony_ci	movel	d1, sp@-
928c2ecf20Sopenharmony_ci	movel	d0, sp@-
938c2ecf20Sopenharmony_ci	jbsr	SYM (__udivsi3)
948c2ecf20Sopenharmony_ci	addql	IMM (8), sp
958c2ecf20Sopenharmony_ci	movel	sp@(8), d1	/* d1 = divisor */
968c2ecf20Sopenharmony_ci#if !(defined(__mcf5200__) || defined(__mcoldfire__))
978c2ecf20Sopenharmony_ci	movel	d1, sp@-
988c2ecf20Sopenharmony_ci	movel	d0, sp@-
998c2ecf20Sopenharmony_ci	jbsr	SYM (__mulsi3)	/* d0 = (a/b)*b */
1008c2ecf20Sopenharmony_ci	addql	IMM (8), sp
1018c2ecf20Sopenharmony_ci#else
1028c2ecf20Sopenharmony_ci	mulsl	d1,d0
1038c2ecf20Sopenharmony_ci#endif
1048c2ecf20Sopenharmony_ci	movel	sp@(4), d1	/* d1 = dividend */
1058c2ecf20Sopenharmony_ci	subl	d0, d1		/* d1 = a - (a/b)*b */
1068c2ecf20Sopenharmony_ci	movel	d1, d0
1078c2ecf20Sopenharmony_ci	rts
1088c2ecf20Sopenharmony_ci	EXPORT_SYMBOL(__umodsi3)
109