TRS-80 DOS - LDOS 5.3.1 for the Model I - PR/FLT Disassembled
Page Customization
Page Index
PR/FLT
Other Navigation
Introduction/Summary
LDOS 5.3.1 PR/FLT Disassembly - The Printer Forms Filter (Model I)
PR/FLT is the forms filter for the printer: FILTER *PR USING PR/FLT (parms) (or FILTER *PR PR (parms), /FLT being the default extension) puts a module of 0125H bytes above HIGH$ in front of the driver of *PR. The module counts the columns and the lines, wraps long lines, adds a left margin, expands tabs, changes one character into another and skips the end of every page. The FORMS command of SYS7/SYS changes its values later, and RESET *PR takes it out again; a later install uses the same memory.
The file is a program run once by the FILTER command (member 14 of SYS6/SYS) at its transfer address 5200H, with Register Pair DE = the device control block (4025H for *PR) and Register Pair HL = the text after the file name. It makes no RST 28H request of its own.
The Parameters
| Name | Kept | What the code does with it |
|---|---|---|
| PAGE, P | 54DBH | The lines of a page, 66 when not given: +03H of the device control block (5317H). |
| LINES, L | 54D9H | The lines printed on a page before the rest of it is skipped, PAGE when not given: +05H of the device control block. It is not compared with PAGE. |
| CHARS, C | 54DDH | The bytes on a line; a full line is ended at once (5596H). 0 (the default) does not wrap. |
| INDENT, I | 54DFH | Spaces at the start of the rest of a wrapped line (55B0H). |
| MARGIN, M | 54E1H | Spaces before every line, not counted as columns (5619H). |
| ADDLF, A | 527AH | A line feed after every carriage return; without it an empty line gets a line feed only (55C0H). |
| FFHARD, F | 5274H | The rest of a page is skipped with one 0CH instead of line ends (55ECH). |
| TAB, T | 526EH | 09H becomes spaces up to the next multiple of 8 columns (560EH). |
| XLATE, X | 5283H | X'aabb': the byte aa is sent as bb (556DH). |
| SLINE, SL | 5330H | 0 (the default): PAGE, line count 0 and LINES as given, 66, 0 and 66 with the defaults; 1: each one more, 67, 1 and 67, and a new page starts with the count 1 (5609H). A value whose low byte is not 0 or 1, or SLINE alone, is a parameter error. |
| PORT | 522DH | The port the built-in printer driver uses instead of 37E8H, 1-255 (522CH). |
How It Is Installed
After the banner, a device that is NIL, routed or not an output device is refused, and so is a second PR/FLT (bit 3 of DFLAG$, 441FH); @PARAM reads the parameters, most of them straight into operands of the installer (5200H). PORT rewrites two instructions of the built-in driver; bit 3 of DFLAG$ is set; the values go into the module's parameter block at 5517H (524AH). The module goes above a HIGH$ lowered by 0125H, or into the memory of an earlier install, whose address 4DF6H keeps (528DH). Its 17 operands that hold an address inside it are moved, and it is copied there (52ADH). When the device's driver is still the one the reset saved in PRSV$ (43BCH), the module's own printer driver takes its place; the device control block is copied into the module, and its driver becomes the module (52DFH). The page values go into +03H-+05H of the device control block (5317H). An installed spooler is given the module's copy of the block (533FH).
The Module
| Offset | File | Contents |
|---|---|---|
| +00H | 5505H | JR to the entry (+19H), the start of the header; the device's driver address points here. |
| +02H | 5507H | The link word: the HIGH$ the module was put above. |
| +04H | 5509H | 03H and the name $FF. |
| +08H | 550DH | The copy of the device control block (8 bytes, not in the file): every request goes on through it, to the driver the device had or to the built-in driver. |
| +10H | 5515H | The address of the device control block (not in the file). |
| +12H | 5517H | The parameter block, Index Register IY +00H-+06H: column, XLATE from, XLATE to, INDENT, flags (bit 0 ADDLF, bit 1 FFHARD, bit 2 TAB, bit 3 SLINE), CHARS, MARGIN. |
| +19H | 551EH | The entry: a read and a control request are passed on; a byte to send is filtered. |
| +3AH | 553FH | The built-in printer driver, for 37E8H or the port of PORT=n. |
How a Byte Is Printed
The ROM's device routine enters the module with Index Register IX = the device control block and Register C = the byte (551EH). XLATE is applied first; 0DH and 0AH end a line, 0CH skips the rest of the page, 06H sets the line count to the start of a page (LPRINT CHR$(6)), 09H is expanded with TAB, other control bytes go out as they are (556DH). A printable byte gets the margin at the start of a line, is sent and counted, and a full line is wrapped with INDENT spaces (5596H). Each line end is counted in +04H of the device control block; at LINES the rest of PAGE is skipped (55DFH). Every byte goes out through the copy of the device control block (5535H). The built-in printer driver treats a status of F0H as no printer attached and writes the byte without waiting, so the computer does not hang without a printer; a printer that is busy is waited for without a time out (553FH).
About This Page
Every byte of the file is shown at its address; the module is shown at its addresses in the file, and its branches link to its rows here. The ROM routines named are those of the Level II ROM, version 1.3. Found in the code: a bad SLINE value is reported after bit 3 of DFLAG$ is set, so the bit stays set with no filter installed and the next install says PR/FLT already active! (524AH); SYSTEM (PRTIME) of SYS7/SYS takes the byte at module +19H as the offset of a time out byte, but here that byte is the code of a JR C (38H), so PRTIME writes over the POP DE at 553DH and the next byte printed returns to a wrong address (5535H), and this filter has no time out; an INDENT not below CHARS wraps with no end, one call deeper each time (5596H); LINES is not compared with PAGE, and above it the rest of the page is taken modulo 256 (55ECH); a 0DH 0AH pair counts two lines (556DH); with INDENT 0, a line of exactly CHARS bytes followed by 0DH gets an empty line; a result of the driver behind the filter is not passed back for a byte sent (555EH); PORT acts only when the built-in driver is used (52DFH); with FFHARD a 0CH leaves the column as it was.
Memory Map
Load Blocks
The file (1135 bytes) starts with a copyright record (type 1FH), then 6 load blocks with 1056 bytes, 5200H-550CH and 5517H-5629H, and the transfer address 5200H. The ten bytes 550DH-5516H are not in the file.
| Address | Contents |
|---|---|
| 5200H-52FFH | 256 bytes |
| 5300H-53FFH | 256 bytes |
| 5400H-54FFH | 256 bytes |
| 5500H-550CH | 13 bytes |
| 5517H-5616H | 256 bytes |
| 5617H-5629H | 19 bytes |
The Parts of the File
| Address | Contents |
|---|---|
| 5200H-5374H | The installer: the tests, the parameters, the memory, the relocation and the copy of the module, the hook to the device, the page values, the spooler, the errors. |
| 5375H-542FH | The banner and the four messages. |
| 5430H-54D8H | The parameter table of @PARAM. |
| 54D9H-54E2H | The cells of LINES, PAGE, CHARS, INDENT and MARGIN. |
| 54E3H-5504H | The relocation table: 17 operands of the module. |
| 5505H-5629H | The module, 0125H bytes, copied above HIGH$: its header (5505H-550CH), the copy of the device control block (550DH-5516H, not in the file), the parameter block (5517H-551DH) and the filter with its printer driver (551EH-5629H). |
Sections of the Disassembly
| Address | Contents |
|---|---|
| 5200H | The Start: the Device and Its Four Tests |
| 522CH | PORT: the Port of the Built-In Printer Driver |
| 524AH | DFLAG$ and the Parameter Block |
| 528DH | The Memory for the Module |
| 52ADH | Moving the Module's Addresses |
| 52DFH | Hooking the Module to the Device |
| 5317H | The Page in the Device Control Block |
| 533FH | The Spooler and the End |
| 5357H | Parameter Error |
| 5360H | The Refusals |
| 5375H | The Banner |
| 53DEH | The Messages of the Refusals |
| 5430H | The Parameter Table |
| 54D9H | The Value Cells |
| 54E3H | The Relocation Table |
| 5505H | The Module: Its Header |
| 550DH | The Copy of the Device Control Block |
| 5517H | The Parameter Block |
| 551EH | The Entry for a Request |
| 552CH | A Byte to Read |
| 5535H | Send a Byte On |
| 553FH | The Built-In Printer Driver |
| 5553H | The Printer's Status |
| 555EH | A Byte to Send |
| 556DH | The Filter |
| 5596H | A Printable Byte |
| 55B5H | Send Spaces |
| 55C0H | The End of a Line |
| 55DFH | A Line Ended: the Count |
| 55ECH | The Rest of the Page |
| 560EH | A Tab |
| 5619H | The Margin |
Memory PR/FLT Uses
| Address | Contents |
|---|---|
| 0013H, 001BH, 0023H | The ROM: read a byte, send a byte and a control request for the device control block at Register Pair DE; they go through 03C2H, which enters the driver with Index Register IX = the block. |
| 37E8H | The printer of the Model I: its status when read, the byte to print when written (the built-in driver). |
| 4025H | PRDCB$, the device control block of *PR, the device FILTER normally names: +00H type, +01H-+02H driver, +03H lines of a page, +04H lines printed, +05H lines to print. |
| 402DH, 4030H | @EXIT and @ABORT. |
| 4049H-404AH | HIGH$, lowered by 0125H for the module. |
| 43BCH-43BDH | PRSV$, the printer driver address the reset saved: when the device still has it, the built-in driver takes its place. |
| 441FH | DFLAG$: bit 0 the spooler is installed, bit 3 PR/FLT is installed. |
| 4409H, 4467H, 4476H, 447BH | @ERROR, @DSPLY, @PARAM, @LOGOT. |
| 4DF0H-4DF1H | The spooler's parameter block (SYS6/SYS). |
| 4DF6H-4DF7H | The address of PR/FLT's module, kept for the next install, SPOOL and the FORMS and PRTIME commands of SYS7/SYS. |
Variables
The data of the file and the bytes of the module that are not in the file, then the operands PR/FLT changes.
Data in the File and in the Module
| Address Size | Contents |
|---|---|
| 5375H-53A7H 51 bytes | DEFM "PR/FLT - Generalized Printer Filter - Version 5.3.1" 5375H-53A7H: the first line of the banner, the name and the version. |
| 53A8H 1 byte | DEFB 0AH 53A8H: 0AH, a line feed: the copyright goes on the next line. |
| 53A9H-53DBH 51 bytes | DEFM "Copyright 1991, MISOSYS, Inc., All rights reserved" 53A9H-53DBH: the second line of the banner, the copyright. |
| 53DCH 1 byte | DEFB 0AH 53DCH: 0AH, a line feed after the copyright, before the 0DH that ends the text. |
| 53DDH 1 byte | DEFB 0DH 53DDH: 0DH, the end of the banner for @DSPLY. |
| 53DEH-53EFH 18 bytes | DEFM "Device not active!" 53DEH-53EFH: the message of 5360H, a NIL device (type byte bit 3, 520DH). |
| 53F0H 1 byte | DEFB 0DH 53F0H: 0DH, the end of the message Device not active! |
| 53F1H-5405H 21 bytes | DEFM "Not an output device!" 53F1H-5405H: the message of 5364H, a device that takes no output (type byte bit 1 clear, 5217H). |
| 5406H 1 byte | DEFB 0DH 5406H: 0DH, the end of the message Not an output device! |
| 5407H-541CH 22 bytes | DEFM "PR/FLT already active!" 5407H-541CH: the message of 5368H, DFLAG$ bit 3 already set (521FH). |
| 541DH 1 byte | DEFB 0DH 541DH: 0DH, the end of the message PR/FLT already active! |
| 541EH-542EH 17 bytes | DEFM "Device is routed!" 541EH-542EH: the message of 536CH, a routed device (type byte bit 4, 5212H). |
| 542FH 1 byte | DEFB 0DH 542FH: 0DH, the end of the message Device is routed! |
| 5430H-5435H 6 bytes | DEFM "LINES " 5430H-5435H: entry 1 of the parameter table, the name LINES. |
| 5436H-5437H 2 bytes | DEFW 54D9H 5436H-5437H: entry 1: 54D9H, where @PARAM stores the value of LINES: the LINES cell 54D9H-54DAH (5322H). |
| 5438H-543DH 6 bytes | DEFM "L " 5438H-543DH: entry 2 of the parameter table, the name L, the short form of LINES. |
| 543EH-543FH 2 bytes | DEFW 54D9H 543EH-543FH: entry 2: 54D9H, where @PARAM stores the value of L: the LINES cell 54D9H-54DAH (5322H). |
| 5440H-5445H 6 bytes | DEFM "PAGE " 5440H-5445H: entry 3 of the parameter table, the name PAGE. |
| 5446H-5447H 2 bytes | DEFW 54DBH 5446H-5447H: entry 3: 54DBH, where @PARAM stores the value of PAGE: the PAGE cell 54DBH-54DCH (5317H). |
| 5448H-544DH 6 bytes | DEFM "P " 5448H-544DH: entry 4 of the parameter table, the name P, the short form of PAGE. |
| 544EH-544FH 2 bytes | DEFW 54DBH 544EH-544FH: entry 4: 54DBH, where @PARAM stores the value of P: the PAGE cell 54DBH-54DCH (5317H). |
| 5450H-5455H 6 bytes | DEFM "CHARS " 5450H-5455H: entry 5 of the parameter table, the name CHARS. |
| 5456H-5457H 2 bytes | DEFW 54DDH 5456H-5457H: entry 5: 54DDH, where @PARAM stores the value of CHARS: the CHARS cell 54DDH-54DEH (524DH). |
| 5458H-545DH 6 bytes | DEFM "C " 5458H-545DH: entry 6 of the parameter table, the name C, the short form of CHARS. |
| 545EH-545FH 2 bytes | DEFW 54DDH 545EH-545FH: entry 6: 54DDH, where @PARAM stores the value of C: the CHARS cell 54DDH-54DEH (524DH). |
| 5460H-5465H 6 bytes | DEFM "INDENT" 5460H-5465H: entry 7 of the parameter table, the name INDENT. |
| 5466H-5467H 2 bytes | DEFW 54DFH 5466H-5467H: entry 7: 54DFH, where @PARAM stores the value of INDENT: the INDENT cell 54DFH-54E0H (5259H). |
| 5468H-546DH 6 bytes | DEFM "I " 5468H-546DH: entry 8 of the parameter table, the name I, the short form of INDENT. |
| 546EH-546FH 2 bytes | DEFW 54DFH 546EH-546FH: entry 8: 54DFH, where @PARAM stores the value of I: the INDENT cell 54DFH-54E0H (5259H). |
| 5470H-5475H 6 bytes | DEFM "ADDLF " 5470H-5475H: entry 9 of the parameter table, the name ADDLF. |
| 5476H-5477H 2 bytes | DEFW 527AH 5476H-5477H: entry 9: 527AH, where @PARAM stores the value of ADDLF: 527AH-527BH, the operand of the LD BC at 5279H (527EH builds bit 0 of the flags from it). |
| 5478H-547DH 6 bytes | DEFM "A " 5478H-547DH: entry 10 of the parameter table, the name A, the short form of ADDLF. |
| 547EH-547FH 2 bytes | DEFW 527AH 547EH-547FH: entry 10: 527AH, where @PARAM stores the value of A: 527AH-527BH, the operand of the LD BC at 5279H (527EH builds bit 0 of the flags from it). |
| 5480H-5485H 6 bytes | DEFM "FFHARD" 5480H-5485H: entry 11 of the parameter table, the name FFHARD. |
| 5486H-5487H 2 bytes | DEFW 5274H 5486H-5487H: entry 11: 5274H, where @PARAM stores the value of FFHARD: 5274H-5275H, the operand of the LD BC at 5273H (bit 1 of the flags). |
| 5488H-548DH 6 bytes | DEFM "F " 5488H-548DH: entry 12 of the parameter table, the name F, the short form of FFHARD. |
| 548EH-548FH 2 bytes | DEFW 5274H 548EH-548FH: entry 12: 5274H, where @PARAM stores the value of F: 5274H-5275H, the operand of the LD BC at 5273H (bit 1 of the flags). |
| 5490H-5495H 6 bytes | DEFM "TAB " 5490H-5495H: entry 13 of the parameter table, the name TAB. |
| 5496H-5497H 2 bytes | DEFW 526EH 5496H-5497H: entry 13: 526EH, where @PARAM stores the value of TAB: 526EH-526FH, the operand of the LD BC at 526DH (bit 2 of the flags). |
| 5498H-549DH 6 bytes | DEFM "T " 5498H-549DH: entry 14 of the parameter table, the name T, the short form of TAB. |
| 549EH-549FH 2 bytes | DEFW 526EH 549EH-549FH: entry 14: 526EH, where @PARAM stores the value of T: 526EH-526FH, the operand of the LD BC at 526DH (bit 2 of the flags). |
| 54A0H-54A5H 6 bytes | DEFM "XLATE " 54A0H-54A5H: entry 15 of the parameter table, the name XLATE. |
| 54A6H-54A7H 2 bytes | DEFW 5283H 54A6H-54A7H: entry 15: 5283H, where @PARAM stores the value of XLATE: 5283H-5284H, the operand of the LD BC at 5282H (5518H and 5519H). |
| 54A8H-54ADH 6 bytes | DEFM "X " 54A8H-54ADH: entry 16 of the parameter table, the name X, the short form of XLATE. |
| 54AEH-54AFH 2 bytes | DEFW 5283H 54AEH-54AFH: entry 16: 5283H, where @PARAM stores the value of X: 5283H-5284H, the operand of the LD BC at 5282H (5518H and 5519H). |
| 54B0H-54B5H 6 bytes | DEFM "MARGIN" 54B0H-54B5H: entry 17 of the parameter table, the name MARGIN. |
| 54B6H-54B7H 2 bytes | DEFW 54E1H 54B6H-54B7H: entry 17: 54E1H, where @PARAM stores the value of MARGIN: the MARGIN cell 54E1H-54E2H (5253H). |
| 54B8H-54BDH 6 bytes | DEFM "M " 54B8H-54BDH: entry 18 of the parameter table, the name M, the short form of MARGIN. |
| 54BEH-54BFH 2 bytes | DEFW 54E1H 54BEH-54BFH: entry 18: 54E1H, where @PARAM stores the value of M: the MARGIN cell 54E1H-54E2H (5253H). |
| 54C0H-54C5H 6 bytes | DEFM "SLINE " 54C0H-54C5H: entry 19 of the parameter table, the name SLINE. |
| 54C6H-54C7H 2 bytes | DEFW 5330H 54C6H-54C7H: entry 19: 5330H, where @PARAM stores the value of SLINE: 5330H-5331H, the operand of the LD HL at 532FH (also read at 525FH). |
| 54C8H-54CDH 6 bytes | DEFM "SL " 54C8H-54CDH: entry 20 of the parameter table, the name SL, the short form of SLINE. |
| 54CEH-54CFH 2 bytes | DEFW 5330H 54CEH-54CFH: entry 20: 5330H, where @PARAM stores the value of SL: 5330H-5331H, the operand of the LD HL at 532FH (also read at 525FH). |
| 54D0H-54D5H 6 bytes | DEFM "PORT " 54D0H-54D5H: entry 21 of the parameter table, the name PORT. |
| 54D6H-54D7H 2 bytes | DEFW 522DH 54D6H-54D7H: entry 21: 522DH, where @PARAM stores the value of PORT: 522DH-522EH, the operand of the LD HL at 522CH (the port of the built-in driver). |
| 54D8H 1 byte | DEFB 00H 54D8H: 00H, the end of the parameter table: @PARAM stops at a first byte of 00H. |
| 54D9H-54DAH 2 bytes | DEFW FFFFH 54D9H-54DAH: LINES: FFFFH, not given; 5322H uses PAGE then. |
| 54DBH-54DCH 2 bytes | DEFW 0042H 54DBH-54DCH: PAGE: 0042H, 66 lines, when not given (5317H). |
| 54DDH-54DEH 2 bytes | DEFW 0000H 54DDH-54DEH: CHARS: 0000H, no wrap, when not given (524DH). |
| 54DFH-54E0H 2 bytes | DEFW 0000H 54DFH-54E0H: INDENT: 0000H when not given (5259H). |
| 54E1H-54E2H 2 bytes | DEFW 0000H 54E1H-54E2H: MARGIN: 0000H when not given (5253H). |
| 54E3H-54E4H 2 bytes | DEFW 552EH 54E3H-54E4H: relocation entry 1: 552EH, the operand of the LD DE,550DH at 552DH. |
| 54E5H-54E6H 2 bytes | DEFW 5525H 54E5H-54E6H: relocation entry 2: 5525H, the operand of the LD DE,550DH at 5524H. |
| 54E7H-54E8H 2 bytes | DEFW 5538H 54E7H-54E8H: relocation entry 3: 5538H, the operand of the LD DE,550DH at 5537H. |
| 54E9H-54EAH 2 bytes | DEFW 554AH 54E9H-54EAH: relocation entry 4: 554AH, the operand of the CALL 5553H at 5549H. |
| 54EBH-54ECH 2 bytes | DEFW 5562H 54EBH-54ECH: relocation entry 5: 5562H, the operand of the LD IY,5517H at 5560H. |
| 54EDH-54EEH 2 bytes | DEFW 5566H 54EDH-54EEH: relocation entry 6: 5566H, the operand of the CALL 556DH at 5565H. |
| 54EFH-54F0H 2 bytes | DEFW 559BH 54EFH-54F0H: relocation entry 7: 559BH, the operand of the CALL NZ,5619H at 559AH. |
| 54F1H-54F2H 2 bytes | DEFW 559EH 54F1H-54F2H: relocation entry 8: 559EH, the operand of the CALL 5535H at 559DH. |
| 54F3H-54F4H 2 bytes | DEFW 55AEH 54F3H-54F4H: relocation entry 9: 55AEH, the operand of the CALL 55DFH at 55ADH. |
| 54F5H-54F6H 2 bytes | DEFW 55BAH 54F5H-54F6H: relocation entry 10: 55BAH, the operand of the CALL 5596H at 55B9H. |
| 54F7H-54F8H 2 bytes | DEFW 55C9H 54F7H-54F8H: relocation entry 11: 55C9H, the operand of the CALL 5535H at 55C8H. |
| 54F9H-54FAH 2 bytes | DEFW 55D8H 54F9H-54FAH: relocation entry 12: 55D8H, the operand of the CALL 5535H at 55D7H. |
| 54FBH-54FCH 2 bytes | DEFW 55E0H 54FBH-54FCH: relocation entry 13: 55E0H, the operand of the CALL 55C0H at 55DFH. |
| 54FDH-54FEH 2 bytes | DEFW 55FFH 54FDH-54FEH: relocation entry 14: 55FFH, the operand of the CALL 5535H at 55FEH. |
| 54FFH-5500H 2 bytes | DEFW 5604H 54FFH-5500H: relocation entry 15: 5604H, the operand of the CALL 55C0H at 5603H. |
| 5501H-5502H 2 bytes | DEFW 5624H 5501H-5502H: relocation entry 16: 5624H, the operand of the CALL 5535H at 5623H. |
| 5503H-5504H 2 bytes | DEFW 5586H 5503H-5504H: relocation entry 17: 5586H, the operand of the JP Z,5609H at 5585H. |
| 5507H-5508H 2 bytes | DEFW 0000H 5507H-5508H: module +02H-+03H, the link word, 0000H in the file: the HIGH$ the module was put above (52AEH), which is its last byte. |
| 5509H 1 byte | DEFB 03H 5509H: module +04H, 03H, the length of the module's name. |
| 550AH-550CH 3 bytes | DEFM "$FF" 550AH-550CH: module +05H-+07H, the module's name $FF. |
| 550DH-5514H 8 bytes | DEFS 8 550DH-5514H: not in the file. Module +08H-+0FH: the copy of the 8 bytes of the device control block (5308H): +00H the type, +01H-+02H the driver the filter passes requests to (the driver the device had, or the module's printer driver at 553FH), +03H-+05H the page values from before the install, +06H-+07H the device's name. 5524H, 552DH and 5537H point Register Pair DE at it, and a spooler installed before PR/FLT is given its address (5351H). |
| 5515H-5516H 2 bytes | DEFS 2 5515H-5516H: not in the file. Module +10H-+11H: the address of the device control block (530CH), read by SYS6/SYS (SPOOL) and SYS7/SYS (FORMS). |
| 5517H 1 byte | DEFB 00H 5517H: IY +00H, the column: the bytes printed on the line since its start, the margin not counted; 00H at the start of a line (55DAH). |
| 5518H 1 byte | DEFB 00H 5518H: IY +01H, the character XLATE changes (5286H); 00H in the file. |
| 5519H 1 byte | DEFB 00H 5519H: IY +02H, the character it becomes (528AH); 00H in the file. |
| 551AH 1 byte | DEFB 00H 551AH: IY +03H, INDENT: the spaces at the start of a wrapped line (525CH). |
| 551BH 1 byte | DEFB 00H 551BH: IY +04H, the flags (527FH): bit 0 ADDLF, bit 1 FFHARD, bit 2 TAB, bit 3 SLINE. |
| 551CH 1 byte | DEFB 00H 551CH: IY +05H, CHARS: the bytes on a line, 00H no wrap (5250H). |
| 551DH 1 byte | DEFB 00H 551DH: IY +06H, MARGIN: the spaces of the left margin (5256H). |
Operands Changed
| Address Size | Contents |
|---|---|
| 522DH-522EH 2 bytes | PORT: 0000H in the file, the value of PORT= (@PARAM). |
| 526EH-526FH 2 bytes | TAB: 0000H in the file, FFFFH for TAB (@PARAM). |
| 5274H-5275H 2 bytes | FFHARD: 0000H in the file, FFFFH for FFHARD (@PARAM). |
| 527AH-527BH 2 bytes | ADDLF: 0000H in the file, FFFFH for ADDLF (@PARAM). |
| 5283H-5284H 2 bytes | XLATE: 0000H in the file, X'aabb' (@PARAM). |
| 5330H-5331H 2 bytes | SLINE: 0000H in the file, 0 or 1 (@PARAM). |
| 5507H-5508H 2 bytes | The module's link word: the HIGH$ it was put above (52AEH). |
| 554FH-5551H 3 bytes | LD (37E8H),A, made OUT (n),A and NOP by PORT=n (5244H, 5247H). |
| 5553H-5555H 3 bytes | LD A,(37E8H), made IN A,(n) and NOP by PORT=n (523CH, 523FH). |
| 560CH 1 byte | The line count at the start of a page: 01H in the file, 00H or 01H from SLINE (526AH). |
| 17 operands 2 bytes each | The operands listed in the relocation table, moved by the distance from 5505H to the module (52C3H). |
| 553DH 1 byte | In memory: SYSTEM (PRTIME) of SYS7/SYS stores 1BH or 00H over this POP DE (551EH). |
Disassembly
5200H - The Start: the Device and Its Four Tests
The transfer address. The FILTER command (member 14 of SYS6/SYS) runs PR/FLT with Register Pair DE = the device control block to filter (4025H for *PR) and Register Pair HL = the text after the file name. The banner is shown; a NIL device, a routed device, a device that takes no output and a second PR/FLT are refused; then @PARAM reads the parameters.
522CH - PORT: the Port of the Built-In Printer Driver
PORT=n makes the built-in printer driver (553FH) use port n instead of the memory address 37E8H: IN A,(n) and OUT (n),A, each followed by a NOP, are written over its LD instructions at 5553H and 554FH. A value above 255 is a parameter error. The built-in driver is used only when the device's driver is still PRSV$ (52E8H), so on another driver PORT does nothing.
524AH - DFLAG$ and the Parameter Block
DFLAG$ bit 3 is set. CHARS, MARGIN and INDENT (the low bytes of their cells) go into the parameter block at 5517H, which the module reads with Index Register IY; SLINE must be 0 or 1 and becomes the line count a new page starts with (the operand at 560CH); SLINE, TAB, FFHARD and ADDLF become bits 3-0 of the flag byte at 551BH; the two characters of XLATE go to 5518H and 5519H.
528DH - The Memory for the Module
The module is 0125H (293) bytes, 5505H-5629H. When 4DF6H-4DF7H holds the address of the module of an earlier install, that memory is used again; else HIGH$ (4049H) is lowered by 0125H and the module goes just above the new HIGH$, its address kept in 4DF6H. The module's link word (5507H) gets the HIGH$ it had before, which is the module's last byte.
52ADH - Moving the Module's Addresses
The module's link word gets the HIGH$ below which the module was put. The relocation table at 54E3H lists the 17 operands of the module that hold an address inside it; the distance from 5505H to the module's address is added to each. Then the 0125H bytes are copied.
52DFH - Hooking the Module to the Device
Index Register IX = the device control block. When its driver is still the one the reset saved in PRSV$ (43BCH), it is first replaced by the module's own printer driver (module +3AH, 553FH). The 8 bytes of the block are then copied into the module (+08H, 550DH), and the module passes every request on through that copy; the block's address goes to module +10H (5515H), and the block's driver becomes the module itself, whose first instruction is JR 551EH.
5317H - The Page in the Device Control Block
+03H of the device control block = PAGE (66 when not given), +04H, the count of the lines printed, = 1, and +05H = LINES (PAGE when not given), PAGE and LINES each plus 1. Unless SLINE=1, all three are made 1 less: 66, 0 and 66 with the defaults. The LINES value is not compared with PAGE.
533FH - The Spooler and the End
When the spooler is installed (DFLAG$ bit 0), it is given the module's copy of the device control block: the word at +08H of the spooler's parameter block (whose address SYS6/SYS keeps at 4DF0H) is the address of the spooler's cell that holds the control block it gives the printer driver, and the copy's address goes there. Then @EXIT.
5357H - Parameter Error
Error 2CH, Parameter error, displayed by @ERROR, then @ABORT.
5360H - The Refusals
Four entries load Register Pair HL with a message: 5360H, and 5364H, 5368H and 536CH inside LD IX instructions (on the way through, the DDH byte before each makes its LD HL an LD IX, so Register Pair HL keeps the message of the entry taken). @LOGOT displays the message and writes it to the job log, then @ABORT.
5375H - The Banner
Displayed by @DSPLY at 5207H: the name and version, a line feed, the copyright, a line feed, and 0DH, which ends the text.
53DEH - The Messages of the Refusals
Each ends with 0DH, where @LOGOT stops (536FH).
5430H - The Parameter Table
Read by @PARAM (5226H): 21 entries of a name of six characters (spaces after a short name) and the address where @PARAM stores the value: FFFFH for the name alone, the number or the X'hex' value after =, 0000H for =N or =OFF. A name must equal a whole entry, the spaces after it included: the short forms are L, P, C, I, A, F, T, X, M and SL, and PORT has none. The table ends with 00H.
54D9H - The Value Cells
@PARAM stores LINES, PAGE, CHARS, INDENT and MARGIN here (the other six go straight into operands of the installer). Only the low byte of each is used.
54E3H - The Relocation Table
17 words, each the address of an operand in the module that holds an address inside the module (the LD DE,550DH of the three routines that pass a request on, the LD IY,5517H, the JP Z,5609H and the 12 CALLs to routines of the module; the CALLs to the ROM are not moved). 52C3H adds the distance the module moves to each of them before the module is copied.
5505H - The Module: Its Header
The 0125H bytes 5505H-5629H are copied above HIGH$ (52DDH). The rows show them at their addresses in the file; the 17 operands that hold an address inside the module are moved by the same distance first (52ADH), so in memory every branch lands on the row it links to here. The module starts with the header of a module in high memory: JR over the header, the link word, the length of the name and the name $FF. The device control block's driver is the module's address, so a request to the device runs the JR.
550DH - The Copy of the Device Control Block
Module +08H-+11H, not in the file: written by the installer (5308H, 530CH). The filter passes every request on through this copy.
5517H - The Parameter Block
Module +12H-+18H: seven bytes the filter reads with Index Register IY = 5517H (5560H), written by the installer (524DH-528AH) and by the FORMS command of SYS7/SYS.
551EH - The Entry for a Request
The device's driver. The ROM's device routine (03C2H) comes here with Index Register IX = the device control block, Register C = the byte, Register A = the request bit (01H, 02H or 04H) and the flags: the CARRY FLAG for a byte to read, the Z FLAG for a byte to send, neither for a control request. A read and a control request are passed on unchanged through the copy of the device control block at 550DH; a byte to send goes to 555EH. SYSTEM (PRTIME) of SYS7/SYS takes the byte at module +19H, 551EH, as the offset of a time out byte; here it is 38H, the code of JR C, and points at 553DH.
552CH - A Byte to Read
Passed on through the copy of the device control block.
5535H - Send a Byte On
Sends Register C to the driver behind the filter through the copy of the device control block: every byte the filter prints goes through here. SYSTEM (PRTIME) of SYS7/SYS writes over the POP DE at 553DH (551EH), so after PRTIME this routine returns to the saved Register Pair DE instead of its caller.
553FH - The Built-In Printer Driver
Module +3AH. The installer makes it the driver of the copy of the device control block when the device's driver was PRSV$ (52E8H). A byte to send waits until the printer can take it and is stored at 37E8H, the printer address of the Model I (or sent to the port of PORT=n); a byte to read gives 00H; a control request with Register C = 00H gives the printer's status, any other 00H. The wait at 5549H has no time out.
5553H - The Printer's Status
Reads 37E8H, or the port of PORT=n, and keeps bits 7-4. The Z FLAG for 30H (bits 7 and 6, busy and out of paper, clear; bits 5 and 4 set), the ready status the ROM's own driver waits for (05D1H), and for F0H, all four set, which is taken as no printer attached: the byte is then written at once instead of waited on, so the computer does not hang.
555EH - A Byte to Send
Index Register IY = 5517H, the parameter block, while the filter at 556DH runs. The return is always the Z FLAG with the CARRY FLAG clear and Register A as it came: a result of the driver behind the filter is not passed back.
556DH - The Filter
XLATE first; then 0DH and 0AH end a line (55DFH), 0CH skips to the next page (55ECH), 06H sets the line count to the start of a page (5609H, the manual's LPRINT CHR$(6)), 09H is expanded when TAB is on, the other bytes below 20H are sent as they are, and a printable byte goes to 5596H. 0DH and 0AH both count as a line, so a 0DH 0AH pair counts two.
5596H - A Printable Byte
At the start of a line the margin comes first (5619H). The byte is sent and the column counted. With CHARS, a line that has CHARS bytes is ended at once (55DFH) and the next one starts with INDENT spaces, sent through 5596H itself, so they are counted and wrapped too: an INDENT not below CHARS wraps again and again with no end. With INDENT 0, a line of exactly CHARS bytes followed by 0DH gets an empty line, since the 0DH then comes at column 0 (55C0H).
55B5H - Send Spaces
Register A spaces through 5596H, which counts them in the column and applies the margin and the wrap: the INDENT after a wrap (55B0H) and the spaces of a tab (560EH).
55C0H - The End of a Line
With ADDLF a carriage return and a line feed; else a carriage return when the column is not 0 and a line feed when it is (an empty line, the manual's LPRINT with no arguments). The column is set to 0. Register C is changed.
55DFH - A Line Ended: the Count
The line is ended and counted in +04H of the device control block at Index Register IX. When the count reaches +05H (LINES), the rest of the page is skipped (55ECH).
55ECH - The Rest of the Page
PAGE (+03H of the device control block) less the count: one 0CH with FFHARD, else that many line ends, which are not counted; then the count is set to the start of a page. A 0CH sent to the device comes here from anywhere on a line (5581H); with FFHARD the column is then left as it was. With LINES above PAGE the difference is taken modulo 256: up to 255 line ends.
560EH - A Tab
8 less the column modulo 8 spaces (1-8), sent through 55B5H.
5619H - The Margin
Register A (MARGIN) spaces, only at column 0, sent through 5535H, so they are not counted in the column.