This appendix contains the text of the two macro libraries used in this book.
The first library is CPMEQU.LIB (Listing B-1). It contains equate statements that give names to the quantities that are often used in the programs. Its first section gives names to the important locations in low storage: the BDOS jump vector, the default FCB where command operands are left, and the default file buffer where the command tail is left.
Most of these addresses are defined in terms of the name "CpmBase." That is the address of the bottom of CP/M's storage. In most systems it is 0000h, but in a few hardware configurations CP/M storage begins at some higher address. If that is the case with your system, change the definition of CpmBase.
At the end of CPMEQU.LIB are the definitions of the sign characters used by the PutSint and TypeSint subroutines. These characters are declared with the SET directive instead of the EQU directive. A symbol that is SET to a value can be re-SET later in the program. If in some program you wanted "DecimalPlus" to mean "+" instead of a blank, you could SET it to that value somewhere before the #include of the subroutines.
The PROG library (Listing B-2) contains executable macros. The first macro is PROLOG, which is used in every program in the book. The PROLOG macro establishes the execution environment for the program. It finds the end of storage and places the program's stack there. It then calls the label "Main," passing the address of the last usable byte of storage. Since the main routine is entered by a CALL, it can terminate with a RET.
PROLOG also defines the label ERROREXIT, which is referenced by the ABORT macro. ERROREXIT implements the program-abort process by typing a message and cancelling any active submit file.
The symbol Z80CPU is defined at the head of PROG.LIB. That symbol is used often in these programs to choose between a sequence of 8080 instructions and an equivalent, but faster or shorter, sequence of Z80 instructions.
At the end of the PROG library there is a sequence of relative-jump macros. These generate ordinary 8080 jumps if Z80CPU is FALSE. If it is TRUE, they generate the short relative-jump instructions supported by the Z80. For another example of the use of Z80CPU, see the MoveHtoD unit of TEXTLIB.INC in Appendix C.