;	File:	libraries.i
;	asm(1.0) macro package - Various defines/macros that
;	may be found useful.
;
;	This macro package has been written and placed in the
;	public domain by Douglas J Leavitt, 1986.  This macro
;	package is based on Commodore-Amiga header files printed
;	In The ROM Kernel Manuals, published and printed by
;	Commodore-Amiga, and Addison-Wesley publishing.
;
;	The goal of this macro file is to be upwardly compatible
;	with the include file of the same name.
;

	ifnd	EXEC_LIBRARIES_I
	EXEC_LIBRARIES = 1

	ifnd	ASM_COMMON
	include	"common/asmcom.i"
	endc
	ifnd	EXEC_TYPES_I
	include	"exec/types.i"
	endc
	ifnd	EXEC_NODES_I
	include	"exec/nodes.i"
	endc

	LIB_VECTSIZE = 6
	LIB_RESERVED = 4
	LIB_BASE     = -LIB_VECTSIZE
	LIB_USERDEF  = LIB_BASE-(LIB_RESERVED*LIB_VECTSIZE)
	LIB_NONSTD   = LIB_USERDEF

;	Set the base offset for function defs
LIBINIT	macro
	___argchk=narg
	ARGCHK	0,1
	ifeq	narg
	COUNT_LIB = LIB_USERDEF
	endc
	ifne	narg
	COUNT_LIB = \1
	endc
	endm

;	Define an entry
LIBDEF	macro
	___argchk=narg
	ARGCHK	1,1
	LIBDEF = COUNT_LIB
	COUNT_LIB = COUNTLIB - LIB_VECTSIZE
	endm

;	Invoke a library finction
CALLIB	macro
	___argchk=narg
	ARGCHK	1,1
	jsr	\1(a6)
	endm

;	Invoke a library function when a6 is NOT set
LINKLIB	macro
	___argchk=narg
	ARGCHK	2,2
	move.l	a6,-(sp)
	move.l	\2,a6
	jsr	\1(a6)
	move.l	(sp)+,a6
	endm

;	Set up any default functions/variables/bitflags

	endc			; EXEC_LIBRARIES_I
