| stripped baserelative startup code for gcc v2.3.3
| (c) by M.Fleischer and G.Nikl Wed Apr 13 17:45 1994

| some specific defines

_LVOForbid	=	-132
_LVOFindTask	=	-294
_LVOGetMsg	=	-372
_LVOReplyMsg	=	-378
_LVOWaitPort	=	-384

pr_MsgPort	=	  92
pr_CLI		=	 172

RETURN_FAIL	=	  20

		.text

| public symbols

		.globl	__exit

| first entry - init some vars, check for cli or wb start

start:		moveml	d2/a2/a6,sp@-

		lea	___a4_init,a4

		movew	#___bss_size,d1
		beqs	nobss
		lea	a4@(__edata:W),a1
clrbss:		clrl	a1@+
		subqw	#4,d1
		bnes	clrbss

nobss:		movel	sp,a4@(___SaveSP:W)
		movel	4:W,a6
		movel	a6,a4@(_SysBase:W)
		subal	a1,a1
		jsr	a6@(_LVOFindTask:W)
		movel	d0,a2
		tstl	a2@(pr_CLI:W)
		bnes	fromCLI

| wb start - get wbmsg

fromWB:		lea	a2@(pr_MsgPort:W),a0
		jsr	a6@(_LVOWaitPort:W)
		lea	a2@(pr_MsgPort:W),a0
		jsr	a6@(_LVOGetMsg:W)
		movel	d0,a4@(__WBenchMsg:W)

| call _main - push args onto stack

fromCLI:	jbsr	__main

| exit() entry - close libs, reply wbmsg

__exit:		movel	a4@(_SysBase:W),a6

		movel	a4@(__WBenchMsg:W),d2
		beqs	todos
		jsr	a6@(_LVOForbid:W)
		movel	d2,a1
		jsr	a6@(_LVOReplyMsg:W)

todos:		moveq	#0,d0
		movel	a4@(___SaveSP:W),sp

		moveml	sp@+,d2/a2/a6
		rts

| data area

		.data

.comm		_SysBase,4
.comm		___SaveSP,4
.comm		__WBenchMsg,4
