;
;************************************************************************
;   BUFFCF.MAC
;************************************************************************
;
;  The following macros is a tool for configuring the various buffers
;  and internal request block in the comm job.
;

;;;        COMM_BUFF (N_RXBD, N_TXBD, N_RPD, N_ICB)
;
;          WHERE:
;          N_RXBD - The number of receiver BD.  Each receiver BD
;                   contains 128 bytes of buffer.  The minimum
;                   number of BD for receiving a full-length
;                   packet is 12.       
;
;          N_TXBD - The number of transmission BD.  Each transmission
;                   BD contains 128 bytes of buffer.  The minimum
;                   number of BD for transmiting a full-length
;                   packet is 12.       
;
;          N_RPD - The number of Receive Packet Descriptor (RPD).
;                  Each received data link packet will use one
;                  RPD.  The number of RPD allocated will affect
;                  the number of back-to-back  receiving.
;
;          N_ICB - The number of Internal Command Block (ICB).
;

%';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
%'
%'  UTILITY MACROS USED BY ALL MAIN MACROS TO CLEANUP PARAMETERS
%'
%';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
%'
%' Define strings for strip.
%'
%define(cr) (
)
%define(lf) (
)
%define(tab) (	)
%define(space) ( )
%'
%' Strip:
%'	strip all occurances of "char" string from "arg" string.
%'
%*define(strip(char,arg)) local str head tail (%'
%' '%define(str) (%0)%'
%' '%define(tail) (%arg)%'
%' '%while(%nes(%tail,%0)) (%'
%'     '%match(head%(%char)tail) (%tail)%'
%'     '%define(str) (%str%head)%'
%' ')%'
%' '%str%'
)%'
%'
%' Cleanup:
%'	strip spaces, tabs and CRLFs from string.
%'
%*define(cleanup(str)) (%strip(%space,%strip(%tab,%strip(%cr,%strip(%lf,%str)))))

%*DEFINE(COMM_BUFF(N_RXBD_P,N_TXBD_P,N_RPD_P,N_ICB_P))(
CGROUP    GROUP     CODE
DGROUP    GROUP     DATA
CODE     SEGMENT    PUBLIC   'CODE'
         PUBLIC     MAXRXBD,MAXTXBD,MAXRPD,MAXCB
%DEFINE (N_RXBD)(%CLEANUP(%N_RXBD_P))
%DEFINE (N_TXBD)(%CLEANUP(%N_TXBD_P))
%DEFINE (N_RPD)(%CLEANUP(%N_RPD_P))
%DEFINE (N_ICB)(%CLEANUP(%N_ICB_P))
MAXRXBD  DW         %N_RXBD
MAXTXBD  DW         %N_TXBD
MAXRPD   DW         %N_RPD
MAXCB    DW         %N_ICB
CODE     ENDS

DATA     SEGMENT    PUBLIC    'DATA'
         PUBLIC     RXBD_AREA,TXBD_AREA,RPD_AREA,CB_AREA

RXBD_AREA EQU       $
          EVEN
          DB        %N_RXBD*(14+128) DUP(?)

RPD_AREA  EQU       $
          EVEN
          DB        %N_RPD*36 DUP(?)

CB_AREA   EQU       $
TXBD_AREA EQU       $
          EVEN
          DB        %N_TXBD*(56+1500) DUP(?)

DATA     ENDS
)