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 368c2ecf20Sopenharmony_ci#include <asm/export.h> 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci/* These are predefined by new versions of GNU cpp. */ 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#ifndef __USER_LABEL_PREFIX__ 418c2ecf20Sopenharmony_ci#define __USER_LABEL_PREFIX__ _ 428c2ecf20Sopenharmony_ci#endif 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci#ifndef __REGISTER_PREFIX__ 458c2ecf20Sopenharmony_ci#define __REGISTER_PREFIX__ 468c2ecf20Sopenharmony_ci#endif 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci#ifndef __IMMEDIATE_PREFIX__ 498c2ecf20Sopenharmony_ci#define __IMMEDIATE_PREFIX__ # 508c2ecf20Sopenharmony_ci#endif 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci/* ANSI concatenation macros. */ 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci#define CONCAT1(a, b) CONCAT2(a, b) 558c2ecf20Sopenharmony_ci#define CONCAT2(a, b) a ## b 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci/* Use the right prefix for global labels. */ 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci/* Use the right prefix for registers. */ 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci/* Use the right prefix for immediate values. */ 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci#define IMM(x) CONCAT1 (__IMMEDIATE_PREFIX__, x) 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci#define d0 REG (d0) 708c2ecf20Sopenharmony_ci#define d1 REG (d1) 718c2ecf20Sopenharmony_ci#define d2 REG (d2) 728c2ecf20Sopenharmony_ci#define d3 REG (d3) 738c2ecf20Sopenharmony_ci#define d4 REG (d4) 748c2ecf20Sopenharmony_ci#define d5 REG (d5) 758c2ecf20Sopenharmony_ci#define d6 REG (d6) 768c2ecf20Sopenharmony_ci#define d7 REG (d7) 778c2ecf20Sopenharmony_ci#define a0 REG (a0) 788c2ecf20Sopenharmony_ci#define a1 REG (a1) 798c2ecf20Sopenharmony_ci#define a2 REG (a2) 808c2ecf20Sopenharmony_ci#define a3 REG (a3) 818c2ecf20Sopenharmony_ci#define a4 REG (a4) 828c2ecf20Sopenharmony_ci#define a5 REG (a5) 838c2ecf20Sopenharmony_ci#define a6 REG (a6) 848c2ecf20Sopenharmony_ci#define fp REG (fp) 858c2ecf20Sopenharmony_ci#define sp REG (sp) 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci .text 888c2ecf20Sopenharmony_ci .proc 898c2ecf20Sopenharmony_ci .globl SYM (__divsi3) 908c2ecf20Sopenharmony_ciSYM (__divsi3): 918c2ecf20Sopenharmony_ci movel d2, sp@- 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci moveq IMM (1), d2 /* sign of result stored in d2 (=1 or =-1) */ 948c2ecf20Sopenharmony_ci movel sp@(12), d1 /* d1 = divisor */ 958c2ecf20Sopenharmony_ci jpl L1 968c2ecf20Sopenharmony_ci negl d1 978c2ecf20Sopenharmony_ci#if !(defined(__mcf5200__) || defined(__mcoldfire__)) 988c2ecf20Sopenharmony_ci negb d2 /* change sign because divisor <0 */ 998c2ecf20Sopenharmony_ci#else 1008c2ecf20Sopenharmony_ci negl d2 /* change sign because divisor <0 */ 1018c2ecf20Sopenharmony_ci#endif 1028c2ecf20Sopenharmony_ciL1: movel sp@(8), d0 /* d0 = dividend */ 1038c2ecf20Sopenharmony_ci jpl L2 1048c2ecf20Sopenharmony_ci negl d0 1058c2ecf20Sopenharmony_ci#if !(defined(__mcf5200__) || defined(__mcoldfire__)) 1068c2ecf20Sopenharmony_ci negb d2 1078c2ecf20Sopenharmony_ci#else 1088c2ecf20Sopenharmony_ci negl d2 1098c2ecf20Sopenharmony_ci#endif 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ciL2: movel d1, sp@- 1128c2ecf20Sopenharmony_ci movel d0, sp@- 1138c2ecf20Sopenharmony_ci jbsr SYM (__udivsi3) /* divide abs(dividend) by abs(divisor) */ 1148c2ecf20Sopenharmony_ci addql IMM (8), sp 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci tstb d2 1178c2ecf20Sopenharmony_ci jpl L3 1188c2ecf20Sopenharmony_ci negl d0 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ciL3: movel sp@+, d2 1218c2ecf20Sopenharmony_ci rts 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci EXPORT_SYMBOL(__divsi3) 124