166d857b0SGreg Ungerer/* libgcc1 routines for 68000 w/o floating-point hardware. 266d857b0SGreg Ungerer Copyright (C) 1994, 1996, 1997, 1998 Free Software Foundation, Inc. 366d857b0SGreg Ungerer 466d857b0SGreg UngererThis file is part of GNU CC. 566d857b0SGreg Ungerer 666d857b0SGreg UngererGNU CC is free software; you can redistribute it and/or modify it 766d857b0SGreg Ungererunder the terms of the GNU General Public License as published by the 866d857b0SGreg UngererFree Software Foundation; either version 2, or (at your option) any 966d857b0SGreg Ungererlater version. 1066d857b0SGreg Ungerer 1166d857b0SGreg UngererIn addition to the permissions in the GNU General Public License, the 1266d857b0SGreg UngererFree Software Foundation gives you unlimited permission to link the 1366d857b0SGreg Ungerercompiled version of this file with other programs, and to distribute 1466d857b0SGreg Ungererthose programs without any restriction coming from the use of this 1566d857b0SGreg Ungererfile. (The General Public License restrictions do apply in other 1666d857b0SGreg Ungererrespects; for example, they cover modification of the file, and 1766d857b0SGreg Ungererdistribution when not linked into another program.) 1866d857b0SGreg Ungerer 1966d857b0SGreg UngererThis file is distributed in the hope that it will be useful, but 2066d857b0SGreg UngererWITHOUT ANY WARRANTY; without even the implied warranty of 2166d857b0SGreg UngererMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22d6410efaSGeert UytterhoevenGeneral Public License for more details. */ 2366d857b0SGreg Ungerer 2466d857b0SGreg Ungerer/* As a special exception, if you link this library with files 2566d857b0SGreg Ungerer compiled with GCC to produce an executable, this does not cause 2666d857b0SGreg Ungerer the resulting executable to be covered by the GNU General Public License. 2766d857b0SGreg Ungerer This exception does not however invalidate any other reasons why 2866d857b0SGreg Ungerer the executable file might be covered by the GNU General Public License. */ 2966d857b0SGreg Ungerer 3066d857b0SGreg Ungerer/* Use this one for any 680x0; assumes no floating point hardware. 3166d857b0SGreg Ungerer The trailing " '" appearing on some lines is for ANSI preprocessors. Yuk. 3266d857b0SGreg Ungerer Some of this code comes from MINIX, via the folks at ericsson. 3366d857b0SGreg Ungerer D. V. Henkel-Wallace (gumby@cygnus.com) Fete Bastille, 1992 3466d857b0SGreg Ungerer*/ 35*7547cbe2SMasahiro Yamada#include <linux/export.h> 3666d857b0SGreg Ungerer/* These are predefined by new versions of GNU cpp. */ 3766d857b0SGreg Ungerer 3866d857b0SGreg Ungerer#ifndef __USER_LABEL_PREFIX__ 3966d857b0SGreg Ungerer#define __USER_LABEL_PREFIX__ _ 4066d857b0SGreg Ungerer#endif 4166d857b0SGreg Ungerer 4266d857b0SGreg Ungerer#ifndef __REGISTER_PREFIX__ 4366d857b0SGreg Ungerer#define __REGISTER_PREFIX__ 4466d857b0SGreg Ungerer#endif 4566d857b0SGreg Ungerer 4666d857b0SGreg Ungerer#ifndef __IMMEDIATE_PREFIX__ 4766d857b0SGreg Ungerer#define __IMMEDIATE_PREFIX__ # 4866d857b0SGreg Ungerer#endif 4966d857b0SGreg Ungerer 5066d857b0SGreg Ungerer/* ANSI concatenation macros. */ 5166d857b0SGreg Ungerer 5266d857b0SGreg Ungerer#define CONCAT1(a, b) CONCAT2(a, b) 5366d857b0SGreg Ungerer#define CONCAT2(a, b) a ## b 5466d857b0SGreg Ungerer 5566d857b0SGreg Ungerer/* Use the right prefix for global labels. */ 5666d857b0SGreg Ungerer 5766d857b0SGreg Ungerer#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) 5866d857b0SGreg Ungerer 5966d857b0SGreg Ungerer/* Use the right prefix for registers. */ 6066d857b0SGreg Ungerer 6166d857b0SGreg Ungerer#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) 6266d857b0SGreg Ungerer 6366d857b0SGreg Ungerer/* Use the right prefix for immediate values. */ 6466d857b0SGreg Ungerer 6566d857b0SGreg Ungerer#define IMM(x) CONCAT1 (__IMMEDIATE_PREFIX__, x) 6666d857b0SGreg Ungerer 6766d857b0SGreg Ungerer#define d0 REG (d0) 6866d857b0SGreg Ungerer#define d1 REG (d1) 6966d857b0SGreg Ungerer#define d2 REG (d2) 7066d857b0SGreg Ungerer#define d3 REG (d3) 7166d857b0SGreg Ungerer#define d4 REG (d4) 7266d857b0SGreg Ungerer#define d5 REG (d5) 7366d857b0SGreg Ungerer#define d6 REG (d6) 7466d857b0SGreg Ungerer#define d7 REG (d7) 7566d857b0SGreg Ungerer#define a0 REG (a0) 7666d857b0SGreg Ungerer#define a1 REG (a1) 7766d857b0SGreg Ungerer#define a2 REG (a2) 7866d857b0SGreg Ungerer#define a3 REG (a3) 7966d857b0SGreg Ungerer#define a4 REG (a4) 8066d857b0SGreg Ungerer#define a5 REG (a5) 8166d857b0SGreg Ungerer#define a6 REG (a6) 8266d857b0SGreg Ungerer#define fp REG (fp) 8366d857b0SGreg Ungerer#define sp REG (sp) 8466d857b0SGreg Ungerer 8566d857b0SGreg Ungerer .text 8666d857b0SGreg Ungerer .proc 8766d857b0SGreg Ungerer .globl SYM (__umodsi3) 8866d857b0SGreg UngererSYM (__umodsi3): 8966d857b0SGreg Ungerer movel sp@(8), d1 /* d1 = divisor */ 9066d857b0SGreg Ungerer movel sp@(4), d0 /* d0 = dividend */ 9166d857b0SGreg Ungerer movel d1, sp@- 9266d857b0SGreg Ungerer movel d0, sp@- 9366d857b0SGreg Ungerer jbsr SYM (__udivsi3) 9466d857b0SGreg Ungerer addql IMM (8), sp 9566d857b0SGreg Ungerer movel sp@(8), d1 /* d1 = divisor */ 9666d857b0SGreg Ungerer#if !(defined(__mcf5200__) || defined(__mcoldfire__)) 9766d857b0SGreg Ungerer movel d1, sp@- 9866d857b0SGreg Ungerer movel d0, sp@- 9966d857b0SGreg Ungerer jbsr SYM (__mulsi3) /* d0 = (a/b)*b */ 10066d857b0SGreg Ungerer addql IMM (8), sp 10166d857b0SGreg Ungerer#else 10266d857b0SGreg Ungerer mulsl d1,d0 10366d857b0SGreg Ungerer#endif 10466d857b0SGreg Ungerer movel sp@(4), d1 /* d1 = dividend */ 10566d857b0SGreg Ungerer subl d0, d1 /* d1 = a - (a/b)*b */ 10666d857b0SGreg Ungerer movel d1, d0 10766d857b0SGreg Ungerer rts 108d13ffb56SAl Viro EXPORT_SYMBOL(__umodsi3) 109