"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
The programs in this book make extensive use of a library of standard code sections. These sections are inserted into the program source by the INCLUDE command developed in Chapter 6. This appendix contains the complete source text of these included code sections and documents them.
The interface to each subroutine is documented in Table C-1. For example, the subroutine CmpBD takes an integer in the BC register, another in the DE register, and returns a setting of the machine flags. It preserves all the registers except for A and the flags.
| Subroutine | Input | Output | Preserves |
| CheckDigit | HL->byte | Z true if HL->digit | BC,DE,HL |
| CmdCharOpt | HL->command tail | HL->x of "/x.." or 00h A = x or 00h Z true if "/x" found | BC,DE |
| CmdNumOpt | HL->command tail | HL->after "/nnn" DE=DecToBinary(nnn) Z true if "/" seen Cy false if "/n" seen | BC |
| CmdSlash | HL->command tail | HL->"/" or to 00h Z true if "/" seen | BC, DE |
| CmpBD | BC=unsigned integer DE=unsigned integer | flags as for BC-DE | BC,DE,HL |
| CmpDH | DE=unsigned integer HL=unsigned integer | flags as for DE-HL | BC,DE,HL |
| CmpString | DE->string HL->string | DE, HL advanced flags for last [DE]-[HL] | BC |
| CmpStrText | DE->string HL->text | DE, HL advanced flags for last [DE]-[HL] | BC |
| CopyString | DE->space HL->string | string copy in [DE] | all |
| DecToBinary | HL->ascii digits | binary value in DE HL advanced | AF,BC |
| Delimiter | HL->byte | Z true if [HL]=delimiter A = byte | BC,DE,HL |
| Div16by8 | A=unsigned byte HL=unsigned integer | HL=quotient HL/A A=remainder HL/A | BC,DE |
| DumpOut | utility I/O variables | output buffer written | all |
| FillA | A=byte BC=byte count DE->space | byte replicated DE=DE+BC | AF,BC,HL |
| FillZero | BC=byte count DE->space | 00h replicated DE=DE+BC | AF,BC,HL |
| FinishOutPut | utility I/O variables | output file closed | all |
| GetChar | utility I/O variables | A=next input byte | BC,DE,HL |
| HexDisplayL | A=byte | A=Ascii display of left hex digit of byte | BC,DE,HL |
| HexDisplayR | A=byte | A=Ascii display of right hex digit of byte | BC,DE,HL |
| MoveHtoD | BC=byte count DE->space HL->text | text copied DE, HL advanced by BC | AF,BC |
| MoveHtoDelim | B=byte count DE->space HL->text | text made uppercase, copied to space to first delimiter or B bytes | C |
| ParseFileRef | DE->FCB HL->text of fileref | fileref formatted into FCB, Z true if o.k. | BC,DE |
| Put9999 | HL=integer in 0..9999 | four decimal digits written via PutChar | all |
| PutBlank | none | AsciiBlank written via call to PutChar | all |
| PutChar | A=byte | byte written to utility output file, buffer dumped if necessary | all |
| PutCRLF | none | CR, LF written via call to PutChar | all |
| PutSint | HL=signed integer | sign and 1..5 digits written via PutChar, A=count of bytes sent | BC,DE,HL |
| PutString | HL->string | string bytes written via calls to PutChar | all |
| PutTab | none | TAB written via call to PutChar | all |
| PutXX | A=byte | hex display of byte written via PutChar | all |
| PutXXXX | HL=unsigned integer | hex display of integer written via PutChar | all |
| PutZZ9 | A=integer in 0..255 | 1..3 decimal digits written via PutChar, A=count of bytes sent | BC,DE,HL |
| PutZZZZ9 | HL=unsigned integer | 1..5 decimal digits written via PutChar, A=count of bytes sent | BC,DE,HL |
| ScanForA | A=byte BC=byte count HL->text | HL advanced to an equal byte or for BC bytes, Z true if match seen | A,DE |
| ScanForBC | B=byte1 C=byte2 HL->text | HL advanced to a match to byte1 or byte2, A=byte found | BC,DE |
| SetUpInput | utility I/O variables | utility input file open (can abort program) | all |
| SetUpOutput | utility I/O variables BC->default FCB DE->start of buffer HL->end of buffer | utility output file open as type .$$$, buffer variables set up. | all |
| Shift | C=byte2 | B=byte2, next byte from input in C and A | DE,HL |
| Shout | B=byte1 C=byte2 | byte1 written via call to PutChar, B=byte2, next input byte in A, C | DE,HL |
| SkipWhite | HL->text | HL advanced to non-tab, non-blank byte, A=byte | BC,DE |
| SRLDE | DE=unsigned integer | integer shifted right with 0-bit in m.s.b. | AF,BC,HL |
| StringLength | HL->string | A=length of string | BC,DE,HL |
| Type9999 | HL=integer in 0..9999 | four decimal digits typed at console | all |
| TypeBlank | none | blank typed at console | all |
| TypeChar | A=byte | byte typed at console | all |
| TypeCRLF | none | CR, LF typed at cons. | all |
| TypeMessage | DE->message,"$" | message typed at cons. | all |
| TypeSint | HL=signed integer | sign, 1..5 digits typed at console, A=count of bytes typed. | BC,DE,HL |
| TypeXX | A=byte | hex display of byte typed at console | all |
| TypeXXXX | HL=unsigned integer | four hex digits typed at console | all |
| TypeZZ9 | A=integer in 0..255 | 1..3 digits typed at console, A=count of digits typed | BC,DE,HL |
| TypeZZZZ9 | HL=unsigned integer | 1..5 digits typed at console, A=count of digits typed | BC,DE,HL |
| UnpackBCD | HL=unsigned integer | C,D,E=five BCD digits, as 01,23,45 | AF,B,HL |
| UpperCase | A=byte | if byte is lowercase, A=uppercase byte | BC,DE,HL |
| WhiteSpace | HL->byte | A=byte, Z true if it is a blank or TAB. | BC,DE,HL |
The code sections are organized into six files. Each file has a filetype of ".INC" and a filename meant to suggest the kind of code sections it contains. Each file contains a number of named units. Each unit contains one or more subroutines. Table C-2 lists all the subroutines, showing for each the name of the file and the smallest section that contains it. Look up the subroutine name "CmpBD," for example. It is in the file ARITHLIB.INC, which is displayed in listing C-1. The CmpBD subroutine is contained in the unit of the same name. If the CmpBD subroutine is to be part of a program, the program must have a line containing the command "#include Arithlib.inc,CmpBD."
| Subroutine | Filename (Listing) | Unitname |
| CheckDigit | Textlib (C-4) | CheckDigit |
| CmdCharOpt | Cmdparse (C-2) | CmdCharOpt |
| CmdNumOpt | Cmdparse (C-2) | CmdNumOpt |
| CmdSlash | Cmdparse (C-2) | CmdSlash |
| CmpBD | Arithlib (C-1) | CmpBD |
| CmpDH | Arithlib (C-1) | CmpDH |
| CmpString | Textlib (C-4) | CmpString |
| CmpStrText | Textlib (C-4) | CmpStrText |
| CopyString | Textlib (C-4) | CopyString |
| DecToBinary | Arithlib (C-1) | DecToBinary |
| Delimiter | Textlib (C-4) | Delimiter |
| Div16by8 | Arithlib (C-1) | Div16by8 |
| DumpOut | Utilio (C-6) | DumpOut |
| FillA | Textlib (C-4) | FillA |
| FillZero | Textlib (C-4) | FillZero |
| FinishOutPut | Utilio (C-6) | SetUpOutput |
| GetChar | Utilio (C-6) | GetChar |
| HexDisplayL | Arithlib (C-1) | HexDisplay |
| HexDisplayR | Arithlib (C-1) | HexDisplay |
| MoveHtoD | Textlib (C-4) | MoveHtoD |
| MoveHtoDelim | Cmdparse (C-4) | MoveHtoDelim |
| ParseFileRef | Cmdparse (C-2) | ParseFileRef |
| Put9999 | Putsubs (C-3) | Put9999 |
| PutBlank | Putsubs (C-3) | PutCommon |
| PutChar | Utilio (C-6) | PutChar |
| PutCRLF | Putsubs (C-3) | PutCommon |
| PutSint | Putsubs (C-3) | PutDecimal |
| PutString | Putsubs (C-3) | PutCommon |
| PutTab | Putsubs (C-3) | PutTab |
| PutXX | Putsubs (C-3) | PutXX |
| PutXXXX | Putsubs (C-3) | PutXXXX |
| PutZZ9 | Putsubs (C-3) | PutDecimal |
| PutZZZZ9 | Putsubs (C-3) | PutDecimal |
| ScanForA | Textlib (C-4) | ScanForA |
| ScanForBC | CmdParse (C-2) | ScanForBC |
| SetUpInput | Utilio (C-6) | SetUpInput |
| SetUpOutput | Utilio (C-6) | SetUpOutput |
| Shift | Utilio (C-6) | Shift |
| Shout | Utilio (C-6) | Shift |
| SkipWhite | Textlib (C-4) | SkipWhite |
| SRLDE | Arithlib (C-1) | SRLDE |
| StringLength | Textlib (C-4) | StringLength |
| Type9999 | TypeSubs (C-5) | Type9999 |
| TypeBlank | TypeSubs (C-5) | TypeCommon |
| TypeChar | TypeSubs (C-5) | TypeChar |
| TypeCRLF | TypeSubs (C-5) | TypeCommon |
| TypeMessage | TypeSubs (C-5) | TypeCommon |
| TypeSint | TypeSubs (C-5) | TypeDecimal |
| TypeXX | TypeSubs (C-5) | TypeXX |
| TypeXXXX | TypeSubs (C-5) | TypeXXXX |
| TypeZZ9 | TypeSubs (C-5) | TypeDecimal |
| TypeZZZZ9 | TypeSubs (C-5) | TypeDecimal |
| UnpackBCD | Arithlib (C-1) | UnpackBCD |
| UpperCase | Textlib (C-4) | UpperCase |
| WhiteSpace | Textlib (C-4) | WhiteSpace |
As noted in Chapter 6, the INCLUDE command allows named units to be nested within each other. The include files here are organized to take advantage of that fact. Often when the code in one unit calls upon code from another unit, the second unit is simply contained within the first one. This nesting of units is conceptually economical, but it makes it hard to document the relationship between units. After a number of experiments with tables more elaborate than Table C-1, I decided that the nesting of units could only be documented graphically.
Each of the six file listings in this appendix is preceded by a Figure that shows how the named units are nested within the file. For an example, turn to Listing C-3. It displays the code of the units in PUTSUBS.INC, and it is preceded by a Figure C-3 that shows relationships of those units graphically.
PUTSUBS contains six named units. Each one is shown in Figure C-3 as a rectangular outline. The name of a unit is shown outside its outline, at the upper left corner. The names of the subroutines contained in the unit are shown within the outline. The subroutine names end in colons. For instance, the PutCommon unit contains the code of three subroutines: PutBlank, PutCRLF, and PutString.
PutXX, one of the units in PUTSUBS, is nested inside another one (PutXXXX). If a program includes the PutXXXX unit, it will automatically include a copy of PutXX as well, because the smaller unit is part of the larger one.
The PutDecimal section doesn't contain another unit, but it does include another unit. This is indicated by a broad arrow followed by a file and unit name. Figure C-3 shows that within the code of PutDecimal there is a statement "#include Arithlib.inc,UnpackBCD." Within the code of PutXX there is an include for unit HexDisplay of file ARITHLIB. The Figure also shows that the Put9999 unit has two include commands—one for UnpackBCD from ARITHLIB, and one for PutXXXX from the PUTSUBS file.
As you can see from this discussion, the Figures contained in the listings of this appendix document a number of aspects of the files far more concisely than could be done by words or tables. With them you can answer such questions as "What is included with section so-and-so?" and "If unit X is included, does unit Y need to be included also?"