****************************************************************************
*
*	This Amiga shared library is based on example source code
*	written by Gary Samad & Bill Hawes. It also employs basic
*	library concepts introduced by Jimm Mackraz (ELib) and
*	Edwin Hoogerbeets (MkLib). This library was generated using
*	a customized version of the MkLib utility.
*
****************************************************************************
*
*	Initial startup routine for Aztec C.
*	Copyright (C) 1986 by Manx Software Systems, Inc.
*
*	But FUNKIFIED by Jimm Mackraz.
*
*	library base	in D0
*	segment list	in A0
*	execbase	in A6
*
*	NOTE: code down to "start" must be placed at beginning of
*	      all programs linked with Aztec Linker using small
*	      code or small data.
*
****************************************************************************

	INCLUDE	'exec/types.i'
	INCLUDE	'exec/nodes.i'
	INCLUDE	'exec/resident.i'
	INCLUDE	'exec/libraries.i'

a4save
	DC.L    0

	PUBLIC	.begin
.begin
        PUBLIC	_LibInit

_LibInit:

	NEAR	CODE

	MOVEM.L	D0/D2/D3/D4-D7/A2-A6,-(SP)

	MOVE.L	A0,A4
	ADD.L	A4,A4
	ADD.L	A4,A4

	MOVE.L	(A4),A4
	ADD.L	A4,A4
	ADD.L	A4,A4

	ADD.L	#32766+4,A4
	LEA	__H1_end,A1
	LEA	__H2_org,A2
	CMP.L	A1,A2
	BNE	start
	MOVE.W	#((__H2_end-__H2_org)/4)-1,D1
	BMI	start
	MOVE.L	#0,D2
loop
	MOVE.L	D2,(A1)+
	DBRA	D1,loop

start
	LEA	a4save,A1
	MOVE.L	A4,(A1)
	MOVE.L	A6,_SysBase

	MOVEM.L	D0/A0,-(SP)
	JSR	_LibMain
	ADDQ.L	#8,SP

	MOVEM.L	(SP)+,D0/D2/D3/D4-D7/A2-A6
	RTS

	PUBLIC	_geta4
_geta4:
        MOVE.L	a4save,A4
        RTS

        DSEG

_SysBase
	DC.L    0

        PUBLIC  _LibMain
        PUBLIC  _SysBase
        PUBLIC  __H1_end,__H2_org,__H2_end

****************************************************************************
*
*	This is the romtag structure for an Amiga Exec library.
*
****************************************************************************

	CSEG

MYVERSION	EQU	1
MYPRI		EQU	0

	PUBLIC	_LibName
	PUBLIC	_LibId
	PUBLIC	_LibInitTab

	DS	0
	PUBLIC	_LibRomTag

_LibRomTag:

	DC.W	RTC_MATCHWORD
	DC.L	_LibRomTag
	DC.L	EndTag
	DC.B	RTF_AUTOINIT
	DC.B	MYVERSION
	DC.B	NT_LIBRARY
	DC.B	MYPRI
	DC.L	_LibName
	DC.L	_LibId
	DC.L	_LibInitTab

EndTag:
	END
