
|	FIFO-HANDLER HTAG.S for GCC, including startup code
|	ATTENTION: Beware of pc@(label+2) bug in gas prior to 2.5.2!!!
|	ATTENTION: pc@(label) generates non-68000 code in some gas

|	Simple startup code, not runnable from WorkBench
|	Just handle _SysBase and _DOSBase

#ifdef USE_PC_REL
#define PC_REL(a) pc@(a)
#else
#define PC_REL(a) a
#endif

.text
	.even
.globl _ENTRY
_ENTRY:
	|  need not save registers (GURU book 20.2.1.1)
	movel sp,___ExitSP
	movel 4:w,a6
	movel a6,_SysBase
	|  OpenLibrary(dos)
	lea  PC_REL(LDOSname),a1
	moveq #0,d0
	jsr a6@(-0x228)
	movel d0,_DOSBase
	jeq L102	|  0 exit status when no Dos...
	|  call _main(void);
	jbsr PC_REL(__main)
	movel d0,d2
	jra L101
.globl __exit
__exit:
	movel sp@(4),d2
L101:
	|  CloseLibrary(dos)
	movel _SysBase,a6
	movel _DOSBase,a1
	jsr a6@(-0x19e)
	movel d2,d0
L102:
	movel ___ExitSP,sp
	rts
LDOSname:
	.ascii "dos.library\0"

.data
	.even
.comm ___ExitSP,4
.comm _SysBase,4
.comm _DOSBase,4



|	Support for software int to transfer packet from
|	private port to IoSink

.text
	.even
.globl _AIntCode
_AIntCode:
	movel a1,sp@-
	jsr PC_REL(_IntCode)
	movel sp@+,a1
	rts
