;
; Command File to Assemble ZEX by Richard Conn
;
; The following files are assumed:
;       ED.COM, MAC.COM, ZSID.COM
; The following resident commands are assumed:
;       ERA, REN, IF, FI
;

;
; 1. Test for Needed Files
;
if exist zex.asm
if exist a:rels.utl

;
; 2. Erase Any Files from Previous Executions
;
ERA ZEX*.BAK
ERA ZEX*.HEX
ERA ZEX*.SYM

;
; 3. Create ZEX30.LIB for Assembly of
;       ORG 0 Relocated Code Segment
;
ED ZEX30.LIB
#A
#K
I
ZEXBASE EQU FALSE ;SUPPRESS ZEX INITIATOR CODE
ZEXREL  EQU 0     ;SET RELOCATED CODE SEGMENT TO ORG 0
^Z
E

;
; 4. Assemble only ORG 0 Relocated Code Segment
;
MAC ZEX $$PZ

;
; 5. Rename Files from Step 4
;
REN ZEX300.HEX=ZEX.HEX
REN ZEX300.SYM=ZEX.SYM

;
; 6. New ZEX30.LIB for Assembly of
;       ORG 100H Relocated Code Segment
;
ED ZEX30.LIB
#A
#K
I
ZEXBASE EQU FALSE ;SUPPRESS ZEX INITIATOR CODE
ZEXREL  EQU 0100H ;SET RELOCATED CODE SEGMENT TO ORG 100H
^Z
E

;
; 7. Assemble only ORG 100H Relocated Code Segment
;
MAC ZEX $$PZ SZ

;
; 8. Rename File from Step 7
;
REN ZEX301.HEX=ZEX.HEX

;
; 9. New ZEX30.LIB for Assembly of
;       ZEX Initiator Code Only
;
ED ZEX30.LIB
#A
#K
I
ZEXBASE EQU TRUE ;ENABLE ZEX INITIATOR CODE
ZEXREL  EQU 0    ;RESET RELOCATED CODE SEGMENT TO ORG 0
^Z
E

;
; 10. Assemble ZEX Initiator Code Only
;
MAC ZEX $$PZ

;
; 11. Use ZSID and RELS.UTL to Create ZEX.COM
;
;       [note: If only REL.UTL is available, comment out the lines
;        starting with IZEX.COM below and change the line
;        SID RELS.UTL to SID REL.UTL and a SAVE 10 ZEX.COM
;        must be added at the end of this file.]
;
;       ZEX.HEX  contains ZEX Initiator Code
;       ZEX.SYM  contains symbols for SID for ZEX Initiator Code
;
;       ZEX300.HEX contains ZEX ORG 0 Relocated Code Segment
;       ZEX300.SYM contains symbols for SID for ZEX ORG 0 Rel Code
;
;       ZEX301.HEX contains ZEX ORG 100H Rel Code Segment
;
;       BEGREL is the symbol for the start of the Rel Code
;        Segment in ZEX.COM
;
;       DRVERL is the symbol for the length of the Rel Code
;        Segment
;
;       DRVL8  is the symbol for the length of the storage
;        needed for the relo table bit map to be created
;        by RELS.UTL
;
;       RELOCL is the symbol for the DW in ZEX.COM that will
;        contain the length of the Relocated Code Segment
;
;
; 11A.  SID is invoked and the .SYM files for the ORG 0 Rel Code
;       Segment and the Initiator Code Segment are loaded.
;
; 11B.  The DW at symbol RELOCL is updated with the value of
;       DRVERL from the ORG 0 Rel Code Segment.
;
; 11C.  Memory for the two copies of the Relocated Code Segment
;       (ORG 0 and ORG 100H) and the rel table bit map is zeroed.
;
; 11D.  The ORG 0 Relocated Code Segment is loaded starting at
;       location BEGREL.
;
; 11E.  The ORG 100H Relocated Code Segment is loaded after the
;       segment loaded in step C plus the length of the rel
;       table bit map.
;
; 11F.  RELS.UTL routine SETADRS sets the starting addresses of
;       the two Relocated Code Segments for creation of the rel
;       table bit map.
;
; 11G.  RELS.UTL routine SETLEN sets the length of the Relocated
;       Code Segment and builds the relocation table bit map.
;
; 11H*  RELS.UTL routine SAVE saves the EX Initiator Code Segment,
;       the ORG 0 Relocated Code Segment, and the rel table
;       bit map created by RELS.UTL.
;
;          * [note: not used if only REL.UTL is available]
;
; 11I.  CP/M is returned to by G0.
;
; 11J** SAVE 10 ZEX.COM saves the ZEX Initiator Code Segment,
;       the ORG 0 Relocated Code Segment, and the rel table
;       bit map created by REL.UTL.
;
;         ** [note: used ONLY if REL.UTL is used]
;
ZSID A:RELS.UTL
IZEX.HEX ZEX300.SYM
R
I* ZEX.SYM
R
SW.RELOCL
DRVERL