     NOLIST
DefineSections MACRO            ; 25 Dec 88
*-------------------------------;    Start of DefineSections macro.
               NOLIST
               IFEQ NARG-1
               LIST
               IDNT "\1"
               NOLIST
               ENDC
               IFND ReEntrant
ReEntrant      SET 0
CurrentLibID   SET 0
               ENDC
               IFND CAPE
               LIST
MetacomcoFix:  SECTION   "",CODE             ; This un-named code section
               JMP CodeStart                 ;  is needed to fix a bug in
                                             ;  the MetaComCo assembler.
               NOLIST
               ENDC
               LIST
DefDSPointer   SET 0
               SECTION   CodeSection,CODE    ; Relocatable code section
CodeStart:
               SECTION   DataSection,DATA    ; Initialized data section
DataStart:
               SECTION   BSS_Section,BSS     ; Un-initialized data section
BSS_Start:
               SECTION   CodeSection,CODE    ; Relocatable code section
*-------------------------------;    End of DefineSections macro.
               ENDM
CallLib   MACRO          ; 9 Feb 89
     NOLIST
     IFND _LVO\1.Ref
_LVO\1.Ref SET 1
     LIST
        XREF _LVO\1
     NOLIST
     ENDC
     IFEQ ReEntrant-1
     LIST
        MOVE.L \2.library.ptr(A5),A6
     NOLIST
     ENDC
     IFNE ReEntrant-1
     LIST
        MOVE.L \2.library.ptr,A6
     NOLIST
     ENDC
     LIST
        JSR _LVO\1(A6)
     ENDM

OpenLib   MACRO                ; 25 Dec 88
*------------------------------; Start of OpenLib macro.
     NOLIST
                               ; Define _AbsExecBase and _LVOOpenLibrary if
     IFND _AbsExecBase         ;  they have not yet been defined.
     LIST
     XREF _AbsExecBase
     NOLIST
     ENDC
     IFND _LVOOpenLibrary
     LIST
     XREF _LVOOpenLibrary
     NOLIST
     ENDC
     LIST
     MOVE.L _AbsExecBase,A6    ; Do set-up for _LVOOpenLibrary.
     CLR.L D0
     MOVE.L #\1.str,A1
     SECTION DataSection,DATA  ; This is the <libname> ASCII string.
\1.str:
     DC.B '\1',0
     CNOP 0,2
     SECTION CodeSection,CODE
     JSR _LVOOpenLibrary(A6)   ; Call OpenLibrary to open <libname>.
     NOLIST
     IFEQ ReEntrant-1
     LIST
     DefDS \1.ptr,1
     MOVE.L D0,\1.ptr(A5)
     NOLIST
     ENDC
     IFNE ReEntrant-1
     LIST
     MOVE.L D0,\1.ptr
     DS_BSS \1.ptr,1,.L
     NOLIST
     ENDC
     LIST
     TST.L D0                  ; Make the zero flag indicate failure.
*------------------------------; End of OpenLib macro.
     ENDM

CloseLib       MACRO           ; 13 Sept 88
*------------------------------; Start of CloseLib macro.
                               ; Put the library pointer in A1.
     NOLIST
     IFEQ ReEntrant-1
     LIST
     MOVE.L \1.ptr(A5),A1
     NOLIST
     ENDC
     IFNE ReEntrant-1
     LIST
     MOVE.L \1.ptr,A1
     NOLIST
     ENDC
     LIST
     CallLib CloseLibrary,exec ; Call CloseLibrary.
*------------------------------; End of CloseLib macro.
     ENDM

DefDS          MACRO     ; 26 Dec 88
               NOLIST
               IFND \1
\1             EQU DefDSPointer
DefDSPointer   SET DefDSPointer+(4*\2)
               ENDC
               LIST
               ENDM

DS_BSS    MACRO          ; 13 Sept 88
          NOLIST
          IFND \1
          SECTION BSS_Section,BSS
          IFC "\3",".W"
          CNOP 0,2
          ENDC
          IFC "\3",".L"
          CNOP 0,4
          ENDC
\1:
          DS\3 \2
          SECTION CodeSection,CODE
          ENDC
          LIST
          ENDM

OnReEntrant    MACRO     ; 13 Sept 88
               NOLIST
ReEntrant      SET 1
               LIST
               ENDM

OffReEntrant   MACRO     ; 13 Sept 88
               NOLIST
ReEntrant      SET 0
               LIST
               ENDM
     LIST
