; === rexxbind.asm =====================================================
;
; Copyright (c) 1986, 1987 by William S. Hawes (All Rights Reserved)
;
; ======================================================================
; "Glue" routines for calling functions in the ARexx Systems Library.
; All calls assume that the external _RexxSysBase has been set to the
; ARexx SYstems library base by a call to OpenLibrary.

; some addes by b_null

	section text,CODE

	    XREF     _RexxSysBase

_LVODeleteArgstring	equ	-$84
_LVOLengthArgstring	equ	-$8A ;bn
_LVOCreateRexxMsg	equ	-$90
_LVODeleteRexxMsg	equ	-$96
_LVOClearRexxMsg	equ	-$9C ;bn
_LVOFillRexxMsg 	equ	-$A2 ;bn
_LVOFreePort		equ	-$EA
_LVOInitPort		equ	-$E4
_LVOIsRexxMsg		equ	-$A8
_LVOCreateArgstring	equ	-$7E
_LVOClearMem		equ	-$D8
_LVOFindRsrcNode	equ	-$B4
_LVOInitList		equ	-$DE
_LVOLockBase		equ	-450 ;d0
_LVOUnlockBase		equ	-456 ;d0
_LVOAddClipNode 	equ	-438 ;a0/1 d0/1
_LVORemClipNode 	equ	-444 ;a0


; First calling convention:
; 1, 2, or 3 parameters in (A0,A1,D0), return value in D0.

	 ; msgptr = CreateRexxMsg(&replyport,&fileext,&hostname)

	 XDEF	  _CreateRexxMsg
_CreateRexxMsg:
	 move.w   #_LVOCreateRexxMsg,d2
	 bra	  CallSeqA01D0


	 ; DeleteArgstring(argptr)

	 XDEF	  _DeleteArgstring
_DeleteArgstring:
	 move.w   #_LVODeleteArgstring,d2
	 bra	  CallSeqA01D0


	 ; DeleteRexxMsg(msgptr)

	 XDEF	  _DeleteRexxMsg
_DeleteRexxMsg:
	 move.w   #_LVODeleteRexxMsg,d2
	 bra	  CallSeqA01D0


	 ; FreePort(&msgport)

	 XDEF	  _FreePort
_FreePort:
	 move.w   #_LVOFreePort,d2
	 bra	  CallSeqA01D0


	 ; signal = InitPort(&replyport)

	 XDEF	  _InitPort
_InitPort:
	 move.w   #_LVOInitPort,d2
	 bra	  CallSeqA01D0


	 ; boolean = IsRexxMsg(msgptr)

	 XDEF	  _IsRexxMsg
_IsRexxMsg:
	 move.w   #_LVOIsRexxMsg,d2
	 bra	  CallSeqA01D0


	 ; long = FindRsrcNode(strptr,long)

	 XDEF	  _FindRsrcNode
_FindRsrcNode:
	 move.w   #_LVOFindRsrcNode,d2
	 bra	  CallSeqA01D0


	;LengthArgstring(argstring)(a0)

	 XDEF	  _LengthArgstring
_LengthArgstring
	 move.w   #_LVOLengthArgstring,d2
	 bra	  CallSeqA0


	;ClearRexxMsg(msgptr,count)(a0,d0)

	 XDEF	  _ClearRexxMsg
_ClearRexxMsg
	 move.w   #_LVOClearRexxMsg,d2
	 bra	  CallSeqA0D0


	;FillRexxMsg(msgptr,count,mask)(a0,d0/d1)

	 XDEF	  _FillRexxMsg
_FillRexxMsg
	 move.w   #_LVOFillRexxMsg,d2
	 bra	  CallSeqA0D01


	 XDEF	  _InitList
_InitList:
	 move.w   #_LVOInitList,d2
	 bra	  CallSeqA0

	 XDEF	  _LockBase
_LockBase:
	 move.w   #_LVOLockBase,d2
	 bra	  CallSeqD0

	 XDEF	  _UnlockBase
_UnlockBase:
	 move.w   #_LVOUnlockBase,d2
	 bra	  CallSeqD0

	 XDEF	  _AddClipNode
_AddClipNode:
	 move.w   #_LVOAddClipNode,d2
	 bra	  CallSeqA01D01

	 XDEF	  _RemClipNode
_RemClipNode:
	 move.w   #_LVORemClipNode,d2
	 bra	  CallSeqA0


; Second calling convention:  2 parameters in (A0,D0), return value in D0.

	 ; argptr = CreateArgstring(&string,length)

	 XDEF	  _CreateArgstring
_CreateArgstring:
	 moveq	  #_LVOCreateArgstring,d2
	 bra	  CallSeqA0D0

	 ; ClearMem(address,length)

	 XDEF	  _ClearMem
_ClearMem:
	 move.w   #_LVOClearMem,d2
	 bra	  CallSeqA0D0


	 ; Load 1 Argument into (A0)
	 nop	    ;fix lattice assembler bug
CallSeqA0 movea.l  4(sp),a0
	 bra	  CallFunc

	 ; Load 1 Argument into (D0)
	 nop	    ;fix lattice assembler bug
CallSeqD0 move.l  4(sp),d0
	 bra	  CallFunc

	 ; Load two arguments into (A0,D0)
	 nop	;fix lattice assembler bug
CallSeqA0D0 movea.l  4(sp),a0
	 move.l   8(sp),d0
	 bra	  CallFunc

	 ; Load four arguments into (A0,A1,D0,D1)
	 nop	    ;fix lattice assembler bug
CallSeqA01D01 movea.l  4(sp),a0
	 movea.l  8(sp),a1
	 move.l   12(sp),d0
	 move.l   16(sp),d1
	 bra	  CallFunc

	 ; Load three arguments into (A0,D0,D1)
	 nop	    ;fix lattice assembler bug
CallSeqA0D01 movea.l  4(sp),a0
	 move.l   8(sp),d0
	 move.l   12(sp),d1
	 bra	  CallFunc

	 ; Load three arguments into (A0,A1,D0)
	 nop	    ;fix lattice assembler bug
CallSeqA01D0 movea.l  4(sp),a0
	 movea.l  8(sp),a1
	 move.l   12(sp),d0


	 ; Call the library function
CallFunc move.l   a6,-(sp)
	 movea.l  _RexxSysBase(A4),a6
	 jsr	  0(a6,d2.w)
	 movea.l  (sp)+,a6
	 rts

	 END





