1/* The start module mcrt0.s for the SysV68 Motorola 3300 Delta Series. 2 Copyright (C) 1996, 1997 Free Software Foundation, Inc. 3 Contributed by Manfred Hollstein (manfred@lts.sel.alcatel.de). 4 5This file is part of GNU CC. 6 7GNU CC is free software; you can redistribute it and/or modify 8it under the terms of the GNU General Public License as published by 9the Free Software Foundation; either version 2, or (at your option) 10any later version. 11 12GNU CC is distributed in the hope that it will be useful, 13but WITHOUT ANY WARRANTY; without even the implied warranty of 14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15GNU General Public License for more details. 16 17You should have received a copy of the GNU General Public License 18along with GNU CC; see the file COPYING. If not, write to 19the Free Software Foundation, 59 Temple Place - Suite 330, 20Boston, MA 02111-1307, USA. */ 21 22#ifdef MOTOROLA 23# define COMM comm 24# define DATA data 25# define EVEN even 26# define FILE(n) file n 27# define GLOBAL_SYM(s) global s 28# define LOCAL_LABEL(l) L%##l 29# define IDENT(s) ident s 30# define TEXT text 31#else /* Assume we are using GNU as. */ 32# define COMM .comm 33# define DATA .data 34# define EVEN .even 35# define FILE(name) .file name 36# define GLOBAL_SYM(s) .globl s 37# define LOCAL_LABEL(l) .L.##l 38# define IDENT(s) .section .comment;.asciz s 39# define TEXT .text 40#endif 41 42 FILE ("mcrt0.s") 43 TEXT 44 GLOBAL_SYM (_start) 45_start: mov.l %d0,splimit% 46 subq.w &8,%sp 47 mov.l 8(%sp),(%sp) 48 lea 12(%sp),%a0 49 mov.l %a0,___Argv 50 mov.l %a0,4(%sp) 51 mov.l %a0,%a1 52LOCAL_LABEL(0): 53 tst.l (%a0)+ 54 bne.b LOCAL_LABEL(0) 55#ifdef SGS_CMP_ORDER 56 cmpa.l %a0,(%a1) 57#else 58 cmpa.l (%a1),%a0 59#endif 60 blt.b LOCAL_LABEL(1) 61 subq.w &4,%a0 62LOCAL_LABEL(1): 63 mov.l %a0,8(%sp) 64 mov.l %a0,environ 65 jsr initfpu 66 67 sub &8,%sp 68 clr.l %d0 /* if (! isatty (fileno (stderr))) */ 69 mov.b _iob+27,%d0 70 mov.l %d0,-(%sp) 71 jsr isatty 72 addq.w &4,%sp 73 tst.l %d0 74 bne.b LOCAL_LABEL(isatty) 75 clr.l -(%sp) /* setbuf (stderr, NULL) */ 76 pea _iob+28 77 jsr setbuf 78 addq.w &8,%sp 79LOCAL_LABEL(isatty): 80 addq.w &8,%sp 81 82 mov.l &600,-(%sp) 83 mov.l &etext,%d1 84 subi.l &LOCAL_LABEL(endofstart),%d1 85 addq.l &1,%d1 86 bclr &0,%d1 87 addi.l &4812,%d1 88 asr.l &1,%d1 89 mov.l %d1,-(%sp) 90 add.l %d1,%d1 91 mov.l %d1,-(%sp) 92 jsr sbrk 93 addq.w &4,%sp 94#ifdef SGS_CMP_ORDER 95 cmpa.l %a0,&-1 96#else 97 cmpa.l &-1,%a0 98#endif 99 beq.b LOCAL_LABEL(3) 100 mov.l %a0,-(%sp) 101 add.l &12,%a0 102 mov.l %a0,_countbase 103 mov.l &etext,-(%sp) 104 mov.l &LOCAL_LABEL(endofstart),-(%sp) 105 jsr monitor 106 lea 20(%sp),%sp 107 jsr main 108 mov.l %d0,(%sp) 109 jsr exit 110_exit: moveq &1,%d0 111 trap &0 112 113 GLOBAL_SYM (__stop_monitor) 114__stop_monitor: 115 clr.l -(%sp) 116 jsr monitor 117 add.w &4,%sp 118 rts 119 120LOCAL_LABEL(errtxt): 121 byte 'N,'o,' ,'s,'p,'a,'c,'e,' ,'f,'o,'r,' ,'m,'o,'n 122 byte 'i,'t,'o,'r,' ,'b,'u,'f,'f,'e,'r,'\n 123LOCAL_LABEL(errtxt_end): 124 125 EVEN 126LOCAL_LABEL(3): 127 pea LOCAL_LABEL(errtxt_end)-LOCAL_LABEL(errtxt) 128 pea LOCAL_LABEL(errtxt)(%pc) 129 pea 2 130 jsr write 131 bra.b _exit 132LOCAL_LABEL(endofstart): 133 134 EVEN 135 136 COMM splimit%,4 137 COMM environ,4 138 COMM _countbase,4 139 140 IDENT ("$Id: mot3300Mcrt0.S,v 1.1.1.1 2003/11/29 12:33:38 espie Exp $") 141 IDENT ("Contributed by Manfred Hollstein (manfred@lts.sel.alcatel.de)") 142 IDENT ("Corrections by Philippe De Muyter (phdm@macqel.be)") 143