TRS-80 DOS - TRSDOS v1.3 - SYS09/SYS Disassembled

General:

SYS09/SYS handles the COPY, DUAL, FORMS, KILL, MASTER, PATCH, RELO, ROUTE, SETCOM, and WP LIBrary Command.

Overlay Overview:

SYS09/SYS is the "1/3 DOS Commands" overlay — one of three command-handler overlays in TRSDOS 1.3 that together implement the library of resident-DOS commands. SYS09 is loaded at 5200H when the command interpreter (SYS1) finds one of its ten commands in its LIBCOM table: SYS1 puts the LIBCOM number in Register C and runs the SYS0 vector SSYS9 at 42A8H (LD A,99H / RST 28H), and SYS9 starts at BEGIN (5200H, its transfer address) with HL pointing at the command line after the command name.

The overlay's BEGIN entry sets a few system flags (CFLAG=55H, FLAG1=0, SCAFLG=0, BASICG=-1) and then dispatches via the GETTAB table-lookup routine. GETTAB walks the TABLE entries (each a DCF tuple of command-code byte + 2-byte handler address); a match returns the handler address in HL, which the caller uses as the new return address. If no match is found, control falls through to ERR2/ERRX and the SYS0 ERROR routine reports error 11 (illegal command parameter).

ROUTE is not available in this system: its first two instructions return error 31 (Program not found), and the rest of its code and texts (5B9FH-5C74H) are never reached. FORMS, RELO, SETCOM, WP and MASTER read their options through the SYS0 vector SWITCH (4454H, SYS1 entry 6) with option tables in this overlay; SWITCH stores each value in the two bytes the table names, which are variables (SETCOM) or the operands of LD instructions (CHAR, FLINE, RLADD, WPDRV). The values are kept as the typed digits in hex form (BAUD=300 is 0300H), which CONVHX (6086H) turns into binary where a number is needed.

Memory Map:

Address RangeRegionNotes
5200H–5217HBEGIN dispatchEntry-point initialization and command-table dispatcher.
5218H–5225HError entriesNOCMD, ERR2, ERR3, ERR9, ERRX paths (each loads an error code and falls through to JP ERROR).
5226H–523DHGETTAB routineTable-lookup helper used by BEGIN to resolve a command code to its handler address.
523EH–525CHTABLECommand lookup table (10 DCF entries, terminated by DEFB 0).
525DH–5567HCOPY commandCOPY logic: parse syntax, single-drive vs dual-drive copy, record-by-record loop, message handling.
5568H–5668HSLANT helpersGETDIR, MOVE1-MOVE4, SKSP, SLANT (COPY /EXT:d :d) and SLANT0, the directory loop COPY and KILL use for every file with one extension.
5669H–56C4HS9KILL commandKILL: one file, or every file with one extension (KILL /EXT:d) through SLANT0; the Killing message.
56C5H–597AHPATCH commandPATCH data (the option names, ADD1, FIND and CHAG99 (not in the file), the flags) and the code: ADD=, FIND=, CHG=, for a user file or a system file (PATCH *n), write-back.
597BH–5A13HHEXGET / patch helpersDecimal string to binary (HEXGET), OPENIT, GETDCB, INITIT, GETSYN, PATERR and the PATCH messages.
5A14H–5B1AHRELO commandRELO logic: relocate a /CMD file to a new load address.
5B1FH–5B99HFORMS commandFORMS: a form feed, or the printer line width and lines per page (WIDTH=, LINES=); then COMPAR, PDATA, PDATA1/PDATA2 and S9EQU, used by the other commands.
5B9AH–5C74HROUTE commandROUTE: error 31 (Program not found) at once; the rest of its code and its texts (5B9FH-5C74H) are never reached.
5C75H–5F33HSETCOM commandSETCOM logic: set RS-232 communication parameters (baud, parity, stop bits, etc.).
5F34H–5FD8HDUAL commandDUAL: ON sends display and printer output through DUALIT (4CE1H in SYS0), OFF restores the drivers; SKIPSP (5F8EH).
5FD9H–603DHWPROT commandWP (Write Protect) command logic.
603EH–60BDHMASTER commandMASTER: sets the master (default) drive, 42B3H (DIFULT); then CONVHX, ADDHL and SHIFT (6086H-60BDH).
60BEH–64FFHDCB / buffer storageS9DCB3, BUFER3, S9DCB, S9DCB1, S9DCB2 (6194H-61FFH), BUFER4, BUFER1, BUFER2 (DEFS storage; not in the load file).

Command Jump Table (TABLE @ 523EH):

Each entry in TABLE is a DCF macro expansion (DEFB cmdcode + DEFW handler, 3 bytes). The 1-byte command codes (CPY, DUALT, FORM, KILLL, MAST, PAT, RELOO, RUTE, SCOM, WPT) are SYS1 globals defined in SYS1.GBL; the entries are scanned by GETTAB until a match against the command-byte in C is found, with terminator DEFB 0 marking end-of-list.

TABLE addrSource equateCommandHandlerHandler addr
523EHCPYCOPYCOPY525DH
5241HDUALTDUALDUAL5F34H
5244HFORMFORMSFORMS5B1FH
5247HKILLLKILLS9KILL5669H
524AHMASTMASTERMASTER603EH
524DHPATPATCHPATCH571BH
5250HRELOORELORELO5A14H
5253HRUTEROUTEROUTE5B9AH
5256HSCOMSETCOMSETCOM5C75H
5259HWPTWP (Write Protect)WPROT5FD9H
525CHDEFB 0 — end-of-list terminator—

Major Routines:

AddressLabelDescription
5200HBEGINOverlay entry. Sets CFLAG=55H, clears FLAG1/SCAFLG, sets BASICG=-1, then dispatches via GETTAB.
5218HNOCMDNo matching command. Pop saved HL and fall through to ERR2.
5219HERR2Bad parameter (LD A,ERICP=0BH); JR ERRX.
521DHERR3Missing parameter (LD A,ERCPM=0AH); JR ERRX.
5221HERR9Drive not in system (LD A,EDNS=02H); fall through to ERRX.
5223HERRXJP ERROR — transfer to SYS0 error handler with code in A.
5226HGETTABTable lookup. Walks TABLE comparing C against each command code; returns with HL=handler addr and CF=0, or CF=1 if not found.
523EHTABLECommand lookup table (10 DCF entries; see Jump Table above).
525DHCOPYCOPY command. Syntax: COPY filespec1 filespec2 / COPY filespec :D / COPY /EXT:D :D.
5273HGETTWOHelper: parse two filespecs from the COPY command line.
52A3HDSPRECSubroutine: bump the record-number counter and display it as the file copies.
52F3HDISPLYSubroutine: display the "Copying filespec1 to filespec2" message.
5310HPRNTITSubroutine: walk a filespec and print printable chars (21H and up) until a space or a control character.
532AHS9WAITSubroutine: flash a prompt and wait for ENTER.
5357HSINGCPSingle-drive copy main loop — load buffer, prompt swap, write buffer.
54D0HCOPY0Two-file copy main entry — cleared LRL, handle dual-drive case.
5669HS9KILLKILL command. Removes a file from the directory.
571BHPATCHPATCH command. Patches data in disk file records using ADD=/FIND=/CHG= directives.
5A14HRELORELO command. Relocates the load address of a /CMD file.
5B1FHFORMSFORMS command. Sets forms-device parameters (WIDTH, LINES).
5B9AHROUTEROUTE command. Returns error 31 (Program not found); the rest of its code is never reached.
5C75HSETCOMSETCOM command. Sets RS-232 parameters (BAUD, WORD, STOP, PARITY, WAIT, etc.).
5F34HDUALDUAL command. DUAL (ON) / DUAL (OFF): display output also goes to the printer, through DUALIT (4CE1H).
5FD9HWPROTWP (Write Protect) command. Sets the write-protect flag for a drive.
603EHMASTERMASTER command. Sets the master drive (42B3H, DIFULT).

Complete Variable List:

The following table lists every workspace and self-modifying-code variable used by SYS09. Self-modifying targets (marked †) are addresses inside the overlay's own code where a LD (nnnn),A or similar instruction stores a transient operand byte; like the rest of the overlay they hold their values only while SYS9 is in memory.

AddressLabelPurpose
52BAHRECCSRecord-count counter (DEFW -1; bumped by DSPREC each record copied).
52EDHRECNUMFive-digit ASCII display buffer for the record number ("00000").
53A4HLRLCHG †Self-mod target: holds the LRL byte for the current copy operation.
54A6HFLFLAGNumber-of-256-byte-blocks counter for single-drive COPY.
54A7HFSFLAGFlash-on/flash-off flag for the prompt display.
54E0HLRLCH1 †Self-mod target: second LRL byte storage during COPY.
5565HSAVE3Saved-buffer-pointer storage (DEFW BUFFER).
5567HS9TRKThe directory sector GETDIR reads next (SLANT0 starts it at 3; DEFB 0).
5649HTOTCHG+1 †Operand of the CALL at 5648H (TOTCHG): 54D0H (COPY0) as loaded and for COPY, 5692H (KILLIT) for KILL.
56C5HADDDDEFT 'ADD=' — encoded compare string for PATCH directive.
56CAHFINDDDEFT 'FIND=' — encoded compare string for PATCH directive.
56D0HCHGGDEFT 'CHG=' — encoded compare string for PATCH directive.
56D5HADD1User-supplied patch address (DEFW 0).
56D7HFIND32-byte buffer for the PATCH FIND= string: length byte and bytes (DEFS, not in the file); COPY keeps the source ERN in its first two bytes.
56F7HCHAG9932-byte buffer for the PATCH CHG= string.
5717HCHGFLGFlag: 00H, non zero once the change was made (586CH).
5718HFNDFLGFlag: 00H, non zero once the ADD= address was found in the file (5844H).
5719HERNSAVSaved end-record-number for the PATCH operation (DEFW 0); stored at 57FAH and not read again.
599AHSYSFLGSystem-files flag for PATCH * (patch system files).
5A27HRLADD †Self-mod target: relocation address operand for RELO.
5B12HRLTABLRELO parameter table (DEFM 'ADD' + DEFW RLADD + terminator).
5B1BHSAVERELO: the offset from the old load address to the ADD= address (DEFS 2, not in the file).
5B1DHSAVE1RELO: the end of the rebuilt file in BUFER2 (DEFS 2, not in the file).
5B44HCHAR †Self-mod target: holds FORMS WIDTH parameter.
5B51HFLINE †Self-mod target: holds FORMS LINES parameter.
5B5FHFORCOMFORMS parameter table (DEFM 'WIDTH' + DEFW CHAR + ...).
5B8DHPCHANG †Self-mod target: the operand of the LD A,',' in PDATA2 (5B8CH); SETCOM stores a space there.
5E03HSOFFSETCOM: RS-232 ON/OFF flag (DEFW 0).
5E05HSBAUDSETCOM: BAUD rate (DEFW 0).
5E07HSWORDSETCOM: WORD length (DEFW 0).
5E09HSSTOPSETCOM: STOP bits (DEFW 0).
5E0BHSPARSETCOM: PARITY (DEFW 0).
5E0DHSWAITSETCOM: WAIT flag (DEFW 0).
5E0FHSSWAITSETCOM: NO-WAIT flag (DEFW 0).
5FEEHWPDRV †Self-mod target: WP (Write Protect) drive number storage.
60BEHS9DCB3DCB#3 storage (DEFS DCBSIZ=50); no instruction in this file uses it.
60F0HBUFER340H-byte buffer; no instruction in this file uses it.
6130HS9DCBDCB#0 storage (DEFS DCBSIZ=50).
6162HS9DCB1DCB#1 storage (DEFS DCBSIZ=50).
6194HS9DCB2DCB#2, the destination file of COPY: 6194H-61FFH (EQU $, then ORG $,256 moves BUFER4 to 6200H).
6200HBUFER4256-byte buffer (boundary-aligned via ORG $,256).
6300HBUFER1256-byte buffer of the source file (COPY, KILL, PATCH); a single drive copy fills memory from here up.
6400HBUFER2256-byte write buffer for COPY.

Disassembly:

5200H - Start.

ORG 5200H
5200BEGIN
LD A,55H 3E 55
LET Register A = 55H (0101 0101).
Original Source Code Comment: SET THE 'CLEAR RAM' FLAG
5202
LD (42B4H),ALD (CFLAG),A 32 B4 42
Store the 55H held in Register A into 42B4H (CFLAG). 55H tells TRSDOS Ready to clear user memory (5200H through MEMEND) when this command ends, since SYS9 uses that memory as work space.
5205
XOR A AF
Set Register A to ZERO and clear all Flags.
Original Source Code Comment: CLEAR A
5206
LD (4414H),ALD (FLAG1),A 32 14 44
Clear 4414H (FLAG1), the request code of the last overlay loaded, so that the next RST 28H request loads its overlay again (this overlay is about to overwrite memory as work space).
Original Source Code Comment: CLEAR THE SYSTEM FLAG
5209
LD (42FFH),ALD (SCAFLG),A 32 FF 42
Clear the protection override flag by storing a 0 (held in Register A) into the memory location 42FFH.
NOTE: 42FFH is the storage location for whether a password check is skipped or undertaken in an OPEN command. If Bit 0 is set, the check is skipped.
Original Source Code Comment: CLEAR THE PROTECTION OVER RIDE SWITCH
520C
DEC A 3D
DECrement the value stored in Register A by 1 so that Register A is now FFH.
Original Source Code Comment: MAKE A -1
520D
LD (427AH),ALD (BASICG),A 32 7A 42
Store the value held in Register A into the memory location 427AH. Putting a FFH (-1) here indicates that BASIC is not in RAM.
Original Source Code Comment: SHOW BASIC NO LONGER IN RAM
5210
PUSH HL E5
Save the POINTER TO THE COMMAND LINE in RAM (held in Register Pair HL) to the top of the stack.
Original Source Code Comment: SAVE COMMAND LINE POINTER
5211
Get the address of the command via a GOSUB to 5226H.
Original Source Code Comment: GET ADDRESS OF COMMAND
5214
If the C FLAG (Carry) has been set then the requested command is not one of the commands available in this overlay, so JUMP to 5218H.
Original Source Code Comment: NOT ANY OF THESE COMMANDS. EXIT
5216
EX (SP),HL E3
EXchange the value stored in Register Pair HL (i.e., the POINTER TO THE COMMAND LINE in RAM) with the value stored at the top of the STACK (i.e., the command address).
Original Source Code Comment: HL=> COMMAND LINE, SP=COMMAND ADDRESS
5217
RET C9
RETurn into the command routine whose address the EX (SP),HL put on the STACK, with Register Pair HL pointing at the command line.
Original Source Code Comment: EXIT TO THE COMMAND

5218H - NOCMD - Jumped to if the command requested is not one of the commands available in this overlay.

5218NOCMD
POP HL E1
Put the value held at the top of the STACK into Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: GET COMMAND LINE POINTER OFF STACK
5219ERR2
LD A,0BHLD A,ERICP 3E 0B
LET Register A = 0BH to indicate an illegal command parameter error.
Original Source Code Comment: BAD PARAMETER
521B
Report the error and abort via a JUMP to 5223H.

521DH - ERR3 - Jumped here if we are missing the parameter.

521DERR3
LD A,0AHLD A,ERCPM 3E 0A
LET Register A = 0AH to indicate a missing parameter.
Original Source Code Comment: MISSING PARAMETER
521F
Report the error and abort via a JUMP to 5223H.

5221H - ERR9 - Jumped here if we we were requested to do something to a drive which is not on the system.

5221ERR9
LD A,02HLD A,EDNS 3E 02
LET Register A = 02H to indicate the drive is not in the system.
Original Source Code Comment: DRIVE NOT IN SYSTEM
5223ERRX
JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.

5226H - GETTAB - Routine to do a Table Lookup.

5226GETTAB
LD HL,523EHLD HL,TABLE 21 3E 52
LET Register Pair HL = 523EH, which points to the lookup table.
Original Source Code Comment: HL => COMMAND TABLE
5229GETTA1
LD A,(HL) 7E
Fetch the table compare byte (i.e., the value stored at the memory location pointed to by Register Pair HL) and put it into A.
Original Source Code Comment: GET THE TABLE COMPARE BYTE
522A
OR A B7
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
Original Source Code Comment: END OF TABLE?
522B
If the NZ FLAG (Not Zero) has been set then we are not at the end of the table yet, so JUMP to 522FH to look it up.
Original Source Code Comment: NO, LOOK IT UP
522D
SCF 37
If we are here, then we ran out of table entries, so turn the CARRY FLAG on to indicate an error.
Original Source Code Comment: SET CARRY. COMMAND NOT FOUND
522E
RET C9
RETurn to the caller.

522FH - GETTA2 - Continuation of the Table Lookup - Jumped here if the table compare byte matched.

522FGETTA2
CP C B9
Compare the value held in Register A against the value held in Register C. Results: If Register A equals the value held in Register C, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: MATCH THE COMMAND?
5230
If the Z FLAG (Zero) has been set then we have a match! JUMP to 5237H to get the address.
Original Source Code Comment: YES, GET THE ADDRESS
5232
INC HL 23
If we're here then we didn't find a match, so we need to skip forward 3 bytes to the next entry. INCrement HL (1 of 3) to skip to next table entry
Original Source Code Comment: HL => LSB OF ADDRESS
5233
INC HL 23
INCrement HL (2 of 3) to skip to next table entry
Original Source Code Comment: HL => MSB OF ADDRESS
5234
INC HL 23
INCrement HL (3 of 3) to skip to next table entry
Original Source Code Comment: HL => NEXT COMMAND BYTE
5235
Loop back to 5229H to read the next table compare byte.
Original Source Code Comment: LOOP TILL FOUND

5237H - GETTA3 - Continuation of the Table Lookup - Jumped here to load HL with the address of the matched routine.

5237GETTA3
INC HL 23
INCrement the value stored in Register Pair HL by 1, so that HL now points to the LSB of the desired command.
Original Source Code Comment: HL => LSB OF ADDRESS
5238
LD E,(HL) 5E
Fetch the LSB of the desired command (i.e., stored at the memory location pointed to by Register Pair HL) and put it into E.
Original Source Code Comment: GET IT
5239
INC HL 23
INCrement the value stored in Register Pair HL by 1, so that HL now points to the MSB of the desired command.
Original Source Code Comment: HL => MSB OF ADDRESS
523A
LD D,(HL) 56
Fetch the MSB of the desired command (i.e., stored at the memory location pointed to by Register Pair HL) and put it into D.
Original Source Code Comment: GET IT
523B
EX DE,HL EB
EXchange Register Pairs DE and HL: HL now holds the address of the command routine (from the table) and DE the table pointer.
Original Source Code Comment: HL = COMMAND ADDRESS
523C
OR A B7
Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
Original Source Code Comment: INSURE CARRY OFF
523D
RET C9
RETurn to the caller with the CARRY FLAG off so that we indicate NO ERROR.

523EH - TABLE - Command Lookup Table.

523ETABLE
DEFB 09H 09
Table entry 1: 09H, the LIBCOM number of COPY (CPY in the SYS1 globals).
523F-5240
DEFW 525DH 5D 52
Address of COPY (525DH).
5241
DEFB 0FH 0F
Table entry 2: 0FH (15), DUAL (DUALT).
5242-5243
DEFW 5F34H 34 5F
Address of DUAL (5F34H).
5244
DEFB 12H 12
Table entry 3: 12H (18), FORMS (FORM).
5245-5246
DEFW 5B1FH 1F 5B
Address of FORMS (5B1FH).
5247
DEFB 16H 16
Table entry 4: 16H (22), KILL (KILLL).
5248-5249
DEFW 5669H 69 56
Address of S9KILL (5669H).
524A
DEFB 1AH 1A
Table entry 5: 1AH (26), MASTER (MAST).
524B-524C
DEFW 603EH 3E 60
Address of MASTER (603EH).
524D
DEFB 1BH 1B
Table entry 6: 1BH (27), PATCH (PAT).
524E-524F
DEFW 571BH 1B 57
Address of PATCH (571BH).
5250
DEFB 1FH 1F
Table entry 7: 1FH (31), RELO (RELOO).
5251-5252
DEFW 5A14H 14 5A
Address of RELO (5A14H).
5253
DEFB 21H 21
Table entry 8: 21H (33), ROUTE (RUTE).
5254-5255
DEFW 5B9AH 9A 5B
Address of ROUTE (5B9AH).
5256
DEFB 22H 22
Table entry 9: 22H (34), SETCOM (SCOM).
5257-5258
DEFW 5C75H 75 5C
Address of SETCOM (5C75H).
5259
DEFB 25H 25
Table entry 10: 25H (37), WP (WPT).
525A-525B
DEFW 5FD9H D9 5F
Address of WPROT (5FD9H).
525C
DEFB 00H 00
End of the table: GETTAB returns with CARRY set when it reaches this 00H.
Original Source Code Comment: END OF LIST

525DH - MAIN ROUTINE --- COPY COMMAND

525DCOPY
PUSH HL E5
Save the POINTER TO THE COMMAND LINE in RAM (held in Register Pair HL) to the top of the stack.
Original Source Code Comment: SAVE THE LINE POINTER
525E
LD HL,54D0HLD HL,COPY0 21 D0 54
LET Register Pair HL = 54D0H to point to the COPY0 routine in this overlay as a vector. This will also be set by the KILL command and will point somewhere else.
Original Source Code Comment: PUT DIRECTORY FIND
5261
LD (5649H),HLLD (TOTCHG+1),HL 22 49 56
Store the value held in Register HL into the memory location 5649H, which is in the middle of a CALL OPCODE. This will set that OPCODE to "COPY". The alternative would be from the "KILL" routine, which would set this to a different address.
Original Source Code Comment: TO COPY FUNCTION
5264
POP HL E1
Restore the POINTER TO THE COMMAND LINE in RAM held at the top of the STACK into Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: GET POINTER BACK
5265
LD D,H 54
LET Register Pair DE = Register Pair HL (i.e., the first filespec). Copy HL to DE (1 of 2): Load H into D
Original Source Code Comment: MIRROR COMMAND LINE POINTER
5266
LD E,L 5D
Copy HL to DE (2 of 2): Load L into E
Original Source Code Comment: TO DE
5267
LD A,(DE) 1A
Fetch the next character of the first filespec (stored at the memory location pointed to by Register Pair DE) and put it into A.
Original Source Code Comment: GET A CHARACTER FROM COMMAND LINE
5268
CP 2FHCP '/' FE 2F
Compare the value held in Register A against /, which is a wildcard. Results: If Register A equals /, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: COPY ALL EXTENSIONS?
526A
If the Z FLAG (Zero) has been set because we had a / then we know to copy everything; JUMP to 55B6H.
Original Source Code Comment: GO COPY IF SO
526D
OTHERWISE ... GOSUB to 59BCH to process the first filespec (i.e., set Register Pair DE to point to the SOURCE FILE DCB, check the syntax of the associated Filespec, and RETurn).
Original Source Code Comment: GET FILE SYNTAX
5270
If the NZ FLAG (Not Zero) has been set, then the CALL produced an error, so JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: EXIT IF SYNTAX ERROR
5273GETTWO
PUSH DE D5
Save the contents of Register Pair DE (the pointer to the first filespec on the command line) to the top of the stack.
Original Source Code Comment: SAVE THE LINE POINTER
5274
LD DE,6194HLD DE,S9DCB2 11 94 61
Let Register Pair DE equal 6194H to point to the DESTINATION FILE DCB.
Original Source Code Comment: POINT TO DCB #2
5277
GOSUB to 441CH to check the syntax of the second filespec.
NOTE: 441CH is the SYS00/SYS routine to CHECK THE SYNTAX OF A FILESPEC before use. This RST 28H's with a value of C1H so as to call ROUTINE 4 in OVERLAY 1.
Original Source Code Comment: CHECK SYNTAX OF 2ND FILESPEC
527A
POP DE D1
Put the value held at the top of the STACK (the pointer to the first filespec on the command line) into Register Pair DE, and then remove the entry from the stack.
527B
If the Z FLAG (Zero) has been set then we were given a good filespec, so JUMP to 54A8H.
Original Source Code Comment: IF OKAY, BOTH FILES GIVEN
527E
CP 3AHCP ':' FE 3A
Compare the value held in Register A against 3AH (ASCII: :) to see if we were only given a drive number. Results: If Register A equals :, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: DRIVE SPECIFICATION ?
5280
If the Z FLAG (Zero) has been set then we were only given a drive number, so JUMP to 528BH.
Original Source Code Comment: IF SO, GO MOVE PGM NAME
5282
CP 2EHCP '.' FE 2E
Compare the value held in Register A against 2EH (ASCII: .). Results: If Register A equals . then we were given a password, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: PW SPECIFICATION ?
5284
If the Z FLAG (Zero) has been set, then we were given only a password and drive number, so JUMP to 528BH.
Original Source Code Comment: IF SO, GO MOVE PGM NAME
5286
CP 2FHCP '/' FE 2F
Compare the value held in Register A against 2FH (ASCII: /). Results: If Register A equals / then we were given only an extension, password, and filename and the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: EXTENSION?
5288
If the NZ FLAG (Not Zero) has been set then we weren't given any of the above good parameters, so we have a problem, so JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: ERROR IF NOT ONE OF THEM
528BCHECK
LD C,A 4F
Copy the first character given for Filespec 2 (held in Register A) into Register C.
Original Source Code Comment: SAVE THE CHARACTER
528C
LD B,00HLD B,0 06 00
Set up Register B to be a counter by setting Register B to 00H.
Original Source Code Comment: CLEAR COUNTER
528E
DEC HL 2B
DECrement the value stored in Register Pair HL by 1 to point to the prior character.
Original Source Code Comment: BACK NAME POINTER UP
528FCHECK1
LD A,(DE) 1A
Fetch the a character from Filespec 1 (held in the memory location pointed to by Register Pair DE) and store it into Register A.
Original Source Code Comment: GET A CHARACTER
5290
CP C B9
Compare the character from Filespec 2 (held in Register A) against the character from Filespec 1 (held in Register C). Results: If Register A equals the value held in Register C, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: SAME AS SAVED CHAR?
5291
If first characters from each filespec match, the Z FLAG (Zero) will have been set. JUMP to 529BH.
Original Source Code Comment: IF SO, MOVE NAME
5293
CP 03HCP 3 FE 03
Compare the value held in Register A against 03H (i.e., EOF) to check for the end of the filename. Results: If Register A equals 03H, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: EOF?
5295
If we reached the end of the filename, then the Z FLAG (Zero) will have been set. JUMP to 529BH.
Original Source Code Comment: IF SO, MOVE NAME
5297
INC DE 13
INCrement Register Pair DE to the next character of filespec 1 (the name in the SOURCE FILE DCB at 6162H).
Original Source Code Comment: POINT TO NEXT CHARACTER
5298
INC B 04
INCrement the counter stored in Register B by 1.
Original Source Code Comment: INCREMENT COUNTER
5299
LOOP BACK to 528FH to check the next character.
Original Source Code Comment: CONTINUE CHECK

529BH - CHECK2 - Part of the COPY routine; jumped here if the filename characters match.

529BCHECK2
DEC HL 2B
DECrement the pointer to the characters in Filespec 2 (stored in Register Pair HL) by 1.
Original Source Code Comment: BACKUP DCB2
529C
DEC DE 1B
DECrement the pointer to the characters in Filespec 1 (stored in Register Pair DE) by 1.
Original Source Code Comment: BACK UP DCB1
529D
LD A,(DE) 1A
Fetch a character from Filespec 1 (held in the memory location pointed to by Register Pair DE) and store it into Register A.
Original Source Code Comment: GET A DCB1 CHAR
529E
LD (HL),A 77
Store the character from Filespec 1 into the corresponding characters lot of Filespec 2 (the memory location pointed to by Register Pair HL).
Original Source Code Comment: PUT IT IN DCB2
529F
LOOP back to 529BH, reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
Original Source Code Comment: DO FOR COUNT
52A1
JUMP to 5273H to do another SYNTAX check.
Original Source Code Comment: DO SYNTAX CHECK AGAIN

52A3H - DSPREC - SUBROUTINE to bump the record number being processed and display that record number as being copied.

52A3DSPREC
PUSH BC C5
Save the contents of Register Pair BC to the top of the stack.
Original Source Code Comment: SAVE CALLER'S REGISTERS
52A4
PUSH DE D5
Save the contents of Register Pair DE to the top of the stack.
52A5
PUSH HL E5
Save the contents of Register Pair HL to the top of the stack.
52A6
LD HL,(52BAH)LD HL,(RECCS) 2A BA 52
Fetch the record number (held in memory location 52BAH) and store it into Register Pair HL.
Original Source Code Comment: GET THE INTERNAL COUNTER
52A9
INC HL 23
INCrement the record number (held in Register Pair HL) by 1.
Original Source Code Comment: BUMP IT
52AA
LD (52BAH),HLLD (RECCS),HL 22 BA 52
Store the bumped record number (held in Register Pair HL) into memory location 52BAH.
Original Source Code Comment: SAVE IT FOR LATER
52AD
GOSUB to 52BCH (ASCII) to turn the new record number into five ASCII digits in RECNUM (52EDH-52F1H), the digits of the message 'Copying Record 00000'.
Original Source Code Comment: MAKE IT ASCII
52B0
LD HL,52DCHLD HL,RECORD 21 DC 52
Let Register Pair HL equal 52DCH (RECORD), the message 1DH 1EH 'Copying Record nnnnn' and 03H: start of the line, clear to the end of the line, then the text.
Original Source Code Comment: POINT TO COPY REC MSG
52B3
GOSUB to 021BH.
NOTE: 021BH is the Model III ROM routine to display the characters at (HL) until a 03H or a 0DH (which is shown) is found.
Original Source Code Comment: PRINT IT
52B6
POP HL E1
Put the value held at the top of the STACK into Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: RESTORE CALLER'S REGISTERS
52B7
POP DE D1
Put the value held at the top of the STACK into Register Pair DE, and then remove the entry from the stack.
52B8
POP BC C1
Put the value held at the top of the STACK into Register Pair BC, and then remove the entry from the stack.
52B9
RET C9
RETurn to the caller.

52BAH - RECCS - MESSAGE and STORAGE AREA.

52BA-52BBRECCS
DEFW FFFFH FF FF
RECCS: the number of the record being copied, FFFFH at load; COPY0 sets it to FFFFH (54D6H) and DSPREC adds 1 before showing it, so the first record shows as 00000.

52BCH - Subroutine to convert the new record number to ASCII and put it into the message "COPYING RECORD nnnn".

52BCASCII
GOSUB to 0A9AH.
NOTE: 0A9AH is the Model III ROM routine to STORE AN INTEGER. The value in HL is put into the single precision number storage area of 4121H and is flagged as an INTEGER.
Original Source Code Comment: HEX TO ASCII ROUTINE IN ROM
52BF
XOR A AF
Set Register A to ZERO and clear all Flags.
52C0
GOSUB to 1034H.
NOTE: 1034H is the Model III ROM routine to initialize the buffer for an ASCII conversion. It checks the edit flag (at 40D8H), sets HL to point to a buffer at 4130H, and puts a space there.
52C3
OR (HL) B6
Set the NZ Flag.
52C4
GOSUB to 0FD9H.
NOTE: 0FD9H is a routine which will convert the integer value in REG 1 (i.e., 4124H) to an ASCII string. Returns with register pair HL pointing to the result.
52C7
LD HL,4131H 21 31 41
Let Register Pair HL equal 4131H, to point to the ASCII converted number.
Original Source Code Comment: POINT TO WHERE ASCII IS
52CA
LD DE,52EDHLD DE,RECNUM 11 ED 52
Let Register Pair DE equal 52EDH (RECNUM), where the five digits of 'Copying Record nnnnn' go.
Original Source Code Comment: POINT TO SCREEN MSG
52CD
LD B,05HLD B,5 06 05
Let Register B equal 05H for a DJNZ loop of up to 5 characters.
Original Source Code Comment: 5 ASCII CHARS
52CFASCII1
LD A,(HL) 7E
Fetch a converted character (held in the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET A ASCII CHAR
52D0
CP 20H FE 20
Compare the value held in Register A against 20H (ASCII: SPACE). Results: If Register A equals SPACE, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: SPACE?
52D2
If it's not a space (and the NZ FLAG [Not Zero] has been set) then we don't need to fill it with zeroes, so skip over the next instruction.
Original Source Code Comment: NO, IT'S OKAY
52D4
LD A,30H 3E 30
Let Register A equal 30H (ASCII: 0).
Original Source Code Comment: CONVERT TO '0'
52D6ASCII2
LD (DE),A 12
Store the ASCII character held in Register A into the memory location pointed to by Register Pair DE.
Original Source Code Comment: STORE IN MSG
52D7
INC HL 23
INCrement the value stored in Register Pair HL by 1 to point to the next number to convert.
Original Source Code Comment: BUMP THE POINTERS
52D8
INC DE 13
INCrement Register Pair DE by 1 to point to the next digit position of 'Copying Record nnnnn' in RECNUM.
52D9
LOOP back to 52CFH, reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
Original Source Code Comment: DO FOR COUNT
52DB
RET C9
RETurn to the caller.

52DCH - RECORD - MESSAGE and STORAGE AREA.

52DCRECORD
DEFB 1DH 1D
RECORD: 1DH, move the cursor to the start of the line.
Original Source Code Comment: MOVE TO BEG OF LINE CHAR
52DD
DEFB 1EH 1E
1EH, erase to the end of the line.
Original Source Code Comment: CLEAR TO END OF LINE CHAR
52DE-52EC
DEFM 'Copying Record ' 43 6F 70 79 69 6E 67 20 52 65 63 6F 72 64 20
Text 'Copying Record '.
52ED-52F1RECNUM
DEFM '00000' 30 30 30 30 30
RECNUM: five digits of the record number, '00000' at load; ASCII (52BCH) writes them.
52F2
DEFB 03H 03
03H ends the message without a new line.
Original Source Code Comment: END OF MSG FLAG BYTE

52F3H - DISPLY - Subroutine to display the message COPYING filespec 1 TO filespec 2.

52F3DISPLY
LD HL,531AHLD HL,COPMSG 21 1A 53
Let Register Pair HL equal 531AH (COPMSG), the message 1DH 1EH 'Copying ' and 03H.
Original Source Code Comment: POINT TO 'COPYING' MSG
52F6
GOSUB to 021BH.
NOTE: 021BH is the Model III ROM routine to display the characters at (HL) until a 03H or a 0DH (which is shown) is found.
Original Source Code Comment: OUTPUT IT TO SCREEN
52F9
LD HL,6162HLD HL,S9DCB1 21 62 61
Let Register Pair HL equal 6162H which is the beginning of the SOURCE FILE DCB. This would then point to the text of FILESPEC 1.
Original Source Code Comment: POINT TO 1ST FILE NAME
52FC
GOSUB to 5310H to display FILESPEC 1.
Original Source Code Comment: SCREEN PRINT THE NAME
52FF
LD HL,5325HLD HL,TOO 21 25 53
Let Register Pair HL equal 5325H to point to the message "TO".
Original Source Code Comment: POINT TO 'TO' MSG
5302
GOSUB to 021BH.
NOTE: 021BH is the Model III ROM routine to display the characters at (HL) until a 03H or a 0DH (which is shown) is found.
Original Source Code Comment: SCREEN PRINT IT
5305
LD HL,6194HLD HL,S9DCB2 21 94 61
Let Register Pair HL equal 6194H, the DESTINATION FILE DCB (S9DCB2), which starts with the second filespec.
Original Source Code Comment: POINT TO 2ND FILE NAME
5308
GOSUB to 5310H to display FILESPEC 2.
Original Source Code Comment: SCREEN PRINT THE NAME
530B
LD A,0DH 3E 0D
Let Register A equal 0DH (ASCII: CARRIAGE RETURN).
Original Source Code Comment: LOAD A CR
530D
JUMP to 0033H.
NOTE: 0033H is the Model III ROM character print routine; displays the character held in Register A at the current cursor position. Since this was JUMPED to instead of CALLed, the RET at the end of this ROM routine will then RETurn to the caller of this subroutine instead of returning to this place.
Original Source Code Comment: OUTPUT IT AND RETURN

5310H - PRNTIT - Subroutine of the Subroutine to display the message COPYING filespec 1 TO filespec 2. Parse the characters in the filespecs and display them.

5310PRNTIT
LD A,(HL) 7E
Fetch a charcter from the applicable filespec (held in the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET A CHAR
5311
CP 21HCP '!' FE 21
Compare the character in Register A against 21H ('!'). CARRY is set for a SPACE or a control character, which ends the filespec in the DCB.
Original Source Code Comment: SPACE OR LESS?
5313
RET C D8
If the character was a SPACE or lower, the C FLAG (Carry) has been set then we are at the end of the filespec so RETurn to the caller.
Original Source Code Comment: RETURN IF SO
5314
GOSUB to 0033H.
NOTE: 0033H is the Model III ROM character print routine; displays the character held in Register A at the current cursor position.
Original Source Code Comment: ELSE OUTPUT THE CHAR
5317
INC HL 23
Point to the next character in the filespec by bumping Register Pair HL by 1.
Original Source Code Comment: BUMP THE POINTER
5318
LOOP BACK to 5310H to keep displaying characters.
Original Source Code Comment: AND CONTINUE

531AH - COPMSG - MESSAGE and STORAGE AREA.

531ACOPMSG
DEFB 1DH 1D
COPMSG: 1DH, move the cursor to the start of the line.
Original Source Code Comment: MOVE TO BEG OF LINE CHAR
531B
DEFB 1EH 1E
1EH, erase to the end of the line.
Original Source Code Comment: ERASE TO END OF LINE CHAR
531C-5323
DEFM 'Copying ' 43 6F 70 79 69 6E 67 20
Text 'Copying '.
5324
DEFB 03H 03
03H ends the message.
Original Source Code Comment: TERMINATOR
5325-5328TOO
DEFM ' to ' 20 74 6F 20
TOO: text ' to ' between the two filespecs.
5329
DEFB 03H 03
03H ends the message.
Original Source Code Comment: TERMINATOR

532AH - S9WAIT - Subroutine to display a flashing prompt of the message pointed to by Register Pair HL.

532AS9WAIT
PUSH HL E5
Save the pointer to the message to be displayed (held in Register Pair HL) to the top of the stack.
Original Source Code Comment: SAVE POINTER TO MESSAGE
532B
GOSUB to 021BH.
NOTE: 021BH is the Model III ROM routine to display the characters at (HL) until a 03H or a 0DH (which is shown) is found.
Original Source Code Comment: DISPLAY IT
532E
POP HL E1
Restore the pointer to the message to be displayed (held at the top of the STACK) into Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: GET POINTER BACK
532FLOOPY
LD BC,0256HLD BC,256H 01 56 02
Let Register Pair BC equal 0256H to act as a timer.
Original Source Code Comment: SET A TIMER
5332LOOPX
GOSUB to 002BH.
NOTE: 002BH is the Model III ROM Keyboard scanning routine; Register A exits with the ASCII value for the key that was pressed or ZERO if no key was pressed.
Original Source Code Comment: SCAN THE KEYBOARD
5335
CP 0DH FE 0D
Compare the value held in Register A against 0DH (ASCII: ENTER). Results: If Register A equals ENTER, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: USER HIT ENTER?
5337
If we got a CARRIAGE RETURN from the user, the Z FLAG (Zero) will have been set; JUMP to 534DH.
Original Source Code Comment: YES, EXIT
5339
DEC BC 0B
DECrement the counter (stored in Register Pair BC) by 1.
Original Source Code Comment: DEC THE TIMER
533A
LD A,B 78
Since the Z-80 cannot test Register Pair BC against zero, the common trick is to set Register A to equal to Register B, and then OR A against Register C. Only if both Register B and Register C were zero can the Z FLAG be set.
Original Source Code Comment: WE TIMED OUT?
533B
OR C B1
OR Register C into Register A: the Z FLAG is set only when the counter in Register Pair BC (Register B and Register C) is 0.
533C
If the NZ FLAG (Not Zero) has been set, then we still have more counting to do, so LOOP BACK to 5332H.
Original Source Code Comment: NO, KEEP TIMING
533E
LD A,(54A7H)LD A,(FSFLAG) 3A A7 54
Fetch the value of the flag held in memory location 54A7H and store it into Register A.
Original Source Code Comment: GET THE FLASH FLAG
5341
XOR 01HXOR 1 EE 01
Toggle the flag.
Original Source Code Comment: FLIP IT
5343
LD (54A7H),ALD (FSFLAG),A 32 A7 54
Store the toggled flag (held in Register A) back into memory location 54A7H.
Original Source Code Comment: PUT IT BACK
5346
If the toggled flag hit 0, the Z FLAG (Zero) will have been set, JUMP to 532AH to redisplay.
Original Source Code Comment: IF Z, PUT THE MESSAGE ON THE SCREEN
5348
Otherwise we want to blank the line so it flashes via a GOSUB to 534DH.
Original Source Code Comment: ELSE ERASE THE MSG FROM SCREEN
534B
Loop back to to 532FH.
Original Source Code Comment: AND RE-TIME

534DH - Jump point in the subroutine to display a flashing prompt of the message pointed to by Register Pair HL. Jumped here if we got a ENTER from the user.

534DLINOFF
LD A,1DHLD A,29 3E 1D
Let Register A equal 1DH (ASCII: Move cursor to start of line).
Original Source Code Comment: LOAD A 'MOVE TO BEG OF LINE' CHAR
534F
GOSUB to 0033H.
NOTE: 0033H is the Model III ROM character print routine; displays the character held in Register A at the current cursor position.
Original Source Code Comment: OUTPUT IT
5352
LD A,1EHLD A,30 3E 1E
Let Register A equal 1EH (ASCII: Clear to end of line).
Original Source Code Comment: LOAD 'ERASE TO END OF LINE CHAR'
5354
JUMP to 0033H.
NOTE: 0033H is the Model III ROM character print routine; displays the character held in Register A at the current cursor position. Since this was JUMPED to instead of CALLed, the RET at the end of this ROM routine will then RETurn to the caller of this subroutine instead of returning to this place.
Original Source Code Comment: OUTPUT IT AND RETURN

5357H - SINGCP - Single Drive, Single File Copy Routine.

This routine finds out how much user ram is available, and reads the first file until EOF or memory full. Ask to swap disks and write until the file is written; swapping back if memory ran out before EOF.

5357SINGCP
LD HL,(4415H)LD HL,(MEM2) 2A 15 44
Fetch the address of the end of usable memory (held in memory location 4415H) and store it into Register Pair HL.
Original Source Code Comment: GET END OF MEMORY
535A
LD DE,6300HLD DE,BUFER1 11 00 63
Let Register Pair DE equal 6300H to point to the READ FILE buffer.
Original Source Code Comment: POINT TO BEGIN OF BUFFER AREA
535D
OR A B7
Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
Original Source Code Comment: CLEAR CARRY
535E
SBC HL,DE ED 52
Subtract 6300H (Register Pair DE, the start of the buffer area BUFER1) from the end of memory (Register Pair HL, MEM2): HL = the number of bytes free from 6300H up.
Original Source Code Comment: HL NOW CONTAINS NO. OF BYTES LEFT IN MEM
5360
LD DE,0100HLD DE,100H 11 00 01
Let Register Pair DE equal 0100H (Decimal: 256), which is the size of 1 sector, to prepare for a division.
Original Source Code Comment: SET FOR DIVIDE BY 256
5363
LD B,00HLD B,0 06 00
Let Register B equal 00H as B will be a counter of the number of blocks of available free RAM.
Original Source Code Comment: CLEAR COUNTER
5365LOOPZ
INC B 04
INCrement the block counter (stored in Register B) by 1.
Original Source Code Comment: INC THE # BLOCKS COUNTER
5366
OR A B7
Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
Original Source Code Comment: CLEAR COUNTERS
5367
SBC HL,DE ED 52
Do division by subtraction by subtracting (with carry) 256 (held in Register Pair DE) from the number of bytes of free RAM (held in Register Pair HL).
Original Source Code Comment: SUBTRACE 256 FROM REMAINING BYTES
5369
If that subtraction didn't wind up going negative (so NC is set), then we can continue to divide, so JUMP to 5365H.
Original Source Code Comment: CONTINUE SUBTRACT IF NO CARRY
536B
LD A,B 78
Copy the number of blocks of free RAM (held in Register B) into Register A.
Original Source Code Comment: A NOW HAS # OF 256 BLOCKS
536C
DEC A 3D
Round down by 1 block via a DECrement of Register A.
Original Source Code Comment: DUMB ONE OFF
536D
LD (54A6H),ALD (FLFLAG),A 32 A6 54
Store the number blocks of free RAM (held in Register A) into memory location 54A6H.
Original Source Code Comment: SAVE THE NUM OF BLOCKS
5370
LD HL,5487HLD HL,S9SRC 21 87 54
Let Register Pair HL equal 5487H, which is a pointer to the "1DH + "
'Insert SOURCE Disk (ENTER) ' + 03H"
Original Source Code Comment: GET SOURCE DISK MESSAGE
5373
GOSUB to 532AH, which is the flashing prompt routine.
Original Source Code Comment: FLASH AND WAIT
5376
We got the user response, so GOSUB to 599BH to open the source file.
Original Source Code Comment: OPEN THE READ FILE
5379
LD IX,6162HLD IX,S9DCB1 DD 21 62 61
Let Special Index Register Pair IX equal 6162H which is the beginning of the SOURCE FILE DCB.
Original Source Code Comment: GET THE PARAMETERS
537D
RES 7,(IX+01H)RES 7,(IX+PROT) DD CB 01 BE
RESet (i.e., set as 0) BIT 7 of the value stored at the memory location pointed to by Register IX+01H so that the the LRL will be 256.
Original Source Code Comment: SHOW LRL OF 256
5381
LD A,(IX+09H)LD A,(IX+LRL) DD 7E 09
Fetch the LRL (held in the memory location pointed to by Special Index Register Pair IX+09H) and store it into Register A.
Note: IX+09H = the position in the DCB for the LOGICAL RECORD LENGTH).
Original Source Code Comment: GET THE LRL
5384
LD (56D5H),ALD (ADD1),A 32 D5 56
Store the LRL (held in Register A) into memory location 56D5H.
Original Source Code Comment: SAVE IT
5387
LD A,(IX+08H)LD A,(IX+EOF) DD 7E 08
Fetch the byte of the EOF (held in the memory location pointed to by Special Index Register Pair IX+08H) and store it into Register A.
Note: IX+08H = the position in the DCB for the BYTE OFFSET IN THE SECTOR FOR LAST BYTE OF THE FILE).
Original Source Code Comment: GET THE EOF
538A
LD (56D6H),ALD (ADD1+1),A 32 D6 56
Store the byte of the EOF (held in Register A) into memory location 56D6H.
Original Source Code Comment: SAVE IT
538D
XOR A AF
Set Register A to ZERO and clear all Flags, which also prepares to desginate a LRL of 256 (which is a force for FULL SECTOR I/O).
Original Source Code Comment: SET FOR LRL 256
538E
LD (53A4H),ALD (LRLCHG),A 32 A4 53
Store the value held in Register A (i.e., a 0) into memory location 53A4H which is in the middle of a LD B,xx OPCODE.
5391
LD A,(IX+0CH)LD A,(IX+ERNL) DD 7E 0C
Fetch the LSB of the ERN, the ending record number (DCB offset 0CH, IX+0CH), into Register A.
Original Source Code Comment: GET THE ERN
5394
LD (56D7H),ALD (FIND),A 32 D7 56
Store the LSB of the ERN (Register A) into 56D7H; COPY borrows the first byte of PATCH's FIND area for it.
Original Source Code Comment: SAVE IT
5397
LD A,(IX+0DH)LD A,(IX+ERNH) DD 7E 0D
Fetch the MSB of the ERN (DCB offset 0DH, IX+0DH) into Register A.
539A
LD (56D8H),ALD (FIND+1),A 32 D8 56
Store the MSB of the ERN (Register A) into 56D8H.
539D
LD HL,5463HLD HL,S9DES 21 63 54
Let Register Pair HL equal 5463H, which is a pointer to the "1DH + 'Insert DESTINATION Disk (ENTER) ' + 03H" Message.
Original Source Code Comment: 'INSERT DESTINATION' MSG
53A0
GOSUB to 532AH, which is the flashing prompt routine.
Original Source Code Comment: FLASH AND WAIT
53A3
LD B,00HLD B,0 06 00
Let Register B equal the LRL for the INIT below. The operand at 53A4H (LRLCHG) is set to 00H (LRL 256) at 538EH, after OPENIT (59A5H) stored the source file's LRL there.
Original Source Code Comment: SET FOR LRL OF 256
53A5
LD DE,6194HLD DE,S9DCB2 11 94 61
Let Register Pair DE equal 6194H to point to the DESTINATION FILE DCB.
Original Source Code Comment: POINT TO THE WRITE FILE DCB
53A8
LD HL,6300HLD HL,BUFER1 21 00 63
Let Register Pair HL equal 6300H to point to the beginning of the READ FILE buffer.
Original Source Code Comment: POINT TO THE READ BUFFER
53AB
GOSUB to 4420H (INIT) to open the destination file, or create it if it is not there, with the DCB at Register Pair DE, the buffer at Register Pair HL and the LRL in Register B.
NOTE: 4420H is the SYS0 vector INIT: LD A,A2H / RST 28H, SYS2 entry 2; CARRY set when a new file was made.
Original Source Code Comment: GO OPEN OR INIT THE FILE
53AE
If the NZ FLAG (Not Zero) has been set, then that CALL returned an error; report the error and abort via a JUMP to 5223H.
Original Source Code Comment: EXIT IF ERROR
53B1LOOPZ0
LD HL,5487HLD HL,S9SRC 21 87 54
Let Register Pair HL equal 5487H, which is a pointer to the "1DH + "
'Insert SOURCE Disk (ENTER) ' + 03H"
Original Source Code Comment: 'INSERT SOURCE' MSG
53B4
GOSUB to 532AH, which is the flashing prompt routine.
Original Source Code Comment: FLASH AND WAIT
53B7
LD HL,6300HLD HL,BUFER1 21 00 63
Let Register Pair HL equal 6300H to point to the beginning of the READ FILE buffer.
Original Source Code Comment: POINT TO READ BUFFER
53BA
LD (6165H),HLLD (S9DCB1+BUFL),HL 22 65 61
Store the pointer to the READ FILE BUFFER (held in Register Pair HL) into memory location 6165H, which is the DCB Buffer Address Location.
Original Source Code Comment: PUT IT INTO THE DCB BUFF ADDR LOC
53BD
LD A,(54A6H)LD A,(FLFLAG) 3A A6 54
Fetch the number of blocks of RAM (held in memory location 54A6H) and store it into Register A.
Original Source Code Comment: NUMBER OF BLOCKS OF MEMORY
53C0
LD B,A 47
Copy the contents of Register A into Register B so that Register B can act as a DJNZ counter of blocks to read into RAM.
Original Source Code Comment: USE IT AS A COUNTER
53C1LOOPZ1
PUSH BC C5
Save the counter (held in Register Pair BC) to the top of the stack.
Original Source Code Comment: SAVE THE COUNTER
53C2
LD DE,6162HLD DE,S9DCB1 11 62 61
Let Register Pair DE equal 6162H which is the beginning of the SOURCE FILE DCB.
Original Source Code Comment: POINT TO THE READ DCB
53C5
Read the next 256 byte record of the source file into the buffer the DCB names (its BUFL/BUFH, set at 53BAH) via a GOSUB to 4436H (READ).
NOTE: 4436H is the SYS0 vector READ: it reads the next record (NRN, DCB offsets 0AH-0BH) of the file whose DCB is at Register Pair DE and advances NRN; Z = no error, NZ with the error code in Register A.
Original Source Code Comment: GO READ 1 BLOCK
53C8
POP BC C1
Restore the counter from the top of the STACK into Register Pair BC, and then remove the entry from the stack.
Original Source Code Comment: RESTORE THE COUNTER
53C9
If the Z FLAG (Zero) has been set then there is no error, so JUMP to 53D6H.
Original Source Code Comment: IF NO ERROR, FINE
53CB
CP 1CHCP EEOF FE 1C
Compare the value held in Register A against 1CH (i.e., EOF ERROR). Results: If Register A equals 1CH, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: EOF ERROR?
53CD
If we have an EOF ERROR, then the Z FLAG (Zero) will have been set, BUT, we are done with the read anyway, so JUMP to 540EH.
Original Source Code Comment: THAT'S OKAY, WE'RE DONE WITH READ
53CF
CP 1DHCP ENRF FE 1D
Compare the value held in Register A against 1DH (i.e., RECORD OUT OF RANGE ERROR). Results: If Register A equals 1DH, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: REC OUT OF RANGE?
53D1
If we have an RECORD OUT OF RANGE ERROR, then the Z FLAG (Zero) will have been set, BUT, we are done with the read anyway, so JUMP to 540EH.
Original Source Code Comment: THEN DONE
53D3
If we're here, then we have another error that we do care about; report the error and abort via a JUMP to 5223H.
Original Source Code Comment: REPORT ERROR AND ABORT

53D6H - LOOPZ2 - Continuation of SINGLE FILE, SINGLE DRIVE Copy - Jumped here when a block as successfully been read into the READ FILE BUFFER.

53D6LOOPZ2
LD HL,(6165H)LD HL,(S9DCB1+BUFL) 2A 65 61
Fetch the pointer to DCB Buffer Address in the READ FILE BUFFER (held at 6165H) into Register Pair HL.
Original Source Code Comment: GET THE BUFF ADDR FROM DCB
53D9
LD DE,0100HLD DE,100H 11 00 01
Let Register Pair DE equal 0100H (Decimal: 256), which is 1 block.
Original Source Code Comment: LOAD 256 INTO DE
53DC
ADD HL,DE 19
Move to the next block of RAM in the READ BUFFER by bumping the READ BUFFER forward 256 bytes (1 block).
Original Source Code Comment: BUMP BUFF ADDR BY 256 (1 BLOCK)
53DD
LD (6165H),HLLD (S9DCB1+BUFL),HL 22 65 61
Store the newly bumped pointer to DCB Buffer Address in the the READ FILE BUFFER (held in Register Pair HL) into memory location 6165H, which is the DCB Buffer Address Location.
Original Source Code Comment: MAKE THIS THE NEW READ BUFFER
53E0
LOOP back to 53C1H to keep reading until the buffer is full, reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
Original Source Code Comment: AND READ SOME MORE

At this point, the READ RAM buffer has been filled, so now we need to write it to disk.

53E2
LD HL,5463HLD HL,S9DES 21 63 54
Let Register Pair HL equal 5463H, which is a pointer to the "1DH + 'Insert DESTINATION Disk (ENTER) ' + 03H" Message.
Original Source Code Comment: 'INSERT DESTINATION' MSG
53E5
GOSUB to 532AH, which is the flashing prompt routine.
Original Source Code Comment: FLASH AND WAIT
53E8
LD HL,6300HLD HL,BUFER1 21 00 63
Let Register Pair HL equal 6300H to point to the beginning of the READ FILE buffer.
Original Source Code Comment: POINT TO BEG OF READ BUFFER
53EB
LD (6165H),HLLD (S9DCB1+BUFL),HL 22 65 61
Store the READ FILE buffer into the address for the read DCB buffer pointer, resetting it.
Original Source Code Comment: RESET THE READ DCB BUFF POINTER
53EE
LD (6197H),HLLD (S9DCB2+BUFL),HL 22 97 61
Store the DCB Buffer Address (held in Register Pair HL) into the DCB Buffer Address for the DESTINATION FILE BUFFER (held in 6197H).
Original Source Code Comment: RESET THE WRITE DCB BUFF POINTER
53F1
LD A,(54A6H)LD A,(FLFLAG) 3A A6 54
Fetch the buffer size in blocks (held in memory location 54A6H) and store it into Register A.
Original Source Code Comment: GET THE BLOCK COUNT
53F4
LD B,A 47
Copy the contents of Register A into Register B so that Register B can act as a DJNZ counter of blocks to read into RAM.
Original Source Code Comment: MAKE IT A COUNTER
53F5LOOPZ3
PUSH BC C5
Save the block counter (held in Register Pair BC) to the top of the stack.
Original Source Code Comment: SAVE COUNTER
53F6
LD DE,6194HLD DE,S9DCB2 11 94 61
Let Register Pair DE equal 6194H to point to the DESTINATION FILE DCB.
Original Source Code Comment: POINT TO WRITE DCB
53F9
Write with Verify via a CALL to 443CH
NOTE: 443CH is the SYS0 vector VERF (write with verify; in this system it holds JP 47B3H): it writes the next record of the file whose DCB is at Register Pair DE; Z = no error, NZ with the error code in Register A.
Original Source Code Comment: WRITE WITH VERIFY
53FC
POP BC C1
Restore the block counter (held at the top of the STACK) into Register Pair BC, and then remove the entry from the stack.
Original Source Code Comment: RESTORE COUNTER
53FD
If the NZ FLAG (Not Zero) has been set, then that CALL returned an error; report the error and abort via a JUMP to 5223H.
Original Source Code Comment: REPORT AND EXIT IF ERROR
5400
LD HL,(6197H)LD HL,(S9DCB2+BUFL) 2A 97 61
Fetch the DCB Buffer Address in the DESTINATION FILE BUFFER (held in memory location 6197H) and store it into Register Pair HL.
Original Source Code Comment: GET THE BUFFER POINTER
5403
LD DE,0100HLD DE,100H 11 00 01
Let Register Pair DE equal 0100H (Decimal: 256), which is 1 block.
Original Source Code Comment: LOAD DE WITH 256
5406
ADD HL,DE 19
Bump the DCB Buffer Address in the the DESTINATION FILE BUFFER by 256 (which is 1 block) to point to the next block to write.
Original Source Code Comment: BUMP POINTER TO NEXT BLOCK
5407
LD (6197H),HLLD (S9DCB2+BUFL),HL 22 97 61
Store the bumped DCB Buffer Address (held in Register Pair HL) into the DCB Buffer Address for the DESTINATION FILE BUFFER (held in 6197H).
Original Source Code Comment: PUT INTO DCB AS POINTER
540A
LOOP back to 53F5H, reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
Original Source Code Comment: CONTINUE FOR COUNT
540C
JUMP to 53B1H to move to the next read.
Original Source Code Comment: GO READ SOME MORE

540EH - GOGO - Continuation of SINGLE FILE, SINGLE DRIVE Copy - Jumped here to write out what we have if we had a (harmless) EOF error or Records Out of Range error.

540EGOGO
LD A,(54A6H)LD A,(FLFLAG) 3A A6 54
Fetch the size of the RAM buffer (in blocks) (held in memory location 54A6H) and store it into Register A.
Original Source Code Comment: GET THE BLOCK COUNT
5411
SUB B 90
LET Register A = the size of the RAM buffer (held in Register A) - the number of blocks we have actually read so far (held in Register B).
Original Source Code Comment: SUB THE NUMBER WE ACTUALLY READ
5412
LD B,A 47
Copy the contents of Register A into Register B so that B can act as a counter.
Original Source Code Comment: USE IT FOR A COUNTER
5413
PUSH BC C5
Save the block counter (held in Register Pair BC) to the top of the stack.
Original Source Code Comment: SAVE THE COUNTER
5414
LD HL,5463HLD HL,S9DES 21 63 54
Let Register Pair HL equal 5463H, which is a pointer to the "1DH + 'Insert DESTINATION Disk (ENTER) ' + 03H" Message.
Original Source Code Comment: 'INSERT DESTINATION' MSG
5417
GOSUB to 532AH, which is the flashing prompt routine.
Original Source Code Comment: FLASH AND WAIT
541A
LD HL,6300HLD HL,BUFER1 21 00 63
Let Register Pair HL equal 6300H to point to the beginning of the READ FILE buffer.
Original Source Code Comment: POINT TO READ BUFFER BEGINNING
541D
LD (6197H),HLLD (S9DCB2+BUFL),HL 22 97 61
Store the DCB Buffer Address (held in Register Pair HL) into the DCB Buffer Address for the DESTINATION FILE BUFFER (held in 6197H).
Original Source Code Comment: RESET THE WRITE BUFF POINTER
5420
POP BC C1
Restore the block counter (held at the top of the STACK) into Register Pair BC.
Original Source Code Comment: GET THE COUNTER BACK
5421GOGO1
PUSH BC C5
Save the block counter (held in Register Pair BC) to the top of the stack.
Original Source Code Comment: SAVE THE COUNTER
5422
LD DE,6194HLD DE,S9DCB2 11 94 61
Let Register Pair DE equal 6194H to point to the DESTINATION FILE DCB (of 6194H).
Original Source Code Comment: POINT TO WRITE DCB
5425
Write with Verify via a CALL to 443CH
NOTE: 443CH is the SYS0 vector VERF (write with verify; in this system it holds JP 47B3H): it writes the next record of the file whose DCB is at Register Pair DE; Z = no error, NZ with the error code in Register A.
Original Source Code Comment: WRITE WITH VERIFY
5428
POP BC C1
Restore the block counter (held at the top of the STACK) into Register Pair BC.
Original Source Code Comment: RESTORE THE COUNTER
5429
If the NZ FLAG (Not Zero) has been set, then that CALL returned an error; report the error and abort via a JUMP to 5223H.
Original Source Code Comment: REPORT AND EXIT IF ERROR
542C
LD HL,(6197H)LD HL,(S9DCB2+BUFL) 2A 97 61
Fetch the DCB Buffer Address in the DESTINATION FILE BUFFER (held in memory location 6197H) and store it into Register Pair HL.
Original Source Code Comment: GET THE BUFFER POINTER
542F
LD DE,0100HLD DE,100H 11 00 01
Let Register Pair DE equal 0100H (Decimal: 256), which is 1 block.
Original Source Code Comment: LOAD 256 INTO DE
5432
ADD HL,DE 19
Bump the DCB Buffer Address in the the DESTINATION FILE BUFFER by 256 (which is 1 block) to point to the next block of RAM to write.
Original Source Code Comment: BUMP THE POINTER BY 1 BLOCK
5433
LD (6197H),HLLD (S9DCB2+BUFL),HL 22 97 61
Store the bumped DCB Buffer Address (held in Register Pair HL) into the DCB Buffer Address for the DESTINATION FILE BUFFER (held in 6197H).
Original Source Code Comment: PUT IT BACK AS NEW POINTER
5436
LOOP back to 5421H, reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
Original Source Code Comment: CONTINUE FOR COUNT

At this point, the buffers have been written, but the EOF cannot simply be transferred because of the EOF / RECORD OUT OF RANGE error on the read, so we need to recalculate and set the appropriate EOF.

5438
LD IX,6194HLD IX,S9DCB2 DD 21 94 61
Let Special Index Register IX equal 6194H to point to the DESTINATION FILE DCB (of 6194H).
Original Source Code Comment: SET UP THE PARAMETERS FROM OPEN
543C
LD A,(56D5H)LD A,(ADD1) 3A D5 56
Fetch the LRL (held in memory location 56D5H) and store it into Register A.
Original Source Code Comment: GET THE LRL
543F
LD (IX+09H),ALD (IX+LRL),A DD 77 09
Store the value held in Register A into the memory location pointed to by Special Index Register Pair IX+09H.
Note: IX+09H = the position in the DCB for the LOGICAL RECORD LENGTH).
5442
LD A,(56D6H)LD A,(ADD1+1) 3A D6 56
Fetch the byte of EOF (held in memory location 56D6H) and store it into Register A.
Original Source Code Comment: GET THE EOF
5445
LD (IX+08H),ALD (IX+EOF),A DD 77 08
Store the value held in Register A into the memory location pointed to by Special Index Register Pair IX+08H.
Note: IX+08H = the position in the DCB for the BYTE OFFSET IN THE SECTOR FOR LAST BYTE OF THE FILE).
5448
LD A,(56D7H)LD A,(FIND) 3A D7 56
Fetch the LSB of the source file's ERN, saved at 56D7H (5394H), into Register A.
Original Source Code Comment: GET THE ERN
544B
LD (IX+0CH),ALD (IX+ERNL),A DD 77 0C
Store it as the LSB of the destination file's ERN (DCB offset 0CH, IX+0CH).
544E
LD A,(56D8H)LD A,(FIND+1) 3A D8 56
Fetch the MSB of the source file's ERN, saved at 56D8H (539AH), into Register A.
5451
LD (IX+0DH),ALD (IX+ERNH),A DD 77 0D
Store it as the MSB of the destination file's ERN (DCB offset 0DH, IX+0DH).
5454
LD DE,6194HLD DE,S9DCB2 11 94 61
Let Register Pair DE equal 6194H to point to the DESTINATION FILE DCB (of 6194H).
Original Source Code Comment: POINT TO WRITE DCB
5457
GOSUB to 4428H to CLOSE the file
NOTE: 4428H is the SYS00/SYS routine to CLOSE A DISK FILE. This RST 28H's with a value of 93H so as to call ROUTINE 1 in OVERLAY 3.
Original Source Code Comment: CLOSE THE FILE
545A
LD HL,5487HLD HL,S9SRC 21 87 54
Let Register Pair HL equal 5487H, which is a pointer to the "1DH + "
'Insert SOURCE Disk (ENTER) ' + 03H"
Original Source Code Comment: 'INSERT SOURCE' MSG
545D
GOSUB to 532AH, which is the flashing prompt routine.
Original Source Code Comment: FLASH AND WAIT
5460
JUMP to 5551H to close the file and exit.
Original Source Code Comment: CLOSE AND EXIT

5463H - S9DES - MESSAGE and STORAGE AREA.

5463S9DES
DEFB 1DH 1D
S9DES: 1DH, move the cursor to the start of the line.
Original Source Code Comment: MOVE TO BEG OF LINE CHAR
5464-5485
DEFM 'Insert DESTINATION Disk (ENTER) ' 49 6E 73 65 72 74 20 44 45 53 54 49 4E 41 54 49 4F 4E 20 44 69 73 6B 20 20 20 28 45 4E 54 45 52 29 20
Text 'Insert DESTINATION Disk (ENTER) '.
5486
DEFB 03H 03
03H ends the message (S9WAIT flashes it).
Original Source Code Comment: TERMINATOR
5487S9SRC
DEFB 1DH 1D
S9SRC: 1DH, move the cursor to the start of the line.
Original Source Code Comment: MOVE TO BEG OF LINE CHAR
5488-54A4
DEFM 'Insert SOURCE Disk (ENTER) ' 49 6E 73 65 72 74 20 53 4F 55 52 43 45 20 44 69 73 6B 20 20 20 28 45 4E 54 45 52 29 20
Text 'Insert SOURCE Disk (ENTER) '.
54A5
DEFB 03H 03
03H ends the message.
Original Source Code Comment: TERMINATOR
54A6FLFLAG
DEFB 00H 00
FLFLAG: the number of 256 byte blocks of memory from 6300H that a single drive copy reads at a time (worked out at 5357H-536DH).
Original Source Code Comment: NUM OF BLOCKS COUNT
54A7FSFLAG
DEFB 00H 00
FSFLAG: the flash flag of S9WAIT, flipped between 00H (message shown) and 01H (line erased).
Original Source Code Comment: FLASH FLAG

54A8H - COPY9 - SINGLE DRIVE COPY ROUTINE - See if the user has selected the drives to make this a single drive copy. This portion parses both for a drive number, and defaults to "0" if none.

54A8COPY9
LD HL,6162HLD HL,S9DCB1 21 62 61
Let Register Pair HL equal 6162H which is the beginning of the SOURCE FILE DCB, and, in specific, the filespec (which appears at the beginning of the DCB).
Original Source Code Comment: POINT TO 1ST FILE DCB
54AB
LD B,18HLD B,24 06 18
Let Register B equal 18H (Decimal: 24) for a count of 24, which is (1 more than) the number of characters in filename/ext.password:d.
Original Source Code Comment: SET FOR COUNT OF 24
54ADCOP90
LD A,(HL) 7E
Fetch a character from filespec in the SOURCE FILE DCB (the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET A CHARACTER
54AE
CP 3AHCP ':' FE 3A
Compare the value held in Register A against 3AH (ASCII: :) to test for a drivespec.
Original Source Code Comment: DRIVE SPECIFIER?
54B0
INC HL 23
INCrement the pointer to the SOURCE FILE DCB (held in Register HL) by 1 to point to the next character.
Original Source Code Comment: BUMP POINTER
54B1
If we got a ":" then the Z FLAG (Zero) would have been set, so JUMP to 54B9H to test the drive.
Original Source Code Comment: IF SO, CHECK DRIVE
54B3
Parse the entire filespec portion of the SOURCE FILE DCB by LOOPing back to 54ADH, reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
Original Source Code Comment: LOOP FOR COUNT
54B5
LD C,30HLD C,'0' 0E 30
Let Register C equal 30H (ASCII: 0) as a default drive.
Original Source Code Comment: ASSUME DRIVE 0 THEN
54B7
JUMP to 54BAH to process the SOURCE FILE with a drive of "0" (i.e., skip the next instruction which sets Register C to something else).
Original Source Code Comment: AND CONTINUE

54B9H - COP91 - Continuation of the routine to see if the user has selected the drives to make this a single drive copy; jumped here if a we got a ":" in the SOURCE FILE DCB.

54B9COP91
LD C,(HL) 4E
Fetch a character from filespec held in the SOURCE FILE DCB (the memory location pointed to by Register Pair HL), which is hopefuly a drive number since it follows a ":", into Register C.
Original Source Code Comment: GET THE DRIVE NUMBER
54BACOP910
LD HL,6194HLD HL,S9DCB2 21 94 61
Let Register Pair HL equal 6194H to point to the DESTINATION FILE DCB, which will also point to the filespec in the DESTINATION FILE DCB.
Original Source Code Comment: POINT TO 2ND FILE NAME
54BD
LD B,18HLD B,24 06 18
Let Register B equal 18H (Decimal: 24) for a count of 24, which is (1 more than) the number of characters in filename/ext.password:d.
Original Source Code Comment: SET FOR COUNT OF 24 CHARS
54BFCOP92
LD A,(HL) 7E
Fetch a character from the filespec of the DESTINATION FILE DCB (the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET A CHAR
54C0
CP 3AHCP ':' FE 3A
Compare the value held in Register A against 3AH (ASCII: :) to test for a drivespec.
Original Source Code Comment: DRIVE SPECIFIER?
54C2
INC HL 23
INCrement the pointer to the DESTINATION FILE DCB (held in Register HL) 1 to the next character.
Original Source Code Comment: BUMP POINTER
54C3
If the character was a ":" the Z FLAG is set: JUMP to 54CBH (COP93) to fetch the destination drive number that follows it.
Original Source Code Comment: YES, GO CHECK DRIVE NUM
54C5
Parse the entire filespec portion of the DESTINATION FILE DCB by LOOPing back to 54BFH, reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
Original Source Code Comment: LOOP FOR COUNT
54C7
LD A,30HLD A,'0' 3E 30
Let Register A equal 30H (ASCII: 0) as a default drive.
Original Source Code Comment: ASSUME DRIVE 0 THEN
54C9
JUMP to 54CCH (COP930) with the default drive "0" in Register A, skipping the next instruction (which would load Register A from the DCB).
Original Source Code Comment: AND CONTINUE

54CBH - COP93 - Continuation of the routine to see if the user has selected the drives to make this a single drive copy; check the two drive numbers (held in A and C) to see if they match.

54CBCOP93
LD A,(HL) 7E
Fetch a the drive number from the DESTINATION FILE DCB (the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET THE DRIVE NUMBER
54CCCOP930
CP C B9
Compare the drive number from the DESTINATION FILE DCB (held in Register a) against the drive number from the READ FILE DCB (held in Register C). Results: If Register A equals the value held in Register C, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: THE TWO DRIVES THE SAME?
54CD
If they match, then the Z FLAG (Zero) will have been set; JUMP to 5357H to do a single drive copy.
Original Source Code Comment: YES, SINGLE DRIVE COPY

54D0H - COPY0 - Copy one file to another record by record (a copy between two drives, and each file of a COPY /EXT).

54D0COPY0
GOSUB to 52F3H (DISPLY) to show 'Copying ' with the source filespec, ' to ' and the destination filespec.
Original Source Code Comment: DISPLAY THE FILE NAMES
54D3
LD HL,0FFFFHLD HL,-1 21 FF FF
Let Register Pair HL equal 0FFFFH (i.e., -1) to act as a counter.
Original Source Code Comment: SET THE INTERNAL COUNTER
54D6
LD (52BAH),HLLD (RECCS),HL 22 BA 52
Store the value held in Register Pair HL into memory location 52BAH, which tracks the RECORD NUMBER BEING COPIED.
54D9
OPEN the file via a GOSUB to 599BH.
Original Source Code Comment: GO OPEN THE READ FILE
54DC
If the NZ FLAG (Not Zero) has been set, then that CALL returned an error; report the error and abort via a JUMP to 5223H.
Original Source Code Comment: EXIT IF ERROR
54DF
LD B,00HLD B,0 06 00
Let Register B equal the LRL for the INIT below. The operand at 54E0H (LRLCH1) holds the source file's LRL, stored there by OPENIT (59A8H), so the new file gets the same record length (00H = 256).
Original Source Code Comment: SET FOR LRL OF 256
54E1
LD DE,6194HLD DE,S9DCB2 11 94 61
Let Register Pair DE equal 6194H to point to the DESTINATION FILE DCB.
Original Source Code Comment: POINT TO DCB #2
54E4
LD HL,6400HLD HL,BUFER2 21 00 64
Let Register Pair HL equal 6400H to point to the beginning of the DESTINATION FILE buffer.
Original Source Code Comment: POINT TO SAME BUFFER
54E7
Create the destination file via a GOSUB to 4420H.
NOTE: 4420H is the SYS00/SYS routine to INITIALIZE A FILE (i.e., CREATE or OPEN). This RST 28H's with a value of A2H so as to call ROUTINE 2 in OVERLAY 2. Register HL needs to point to a RAM BUFFER for the DCB's.
Original Source Code Comment: OPEN OR INIT THE FILE
54EA
If the NZ FLAG (Not Zero) has been set, then that CALL returned an error; report the error and abort via a JUMP to 5223H.
Original Source Code Comment: EXIT IF ERROR
54EDCONTT
Display the record number via a GOSUB to 52A3H.
Original Source Code Comment: DISPLAY RECORD NUMBER
54F0
LD DE,6162HLD DE,S9DCB1 11 62 61
Let Register Pair DE equal equal 6162H which is the beginning of the SOURCE FILE DCB.
Original Source Code Comment: POINT TO DCB #1
54F3
LD HL,6200HLD HL,BUFER4 21 00 62
Let Register Pair HL equal 6200H (BUFER4), the buffer READ puts one record into when the LRL is not 256.
Original Source Code Comment: HL => DATA BUFFER
54F6
Read the next record of the source file via a GOSUB to 4436H (READ): with an LRL of 256 into the DCB's own buffer (6300H), otherwise into 6200H (Register Pair HL).
NOTE: 4436H is the SYS0 vector READ: Z = no error, NZ with the error code in Register A.
Original Source Code Comment: READ IN A RECORD
54F9
If the Z FLAG (Zero) has been set then there was no error, so do the WRITE via a JUMP to 5506H.
Original Source Code Comment: IF NO ERROR, GO WRITE
54FB
CP 1CHCP EEOF FE 1C
Compare the value held in Register A against 1CH (i.e., EOF ERROR). Results: If Register A equals 1CH, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: EOF ERROR ?
54FD
If the Z FLAG (Zero) has been set we have an EOF error, but we are also done; so JUMP to 5525H.
Original Source Code Comment: YES, ALL DONE
54FF
CP 1DHCP ENRF FE 1D
Compare the value held in Register A against 1DH (i.e., RECORD OUT OF RANGE ERROR). Results: If Register A equals 1DH, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: NRN ERROR ?
5501
If the Z FLAG (Zero) has been set we have a RECORD OUT OF RANGE error, but we are also done, so JUMP to 5525H.
Original Source Code Comment: IF SO, DONE BUT ADJUST
5503
If we're here then we have an error we care about, so report the error and abort via a JUMP to 5223H.
Original Source Code Comment: REPORT TRUE ERROR AND EXIT

5506H - NEXT - Copy the READ FILE BUFFER to the DESTINATION FILE BUFFER, and WRITE.

5506NEXT
LD A,(616BH)LD A,(S9DCB1+LRL) 3A 6B 61
Fetch the LRL of the SOURCE FILE (held in memory location 616BH) and store it into Register A.
Original Source Code Comment: GET THE LRL
5509
OR A B7
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
Original Source Code Comment: LRL OF 256?
550A
If the NZ FLAG (Not Zero) has been set, then we do not have a LRL of 256, so JUMP to 5517H.
Original Source Code Comment: NO, CONTINUE
550C
LD HL,6300HLD HL,BUFER1 21 00 63
Let Register Pair HL equal 6300H to point to the beginning of the READ FILE buffer.
Original Source Code Comment: HL => READ BUFFER
550F
LD DE,6400HLD DE,BUFER2 11 00 64
Let Register Pair DE equal 6400H to point to the beginning of the DESTINATION FILE buffer.
Original Source Code Comment: DE => WRITE BUFFER
5512
LD BC,0100HLD BC,SECTOR 01 00 01
Let Register Pair BC equal 0100H (256), the number of bytes the LDIR copies from the read buffer to the write buffer.
Original Source Code Comment: NUMBER OF BYTES TO MORE
5515
LDIR ED B0
Transfers a byte of data from the memory location pointed to by HL to the memory location pointed to by DE. Then HL and DE are incremented and BC is decremented. If BC is not zero, this operation is repeated. Interrupts can trigger while this instruction is processing.
Original Source Code Comment: MOVE IT TO THE WRITE BUFFER
5517NEXTV
LD DE,6194HLD DE,S9DCB2 11 94 61
Let Register Pair DE equal 6194H to point to the DESTINATION FILE DCB.
Original Source Code Comment: POINT TO DCB #2
551A
LD HL,6200HLD HL,BUFER4 21 00 62
Let Register Pair HL equal 6200H to point to buffer number 4 (which is used for non 256 LRL files).
Original Source Code Comment: HL => DATA BUFFER (NON-256)
551D
Write the record to the destination file via a GOSUB to 4439H.
NOTE: 4439H is the SYS0 vector WRITE: it writes the next record of the file whose DCB is at Register Pair DE (from 6400H, or from 6200H at Register Pair HL when the LRL is not 256); Z = no error.
Original Source Code Comment: WRITE OUT THE RECORD
5520
If the Z FLAG (Zero) has been set then the write was successful, so do move via a LOOP BACK to 54EDH.
Original Source Code Comment: IF NO ERR, CONTINUE
5522
Report the error and abort via a JUMP to 5223H.
Original Source Code Comment: REPORT ERROR AND EXIT

5525H - DONE0 - The copy routine has completed but with a (harmless) EOF or RECORD OUT OF RANGE ERROR.

5525DONE0
LD A,(616BH)LD A,(S9DCB1+LRL) 3A 6B 61
Fetch the LRL of the SOURCE FILE (held in memory location 616BH) and store it into Register A.
Original Source Code Comment: GET THE LRL
5528
OR A B7
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
Original Source Code Comment: LRL 256?
5529
If the NZ FLAG (Not Zero) has been set, then the LRL is not a standard 256 (i.e., we do not have a full sector), so JUMP to 5542H to deal with that.
Original Source Code Comment: NO, CONTINUE
552B
LD A,(616AH)LD A,(S9DCB1+EOF) 3A 6A 61
Fetch the EOF BYTE of the SOURCE FILE (held in memory location 616AH) and store it into Register A.
Original Source Code Comment: GET THE EOF BYTE
552E
OR A B7
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
Original Source Code Comment: ON SECTOR BOUNDARY?
552F
If the Z FLAG (Zero) has been set, then the EOF is on the sector boundary and we don't need to do any special math to calculate it, so continue via a JUMP to 5542H.
Original Source Code Comment: YES, CONTINUE

If we are here then we need to specially calculate the EOF.

5531
LD IX,6194HLD IX,S9DCB2 DD 21 94 61
Let Special Index Register IX equal 6194H to point to the DESTINATION FILE DCB.
5535
LD L,(IX+0CH)LD L,(IX+ERNL) DD 6E 0C
Fetch the LSB of the destination file's ERN (DCB offset 0CH, IX+0CH) into Register L.
Original Source Code Comment: GET THE ERN
5538
LD H,(IX+0DH)LD H,(IX+ERNH) DD 66 0D
Fetch the MSB of the destination file's ERN (DCB offset 0DH, IX+0DH) into Register H.
553B
DEC HL 2B
DECrement Register Pair HL: the last record is a partial sector (the EOF byte is not 00H), so the ending record number is one less.
Original Source Code Comment: BACK UP TO LAST RECORD
553C
LD (IX+0CH),LLD (IX+ERNL),L DD 75 0C
Store the LSB of the corrected ERN (Register L) back into DCB offset 0CH.
Original Source Code Comment: STORE IT
553F
LD (IX+0DH),HLD (IX+ERNH),H DD 74 0D
Store the MSB of the corrected ERN (Register H) back into DCB offset 0DH.
5542DONE1
LD A,(616AH)LD A,(S9DCB1+EOF) 3A 6A 61
Fetch the EOF BYTE of the SOURCE FILE (held in memory location 616AH) and store it into Register A.
Original Source Code Comment: GET THE EOF BYTE
5545
LD (619CH),ALD (S9DCB2+EOF),A 32 9C 61
Store the the EOF BYTE of the SOURCE FILE (held in Register A) into the DESTINATION FILE DCB (held at memory location 619CH).
Original Source Code Comment: PUT IT INTO THE DESTINATION DCB
5548CCLSE
LD DE,6194HLD DE,S9DCB2 11 94 61
Let Register Pair DE equal 6194H to point to the DESTINATION FILE DCB.
Original Source Code Comment: POINT TO WRITE DCB
554B
GOSUB to 4428H to CLOSE the file
NOTE: 4428H is the SYS00/SYS routine to CLOSE A DISK FILE. This RST 28H's with a value of 93H so as to call ROUTINE 1 in OVERLAY 3.
Original Source Code Comment: GO CLOSE IT
554E
If the NZ FLAG (Not Zero) has been set, then that CALL returned an error; report the error and abort via a JUMP to 5223H.
Original Source Code Comment: EXIT IF ERROR
5551CCLSE1
LD DE,6162HLD DE,S9DCB1 11 62 61
Let Register Pair DE equal equal 6162H which is the beginning of the SOURCE FILE DCB.
Original Source Code Comment: POINT TO READ DCB
5554CCLSE2
GOSUB to 4428H to CLOSE the file
NOTE: 4428H is the SYS00/SYS routine to CLOSE A DISK FILE. This RST 28H's with a value of 93H so as to call ROUTINE 1 in OVERLAY 3.
Original Source Code Comment: GO CLOSE THE FILE
5557
If the NZ FLAG (Not Zero) has been set, then that CALL returned an error; report the error and abort via a JUMP to 5223H.
Original Source Code Comment: EXIT IF ERROR
555A
RET C9
RETurn to the caller of the command (TRSDOS Ready), or, for a COPY /EXT, to the directory loop at 564BH.
Original Source Code Comment: RETURN TO DOS

555BH - DRIVE1 - MESSAGE and STORAGE AREA.

555B-555CDRIVE1
DEFM ':0' 3A 30
DRIVE1: ':' and the source drive digit for COPY /EXT and KILL /EXT (':0' at load), stored by MOVE1.
555D
DEFB 0DH 0D
0DH after the source drive, copied into the DCB by MOVE4.
555E-555FDRIVE2
DEFM ':1' 3A 31
DRIVE2: ':' and the destination drive digit for COPY /EXT (':1' at load).
5560
DEFB 0DH 0D
0DH after the destination drive.
5561ZSLANT
DEFM '/' 2F
ZSLANT: the '/' that MOVE3 copies in front of the extension.
5562-5564S9CMD
DEFM 'BAS' 42 41 53
S9CMD: the 3 characters of the extension given ('BAS' at load), stored by MOVE1.
5565-5566SAVE3
DEFW 4300H 00 43
SAVE3: the pointer to the directory record being looked at in the sector buffer (4300H at load).
5567S9TRK
DEFB 00H 00
S9TRK: the directory sector GETDIR reads (SLANT0 starts it at 3).

5568H - GETDIR - Read the Directory Track into a Buffer at 4300H.

5568GETDIR
LD A,(555CH)LD A,(DRIVE1 + 1) 3A 5C 55
Fetch the drive number (held in memory location 555CH) and store it into Register A.
Original Source Code Comment: GET THE DRIVE NUMBER
556B
AND 0FH E6 0F
MASK the value of Register A against 0FH (0000 1111) to leave only bits 3, 2, 1, 0 active; basically turning the ASCII into BINARY.
Original Source Code Comment: MASK OFF ASCII
556D
LD C,A 4F
Since SYS00/SYS Disk I/O calls usually require Register C to contain the drive number, copy the drive number (held in Register A) into Register C.
Original Source Code Comment: SAVE IT IN C
556E
Get the directory track via a GOSUB to 4B3EH.
NOTE: 4B3EH is the SYS00/SYS routine to identify the track number of the directory. Routine exits with the director track number in Register D.
Original Source Code Comment: GET THE DIRECTORY TRACK THIS DRIVE
5571
LD A,(5567H)LD A,(S9TRK) 3A 67 55
Fetch the directory sector we want to read (held in memory location 5567H) and store it into Register A.
Original Source Code Comment: GET DIR SECTOR WE'RE GONNA READ
5574
LD E,A 5F
Copy the the directory sector we want to read (held in Register A) into Register E.
Original Source Code Comment: PUT IT INTO E
5575
LD HL,4300HLD HL,BUFF1 21 00 43
Let Register Pair HL equal 4300H, whiich will be a buffer.
Original Source Code Comment: DOS BUFFER
5578
GOSUB to 4675H of SYS00/SYS to position the drive head and read the requested sector into the buffer pointed to by Register Pair HL.
Original Source Code Comment: GO READ SECTOR OF DIRECTORY
557B
RET C9
RETurn to the caller.
Original Source Code Comment: EXIT

557CH - MOVE1 - Routine to transfer B number of characters from (DE) to (IX), aborting if a SPACE is found.

557CMOVE1
LD A,(DE) 1A
Fetch a character held in the memory location pointed to by Register Pair DE and store it into Register A.
Original Source Code Comment: GET A CHAR
557D
CP 20HCP ' ' FE 20
Compare the value held in Register A against 20H (ASCII: SPACE).
Original Source Code Comment: IS IT A SPACE?
557F
POP IY FD E1
In case there is a match, and we therefore have an illegal character, and we need to clear the return address from the top of the STACK.
Original Source Code Comment: DESTROY MOVE1 CALL IN CASE
5581
If we got a SPACE, which is bad, the Z FLAG (Zero) will have been set, so JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: YES, ILLEGAL
5584
PUSH IY FD E5
If we are here, then we didn't get an illegal character, so put the return address back to the top of the stack.
Original Source Code Comment: PUT CALL BACK, IT'S OKAY
5586
LD (IX+00H),ALD (IX),A DD 77 00
Store the character (Register A) at the save area Register IX points to (S9CMD 5562H, DRIVE1 555BH or DRIVE2 555EH).
Original Source Code Comment: SAVE THE CHAR
5589
INC DE 13
INCrement the value stored in Register Pair DE by 1 to point to the next character to test.
Original Source Code Comment: BUMP THE POINTERS
558A
INC IX DD 23
INCrement the value stored in Special Index Register IX by 1 to move to the next area to save the character to.
558C
LOOP back to 557CH, reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
Original Source Code Comment: CONTINUE FOR COUNT
558E
RET C9
RETurn to the caller.

558FH - MOVE2 - Routine to copy a filename from the directory entry (pointed to by DE) into the DCB (pointed to HL); returns with Register C containing the number of characters in the filename.

558FMOVE2
LD B,08HLD B,8 06 08
Let Register B equal 08H as there are 8 characters in a filespec.
Original Source Code Comment: SET FOR 8 CHARS
5591MOVE20
LD A,(DE) 1A
Fetch a character (held in the memory location pointed to by Register Pair DE) and store it into Register A.
Original Source Code Comment: GET A CHAR
5592
CP 20HCP ' ' FE 20
Compare the value held in Register A against 20H (ASCII: SPACE).
Original Source Code Comment: SPACE?
5594
RET Z C8
If we got a SPACE then we are done; so RETURN.
Original Source Code Comment: YES, DONE
5595
LD (HL),A 77
If we are here, the character is good, so store the character (held in Register A) into the DCB (pointed to by Register Pair HL).
Original Source Code Comment: SAVE THE CHAR
5596
INC C 0C
INCrement the counter (Register C) by 1.
Original Source Code Comment: INC A COUNT
5597
INC HL 23
INCrement the pointer for the destination (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP THE POINTERS
5598
INC DE 13
INCrement the pointer for the source (stored in Register Pair DE) by 1.
5599
LOOP back to 5591H for up to 8 iterations, reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
Original Source Code Comment: CONTINUE FOR COUNT
559B
RET C9
RETurn to the caller.

559CH - MOVE3 - Routine to copy 4 bytes, the "/" and the 3 character extension at 5561H-5564H (pointed to by DE), into the DCB (pointed to by HL); Register C counts them on from the name length MOVE2 left in it.

559CMOVE3
LD B,04HLD B,4 06 04
Let Register B equal 04H, which is the number of characters in an extension (including the delimeter).
Original Source Code Comment: SET FOR 4 CHARS
559EMOVE30
LD A,(DE) 1A
Fetch a character (held in the memory location pointed to by Register Pair DE) and store it into Register A.
Original Source Code Comment: GET A CHAR
559F
LD (HL),A 77
Store the character (held in Register A) into the memory location pointed to by Register Pair HL.
Original Source Code Comment: SAVE IT
55A0
INC C 0C
INCrement the counter (Register C) by 1.
Original Source Code Comment: INC A COUNTER
55A1
INC HL 23
INCrement the pointer for the destination (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP THE POINTERS
55A2
INC DE 13
INCrement the pointer for the source (stored in Register Pair DE) by 1.
55A3
LOOP back to 559EH for up to 4 iterations, reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
Original Source Code Comment: CONTINUE FOR COUNT
55A5
RET C9
RETurn to the caller.

55A6H - MOVE4 - Routine to copy 3 bytes, a drivespec (":" and the drive digit) and its 0DH, from DRIVE1 or DRIVE2 (pointed to by DE) into the DCB (pointed to by HL).

55A6MOVE4
LD B,03HLD B,3 06 03
Let Register B equal 03H, for a count of 3 characters.
Original Source Code Comment: SET FOR COUNT OF 3 CHARS
55A8MOVE40
LD A,(DE) 1A
Fetch a character (held in the memory location pointed to by Register Pair DE) and store it into Register A.
Original Source Code Comment: GET A CHAR
55A9
LD (HL),A 77
Store the character (held in Register A) into the memory location pointed to by Register Pair HL.
Original Source Code Comment: SAVE IT
55AA
INC HL 23
INCrement the pointer for the destination (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP THE POINTERS
55AB
INC DE 13
INCrement the pointer for the source (stored in Register Pair DE) by 1.
55AC
LOOP back to 55A8H for up to 3 iterations, reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
Original Source Code Comment: CONTINUE FOR COUNT
55AE
RET C9
RETurn to the caller.

55AFH - SKSP - Routine to Skip Spaces in DE and Point to the next Non-Blank Character.

55AFSKSP
LD A,(DE) 1A
Fetch a character (held in the memory location pointed to by Register Pair DE) and store it into Register A.
Original Source Code Comment: GET A CHAR
55B0
CP 20HCP ' ' FE 20
Compare the value held in Register A against 20H (ASCII: SPACE).
Original Source Code Comment: SPACE?
55B2
RET NZ C0
If the NZ FLAG (Not Zero) has been set, RETurn to the caller.
Original Source Code Comment: NO, RET
55B3
INC DE 13
INCrement the pointer for the source (stored in Register Pair DE) by 1.
Original Source Code Comment: BUMP THE POINTER
55B4
Loop back to 55AFH to keep parsing.
Original Source Code Comment: AND KEEP LOOKING

55B6H - SLANT - This routine gets called if the user entered a wildcard copy command such as "COPY /EXT:x :x".

55B6SLANT
INC DE 13
INCrement the command line pointer (stored in Register Pair DE) by 1.
Original Source Code Comment: BUMP THE COMMAND LINE POINTER
55B7
LD IX,5562HLD IX,S9CMD DD 21 62 55
Let Special Index Register Pair IX equal the extension storage area of 5562H.
Original Source Code Comment: PLACE TO STORE EXTENSION
55BB
LD B,03HLD B,3 06 03
Let Register B equal 03H, the length of an extension without the "/" delimeter.
Original Source Code Comment: SET FOR 3 CHARS
55BD
Transfer characters the number of characters held in Register B from (DE) to (IX), aborting if a SPACE is found via a GOSUB to 557CH.
Original Source Code Comment: GO GET'EM
55C0
LD A,(DE) 1A
Fetch the next character from the COMMAND LINE (held in the memory location pointed to by Register Pair DE) and store it into Register A.
Original Source Code Comment: GET NEXT COMMAND LINE CHAR
55C1
CP 3AHCP ':' FE 3A
Compare the value held in Register A against 3AH (ASCII: :). Results: If Register A equals :, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: DRIVE SPECIFIER?
55C3
If we got a ":" then are good; but if we didn't then the NZ FLAG (Not Zero) will have been set, so JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: NO, ERROR THEN. MUST HAVE DRIVE NUM
55C6
LD IX,555BHLD IX,DRIVE1 DD 21 5B 55
Let Special Index Register Pair IX point to the read drive save area.
Original Source Code Comment: POINT TO READ DRIVE SAVE
55CA
LD B,02HLD B,2 06 02
Let Register B equal 02H to move 2 characters (:d).
Original Source Code Comment: SET FOR 2 CHARS (:D)
55CC
Get the SOURCE filespec by transfering characters the number of characters held in Register B from (DE) to (IX), aborting if a SPACE is found via a GOSUB to 557CH.
Original Source Code Comment: GO GET THE READ DRIVE NUM
55CF
GOSUB to 55AFH to skip spaces pointed to by Register Pair DE and point to the next Non-Blank character pointed to by Register Pair DE.
Original Source Code Comment: SKIP ANY SPACES
55D2
CP 3AHCP ':' FE 3A
Compare the value held in Register A against 3AH (ASCII: :). Results: If Register A equals :, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: DRIVE SPECIFIER?
55D4
If we got a ":" then are good; but if we didn't then the NZ FLAG (Not Zero) will have been set, so JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: NO, ERROR THEN
55D7
LD IX,555EHLD IX,DRIVE2 DD 21 5E 55
Let Special Index Register Pair IX point to the destination drive save area.
Original Source Code Comment: PLACE TO SAVE WRITE DRIVE NUM
55DB
LD B,02HLD B,2 06 02
Let Register B equal 02H to move 2 characters (:d).
Original Source Code Comment: SET FOR 2 CHARS (:D)
55DD
Transfer characters the number of characters held in Register B from (DE) to (IX), aborting if a SPACE is found via a GOSUB to 557CH.
Original Source Code Comment: GO GET WRITE DRIVE NUM
55E0
LD A,(555FH)LD A,(DRIVE2+1) 3A 5F 55
Fetch the 2nd character pointing to the destination drive save area (held in memory location 555FH) and store it into Register A.
Original Source Code Comment: GET WRITE DRIVE NUM
55E3
CP 34HCP '4' FE 34
Compare the value held in Register A against 34H (ASCII: 4). Results:
  • If Register A equals 4, the Z FLAG is set.
  • If A < 4, the CARRY FLAG will be set.
  • if A >= 4, the NO CARRY FLAG will be set.

Original Source Code Comment: GREATER THAN 3?
55E5
If the destination drive digit is "4" or higher the NC FLAG is set: JUMP to 5221H (ERR9) to report error 2 (disk drive not in system).
Original Source Code Comment: YES, NO SUCH DRIVE

55E8H - SLANT0 - Common Routine for COPY and KILL - Wild Card Search Routine.

55E8SLANT0
LD A,03HLD A,DIRSEC 3E 03
Let Register A equal 03H to point to the beginning of the directory, which is sector 3 of the directory track.
Original Source Code Comment: LOAD BEGIN OF DIRECTORY
55EA
LD (5567H),ALD (S9TRK),A 32 67 55
Store the value held in Register A (i.e., 03H) into the memory location (5567H) which holds the directory sector we want to read.
Original Source Code Comment: RESET SECTOR LOCATION TO 3
55ED
LD A,(555CH)LD A,(DRIVE1+1) 3A 5C 55
Fetch the READ DRIVE DRIVE NUMBER (held in memory location 555CH) and store it into Register A.
Original Source Code Comment: GET READ DRIVE NUM
55F0
CP 34HCP '4' FE 34
Compare the value held in Register A against 34H (ASCII: 4). Results:
  • If Register A equals 4, the Z FLAG is set.
  • If A < 4, the CARRY FLAG will be set.
  • if A >= 4, the NO CARRY FLAG will be set.

Original Source Code Comment: GREATER THAN 3?
55F2
If the source drive digit is "4" or higher the NC FLAG is set: JUMP to 5221H (ERR9) to report error 2 (disk drive not in system).
Original Source Code Comment: YES, NO SUCH DRIVE
55F5
LD B,10HLD B,DLENGH 06 10
Let Register B equal 10H (16), the number of directory sectors (3 through 18) the loop at 55F7H reads.
Original Source Code Comment: LENGTH OF DIRECTORY RECORDS
55F7TOTAL
PUSH BC C5
Save the counter (held in Register Pair BC) to the top of the stack.
Original Source Code Comment: SAVE THE COUNTER
55F8
Read the Directory into 4300H via a GOSUB to 5568H.
Original Source Code Comment: GET A SECTOR FROM DIRECTORY
55FB
LD DE,4300HLD DE,BUFFER 11 00 43
Let Register Pair DE equal 4300H to point to the start of the directory sector in RAM.
Original Source Code Comment: POINT TO BUFFER
55FE
LD (5565H),DELD (SAVE3),DE ED 53 65 55
Store the buffer start pointer (held in Register Pair DE) into memory location 5565H.
Original Source Code Comment: SAVE POINTER
5602TOTAL0
LD A,(DE) 1A
Fetch a character from directory (held in the memory location pointed to by Register Pair DE) and store it into Register A.
Original Source Code Comment: GET 1ST CHAR OF DIR
5603
CP 10H FE 10
Compare the attribute byte of the directory record (Register A) against 10H. Only a record whose attribute byte is exactly 10H (in use, with no other attribute bit set) is taken; NZ for a free record or a file with other attribute bits.
Original Source Code Comment: IS THIS FILE PROTECTED IN 'ANY' WAY?
5605
If the file is protected, then the NZ FLAG (Not Zero) will have been set, so skip this file by JUMPing to 564EH.
Original Source Code Comment: YES, IGNORE IT THEN

If we are here, then the file CAN be copied or killed, next we need to see if the user supplied extension matches the filename's extension.

5607
LD A,E 7B
Copy the LSB of the directory pointer (held in Register E) into Register A.
Original Source Code Comment: GET THE LSB OF DIR POINTER
5608
ADD A,0DHADD A,DEXT C6 0D
LET Register A = Register A + 0DH so as to now point to the filename extension of the current file.
Original Source Code Comment: POINT TO TO THE 'EXT'
560A
LD E,A 5F
Store the pointer to the extension of the directory record (Register A) back into Register E.
Original Source Code Comment: PUT IT BACK
560B
LD HL,5562HLD HL,S9CMD 21 62 55
Let Register Pair HL point to the user requested filename extension held at 5562H.
Original Source Code Comment: POINT TO 'USR' ASKED EXT
560E
LD B,03HLD B,3 06 03
Let Register B equal 03H to prepare for 3 characters, as we need to compare the user requested exension against the extension of the current file.
Original Source Code Comment: SET FOR THREE CHARS
5610TOTAL1
LD A,(DE) 1A
Fetch a character from the file's extension from the directory (held in the memory location pointed to by Register Pair DE) and store it into Register A.
Original Source Code Comment: GET A CHAR FROM DIR
5611
CP (HL) BE
Compare the character from the file's extension from the directory (held in Register A) against the value requested by the user (held in the memory location pointed to by the value held in Register Pair HL). Results: If Register they match, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: MATCH USER?
5612
If the don't match, then the NZ FLAG (Not Zero) will have been set, and we will want to skip this file by JUMP to 564EH.
Original Source Code Comment: NO, SKIP THIS FILE
5615
INC DE 13
INCrement the pointer to the character from the file's extension from the directory (stored in Register Pair DE) by 1.
Original Source Code Comment: BUMP THE POINTERS
5616
INC HL 23
INCrement the pointer to the character from the user specified extension (stored in Register Pair HL) by 1.
5617
Keep checking the 3 extension characters by LOOPing back to 5610H, reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
Original Source Code Comment: CONTINUE FOR COUNT
5619
LD DE,(5565H)LD DE,(SAVE3) ED 5B 65 55
If we're here, the user extension matched the current filename in the directory's extension so fetch the buffer pointer (held in memory location 5565H) and store it into Register Pair DE.
Original Source Code Comment: GET THE BUFFER POINTER BACK
561D
LD A,E 7B
Copy the LSB of the directory pointer (held in Register E) into Register A.
Original Source Code Comment: GET THE LSB OF DIR POINTER
561E
ADD A,05HADD A,DNAME C6 05
LET Register A = Register A + 05H so as to point to the file's filespec.
Original Source Code Comment: MAKE IT POINT AT THIS FILE'S NAME
5620
LD E,A 5F
Put the LSB of the directory pointer, now pointing to the name, back into Register E.
Original Source Code Comment: PUT IT BACK
5621
LD C,00HLD C,0 0E 00
Let Register C equal 00H so that Register C can be a counter.
Original Source Code Comment: CLEAR CHAR COUNTER
5623
LD HL,6162HLD HL,S9DCB1 21 62 61
Let Register Pair HL equal equal 6162H which is the beginning of the SOURCE FILE DCB.
Original Source Code Comment: POINT TO READ DCB
5626
Copy a filename from the directory entry (pointed to by DE) into the DCB (pointed to HL) via a GOSUB to 558FH. Returns with Register C containing the number of characters in the filename.
Original Source Code Comment: MOVE FILE NAME TO READ DCB
5629
LD DE,5561HLD DE,ZSLANT 11 61 55
Let Register Pair DE equal 5561H, which is the pointer to the RAM SAVE area for the extension, starting with the "/".
Original Source Code Comment: PLACE WHERE EXT IS STORED
562C
Attach the extension to the file filename via a GOSUB to 559CH.
Original Source Code Comment: GO GET THE EXTENSION INTO DCB
562F
PUSH BC C5
Save the counter/length of the filespec (held in Register Pair BC) to the top of the stack.
Original Source Code Comment: SAVE THE COUNTER
5630
LD DE,555BHLD DE,DRIVE1 11 5B 55
Let Register Pair DE equal 555BH to point to the SOURCE FILE drivespec.
Original Source Code Comment: POINT TO READ DRIVE NUMBER
5633
Attach the drivespec to the filename via a GOSUB to 55A6H.
Original Source Code Comment: MOVE IT INTO DCB
5636
LD HL,6162HLD HL,S9DCB1 21 62 61
Let Register Pair HL equal equal 6162H which is the beginning of the SOURCE FILE DCB (which starts with the filename).
Original Source Code Comment: POINT TO READ DCB
5639
LD DE,6194HLD DE,S9DCB2 11 94 61
Let Register Pair DE equal 6194H to point to the DESTINATION FILE DCB (which starts with the filename).
Original Source Code Comment: POINT TO WRITE DCB
563C
POP BC C1
Fetch the counter/length of the filespec from the the top of the STACK into Register Pair BC, and then remove the entry from the stack.
Original Source Code Comment: GET THE COUNT BACK
563D
LD B,00HLD B,0 06 00
In preparation for a LDIR, Register Pair BC needs to be set up. Right now only Register C is set up. So here we set Register B to equal 00H to set the MSB of the length so that BC is now the length of the filespec.
Original Source Code Comment: CLEAR THE MSB OF COUNT
563F
LDIR ED B0
Copy the filespec from the SOURCE FILE DCB to the DESTINATION FILE DCB via LDIR, which transfers a byte of data from the memory location pointed to by HL to the memory location pointed to by DE. Then HL and DE are incremented and BC is decremented. If BC is not zero, this operation is repeated. Interrupts can trigger while this instruction is processing.
Original Source Code Comment: DUPLICATE THE FILE NAME INTO WRITE DCB
5641
EX DE,HL EB
EXchange the value stored in Register Pair HL (i.e., the end of the filename in the SOURCE FILE DCB) with the value stored in Register Pair DE (i.e., the end of the filename in the DESTINATION FILE DCB).
Original Source Code Comment: GET THE WRITE POINTER INTO HL
5642
LD DE,555EHLD DE,DRIVE2 11 5E 55
Let Register Pair DE equal the DESTINATION FILE DRIVESPEC (held in 555EH).
Original Source Code Comment: POINT TO WRITE DRIVE NUMBER
5645
Attach the drivespec to the filename via a GOSUB to 55A6H.
Original Source Code Comment: MOVE DRIVE INTO WRITE DCB
5648TOTCHG
GOSUB to the routine for one file. The operand at 5649H-564AH (TOTCHG+1) is 54D0H (COPY0) as loaded and as COPY sets it (5261H), or 5692H (KILLIT) as KILL sets it (568CH).
Original Source Code Comment: GO COPY THE FILE
564B
Read the directory sector in S9TRK (5567H) into 4300H again via a GOSUB to 5568H (GETDIR), since the copy or kill used that buffer.
Original Source Code Comment: GET NEXT FILE IN DIRECTORY
564ETOTNXT
LD DE,(5565H)LD DE,(SAVE3) ED 5B 65 55
Fetch the applicable buffer address for the current location in the directory sector (held in memory location 5565H) and store it into Register Pair DE.
Original Source Code Comment: GET THE DIR POINTER
5652
LD A,E 7B
Fetch the LSB of the directory record pointer (Register E) into Register A.
Original Source Code Comment: GET THE LSB OF POINTER
5653
ADD A,30HADD A,SIZDIR C6 30
Add 30H (48), the size of a directory record, to Register A to point to the next record.
Original Source Code Comment: POINT TO NEXT FILE
5655
LD E,A 5F
Store the new LSB (Register A) back into Register E: Register Pair DE points to the next directory record.
5656
LD (5565H),DELD (SAVE3),DE ED 53 65 55
Store the new directory record pointer (Register Pair DE) into 5565H (SAVE3).
Original Source Code Comment: SAVE AS NEW POINTER
565A
CP 0F0H FE F0
Compare the LSB of the new record pointer (Register A) against F0H. A sector holds five records (00H, 30H, 60H, 90H, C0H); F0H is past the last.
Original Source Code Comment: AT END OF THIS DIRECTORY SECTOR?
565C
If Register A is below F0H the C FLAG is set: there is another record in this sector, so JUMP to 5602H (TOTAL0).
Original Source Code Comment: NO, CONTINUE
565E
POP BC C1
Fetch the sector counter (held at the top of the STACK) into Register Pair BC, and then remove the entry from the stack.
Original Source Code Comment: GET THE SECTOR COUNT BACK
565F
LD A,(5567H)LD A,(S9TRK) 3A 67 55
Fetch the sector number (held in memory location 5567H) and store it into Register A.
Original Source Code Comment: LOAD THE SECTOR POINTER
5662
INC A 3C
INCrement the value stored in Register A by 1 so as to point to the next sector.
Original Source Code Comment: BUMP TO NEXT SECTOR
5663
LD (5567H),ALD (S9TRK),A 32 67 55
Store the bumped sector number (held in Register A) into memory location 5567H.
Original Source Code Comment: RE-SAVE IT
5666
Process the entire directory track by LOOPing back to 55F7H, reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
Original Source Code Comment: AND CONTINUE FOR ALL SECTORS
5668
RET C9
RETurn to the caller.
Original Source Code Comment: DONE, ALL FILES COPIED

5669H - S9KILL - "KILL" Routine.

5669S9KILL
LD D,H 54
Copy Register H into Register D (first half of LD DE,HL) ...
Original Source Code Comment: MIRROR THE COMMAND LINE TO DE
566A
LD E,L 5D
... and Register L into Register E: Register Pair DE = the command line pointer.
566B
LD A,(DE) 1A
Fetch the first character held on the command line (in the memory location pointed to by Register Pair DE) and store it into Register A.
Original Source Code Comment: GET A COMMAND LINE CHAR
566C
CP 2FHCP '/' FE 2F
Compare the value held in Register A against 2FH (ASCII: /). Results: If Register A equals /, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: KILL ALL MATCH EXT?
566E
If the first characer is NOT a /, then NZ FLAG (Not Zero) will have been set, and the user is NOT using a wildcard. JUMP to 5697H.
Original Source Code Comment: NO, REGULAR KILL

If we are here, then the user requested to KILL based on a WILDCARD.

5670
INC DE 13
INCrement the value stored in Register Pair DE by 1 to point to the second character from the COMMAND LINE.
Original Source Code Comment: BUMP THE POINTER
5671
LD IX,5562HLD IX,S9CMD DD 21 62 55
Let Special Index Register Pair IX equal the extension storage area of 5562H.
Original Source Code Comment: PLACE TO SAVE 'EXT'
5675
LD B,03HLD B,3 06 03
Let Register B equal 03H to move 3 characters.
Original Source Code Comment: SET FOR 3 CHARS
5677
Transfer characters the number of characters held in Register B from (DE) to (IX), aborting if a SPACE is found via a GOSUB to 557CH.
Original Source Code Comment: MOVE 'EM
567A
LD A,(DE) 1A
Fetch the next character from the COMMAND LINE (held in the memory location pointed to by Register Pair DE) and store it into Register A.
Original Source Code Comment: GET NEXT CHAR
567B
CP 3AHCP ':' FE 3A
Compare the value held in Register A against 3AH (ASCII: :). Results: If Register A equals 3AH :, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: DRIVE SPECIFIER?
567D
We needed a :. If we didn't get one, then the the NZ FLAG (Not Zero) will have been set, so JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: NO, ERROR. MUST HAVE DRIVE NUM
5680
LD IX,555BHLD IX,DRIVE1 DD 21 5B 55
Let Special Index Register Pair IX point to the SOURCE DRIVESPEC (555BH).
Original Source Code Comment: PLACE TO SAVE DRIVE NUM
5684
LD B,02HLD B,2 06 02
Let Register B equal 02H for a move of 2 drivespec characters.
Original Source Code Comment: SET FOR 2 CHARS (:D)
5686
Transfer characters the number of characters held in Register B from (DE) to (IX), aborting if a SPACE is found via a GOSUB to 557CH.
Original Source Code Comment: GET DRIVE
5689
LD HL,5692HLD HL,KILLIT 21 92 56
Let Register Pair HL equal 5692H (KILLIT), the routine the directory loop is to call for each file.
Original Source Code Comment: SET LOOPER ROUTINE FOR KILL
568C
LD (5649H),HLLD (TOTCHG + 1),HL 22 49 56
Store the value held in Register HL into the memory location 5649H, which is in the middle of a CALL OPCODE. This will set that OPCODE to "KILL". The alternative would be from the "COPY" routine, which would set this to a different address.
Original Source Code Comment: INSTEAD OF COPY
568F
JUMP to 55E8H (SLANT0) to kill every file with the extension given.
Original Source Code Comment: AND GO KILL

5692H - KILLIT - Continuation of the KILL ROUTINE.

5692KILLIT
GOSUB to 59ADH (GETDCB): Register B = 00H, Register Pair DE = 6162H (S9DCB1, whose name SLANT0 filled in) and Register Pair HL = 6300H.
Original Source Code Comment: GO OPEN THE FILE
5695
JUMP to 569DH to kill the file.
Original Source Code Comment: AND KILL IT

5697H - KILL1 - Continuation of the KILL ROUTINE; display the KILLING message and kill the file.

5697KILL1
Process the filespec (i.e., set Register Pair DE to point to the SOURCE FILE DCB, check the syntax of the associated Filespec, and RETurn) via a GOSUB to 59BCH.
Original Source Code Comment: GET SYNTAX OF FILE NAME
569A
If the NZ FLAG is set the filespec is not valid: JUMP to 521DH (ERR3) to report error 10 (required command parameter not found).
Original Source Code Comment: EXIT IF SYNTAX ERROR
569DKILL0
PUSH HL E5
Save the contents of Register Pair HL to the top of the stack.
Original Source Code Comment: SAVE REGS
569E
PUSH DE D5
Save the contents of Register Pair DE to the top of the stack.
569F
LD HL,56BAHLD HL,KILMSG 21 BA 56
Let Register Pair HL equal 56BAH, to point to the message "'KILLING '".
Original Source Code Comment: POINT TO 'KILLING' MSG
56A2
GOSUB to 021BH.
NOTE: 021BH is the Model III ROM routine to display the characters at (HL) until a 03H or a 0DH (which is shown) is found.
Original Source Code Comment: PRINT IT
56A5
LD HL,6162HLD HL,S9DCB1 21 62 61
Let Register Pair HL equal 6162H which is the beginning of the SOURCE FILE DCB, which is also the filespec.
Original Source Code Comment: POINT TO THE FILE NAME
56A8
Display the filespec in the SOURCE FILE DCB (Register Pair HL = 6162H) after the "Killing " message via a GOSUB to 5310H (PRNTIT).
Original Source Code Comment: PRINT IT ALSO
56AB
POP DE D1
Put the value held at the top of the STACK into Register Pair DE, and then remove the entry from the stack.
Original Source Code Comment: RESTORE THE REGIS
56AC
POP HL E1
Put the value held at the top of the STACK into Register Pair HL, and then remove the entry from the stack.
56AD
Open the file via a GOSUB to 4424H (OPEN) with the DCB at Register Pair DE, the buffer at Register Pair HL and the LRL in Register B.
NOTE: 4424H is the SYS0 vector OPEN: LD A,92H / RST 28H, SYS2 entry 1.
Original Source Code Comment: GO OPEN THE FILE
56B0
If the NZ FLAG (Not Zero) has been set, then that CALL returned an error; report the error and abort via a JUMP to 5223H.
Original Source Code Comment: EXIT IF ERROR
56B3
Kill the file via a GOSUB to 442CH.
NOTE: 442CH is the SYS0 vector KILL (JP 42CEH, KILFIL), which runs SYS3 entry 2 for the open file whose DCB is at Register Pair DE; Z = no error.
Original Source Code Comment: NOW KILL IT
56B6
If the NZ FLAG (Not Zero) has been set, then that CALL returned an error; report the error and abort via a JUMP to 5223H.
Original Source Code Comment: EXIT IF ERROR
56B9
RET C9
RETurn to the caller.

56BAH - KILMSG - MESSAGE and STORAGE AREA for KILL.

56BAKILMSG
DEFB 1DH 1D
KILMSG: 1DH, move the cursor to the start of the line.
Original Source Code Comment: MOVE TO BEG OF LINE CHAR
56BB
DEFB 1EH 1E
1EH, erase to the end of the line.
Original Source Code Comment: ERASE TO END OF LINE CHAR
56BC-56C3
DEFM 'Killing ' 4B 69 6C 6C 69 6E 67 20
Text 'Killing '.
56C4
DEFB 03H 03
03H ends the message.
Original Source Code Comment: TERMINATOR

56C5H - ADDD - MESSAGE and STORAGE AREA for PATCH (the option names, the address, the FIND and CHG strings and the flags).

56C5ADDD
DEFB 04H 04
ADDD: 04H, the length of the text that follows (DEFT).
56C6-56C9
DEFM 'ADD=' 41 44 44 3D
Text 'ADD=', compared with the command line by COMPAR.
56CAFINDD
DEFB 05H 05
FINDD: 05H, the length of the text that follows.
56CB-56CF
DEFM 'FIND=' 46 49 4E 44 3D
Text 'FIND='.
56D0CHGG
DEFB 04H 04
CHGG: 04H, the length of the text that follows.
56D1-56D4
DEFM 'CHG=' 43 48 47 3D
Text 'CHG='.
56D5-56D6ADD1
DEFW 0000H 00 00
ADD1: the ADD= address PATCH looks for (PLOOP3). COPY uses the two bytes for the source LRL (5384H) and EOF byte (538AH) in a single drive copy.
Original Source Code Comment: USER ADDRESS TO PATCH
56D7-56F6FIND
DEFS 32
FIND: 32 bytes, the length byte (5792H) and the bytes of the FIND= string (MOVLTH from 56D8H). COPY uses 56D7H-56D8H for the source ERN. Not in the file.
Original Source Code Comment: BUFFER FOR FIND STRING
56F7-5716CHAG99
DEFS 32
CHAG99: 32 bytes, the length byte (57B1H) and the bytes of the CHG= string (from 56F8H). Not in the file.
Original Source Code Comment: BUFFER FOR CHANGE STRING
5717CHGFLG
DEFB 00H 00
CHGFLG: 00H, set non zero at 586CH when the change was made; PATEN1 (58A3H) reads it.
Original Source Code Comment: FLAG TO SHOW CHANGE OR NOT
5718FNDFLG
DEFB 00H 00
FNDFLG: 00H, set non zero at 5844H when the ADD= address was found in a block of the file; PATEND (5897H) reads it.
Original Source Code Comment: FLAG TO SHOW FIND ADDRESS OR NOT
5719-571AERNSAV
DEFW 0000H 00 00
ERNSAV: the ERN of the file being patched, stored at 57FAH (nothing in this file reads it back).
Original Source Code Comment: END REC NUM SAVE

571BH - PATCH Main Routine.

571BPATCH
LD A,(HL) 7E
Fetch the first character of the COMMAND LINE (held in the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET THE CHARACTER FROM THE COMMAND LINE
571C
CP 2AHCP '*' FE 2A
Compare the value held in Register A against 2AH (ASCII: *). Results: If Register A equals *, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: ASKING FOR SYSTEM FILES?
571E
If the character was a *, then the Z FLAG (Zero) would have been set, and the user requested to patch a SYSTEM file; so JUMP to 58FEH.
Original Source Code Comment: YES, DO IT
5721
If we are here, then the user wants to patch a user file (and a filename would be needed). Process the COMMAND LINE filename (i.e., set Register Pair DE to point to the SOURCE FILE DCB, check the syntax of the associated Filespec, and RETurn) via a GOSUB to 59BCH.
Original Source Code Comment: CHECK SYNTAX OF FILESPEC
5724
If the NZ FLAG is set the filespec is not valid: JUMP to 521DH (ERR3) to report error 10 (required command parameter not found).
Original Source Code Comment: EXIT IF ERROR
5727PAT0
Get the next non-space COMMAND LINE character via a GOSUB to 5F8EH.
Original Source Code Comment: SKIP SPACES
572A
CP 0DH FE 0D
Compare the value held in Register A against 0DH (ASCII: ENTER). Results: If Register A equals ENTER, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: END OF LINE?
572C
If the next character was an CARRIAGE RETURN then the Z FLAG (Zero) will have been set, and we didn't get enough information. Exit with an error via a JUMP to 521DH.
Original Source Code Comment: YES, ERROR
572F
CP 28HCP '(' FE 28
Compare the value held in Register A against 28H (ASCII: (). Results: If Register A equals (, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: START OF LIST?
5731
If the next character wasn't a (, the NZ FLAG (Not Zero) will have been set, and we did not get the character we needed to proceed. JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: NO, ERROR
5734
INC HL 23
INCrement the value stored in Register Pair HL by 1 so as to point to the first character after the parenthesis.
Original Source Code Comment: BUMP TO 1ST CHAR
5735
LD DE,56C5HLD DE,ADDD 11 C5 56
Point DE to the parameter table in RAM by setting Register Pair DE to equal 56C5H, which is the start of the PATCH routine lookup area, and points to the "ADD=" message.
Original Source Code Comment: DE => 'ADD=' COMPARE
5738
LD A,(DE) 1A
That table is broken down into a byte for the length of the message, and then the message. Fetch the value held in the memory location pointed to by Register Pair DE, which will be the length of the "ADD=" label, and store it into Register A.
Original Source Code Comment: GET THE LENGTH
5739
LD C,A 4F
Set Register C = length of the "ADD=" label (04H)
Original Source Code Comment: INTO BC
573A
LD B,00HLD B,0 06 00
Clear B to complete the BC register pair
573C
INC DE 13
Point Register Pair DE to the next byte in the table (i.e., the beginning of the message "ADD=").
Original Source Code Comment: POINT TO TEXT
573D
Check to see if the command line paramter matches the label set in DE (in this case, checking to see if the user's next command letters were "ADD=") via a GOSUB to 5B70H.
Original Source Code Comment: DO THE COMPARE
5740
If the user didn't have "ADD=" as the next characters the NZ FLAG (Not Zero) will have been set, so JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: NO MATCH, PARAM ERROR
5743
ADD HL,BC 09
Advance the pointer to the command line (i.e., Register Pair HL) to the end of that label by letting Register Pair HL = Register Pair HL (the current position on the COMMAND LINE) + Register BC (the length of the label we just checked).
Original Source Code Comment: BUMP PAST ADD=
5744
PUSH HL E5
We are now going to need to parse for a value, so save the contents of Register Pair HL (i.e., the pointer to the characters following the "ADD=" label on the command line) to the top of the stack.
Original Source Code Comment: PUT THE POINTER INTO IX
5745
POP IX DD E1
Restore HL into Register Pair IX.
5747
LD HL,0000HLD HL,0 21 00 00
Let Register Pair HL equal 0000H as a base for math.
Original Source Code Comment: CLEAR AN ACCUMULATOR
574APLOOP1
LD A,(IX+00H)LD A,(IX) DD 7E 00
Fetch the next character of the ADD= value on the command line (the byte Register IX points to) into Register A.
Original Source Code Comment: GET A DIGIT

The next few instructions compare the character to 0, : (i.e., 1 above 9), A, and G (i.e., 1 above F) to make sure that it is in the range of a valid hex character.

574D
CP 30HCP '0' FE 30
Compare the value held in Register A against 30H (ASCII: 0). Results:
  • If Register A equals 0, the Z FLAG is set.
  • If A < 0, the CARRY FLAG will be set.
  • if A >= 0, the NO CARRY FLAG will be set.

Original Source Code Comment: NUMERIC?
574F
If A < 0 then the C FLAG (Carry) will have been set to indicate that the character was too low to be a valid hex character (i.e., it is below "0"), JUMP to 5771H.
Original Source Code Comment: YES, EXIT
5751
CP 3AHCP '9'+1 FE 3A
Compare the value held in Register A against 3AH (1 more than ASCII: 9). Results:
  • If Register A equals 1 more than 9, the Z FLAG is set.
  • If A < 1 more than 9, the CARRY FLAG will be set.
  • if A >= 1 more than 9, the NO CARRY FLAG will be set.
5753
If Register A is below 3AH (one more than "9") the C FLAG (Carry) is set: the character is a digit "0"-"9", so JUMP to 575DH (PLOOP2) to add it to the address.
Original Source Code Comment: YES
5755
CP 41HCP 'A' FE 41
Compare the value held in Register A against 41H (ASCII: A). Results:
  • If Register A equals A, the Z FLAG is set.
  • If A < A, the CARRY FLAG will be set.
  • if A >= A, the NO CARRY FLAG will be set.

Original Source Code Comment: ALPHA?
5757
If Register A is below 41H ("A") the C FLAG (Carry) is set: the character is between "9" and "A" and is not a hex digit, so JUMP to 5771H (PLOOP3) to end the value.
Original Source Code Comment: NO, EXIT
5759
CP 47HCP 'F'+1 FE 47
Compare the value held in Register A against 47H (ASCII: G). Results:
  • If Register A equals G, the Z FLAG is set.
  • If A < G, the CARRY FLAG will be set.
  • if A >= G, the NO CARRY FLAG will be set.
575B
If Register A is 47H ("G") or above the NC FLAG (No Carry) is set: the character is above "F" and is not a hex digit, so JUMP to 5771H (PLOOP3) to end the value.

The next few instructions turn the validated hex character into decimal.

575DPLOOP2
ADD HL,HL 29
LET Register Pair HL (the address built so far) = HL + HL, a shift left of one bit (1 of 4); four shifts multiply it by 16 to make room for the new hex digit.
Original Source Code Comment: HL:=HL*16
575E
ADD HL,HL 29
LET Register Pair HL = HL + HL (2 of 4): Register Pair HL is now the old address times 4.
575F
ADD HL,HL 29
LET Register Pair HL = HL + HL (3 of 4): Register Pair HL is now the old address times 8.
5760
ADD HL,HL 29
LET Register Pair HL = HL + HL (4 of 4): Register Pair HL is now the old address times 16, with bits 3-0 clear for the new digit.
5761
SUB 30HSUB '0' D6 30
SUBtract the value 30H from Register A. Note: Subtracting 30H from from Register A will convert an ASCII number '0'-'9' to its decimal equivalent (i.e., 6 in ASCII is 36H in Hex; so 36H-30H = 6).
Original Source Code Comment: MASK OFF ASCII
5763
CP 0AHCP 10 FE 0A
Compare the value held in Register A against 0AH (Decimal: 10). Results:
  • If Register A equals 10, the Z FLAG is set.
  • If A < 10, the CARRY FLAG will be set.
  • if A >= 10, the NO CARRY FLAG will be set.

Original Source Code Comment: ALPHA?
5765
If A < 10 then the C FLAG (Carry) will have been set and we are done converting the character, so JUMP to 5769H.
Original Source Code Comment: NO
5767
SUB 07HSUB 7 D6 07
SUBtract 07H from Register A, which turns the letters "A"-"F" (11H-16H after the SUB 30H) into 0AH-0FH.
Original Source Code Comment: YES, CORRECT

The parameter character is now a decimal number held in Register A.

5769PLOP2
LD E,A 5F
Copy the value of the hex digit (00H-0FH, Register A) into Register E.
Original Source Code Comment: NEW DIGIT INTO DE
576A
LD D,00HLD D,0 16 00
Let Register D equal 00H so that Register Pair DE = Register A.
576C
ADD HL,DE 19
LET Register Pair HL = the old character address value (held in Register Pair HL) + the new value (held in Register Pair DE).
576D
INC IX DD 23
INCrement the value stored in Special Index Register IX by 1 to point to the next digit/character in the ADD= field in the command line.
Original Source Code Comment: BUMP TO NEXT DIGIT
576F
LOOP BACK to 574AH until the end of the parameter is reached.
Original Source Code Comment: AND CONTINUE

5771H - PLOOP3 - Continuation of the PATCH command. Jumped here if we were given an invalid hex character on the ADD= portion of the command line. A is holding the character from the COMMAND LINE which we know is NOT a valid hex character.

5771PLOOP3
LD (56D5H),HLLD (ADD1),HL 22 D5 56
Store the address (held in Register Pair HL) into the desingated memory location to hold the patch address (i.e., 56D5H).
Original Source Code Comment: SAVE THE ADDRESS
5774
CP 2CHCP ',' FE 2C
Compare the character in Register A against 2CH (ASCII: ,). Results: If Register A equals 2CH, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: COMMA?
5776
If the character after the ADD= value is not a comma (2CH) the NZ FLAG is set and the command line is wrong: JUMP to 5219H (ERR2) to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: NO, BAD PARAM
5779
PUSH IX DD E5
Save Register IX (the command line pointer, at the character after the ADD= value) to the STACK ...
Original Source Code Comment: MOVE THE POINTER BACK TO HL
577B
POP HL E1
... and fetch it into Register Pair HL.
577C
INC HL 23
Skip over the "," on the command line by pointing to the next character on the COMMAND LINE by INCrementing the value stored in Register Pair HL by 1.
Original Source Code Comment: BUMP PAST ','
577D
LD DE,56CAHLD DE,FINDD 11 CA 56
Let Register Pair DE equal 56CAH, which is in the PATCH routine lookup area, and points to the "FIND=" message.
Original Source Code Comment: DE => 'FIND=' COMPARE
5780
LD A,(DE) 1A
Fetch the first byte at that message, which is the length of the "FIND=" command (i.e., 5) and store it into Register A.
Original Source Code Comment: GET THE LENGTH
5781
INC DE 13
Move past the length byte to the message by INCrementing the value stored in Register Pair DE by 1. DE now points to the "FIND=" text.
Original Source Code Comment: POINT TO TEXT
5782
LD C,A 4F
Set C to length of "FIND=" (5 characters)
Original Source Code Comment: INTO BC
5783
LD B,00HLD B,0 06 00
Clear B to complete the BC register pair
5785
Check to see if the command line text at Register Pair HL is "FIND=" (Register Pair DE, BC = 5 characters) via a GOSUB to 5B70H (COMPAR).
Original Source Code Comment: DO THE COMPARE
5788
If the NZ FLAG (Not Zero) has been set, then the user label didn't match the required "FIND=" label, which is bad, so JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: EXIT IF NO MATCH
578B
ADD HL,BC 09
Advance Register Pair HL to the user provided value associated with a "FIND=" lead in by setting Register Pair HL = the current location on the COMMAND LINE (held in Register Pair HL) + the length of the text "FIND=" (held in Register BC).
Original Source Code Comment: HL => FIND STRING
578C
LD DE,56D8HLD DE,FIND+1 11 D8 56
Let Register Pair DE equal 56D8H to point to the FIND FIELD storage buffer of 31 characters.
Original Source Code Comment: PLACE TO STORE IT
578F
Decode the FIND FIELD input via a GOSUB to 58C0H. Routine returns with DE pointing to the converted field and Register A holding the length of the field.
Original Source Code Comment: MOVE IT AND GET LENGTH
5792
LD (56D7H),ALD (FIND),A 32 D7 56
Store the number of bytes MOVLTH decoded from the FIND= value (Register A) into 56D7H, the length byte of the FIND area.
Original Source Code Comment: SAVE THE LENGTH
5795
LD A,(HL) 7E
Fetch the next character on the command line (in the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET THE NEXT CHAR
5796
CP 2CHCP ',' FE 2C
Compare the character in Register A against 2CH (ASCII: ,). Results: If Register A equals 2CH, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: COMMA?
5798
If the character after the FIND= value is not a comma (2CH) the NZ FLAG is set and the command line is wrong: JUMP to 5219H (ERR2) to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: EXIT IF NOT
579B
INC HL 23
If we're here then we got the "," and are still working on a valid command line. Point HL to the next character on the command line.
Original Source Code Comment: BUMP TO NEXT CHAR
579C
LD DE,56D0HLD DE,CHGG 11 D0 56
Let Register Pair DE equal 56D0H, which is in the PATCH routine lookup area, and points to the "CHG=" message.
Original Source Code Comment: DE => 'CHG=' COMPARE
579F
LD A,(DE) 1A
Fetch the first byte at that message, which is the length of the "CHG=" command (i.e., 4) and store it into Register A.
Original Source Code Comment: GET THE LENGTH
57A0
INC DE 13
INCrement the value stored in Register Pair DE by 1 to now point to the "CHG=" text.
Original Source Code Comment: BUMP TO TEXT
57A1
LD C,A 4F
Set C to length of "CHG=" (4 characters)
Original Source Code Comment: PUT THE LENGTH INTO BC
57A2
LD B,00HLD B,0 06 00
Clear B to complete the BC register pair
57A4
Check to see if the command line text at Register Pair HL is "CHG=" (Register Pair DE, BC = 4 characters) via a GOSUB to 5B70H (COMPAR).
Original Source Code Comment: DO THE COMPARE
57A7
If the NZ FLAG (Not Zero) has been set, then the user label didn't match the required "CHG=" label, which is bad, so JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: EXIT IF PARAM ERROR
57AA
ADD HL,BC 09
Advance Register Pair HL past the "CHG=" (Register Pair BC = 4) to the value on the command line.
Original Source Code Comment: HL => CHANGE STRING
57AB
LD DE,56F8HLD DE,CHAG99+1 11 F8 56
Let Register Pair DE equal 56F8H to point to the CHANGE FIELD storage buffer of 31 characters.
Original Source Code Comment: PLACE TO STORE IT
57AE
Decode the CHANGE FIELD input via a GOSUB to 58C0H. Routine returns with DE pointing to the converted field and Register A holding the length of the field.
Original Source Code Comment: MOVE IT AND GET LENGTH
57B1
LD (56F7H),ALD (CHAG99),A 32 F7 56
Store the the length of the given change field (held in Register A after the CALL to 58C0H) into memory location 56F7H.
Original Source Code Comment: SAVE THE LENGTH
57B4
LD B,A 47
Let Register B = the length of the given change field (held in Register A after the CALL to 58C0H).
Original Source Code Comment: SAVE THE LENGTH
57B5
LD A,(56D7H)LD A,(FIND) 3A D7 56
Fetch the length of the given find field (held in memory location 56D7H) and store it into Register A.
Original Source Code Comment: SEE IF THEY ARE THE SAME
57B8
CP B B8
Check to see if the length of the FIND field (held in Register A) and the length of the CHANGE field (held in Register B) are the same. Results: If Register A equals the value held in Register B, the Z FLAG is set; otherwise the NZ FLAG is set.
57B9
If they FIND and CHG fields were not the same length, the NZ FLAG (Not Zero) will have been set. JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: NO, BAD PARAM

If we are here, then we have the FIND field and the CHANGE fields stored and they are of matching length.

57BC
XOR A AF
Set Register A to ZERO and clear all Flags so that we can put a 00H into some memory locations.
Original Source Code Comment: CLEAR OUT A
57BD
LD (5717H),ALD (CHGFLG),A 32 17 57
Store the 00H held in Register A into 5717H (CHGFLG), the flag that shows whether the change was made.
Original Source Code Comment: SET FOR NO CHANGE MADE
57C0
LD (5718H),ALD (FNDFLG),A 32 18 57
Store the value held in Register A into memory location 5718H (which points to the ADDRESS FOUND flag).
Original Source Code Comment: SET FOR DIDN'T FIND
57C3
LD A,(599AH)LD A,(SYSFLG) 3A 9A 59
Fetch the value held in memory location 599AH (i.e., the SYSTEM OVERLAY FLAG for the PATCH routine; NZ if system file being patched) and store it into Register A.
Original Source Code Comment: SEE IF DOING SYSTEM FILES
57C6
OR A B7
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
57C7
If patching file overlay system then we are going to want to skip the FILE OPEN portion of this routine, JUMP to 57D8H.
Original Source Code Comment: YES, BYPASS OPEN
57C9
LD IYL, 0FFHLD YL,SCAFLG.LSB. FD 2E FF
Set IY low byte to FFH (part of protection override flag address)
Original Source Code Comment: SET THE PROTECTION OVER-RIDE FLAG
57CC
LD IYH, 42HLD YH,SCAFLG.MSB. FD 26 42
Set IY high byte to 42H, resulting in IY = 42FFH
57CF
DEC (IY+00H)DEC (IY) FD 35 00
Turn off the password check by DECrementing the value stored in the memory location pointed to by Special Index Register IY+00H by 1.
57D2
OPEN the file via a GOSUB to 599BH.
Original Source Code Comment: OPEN THE FILE
57D5
If the NZ FLAG (Not Zero) has been set, then that CALL returned an error; report the error and abort via a JUMP to 5223H.
Original Source Code Comment: EXIT IF ERROR
57D8PATL00
LD A,(6163H)LD A,(S9DCB1+PROT) 3A 63 61
Fetch the file status/protection byte (held in memory location 6163H) and store it into Register A.
Original Source Code Comment: GET THE STATUS/PROTECTION LEVEL
57DB
AND 0F8H E6 F8
MASK the value of Register A against 0F8H (1111 1000) to zero out the 3 bytes consisting of the access code, thus granting full access.
Original Source Code Comment: INSURE FULL ACCESS
57DD
LD (6163H),ALD (S9DCB1+PROT),A 32 63 61
Put the masked file status/protection byte back into memory location 6163H (where the options byte is stored).
Original Source Code Comment: PUT IT BACK
57E0
LD HL,(6172H)LD HL,(S9DCB1+EXTBEG) 2A 72 61
Fetch the first extent element (held in memory location 6172H) and store it into Register Pair HL.
Original Source Code Comment: GET THE 1ST EXTENT
57E3
LD A,L 7D
The LSB of the extent element (i.e., Register L) is the track number, so copy the track number (held in Register L) into Register A.
Original Source Code Comment: IS THIS SYS 0?
57E4
OR A B7
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
Original Source Code Comment: IS THIS SYS 0?
57E5
If we are not at SYS00/SYS, then tne NZ flag will be set, so skip the next few command via a JUMP to 57F3H.
Original Source Code Comment: NO, CONTINUE
57E7
LD A,H 7C
Let's double check to make sure we aren't at SYS00/SYS. First, copy the gran offset into the track (held in the MSB of the extent element; currently in Register H) into Register A.
Original Source Code Comment: FINAL CHECK
57E8
AND 0E0H E6 E0
MASK the value of Register A against 0E0H (1110 0000) to mask off the number of grans.
Original Source Code Comment: MASK OFF NUMBER OF GRANS
57EA
If that is still not zero, then the user is not trying to patch OVERLAY 0 then the NZ FLAG (Not Zero) will have been set, so skip the next few command via a JUMP to 57F3H.
Original Source Code Comment: NOT SYS 0
57EC
LD A,(616CH)LD A,(S9DCB1+NRNL) 3A 6C 61
Fetch the "next sector" number (held in memory location 616CH) and store it into Register A.
Original Source Code Comment: GET THE NEXT RECORD NUMBER
57EF
INC A 3C
INCrement the value stored in Register A by 1 so that Register A will never be 0 (and hence, will never patch the BOOT file).
Original Source Code Comment: FOOL GETPDA TO BYPASS BOOT SECTOR
57F0
LD (616CH),ALD (S9DCB1+NRNL),A 32 6C 61
Store the bumped "next sector" (held in Register A) into the "next sector" memory location of 616CH.
Original Source Code Comment: SET NEW RECORD NUMBER
57F3PATL01
Read the first sector via a GOSUB to 58B3H.
Original Source Code Comment: DO FIRST READ ON FILE
57F6
LD BC,(616EH)LD BC,(S9DCB1+ERNL) ED 4B 6E 61
Fetch the EOF sector (head in memory location 616EH) and store it into Register Pair BC.
Original Source Code Comment: GET ERN
57FA
LD (5719H),BCLD (ERNSAV),BC ED 43 19 57
Store the EOF sector into memory location 5719H (which is the designated storage location of the EOF sector number).
Original Source Code Comment: SAVE ERN

Next, we need to get a block of data from the file.

57FEPATLO0
LD A,(HL) 7E
Fetch the byte of data held in the buffer memory location pointed to by Register Pair HL and store it into Register A.
Original Source Code Comment: GET CHARACTER FROM BUFF
57FF
CP 01HCP 1 FE 01
Compare the value held in Register A against 01H to see if it is a CODE BLOCK. Results: If Register A equals 01H, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: LOAD FILE CHARACTER?
5801
If the Z FLAG (Zero) has been set, JUMP to 5816H to process a CODE BLOCK.
Original Source Code Comment: GO IF SO
5803
CP 02HCP 2 FE 02
Compare the value held in Register A against 02H to see if it is an EXECUTION ADDRESS. Results: If Register A equals 02H, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: END OF FILE CHARACTER?
5805
If the Z FLAG (Zero) has been set, JUMP to 5897H to display the results of the Patch.
Original Source Code Comment: DONE IF SO
5808
CP 03HCP 3 FE 03
Compare the value held in Register A against 03H to see if it is an END OF FILE CHARACTER. Results: If Register A equals BREAK, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: END OF FILE CHARACTER?
580A
If the Z FLAG (Zero) has been set, JUMP to 5897H to display the results of the Patch.
Original Source Code Comment: DONE IF SO
580D
CP 21H FE 21
Compare the value held in Register A against 21H to see if it is a COMMENT BLOCK. Results:
  • If Register A equals 21H, the Z FLAG is set.
  • If A < 21H, the CARRY FLAG will be set.
  • if A >= 21H, the NO CARRY FLAG will be set.

Original Source Code Comment: COMMENT OR SUCH?
580F
If the C FLAG (Carry) has been set, JUMP to 5888H to throw away the comment block.
Original Source Code Comment: BYPASS IF SO
5811
LD A,22HLD A,ELFFE 3E 22
If we haven't jumped away, then we have an invalid block. Let Register A equal 22H to indicate an INVALID FILE FORMAT error.
Original Source Code Comment: LOAD FILE FORMAT ERROR
5813
Report the error and abort via a JUMP to 5223H.
Original Source Code Comment: EXIT TO ERROR

5816H - PATCHK - Continuation of the PATCH command. Read a CODE BLOCK from the file

5816PATCHK
INC HL 23
Point to the next byte in the buffer holding the CODE BLOCK of the file via a bump to Register Pair HL.
Original Source Code Comment: GET NEXT CHARACTER IN BUFF
5817
LD B,(HL) 46
Fetch the next byte of the CODE BLOCK, which is the field size/character count, and put that into Register B.
Original Source Code Comment: PUT CHARACTER COUNT IN B
5818
INC HL 23
Point to the next byte of the CODE BLOCK (the load address) in the file via a bump to Register Pair HL.
Original Source Code Comment: POINT TO LOAD ADDRESS
5819
LD E,(HL) 5E
Fetch the next byte of the CODE BLOCK, which is the LSB of the LOAD ADDRESS, and put that into Register B.
Original Source Code Comment: GET LSB OF LOAD ADDRESS
581A
DEC B 05
DECrement the field size/character count (held in Register B) by 1 byte.
Original Source Code Comment: BUMP COUNT FOR IT
581B
INC HL 23
Fetch the next byte of the CODE BLOCK, which is the MSB of the LOAD ADDRESS, and put that into Register B.
581C
LD D,(HL) 56
Fetch the next byte of the CODE BLOCK, which is the data address MSB, and put that into Register B.
Original Source Code Comment: GET MSB OF LOAD ADDRESS
581D
DEC B 05
DECrement the field size/character count (held in Register B) by 1 byte.
Original Source Code Comment: BUMP COUNT FOR IT
581E
PUSH HL E5
Save the pointer in the buffer to the current location of the CODE BLOCK (held in Register Pair HL) to the top of the stack.
Original Source Code Comment: SAVE BUFFER LOCATION
581F
PUSH DE D5
Save the LOAD ADDRESS (held in Register Pair DE) to the top of the stack.
Original Source Code Comment: SAVE LOAD ADDRESS
5820
If Register B isn't zero then the NZ FLAG (Not Zero) will have been set, meaning we have more data to read so JUMP to 5825H.
Original Source Code Comment: IF B<>0 THEN COUNT NOT 256
5822
SCF 37
Register B is 0, which means 256 data bytes (a count byte of 02H). Set the CARRY FLAG so that PATCH1 adds 1 to the MSB: Register Pair DE becomes the load address plus 256.
Original Source Code Comment: B=0 OR B=256 - SET ADD ACCOURDINGLY
5823
JUMP to 5828H to offset the address.
Original Source Code Comment: GO OFFSET ADDRESS

5825H - PATCH0 - Continuation of the PATCH command's CODE BLOCK routine; jumped here when Register B (the number of data bytes) is not 0, to make Register Pair DE the load address plus B.

The next few instructions are to set DE to be DE + the length of the field. This requires some math. First, work the LSB of Register Pair DE.

5825PATCH0
LD A,E 7B
Copy the LSB of the load address (Register E) into Register A.
Original Source Code Comment: PUT LSB INTO A
5826
ADD A,B 80
Add the number of data bytes (Register B) to it; CARRY when the block crosses a page.
Original Source Code Comment: ADD CHAR COUNT TO IT
5827
LD E,A 5F
Store the result back into Register E.
Original Source Code Comment: NEW LSB ADDRESS
5828PATCH1
LD A,D 7A
Copy the MSB of the load address (Register D) into Register A.
Original Source Code Comment: PUT MSB INTO A
5829
ADC A,00HADC A,0 CE 00
Add the carry from the LSB into Register A.
Original Source Code Comment: ANY CARRY, ADD IT
582B
LD D,A 57
Store it back into Register D: Register Pair DE = the address just above the last byte of this block.
Original Source Code Comment: DE => LOAD ADDRESS + COUNT
582C
LD HL,(56D5H)LD HL,(ADD1) 2A D5 56
Fetch the user requested patch address from its storage place (in memory location 56D5H) into Register Pair HL.
Original Source Code Comment: GET THE ASKED FOR ADDRESS
582F
OR A B7
Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG, which we will need cleared for the next operation).
Original Source Code Comment: CLEAR FLAGS
5830
SBC HL,DE ED 52
Subtract that end address (Register Pair DE) from the address asked for (Register Pair HL, ADD1). NC means the address asked for is at or above the end of this block.
Original Source Code Comment: SUBTRACT END ADD FROM ASKED
5832
POP DE D1
Restore the load address of the block from the STACK into Register Pair DE.
Original Source Code Comment: RESTORE STACK PROPERLY
5833
POP HL E1
Restore the buffer pointer (at the MSB of the load address in the sector buffer) from the STACK into Register Pair HL.
5834
If the NC FLAG is set the address is not in this block: JUMP to 588AH (DLYLO1) to skip its B data bytes and go to the next block.
Original Source Code Comment: IF NO CARRY, LOAD ADDRESS TOO LOW
5836
PUSH HL E5
Save the buffer pointer (Register Pair HL) to the STACK.
Original Source Code Comment: SAVE BUFFER ADD
5837
LD HL,(56D5H)LD HL,(ADD1) 2A D5 56
Fetch the patch address from its storage place (in memory location 56D5H) into Register Pair HL.
Original Source Code Comment: GET ASKED ADDRESS
583A
OR A B7
Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
Original Source Code Comment: CLEAR FLAGS
583B
SBC HL,DE ED 52
Subtract the load address (Register Pair DE) from the address asked for (Register Pair HL): HL = the offset of that address in this block (CARRY when the address is below the block).
Original Source Code Comment: ASKED ADD - LOAD ADD
583D
LD B,L 45
Copy the LSB of the offset (Register L) into Register B; the offset is below 256 because the address is inside this block.
Original Source Code Comment: SAVE DIFFERENCE IN B
583E
POP HL E1
Restore the buffer pointer from the STACK into Register Pair HL.
Original Source Code Comment: RESTORE BUFFER ADD
583F
If the C FLAG is set the address asked for is below this block: JUMP to 588AH (DLYLO1) to skip the block.
Original Source Code Comment: IF CARRY, TOO LOW
5841
INC L 2C
INCrement Register L to point from the MSB of the load address to the first data byte of the block.
Original Source Code Comment: BUMP PAST THE MSB OF LOAD ADDRESS
5842
OR 01HOR 1 F6 01
OR Register A with 01H so that it is not zero, for the flag below.
Original Source Code Comment: FORCE NON-ZERO
5844
LD (5718H),ALD (FNDFLG),A 32 18 57
Store the non-zero Register A into 5718H (FNDFLG): the address was found in the file.
Original Source Code Comment: SHOW WE'VE FOUND ADDRESS
5847
LD A,B 78
Copy the offset in the block (Register B) into Register A.
Original Source Code Comment: GET THE BYTE COUNT OFFSET
5848
OR A B7
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
Original Source Code Comment: ANY OFFSET?
5849
If the offset is 0 the Z FLAG is set and Register Pair HL already points at the byte: JUMP to 5851H (PATCH3).
Original Source Code Comment: NO, BYPASS DJNZ
584BPATCH2
INC L 2C
INCrement Register L to the next byte of the sector buffer (6300H-63FFH).
Original Source Code Comment: NOW GET TO SPECIFIC ADD
584C
If Register L wrapped to 00H the Z FLAG is set: GOSUB to 58B3H (REDIT) to read the next sector of the file into 6300H.
Original Source Code Comment: IF OUT OF BUFFER, READ NEXT SECTOR
584F
DECrement the offset (Register B) and LOOP back to 584BH until Register Pair HL points at the address asked for.
5851PATCH3
LD DE,56D7HLD DE,FIND 11 D7 56
Let Register Pair DE equal 56D7H (FIND), the length byte of the FIND string.
Original Source Code Comment: DE => FIND STRING
5854
LD A,(DE) 1A
Fetch the length of the find field from the memory location pointed to by Register Pair DE and store it into Register A.
Original Source Code Comment: GET THE LENGTH
5855
INC DE 13
INCrement the value stored in Register Pair DE by 1 so that it now points to the 31 byte storage location for the FIND FIELD.
Original Source Code Comment: BUMP TO TEXT
5856
LD C,A 4F
Copy the field length (held in Register A) into Register C.
Original Source Code Comment: PUT THE LENGTH INTO BC
5857
LD B,00HLD B,0 06 00
Let Register B equal 00H so that Register Pair BC will hold the field length.
5859
Compare the bytes in the buffer (Register Pair HL) with the FIND string (Register Pair DE), Register Pair BC bytes, via a GOSUB to 5B70H (COMPAR), which keeps BC, DE and HL. The comparison does not follow the file into the next sector.
Original Source Code Comment: DO THE COMPARISON
585C
If the NZ FLAG (Not Zero) has been set, the FIND= bytes do not match the bytes at the ADD= address: JUMP to 59C2H (PATERR) to show 'String NOT Found' and ABORT.
Original Source Code Comment: IF NOT, TELL USER SO
585F
LD DE,56F8HLD DE,CHAG99+1 11 F8 56
Let Register Pair DE equal 56F8H to point to the CHANGE FIELD storage buffer of 31 characters.
Original Source Code Comment: DE => CHANGE STRING
5862
Compare the same bytes (Register Pair HL, BC bytes) with the CHG= string (Register Pair DE = 56F8H) via a GOSUB to 5B70H (COMPAR); Z when they are already the same.
Original Source Code Comment: ARE FIND AND CHANGE THE SAME?
5865
If the Z FLAG (Zero) has been set then what we wanted to check it to was actually what was there, so JUMP to 5897H to display the results of the patch.
Original Source Code Comment: YES. DON'T NEED TO CHANGE ANYTHING
5867
EX DE,HL EB
EXchange Register Pairs DE and HL: HL = the CHG= string, DE = the bytes in the buffer.
Original Source Code Comment: SWAP POINTERS
5868
LDIR ED B0
Copy the CHG= string (Register Pair HL) over the bytes in the sector buffer (Register Pair DE), Register Pair BC bytes, via LDIR.
Original Source Code Comment: MOVE IN THE NEW STRING
586A
OR 01HOR 1 F6 01
OR Register A with 01H (0000 0001) so that Register A is not zero, the value that marks the change as made.
Original Source Code Comment: FORCE NON-ZERO
586C
LD (5717H),ALD (CHGFLG),A 32 17 57
Store Register A (not zero) into 5717H (CHGFLG): the change has been made.
Original Source Code Comment: SHOW WE MADE CHANGE
586F
LD A,(599AH)LD A,(SYSFLG) 3A 9A 59
Fetch the value held in memory location 599AH (i.e., the SYSTEM OVERLAY FLAG for the PATCH routine; NZ if system file being patched) and store it into Register A.
Original Source Code Comment: IS THIS A SYSTEM FILE?
5872
OR A B7
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
5873
PUSH AF F5
Save the status flags from the check to see if this a SYSTEM FILE to the top of the stack.
Original Source Code Comment: SAVE THE FLAG
5874
If the NZ FLAG (Not Zero) has been set then we were working on a SYSTEM FILE, so we need to close it via a GOSUB to 5963H.
Original Source Code Comment: YES, CLOSE THE SYSTEM FILE
5877
POP AF F1
Restore the status flags into Register Pair AF, and then remove the entry from the stack.
Original Source Code Comment: GET THE FLAG BACK
5878
If the NZ FLAG (Not Zero) has been set then we were working on a SYSTEM FILE, so exit by JUMPing to 5897H to display the results of the patch.
Original Source Code Comment: EXIT IF SYSTEM FILE

If we are here, then we just patched a non-SYSTEM file.

587A
GOSUB to 59ADH (GETDCB): Register B = 00H, Register Pair DE = 6162H (S9DCB1) and Register Pair HL = 6300H.
Original Source Code Comment: SET REGISTERS UP FOR WRITE AND CLOSE
587D
Back the file up one record via a GOSUB to 4445H (BACKSP), so that the write below goes to the sector just read.
NOTE: 4445H is the SYS0 vector BACKSP: it lowers NRN (DCB offsets 0AH-0BH) of the file whose DCB is at Register Pair DE by one.
Original Source Code Comment: BACK UP ON LRL
5880
GOSUB to 59ADH (GETDCB) to set up Register B, Register Pair DE and Register Pair HL again for the write.
5883
Write the changed sector back with verify via a GOSUB to 443CH (VERF).
NOTE: 443CH is the SYS0 vector VERF (in this system it holds JP 47B3H): it writes the next record of the file whose DCB is at Register Pair DE; Z = no error, NZ with the error code in Register A.
Original Source Code Comment: WRITE & VERIFY
5886
JUMP to 5897H to disply the results of the patch and finish.
Original Source Code Comment: WE'RE DONE

5888H - DLYLOP - Continuation of the PATCH command to deal with a COMMENT BLOCK.

5888DLYLOP
INC HL 23
INCrement Register Pair HL from the block type byte (a comment block, below 21H other than 01H-03H) to its length byte.
Original Source Code Comment: BYPASS NO-USE DATA
5889
LD B,(HL) 46
Fetch the length of the block (the byte at Register Pair HL) into Register B.
Original Source Code Comment: GET CHARACTER COUNT
588ADLYLO1
INC L 2C
INCrement Register L to the next byte of the sector buffer.
588B
If the Z FLAG (Zero) has been set then we slipped to the next sector and ran out of buffer; so get the next sector via a GOSUB to 58B3H.
Original Source Code Comment: IF END OF BUFF, DO READ
588E
Skip the entire comment block (based on the field length byte) via a DJNZ LOOP back to 588AH, reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
5890
INC L 2C
INCrement Register L past the last byte of the block to the type byte of the next block.
5891
If the Z FLAG (Zero) has been set then we slipped to the next sector; so get the next sector via a GOSUB to 58B3H.
5894
JUMP to 57FEH to get the next block.

5897H - PATEND - Continuation of the PATCH command to display the results of the Patch and exit.

5897PATEND
LD A,(5718H)LD A,(FNDFLG) 3A 18 57
See if we found the address by fetching the "Requested Address Found" Flag from where it lives (memory location 5718H) and store it into Register A.
Original Source Code Comment: DID WE FIND ADDRESS?
589A
OR A B7
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
589B
If the NZ FLAG (Not Zero) has been set then we have found the requested address, so JUMP to 58A3H to see if we had to make a change.
Original Source Code Comment: IF SO, CHECK IF CHANGE
589D
LD HL,59E4HLD HL,NOFIND 21 E4 59
Let Register Pair HL equal 59E4H to point to the message "SPECIFIED ADDRESS NOT FOUND".
Original Source Code Comment: SHOW DIDN'T FIND ADD
58A0PATEN0
JUMP to 021BH.
NOTE: 021BH is the Model III ROM routine to display the characters at (HL) until a 03H or a 0DH (which is shown) is found. Since this was JUMPED to instead of CALLed, the RET at the end of this ROM routine will then RETurn to the caller of this subroutine instead of returning to this place.
Original Source Code Comment: PRINT AND EXIT TO DOS

58A3H - PATEN1 - Continuation of the PATCH command to display the results of the Patch if we have a match.

58A3PATEN1
LD A,(5717H)LD A,(CHGFLG) 3A 17 57
Fetch 5717H (CHGFLG) into Register A: not zero when the change was made.
Original Source Code Comment: DID WE CHANGE IT?
58A6
OR A B7
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
58A7
If the NZ FLAG (Not Zero) has been set, then the change field was NOT the same as the found field, which is bad; so skip via a JUMP to 58AEH.
Original Source Code Comment: IF SO, TELL USER
58A9
LD HL,5A01HLD HL,NOCHAG 21 01 5A
Let Register Pair HL equal 5A01H (NOCHAG), the message "NO Change Required".
Original Source Code Comment: SHOW DIDN'T CHANGE
58AC
JUMP to 58A0H to display the message pointed to by Register Pair HL and exit.
Original Source Code Comment: EXIT

58AEH - PATEN2 - Continuation of the PATCH command to display the results of a successful Patch.

58AEPATEN2
LD HL,59C8HLD HL,CHGMAD 21 C8 59
Let Register Pair HL equal 59C8H (CHGMAD), the message 'Patch Made' and 0DH.
Original Source Code Comment: SHOW CHANGE MADE
58B1
JUMP to 58A0H to display the message pointed to by Register Pair HL and exit.
Original Source Code Comment: EXIT

58B3H - REDIT - Continuation of the PATCH command. Subroutine to read a sector.

58B3REDIT
PUSH BC C5
Save the contents of Register Pair BC to the top of the stack.
Original Source Code Comment: SAVE BC
58B4
Set up for FILE I/O via a GOSUB to 59ADH to set up for FULL SECTOR I/O and sets up registers B, DE, and HL.
Original Source Code Comment: SET UP THE DCB
58B7
GOSUB to 4436H.
NOTE: 4436H is the SYS0 vector READ: it reads the next record (NRN, DCB offsets 0AH-0BH) of the file whose DCB is at Register Pair DE and advances NRN; Z = no error, NZ with the error code in Register A.
Original Source Code Comment: READ A RECORD
58BA
POP BC C1
Put the value held at the top of the STACK into Register Pair BC, and then remove the entry from the stack.
Original Source Code Comment: RESTORE BC
58BB
RET Z C8
If the Z FLAG (Zero) has been set then there was no error from that GOSUB, so RETurn to the caller.
Original Source Code Comment: EXIT IF GOOD
58BCREDI0
POP HL E1
There was a read error: discard the return address of the CALL to REDIT from the STACK (the error code stays in Register A).
Original Source Code Comment: DESTROY CALL TO READIT
58BD
Report the error and abort via a JUMP to 5223H.
Original Source Code Comment: AND REPORT ERROR

58C0H - MOVLTH - Part of the PATCH routine. This routine decodes an arbitrary length hexadecimal field. It is called related to the FIND and CHG fields given by the user. HL points to the source, and DE points to the destination.

58C0MOVLTH
LD B,00HLD B,0 06 00
Let Register B equal 00H as it will be a length counter.
Original Source Code Comment: CLEAR A COUNTER
58C2MOVLT1
LD A,(HL) 7E
Fetch the character held in the memory location pointed to by Register Pair HL and store it into Register A.
Original Source Code Comment: GET A CHARACTER
58C3
CP 30HCP '0' FE 30
Compare the value held in Register A against 30H to see if we got a character less than "0" (i.e., END OF STRING). Results:
  • If Register A equals 30H, the Z FLAG is set.
  • If A < 30H, the CARRY FLAG will be set.
  • if A >= 30H, the NO CARRY FLAG will be set.

Original Source Code Comment: END OF LINE?
58C5
If the C FLAG (Carry) has been set then we are at the end of the string, so JUMP to 58D7H.
Original Source Code Comment: YES, EXIT
58C7
GOSUB to 58DDH to convert the value to HEX (which will sit in the the LEFT NYBBLE).
Original Source Code Comment: CONVERT IT TO HEX
58CA
LD C,A 4F
Copy the left nybble (held in Register A) into Register C.
Original Source Code Comment: SAVE IT IN C
58CB
INC HL 23
Point to the next character in the field by INCrementing the value stored in Register Pair HL by 1.
Original Source Code Comment: BUMP TO NEXT VALUE
58CC
LD A,(HL) 7E
Fetch the next character (held in the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET IT
58CD
GOSUB to 58E9H to convert the value to HEX (which will sit in the RIGHT NYBBLE).
Original Source Code Comment: CONVERT IT TO HEX
58D0
OR C B1
Combine the LEFT and RIGHT nybbles via an OR. The results are stored in Register A.
Original Source Code Comment: ADD IN THE MSB
58D1
LD (DE),A 12
Store the combined/derived value (held in Register A) into the memory location pointed to by Register Pair DE.
Original Source Code Comment: STORE IT
58D2
INC DE 13
INCrement the destination pointer to the next slot.
Original Source Code Comment: BUMP TO NEXT SLOT
58D3
INC HL 23
INCrement the source pointer to the next character.
Original Source Code Comment: BUMP TO NEXT CHARACTER
58D4
INC B 04
INCrement the counter (stored in Register B) by 1.
Original Source Code Comment: BUMP THE COUNTER
58D5
LOOP back to almost the top of this routine at 58C2H.
Original Source Code Comment: LOOP TILL DONE

58D7H - MOVLT2 - Part of the PATCH routine's subroutine which decodes an arbitrary length hexadecimal field. Jumped here when we hit the END OF STRING (by virtue of a character below "0" being found).

58D7MOVLT2
LD A,B 78
Copy the found field length (held in Register B as a counter) into Register A.
Original Source Code Comment: GET THE COUNTER
58D8
OR A B7
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
Original Source Code Comment: ANYTHING ENTERED?
58D9
If the Z FLAG (Zero) has been set, the field length was zero and we were therefore missing a parameter, which is bad. JUMP to 521DH to exit with an error.
Original Source Code Comment: NO, MISSING PARAM
58DC
RET C9
RETurn to the caller.

58DDH - TCONV - Convert a Byte Containing a Hex Character to the High Nybble.

58DDTCONV
Get the value of the ASCII character via a GOSUB to 58E9H.
Original Source Code Comment: CONVERT IT
58E0
SLA A CB 27
Shift Register A left one bit (1 of 4), a 0 going into bit 0 ...
Original Source Code Comment: MOVE IT TO THE MSB
58E2
SLA A CB 27
Shift Register A left one bit (2 of 4), a 0 going into bit 0.
58E4
SLA A CB 27
Shift Register A left one bit (3 of 4), a 0 going into bit 0.
58E6
SLA A CB 27
... (4 of 4): the value of the digit is now the high nybble.
58E8
RET C9
RETurn to the caller.

58E9H - TCONV1 - Convert a Byte Containing a Hex Character to the Low Nybble a/k/a get the value of an ASCII character.

58E9TCONV1
SUB 30HSUB '0' D6 30
SUBtract the value 30H from Register A. Note: Subtracting 30H from from Register A will convert an ASCII number '0'-'9' to its decimal equivalent (i.e., 6 in ASCII is 36H in Hex; so 36H-30H = 6).
Original Source Code Comment: MASK OFF ASCII
58EB
If the C FLAG (Carry) has been set then the character is below "0", so JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: EXIT IF PARAM ERROR
58EE
CP 0AHCP 10 FE 0A
If we're here then the character is not below "0". Next compare the value held in Register A against 0AH (Decimal: 10). Results:
  • If Register A equals 10, the Z FLAG is set.
  • If A < 10, the CARRY FLAG will be set.
  • if A >= 10, the NO CARRY FLAG will be set.
    Original Source Code Comment: NUMBER?
58F0
RET C D8
If the C FLAG (Carry) has been set then the character is less than 10, so we are good! RETurn to the caller.
Original Source Code Comment: YES, EXIT
58F1
SUB 07HSUB 7 D6 07
SUBtract 07H from Register A, since there are 7 characters between "9" and "A": "A"-"F" (11H-16H) become 0AH-0FH.
Original Source Code Comment: TRY ALPHA
58F3
CP 0AHCP 10 FE 0A
Compare the value held in Register A against 0AH (Decimal: 10). Results:
  • If Register A equals 10, the Z FLAG is set.
  • If A < 10, the CARRY FLAG will be set.
  • if A >= 10, the NO CARRY FLAG will be set.
58F5
If the C FLAG (Carry) has been set then A < 10 which is too low to be an "A"-"F", so JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: NO, PARAM ERROR
58F8
CP 10HCP 16 FE 10
Compare the value held in Register A against 10H (Decimal: 16). Results:
  • If Register A equals 16, the Z FLAG is set.
  • If A < 16, the CARRY FLAG will be set.
  • if A >= 16, the NO CARRY FLAG will be set.
58FA
RET C D8
If If A < 16 the C FLAG (Carry) will have been set and we have a good character, RETurn to the caller.
58FB
JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.

58FEH - HSYS - PATCH routine for a SYSTEM/OVERLAY File.

58FEHSYS
INC HL 23
INCrement the pointer to the COMMAND LINE (stored in Register Pair HL) by 1; this should be a value.
Original Source Code Comment: BUMP TO NEXT VALUE
58FF
Get the overlay number (following the "*" we just got) via a GOSUB to 597BH. Response in Register Pair DE.
Original Source Code Comment: GET THE SYSTEM NUMBER
5902
PUSH DE D5
Save the overlay number from that GOSUB (held in Register Pair DE) to the top of the stack.
Original Source Code Comment: COMES BACK IN DE
5903
Get the next COMMAND LINE character (skipping spaces) via a GOSUB to 5F8EH.
Original Source Code Comment: SKIP SPACES
5906
LD C,00HLD C,0 0E 00
Let Register C equal 00H for a default drivespec of 0.
Original Source Code Comment: ASSUME DRIVE 0
5908
CP 3AHCP ':' FE 3A
Compare the value held in Register A against 3AH (ASCII: :). Results: If Register A equals :, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: DRIVE SPECIFIER
590A
If we did not get a : then we are not getting a drive number, so skip the next few instructions which would seek to interpret the command line for a drive number and JUMP to 5915H.
Original Source Code Comment: NO, CONTINUE
590C
INC HL 23
INCrement the pointer to the COMMAND LINE (stored in Register Pair HL) by 1 to point to the ASCII drive number.
Original Source Code Comment: BUMP TO DRIVE NUMBER
590D
LD A,(HL) 7E
Fetch the drive number (the next character from the COMMAND LINE; held in the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET IT
590E
INC HL 23
INCrement the pointer to the COMMAND LINE (stored in Register Pair HL) by 1 to move past the ASCII drive number.
Original Source Code Comment: BUMP PAST DRIVE NUMB
590F
SUB 30HSUB '0' D6 30
SUBtract the value 30H from Register A (which is supposed to hold a drive number). Note: Subtracting 30H from from Register A will convert an ASCII number '0'-'9' to its decimal equivalent (i.e., 6 in ASCII is 36H in Hex; so 36H-30H = 6).
Original Source Code Comment: MASK OFF ASCII
5911
If the number is too low then the C FLAG (Carry) will have been set, so JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: EXIT IF SILLY DRIVE NUMBER
5914
LD C,A 4F
Copy the drive number in binary form (held in Register A) into Register C.
Original Source Code Comment: PUT THE DRIVE INTO C
5915HSYS1
EX (SP),HL E3
EXchange the value stored in Register Pair HL (the pointer to the current letter on the COMMAND LINE) with the value stored at the top of stack (i.e., the system overlay number).
Original Source Code Comment: COMMAND LINE TO STACK, SYSTEM NUMBER TO HL
5916
PUSH HL E5
Save the overlay number (held in Register Pair HL) to the top of the stack.
Original Source Code Comment: PUT THE SYSTEM NUMBER ON STACK
5917
PUSH BC C5
Save the drive number (held in Register Pair BC) to the top of the stack.
Original Source Code Comment: PUT THE DRIVE NUMBER ON STACK
5918
LD HL,6162HLD HL,S9DCB1 21 62 61
Let Register Pair HL equal 6162H which is the beginning of the SOURCE FILE DCB.
Original Source Code Comment: CLEAR OUT THE DCB
591B
LD DE,6163HLD DE,S9DCB1+1 11 63 61
Let Register Pair DE equal the second byte of the SOURCE FILE DCB.
591E
LD BC,0031HLD BC,DCBSIZ-1 01 31 00
Let Register Pair BC equal 0031H for the size of a DCB (i.e., 49) bytes to move.
Original Source Code Comment: SIZE OF THE DCB
5921
LD (HL),00HLD (HL),0 36 00
Store the value held in 00H into the memory location pointed to by Register Pair HL so that the LDIR will zero out everything.
Original Source Code Comment: CLEAR BYTE
5923
LDIR ED B0
Transfers a byte of data from the memory location pointed to by HL to the memory location pointed to by DE. Then HL and DE are incremented and BC is decremented. If BC is not zero, this operation is repeated. Interrupts can trigger while this instruction is processing.
Original Source Code Comment: CLEAR IT OUT
5925
LD IX,6162HLD IX,S9DCB1 DD 21 62 61
Let Special Index Register Pair IX equal 6162H which is the beginning of the SOURCE FILE DCB.
Original Source Code Comment: IX => DCB
5929
LD (IX+00H),80HLD (IX),80H DD 36 00 80
Set DCB offset 00H (IX+00H, the TYPE byte) to 80H (1000 0000): bit 7 set = the DCB is open, so the system file can be read without an OPEN.
Original Source Code Comment: SET THE DISK DCB TYPE
592D
LD (IX+0CH),0FFHLD (IX+ERNL),-1 DD 36 0C FF
Store a 0FFH (i.e., indefinite) into the memory location pointed to by Special Index Register Pair IX+0CH.
Note: IX+0CH = the position in the DCB for the LSB of the ERN, the ending record number)
Original Source Code Comment: SET THE END RECORD NUMBER
5931
LD (IX+0DH),0FFHLD (IX+ERNH),-1 DD 36 0D FF
Store a 0FFH (i.e., indefinite) into the memory location pointed to by Special Index Register Pair IX+0DH.
Note: IX+0DH = the position in the DCB for the MSB of the ERN, the ending record number)
5935
LD (IX+03H),00HLD (IX+BUFL),BUFER1.LOW. DD 36 03 00
Store the value held in 00H into the memory location pointed to by Special Index Register Pair IX+03H.
Note: IX+03H = the position in the DCB for the LSB of the FILE BUFFER RAM ADDRESS).
Original Source Code Comment: SET THE BUFFER
5939
LD (IX+04H),63HLD (IX+BUFH),BUFER1.HIGH. DD 36 04 63
Store the value held in 63H into the memory location pointed to by Special Index Register Pair IX+04H.
Note: IX+04H = the position in the DCB for the MSB of the FILE BUFFER RAM ADDRESS).
593D
POP BC C1
Put the drive number (held at the top of the STACK) into Register Pair BC, and then remove the entry from the stack.
Original Source Code Comment: GET THE DRIVE NUMBER BACK
593E
LD (IX+06H),CLD (IX+DRVNUM),C DD 71 06
Store the drive number (held in Register C) into the memory location pointed to by Special Index Register Pair IX+06H.
Note: IX+06H = the position in the DCB for the DRIVE NUMBER).
Original Source Code Comment: SAVE THE DRIVE NUMBER
5941
POP DE D1
Restore the overlay number from the top of the STACK into Register Pair DE, and then remove the entry from the stack.
Original Source Code Comment: GET THE SYSTEM MODULE
5942
LD (IX+07H),ELD (IX+LFN),E DD 73 07
Store the overlay number (held in Register E) into the memory location pointed to by Special Index Register Pair IX+07H.
Note: IX+07H = the position in the DCB for the LOGICAL FILE NUMBER [the directory entry number]).
Original Source Code Comment: SET IT IN THE DCB
5945
GOSUB to 4ABAH.
NOTE: 4ABAH is the SYS00/SYS routine to read the HIT sector into RAM.
Original Source Code Comment: READ IN THE HIT TABLE
5948
If the NZ FLAG (Not Zero) has been set, then the CALL produced an error, so JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.
Original Source Code Comment: EXIT IF ERROR
594B
RLC E CB 03
Double the system file number in Register E (RLC E), since each system file pointer in the HIT is 2 bytes.
Original Source Code Comment: SYSTEM NUMBER TIMES 2
594D
LD A,0E0HLD A,SYSOFF 3E E0
Let Register A equal E0H, the offset of the system file pointers in the HIT (its last 32 bytes, two per system file).
Original Source Code Comment: OFFSET TO THE SYSTEM NUMBERS
594F
ADD A,E 83
Add the doubled system file number (Register E) to Register A: the offset of this system file's pointer in the HIT.
Original Source Code Comment: ADD IN THIS SYSTEM
5950
LD L,A 6F
Copy the offset (Register A) into Register L.
Original Source Code Comment: INTO HL
5951
LD H,43HLD H,BUFF1.HIGH. 26 43
Let Register H equal 43H: Register Pair HL points into the HIT, which RDHIT read into 4300H.
Original Source Code Comment: HL => EXTENT BYTES FOR SYSTEM FILE
5953
LD D,(HL) 56
Fetch the first byte of the pointer, the gran byte (bits 7-5 the first gran, bits 4-0 the gran count), into Register D.
Original Source Code Comment: GET THE STARTING GRAN
5954
INC HL 23
INCrement the value stored in Register Pair HL by 1.
Original Source Code Comment: BUMP TO TRACK NUMBER
5955
LD E,(HL) 5E
Fetch the second byte of the pointer, the track, into Register E.
5956
LD (6172H),DELD (S9DCB1+EXTBEG),DE ED 53 72 61
Store the extent (Register E = track at 6172H, Register D = gran byte at 6173H) as the first extent of the SOURCE FILE DCB (DCB offset 10H).
Original Source Code Comment: SET IT IN THE DCB
595A
LD A,0FFHLD A,-1 3E FF
Let Register A equal 0FFH to flag a system file.
Original Source Code Comment: SET THE SYSTEM FLAG
595C
LD (599AH),ALD (SYSFLG),A 32 9A 59
Store the FFH (Register A) into 599AH (SYSFLG): a system file is being patched.
595F
POP HL E1
Put the pointer to the COMMAND LINE back into Register Pair HL.
Original Source Code Comment: GET THE COMMAND LINE POINTER BACK
5960
JUMP to 5727H to continue the routine.
Original Source Code Comment: AND CONTINUE

5963H - CLOSYS - Patch File routine to update a system overlay file. The flags were preserved to the stack before this routine was called and are retrieved right after.

5963CLOSYS
LD HL,(616CH)LD HL,(S9DCB1+NRNL) 2A 6C 61
Fetch "next" sector/record number from memory location 616CH and store it into Register Pair HL.
Original Source Code Comment: GET THE RECORD NUMBER
5966
DEC HL 2B
Back up 1 record/sector by DECrementing the value stored in Register Pair HL by 1.
Original Source Code Comment: BACK UP ONE RECORD
5967
LD (616CH),HLLD (S9DCB1+NRNL),HL 22 6C 61
Store the new "next" sector (held in Register Pair HL) into memory location 616CH.
Original Source Code Comment: PUT IT BACK
596A
LD IX,6162HLD IX,S9DCB1 DD 21 62 61
Let Special Index Register Pair IX equal 6162H which is the beginning of the SOURCE FILE DCB.
Original Source Code Comment: IX => DCB
596E
Find the track/sector number of the "next sector" via a GOSUB to 49D4H.
Original Source Code Comment: GET THE DISK TRACK/SECTOR
5971
LD HL,6300HLD HL,BUFER1 21 00 63
Let Register Pair HL equal 6300H to point to the beginning of the READ FILE buffer.
Original Source Code Comment: HL => WHERE THE DATA IS
5974
Write the sector at 6300H (Register Pair HL) to drive C, track D, sector E via a GOSUB to 45F7H (XWRITE).
Original Source Code Comment: DO THE WRITE OUT
5977
If the NZ FLAG (Not Zero) has been set, then the CALL produced an error, so JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.
Original Source Code Comment: EXIT IF ERROR
597A
RET C9
RETurn to the caller.
Original Source Code Comment: ELSE DONE

597BH - HEXGET - Evaluate the overlay number a/k/a Convert a Decimal String into a Binary Value.

597BHEXGET
LD B,HLD BC,HL 44
Copy Register H into Register B (first half of LD BC,HL).
Original Source Code Comment: MOVE THE POINTER TO BC
597C
LD C,L 4D
Copy Register L into Register C: Register Pair BC = the command line pointer.
597D
LD HL,0000HLD HL,0 21 00 00
Let Register Pair HL equal 0000H for upcoming math.
Original Source Code Comment: CLEAR AN ACCUM
5980HEXGE1
LD A,(BC) 0A
Fetch the next character (which is hopefully a digit) on the command line (held in the memory location pointed to by Register Pair BC) and store it into Register A.
Original Source Code Comment: GET A DIGIT
5981
SUB 30HSUB '0' D6 30
SUBtract the value 30H from Register A. Note: Subtracting 30H from from Register A will convert an ASCII number '0'-'9' to its decimal equivalent (i.e., 6 in ASCII is 36H in Hex; so 36H-30H = 6).
Original Source Code Comment: MASK OFF ASCII
5983
If the C FLAG is set the character is below "0" and ends the number: JUMP to 5996H (HEXGE2).
Original Source Code Comment: EXIT IF END OF NUMBER
5985
CP 0AHCP 10 FE 0A
Compare the value held in Register A against 0AH (Decimal: 10). Results:
  • If Register A equals 10, the Z FLAG is set.
  • If A < 10, the CARRY FLAG will be set.
  • if A >= 10, the NO CARRY FLAG will be set.

Original Source Code Comment: GREATER THAN NUMBER?
5987
If the NC FLAG is set the character is above "9" and ends the number: JUMP to 5996H (HEXGE2).
Original Source Code Comment: YES, EXIT
5989
INC BC 03
Point to the next character on the COMMAND LINE by INCrementing the value stored in Register Pair BC by 1.
Original Source Code Comment: BUMP TO NEXT VALUE
598A
LD D,HLD DE,HL 54
Copy Register H into Register D (first half of LD DE,HL).
Original Source Code Comment: MIRROR THE VALUE TO DE
598B
LD E,L 5D
Copy Register L into Register E: Register Pair DE = the value so far.
598C
ADD HL,HL 29
ADD Register Pair HL to itself: HL = the value times 2.
Original Source Code Comment: TIMES 2
598D
ADD HL,HL 29
ADD Register Pair HL to itself: HL = the value times 4.
Original Source Code Comment: TIMES 4
598E
ADD HL,DE 19
ADD Register Pair DE (the value) to Register Pair HL: HL = the value times 5.
Original Source Code Comment: TIMES 5
598F
ADD HL,HL 29
ADD Register Pair HL to itself: HL = the value times 10.
Original Source Code Comment: TIMES 10
5990
LD E,ALD DE,A 5F
Copy the value of the new digit (Register A) into Register E.
Original Source Code Comment: NEW DIGIT INTO DE
5991
LD D,00H 16 00
Let Register D equal 00H: Register Pair DE = the digit.
5993
ADD HL,DE 19
LET Register Pair HL = original number but in the 10's place (held in Register Pair HL) + other character in the 1's place (held in Register DE).
Original Source Code Comment: ADD IN THE NEW DIGIT
5994
JUMP to 5980H to keep processing (and shifting nn to nn_).
Original Source Code Comment: GET THE NEXT DIGIT

5996H - HEXGE2 - Continuation of the above evaluation routine when a character that is not a digit (below "0" or above "9") ends the number.

5996HEXGE2
EX DE,HL EB
EXchange Register Pairs DE and HL: DE = the number, HL = the last digit value (not used).
Original Source Code Comment: VALUE TO DE
5997
LD H,BLD HL,BC 60
Copy Register B into Register H (first half of LD HL,BC).
Original Source Code Comment: MOVE THE COMMAND LINE BACK TO HL
5998
LD L,C 69
Copy Register C into Register L: Register Pair HL = the command line pointer, at the character that ended the number.
5999
RET C9
RETurn to the caller.
Original Source Code Comment: DONE

599AH - SYSFLG - MESSAGE and STORAGE AREA.

599ASYSFLG
DEFB 00H 00
SYSFLG: 00H at load; HSYS stores FFH (595CH) when PATCH * patches a system file.

599BH - OPENIT - General Disk Routine. Open the disk file and preserve the LRL.

599BOPENIT
Set up for FILE I/O via a GOSUB to 59ADH to set up for FULL SECTOR I/O and sets up registers B, DE, and HL.
Original Source Code Comment: SET UP THE DCB
599E
GOSUB to 4424H.
NOTE: 4424H is the SYS00/SYS routine to OPEN A DISK FILE for use. This RST 28H's with a value of 92H so as to call ROUTINE 1 in OVERLAY 2.
59A1
PUSH AF F5
Save the contents of Register Pair AF (i.e., any error status from the OPEN) to the top of the stack.
Original Source Code Comment: SAVE POSSIBLE ERROR
59A2
LD A,(616BH)LD A,(S9DCB1+LRL) 3A 6B 61
Fetch the value held in memory location 616BH (i.e., the record length) and store it into Register A.
Original Source Code Comment: GET THE SOURCE LRL
59A5
LD (53A4H),ALD (LRLCHG),A 32 A4 53
Store the value held in Register A into memory location 53A4H which is in the middle of a LD B,xx OPCODE.
Original Source Code Comment: SAVE IT FOR COPY
59A8
LD (54E0H),ALD (LRLCH1),A 32 E0 54
Store the value held in Register A into memory location 54E0H.
59AB
POP AF F1
Restore the error status (held at the top of the STACK) into Register Pair AF, and then remove the entry from the stack.
Original Source Code Comment: GET POSSIBLE ERROR BACK
59AC
RET C9
RETurn to the caller.

59ADH - GETDCB - General Disk Routine. Set up for full sector FILE I/O.

59ADGETDCB
LD B,00HLD B,0 06 00
Let Register B equal 00H to indicate FULL SECTOR FILE I/O / LRL of 256 bytes.
Original Source Code Comment: SET FOR LRL OF 256
59AFGETDC1
LD DE,6162HLD DE,S9DCB1 11 62 61
Let Register Pair DE equal 6162H which is the beginning of the SOURCE FILE DCB.
Original Source Code Comment: POINT TO DCB
59B2
LD HL,6300HLD HL,BUFER1 21 00 63
Let Register Pair HL equal 6300H to point to the beginning of the READ FILE buffer.
Original Source Code Comment: POINT TO BUFFER
59B5
RET C9
RETurn to the caller.
Original Source Code Comment: EXIT

59B6H - INITIT - General Disk Routine. Set up for full sector FILE I/O and Create A FiLE.

59B6INITIT
GOSUB to GOSUB to 59ADH to set up for FULL SECTOR I/O and sets up registers B, DE, and HL.
Original Source Code Comment: SET UP THE DCB
59B9
JUMP to 4420H.
NOTE: 4420H is the SYS00/SYS routine to INITIALIZE A FILE (i.e., CREATE or OPEN). This RST 28H's with a value of A2H so as to call ROUTINE 2 in OVERLAY 2. Register HL needs to point to a RAM BUFFER for the DCB's.
Original Source Code Comment: OPEN OR INIT AND RET

59BCH - GETSYN - General Disk Routine. Set Register Pair DE to point to the SOURCE FILE DCB, check the syntax of the associated Filespec, and RETurn.

59BCGETSYN
LD DE,6162HLD DE,S9DCB1 11 62 61
Let Register Pair DE equal 6162H which is the beginning of the SOURCE FILE DCB.
Original Source Code Comment: POINT TO READ DCB
59BF
JUMP to 441CH.
NOTE: 441CH is the SYS00/SYS routine to CHECK THE SYNTAX OF A FILESPEC before use. This RST 28H's with a value of C1H so as to call ROUTINE 4 in OVERLAY 1.
Original Source Code Comment: AND CHECK IT OUT

59C2H - PATERR - Patch Error Routine. Display a STRING NOT FOUND message and ABORT.

59C2PATERR
LD HL,59D3HLD HL,NOFID1 21 D3 59
Let Register Pair HL equal 59D3H (NOFID1), the message 'String NOT Found' and 0DH.
59C5
JUMP to 021BH.
NOTE: 021BH is the Model III ROM routine to display the characters at (HL) until a 03H or a 0DH (which is shown) is found. Since this was JUMPED to instead of CALLed, the RET at the end of this ROM routine will then RETurn to the caller of this subroutine instead of returning to this place.

59C8H - CHGMAD - MESSAGE and STORAGE AREA for the PATCH command.

59C8-59D1CHGMAD
DEFM 'Patch Made' 50 61 74 63 68 20 4D 61 64 65
CHGMAD: text 'Patch Made'.
59D2
DEFB 0DH 0D
0DH ends the message with a new line.
59D3-59E2NOFID1
DEFM 'String NOT Found' 53 74 72 69 6E 67 20 4E 4F 54 20 46 6F 75 6E 64
NOFID1: text 'String NOT Found'.
59E3
DEFB 0DH 0D
0DH ends the message.
59E4-59E6NOFIND
DEFM 'Can' 43 61 6E
NOFIND: text 'Can'.
59E7
DEFB 27H 27
27H, the apostrophe.
59E8-59FF
DEFM 't Find Specified Address' 74 20 46 69 6E 64 20 53 70 65 63 69 66 69 65 64 20 41 64 64 72 65 73 73
Text 't Find Specified Address'.
5A00
DEFB 0DH 0D
0DH ends the message.
5A01-5A12NOCHAG
DEFM 'NO Change Required' 4E 4F 20 43 68 61 6E 67 65 20 52 65 71 75 69 72 65 64
NOCHAG: text 'NO Change Required'.
5A13
DEFB 0DH 0D
0DH ends the message.

5A14H - "RELO" Routine. This routine ONLY updates the LOAD FILE FORMAT ADDRESS, it does not "renum" the file.

5A14RELO
LD DE,6130HLD DE,S9DCB 11 30 61
Let Register Pair DE equal 6130H, which is a pointer to the FILE CONTROL BLOCK.
Original Source Code Comment: DE => DCB
5A17
GOSUB to 441CH.
NOTE: 441CH is the SYS00/SYS routine to CHECK THE SYNTAX OF A FILESPEC before use. This RST 28H's with a value of C1H so as to call ROUTINE 4 in OVERLAY 1.
Original Source Code Comment: CHECK SYNTAX OF FILESPEC
5A1A
If the NZ FLAG (Not Zero) has been set, then the CALL produced an error, so JUMP to 521DH.
Original Source Code Comment: EXIT IF ERROR
5A1D
LD DE,5B12HLD DE,RLTABL 11 12 5B
Let Register Pair DE equal 5B12H, which is a pointer to the table to be parsed.
Original Source Code Comment: DE => SYNTAX TABLE
5A20
GOSUB to 4454H.
NOTE: 4454H is the SYS0 vector SWITCH (SYS1 entry 6, PARAM): it matches the options in parentheses at Register Pair HL against the table at Register Pair DE and stores each value (FFFFH for a name alone) in the two bytes the matching table entry points to; NZ = an option that is not in the table.
Original Source Code Comment: GET THE OPTIONS
5A23
If the NZ FLAG (Not Zero) has been set, then the CALL produced an error, so JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: EXIT IF ERROR
5A26
LD HL,0000HLD HL,0 21 00 00
Let Register Pair HL equal the ADD= address. The operand at 5A27H-5A28H (RLADD) is 0000H in the file; SWITCH (5A20H) stores the value there, through the DEFW RLADD of the table at 5B12H.
Original Source Code Comment: RELO ADDRESS STORED HERE
5A29
PUSH HL E5
Save the relocation address (held in Register Pair HL) to the top of the stack.
Original Source Code Comment: SAVE THE NUMBER
5A2A
LD HL,6300HLD HL,BUFER1 21 00 63
Let Register Pair HL equal 6300H to point to the beginning of the READ FILE buffer.
Original Source Code Comment: POINT TO BUFFER 1
5A2D
LD DE,6130HLD DE,S9DCB 11 30 61
Let Register Pair DE equal 6130H, which is a pointer to the FILE CONTROL BLOCK.
Original Source Code Comment: POINT TO DCB
5A30
LD B,00HLD B,0 06 00
Let Register B equal 00H for a LRL of 256 bytes.
Original Source Code Comment: LRL OF 256
5A32
GOSUB to 4424H.
NOTE: 4424H is the SYS00/SYS routine to OPEN A DISK FILE for use. This RST 28H's with a value of 92H so as to call ROUTINE 1 in OVERLAY 2.
Original Source Code Comment: OPEN THE FILE
5A35
If the NZ FLAG (Not Zero) has been set, then the CALL produced an error, so JUMP to 5B04H.
Original Source Code Comment: EXIT IF ERROR
5A38LOOP2
Read a byte via a GOSUB to 5AFBH.
Original Source Code Comment: READ A BYTE
5A3B
PUSH AF F5
Save the byte (held in Register Pair AF) to the top of the stack.
Original Source Code Comment: SAVE IT
5A3C
Read a byte (which should be the number of bytes) via a GOSUB to 5AFBH.
Original Source Code Comment: READ SECOND BYTE
5A3F
LD B,A 47
Copy the byte which was just read (held in Register A) into Register B, which will inform a DJNZ loop if the STALL routine is called because we hit a COMMENT FIELD.
Original Source Code Comment: PUT IT INTO B
5A40
POP AF F1
Put the first byte read (held at the top of the STACK) into Register Pair AF, and then remove the entry from the stack.
Original Source Code Comment: GET CHAR BACK
5A41
CP 05HCP 5 FE 05
See if the first byte read was a COMMENT BYTE (i.e., 05H) by comparing the value held in Register A against 05H. Results: If Register A equals 05H, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: COMMENT?
5A43
If we have a comment byte, then the Z FLAG (Zero) will have been set, JUMP to 5AF3H to skip past B number bytes in the COMMENT BLOCK.
Original Source Code Comment: YES, STALL
5A46
CP 01HCP 1 FE 01
See if the first byte read was a CODE BLOCK (i.e., 01H) by comparing the value held in Register A against 01H. Results: If Register A equals 01H, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: LOAD FILE FORMAT?
5A48
If we have a CODE BLOCK, then the Z FLAG (Zero) will have been set, JUMP to 5A4FH.
Original Source Code Comment: YES, GO
5A4ALFERR
LD A,22HLD A,ELFFE 3E 22
If we haven't jumped away, then we have an invalid block. Let Register A equal 22H to indicate an INVALID FILE FORMAT error.
Original Source Code Comment: ERROR
5A4C
Exit via a JUMP to 5B04H.

5A4FH - LOOP0 - Part of the RELO command. Jumped here if the character indicated a CODE BLOCK.

5A4FLOOP0
Read a byte, which is the LSB of the address, via a GOSUB to 5AFBH.
Original Source Code Comment: READ THE LSB OF ADDRESS
5A52
LD L,A 6F
Copy the LSB of the address (held in Register A) into Register L.
Original Source Code Comment: SAVE IT
5A53
Read a byte, which is the MSB of the address, via a GOSUB to 5AFBH.
5A56
LD H,A 67
Copy the MSB of the address (held in Register A) into Register L.
Original Source Code Comment: GOT ADDRESS
5A57
EX DE,HL EB
EXchange the value stored in Register Pair HL (the address just read) with the value stored in Register Pair DE (irrelevant).
Original Source Code Comment: PUT IT IN DE
5A58
POP HL E1
Restore the relocation address (held at the top of the STACK) into Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: GET THE RELO ADDRESS
5A59
PUSH HL E5
Save the relocation address (held in Register Pair HL) to the top of the stack.
Original Source Code Comment: SAVE IT AGAIN
5A5A
OR A B7
Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
Original Source Code Comment: CLEAR CARRY
5A5B
SBC HL,DE ED 52
Get the difference between the address in the code block and the requested address via a subtracts with carry which subtracts the value stored in Register Pair DE and the carry flag from the value stored in Register Pair HL.
Original Source Code Comment: GET THE DIFFERENCE
5A5D
LD (5B1BH),HLLD (SAVE),HL 22 1B 5B
The result of that subtraction is in HL and is the offset. Store the offset (held in Register Pair HL) into memory location 5B1BH.
Original Source Code Comment: SAVE THE OFFSET
5A60
LD IY,6400HLD IY,BUFER2 FD 21 00 64
Let Special Index Register Pair IY equal 6400H which will act as a buffer.
Original Source Code Comment: POINT TO MAIN BUFFER
5A64
POP HL E1
Restore the relocation address (held at the top of the STACK) into Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: GET THE RELO ADDRESS
5A65LOOP3
LD (IY+00H),01HLD (IY),1 FD 36 00 01
Store a CODE BLOCK indicator (i.e., 01H) into the memory location pointed to by Special Index Register Pair IY+00H.
Original Source Code Comment: SET A LOAD FILE HEADER
5A69
INC IY FD 23
INCrement the value stored in Special Index Register IY by 1.
5A6B
LD (IY+00H),BLD (IY),B FD 70 00
Store the character count (held in in Register B) into the memory location pointed to by Special Index Register Pair IY+00H.
Original Source Code Comment: STORE THE CHAR COUNT
5A6E
INC IY FD 23
INCrement the value stored in Special Index Register IY by 1.
5A70
LD (IY+00H),LLD (IY),L FD 75 00
Store the LSB of the address (held in Register L) into the memory location pointed to by Special Index Register Pair IY+00H.
5A73
INC IY FD 23
INCrement the value stored in Special Index Register IY by 1.
5A75
LD (IY+00H),HLD (IY),H FD 74 00
Store the MSB of the address (Register H) into the buffer at Register IY.
Original Source Code Comment: STORE THE ADDRESS
5A78
DEC B 05
DECrement byte counter (1 of 2) for address
Original Source Code Comment: DEC FOR THE ADDRESS
5A79
DEC B 05
DECrement byte counter (2 of 2) for address
5A7A
INC IY FD 23
INCrement the value stored in Special Index Register IY by 1.
5A7CLOOP4
LD DE,6130HLD DE,S9DCB 11 30 61
Let Register Pair DE equal 6130H, which is a pointer to the FILE CONTROL BLOCK.
Original Source Code Comment: POINT TO DCB
5A7F
Read a byte via a GOSUB to 5AFBH.
Original Source Code Comment: READ A BYTE
5A82
LD (IY+00H),ALD (IY),A FD 77 00
Store the value held in Register A into the memory location pointed to by Special Index Register Pair IY+00H.
Original Source Code Comment: STORE IN BUFFER
5A85
INC IY FD 23
INCrement the value stored in Special Index Register IY by 1.
5A87
LOOP back to 5A7CH, reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
Original Source Code Comment: CONTINUE FOR COUNT
5A89
Read a byte, which will be the LOAD FILE HEADER, via a GOSUB to 5AFBH.
Original Source Code Comment: READ THE LOAD FILE HEADER
5A8C
CP 02HCP 2 FE 02
Check to see if we are at the end of the record via receipt of an 02H by comparing the value held in Register A against 02H. Results: If Register A equals 02H, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: END OF RECORD?
5A8E
If we fetched an 02H byte, then we are at the end of the record and the Z FLAG (Zero) will have set, JUMP to 5AA9H to exit.
Original Source Code Comment: END IF SO
5A90
CP 01HCP 1 FE 01
See if the byte read was a CODE BLOCK (i.e., 01H) by comparing the value held in Register A against 01H. Results: If Register A equals 01H, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: LOAD FILE FORMAT?
5A92
If we did NOT fetch an 01H, then we have a problem and the NZ FLAG (Not Zero) will have been set, JUMP to 5A4AH.
Original Source Code Comment: NO, ERROR
5A95
Read a byte (the character count) via a GOSUB to 5AFBH.
Original Source Code Comment: READ THE CHAR COUNT
5A98
LD B,A 47
Copy the character count (held in Register A) into Register B.
Original Source Code Comment: SAVE IN B
5A99
Read a byte, which is the LSB of the address, via a GOSUB to 5AFBH.
Original Source Code Comment: GET THE ADDRESS
5A9C
LD L,A 6F
Copy the LSB of the address (held in Register A) into Register L.
Original Source Code Comment: SAVE IN L
5A9D
Read a byte, which is the MSB of the address, via a GOSUB to 5AFBH.
Original Source Code Comment: GET THE MSB
5AA0
LD H,A 67
Copy the MSB of the address (held in Register A) into Register H.
Original Source Code Comment: SAVE IN H
5AA1
LD DE,(5B1BH)LD DE,(SAVE) ED 5B 1B 5B
Fetch the offset value (held in memory location 5B1BH) and store it into Register Pair DE.
Original Source Code Comment: GET THE OFFSET
5AA5
ADD HL,DE 19
Add the offset to the load address by LETing Register Pair HL = Register Pair HL (load address) + Register DE (offset to the requested load address).
Original Source Code Comment: ADD TO ADDRESS
5AA6
Continue via a JUMP BACK to 5A65H.
Original Source Code Comment: AND CONTINUE

5AA9H - LOOP7 - Part of the RELO command. Jumped here if loop to read the characters in the prior routine hit an 02H to indicate END OF RECORD.

5AA9LOOP7
LD (IY+00H),ALD (IY),A FD 77 00
Store the value held in Register A (i.e., an 02H) into the memory location pointed to by Special Index Register Pair IY+00H.
Original Source Code Comment: SAVE THE 2
5AAC
INC IY FD 23
INCrement the value stored in Special Index Register IY by 1.
5AAE
Read a byte (which will be an 02H) via a GOSUB to 5AFBH.
Original Source Code Comment: GET THE NEXT 2
5AB1
Read a byte (the LSB of the entry address) via a GOSUB to 5AFBH.
Original Source Code Comment: GET THE ENTRY ADDR
5AB4
LD (IY+00H),02HLD (IY),2 FD 36 00 02
Store the lneght of the data which follows (i.e., 2 bytes) into the memory location pointed to by Special Index Register Pair IY+00H.
Original Source Code Comment: STORE THE LENGTH
5AB8
INC IY FD 23
INCrement the value stored in Special Index Register IY by 1.
5ABA
LD (IY+00H),ALD (IY),A FD 77 00
Store the LSB of the address (held in Register A) into the memory location pointed to by Special Index Register Pair IY+00H.
Original Source Code Comment: STORE THE LSB OF ADDR
5ABD
INC IY FD 23
INCrement the value stored in Special Index Register IY by 1.
5ABF
Read a byte (the MSB of the entry address) via a GOSUB to 5AFBH.
Original Source Code Comment: GET THE MSB
5AC2
LD (IY+00H),ALD (IY),A FD 77 00
Store the MSB of the address (held in Register A) into the memory location pointed to by Special Index Register Pair IY+00H.
Original Source Code Comment: STORE THE MSB OF ADDR
5AC5
INC IY FD 23
INCrement the value stored in Special Index Register IY by 1.
5AC7
LD (5B1DH),IYLD (SAVE1),IY FD 22 1D 5B
Store the value held in Special Index Register Pair IY (i.e., the end pointer) into memory location 5B1DH.
Original Source Code Comment: SAVE THE END POINTER
5ACB
LD DE,6130HLD DE,S9DCB 11 30 61
Let Register Pair DE equal 6130H, which is a pointer to the FILE CONTROL BLOCK.
Original Source Code Comment: POINT TO DCB
5ACE
GOSUB to 443FH.
NOTE: 443FH is the SYS00/SYS vector for 'REWIND', which will rewind the open file.
Original Source Code Comment: BACK TO BEGINNING OF FILE
5AD1
If the NZ FLAG (Not Zero) has been set, then the CALL produced an error, so JUMP to 5B04H.
Original Source Code Comment: EXIT IF ERROR
5AD4
LD HL,(5B1DH)LD HL,(SAVE1) 2A 1D 5B
Fetch the end pointer (held in memory location 5B1DH) and store it into Register Pair HL.
Original Source Code Comment: GET THE END ADDRESS
5AD7
LD DE,6400HLD DE,BUFER2 11 00 64
Let Register Pair DE equal 6400H which is a BUFFER in RAM for DATA.
Original Source Code Comment: GET THE START ADDR
5ADA
OR A B7
Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
5ADB
SBC HL,DE ED 52
Determine the applicable number of bytes by subtracting the value stored in Register Pair DE (the buffer starting address) and the carry flag from the value stored in Register Pair HL (the end pointer).
Original Source Code Comment: GET THE NUM OF BYTES
5ADD
LD B,H 44
Copy Register H into Register B.
Original Source Code Comment: MOVE TO BC
5ADE
LD C,L 4D
Copy Register L into Register C: Register Pair BC = the number of bytes to write back.
5ADF
EX DE,HL EB
EXchange Register Pairs DE and HL: HL = 6400H (the start of the buffer, from DE), DE = the byte count (not used; BC holds it).
Original Source Code Comment: GET THE BUFFER IN HL
5AE0
LD DE,6130HLD DE,S9DCB 11 30 61
Let Register Pair DE equal 6130H, which is a pointer to the FILE CONTROL BLOCK.
Original Source Code Comment: POINT TO DCB
5AE3LOOP8
LD A,(HL) 7E
Fetch the a character held in the memory location pointed to by Register Pair HL and store it into Register A.
Original Source Code Comment: GET A CHARACTER
5AE4
Write that character out via a GOSUB to 5B07H.
Original Source Code Comment: WRITE IT OUT
5AE7
INC HL 23
INCrement the buffer pointer (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP POINTER
5AE8
DEC BC 0B
DECrement the byte counter (stored in Register Pair BC) by 1.
Original Source Code Comment: DEC THE COUNTER
5AE9
LD A,B 78
Copy Register B into Register A ...
Original Source Code Comment: WE DONE?
5AEA
OR C B1
... and OR it with Register C: the Z FLAG is set only when the byte count in Register Pair BC is 0.
5AEB
If the byte counter did NOT hit zero, then the NZ FLAG (Not Zero) will have been set, so LOOP BACK to 5AE3H.
Original Source Code Comment: NO, CONTINUE
5AED
GOSUB to 4428H to CLOSE the file
NOTE: 4428H is the SYS00/SYS routine to CLOSE A DISK FILE. This RST 28H's with a value of 93H so as to call ROUTINE 1 in OVERLAY 3.
Original Source Code Comment: CLOSE THE FILE
5AF0
Return to DOS READY via a JUMP to the SYS00/SYS vector at 402DH.
Original Source Code Comment: AND DONE

5AF3H - STALL - Continuation of RELO Command. Jumped here if we need to skip over all the bytes in a COMMENT block. Requires Register B to contain the number of bytes in the COMMENT BLOCK to be skipped.

5AF3STALL
Read a byte via a GOSUB to 5AFBH.
Original Source Code Comment: READ THE COMMENT
5AF6
LOOP back to 5AF3H, reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
5AF8
JUMP back into the applicable loop of the RELO routine - 5A38H.

5AFBH - ZREAD - Continuation of RELO Command. This routine reads a byte and puts it into Register A.

5AFBZREAD
PUSH DE D5
Save the contents of Register Pair DE to the top of the stack.
Original Source Code Comment: SAVE DE
5AFC
LD DE,6130HLD DE,S9DCB 11 30 61
Let Register Pair DE equal 6130H, which is a pointer to the FILE CONTROL BLOCK.
Original Source Code Comment: POINT TO DCB
5AFF
GOSUB to 0013H.
NOTE: 0013H is the Model III ROM routine to read a byte from an input device. Requires DE = starting address of DCB of device and on Exit Register A = byte received from device, Z set if device ready. Uses AF.
Original Source Code Comment: READ A BYTE
5B02
POP DE D1
Put the value held at the top of the STACK into Register Pair DE, and then remove the entry from the stack.
Original Source Code Comment: RESTORE DE
5B03
RET Z C8
If the Z FLAG is set the byte was read: RETurn with it in Register A. Otherwise fall into EROR (5B04H) with the error code in Register A.
Original Source Code Comment: RET OF OKAY

5B04H - EROR - Continuation of the RELO Command. Exit to the error handler.

5B04EROR
JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.
Original Source Code Comment: EXIT TO ERROR HANDLER

5B07H - ZWRITE - Continuation of the RELO Command. Write a byte out.

5B07ZWRITE
PUSH DE D5
Save the contents of Register Pair DE to the top of the stack.
Original Source Code Comment: SAVE DE
5B08
LD DE,6130HLD DE,S9DCB 11 30 61
Let Register Pair DE equal 6130H, which is a pointer to the FILE CONTROL BLOCK.
Original Source Code Comment: POINT TO DCB
5B0B
GOSUB to 001BH.
NOTE: 001BH is the Model III ROM routine to write a byte to an output device. Requires Register A to contain the byte to output and Register Pair DE to be the starting address of DCB of device. On exit, Z set if device ready. Uses AF.
Original Source Code Comment: ZWRITE A BYTE
5B0E
POP DE D1
Put the value held at the top of the STACK into Register Pair DE, and then remove the entry from the stack.
5B0F
RET Z C8
If the Z FLAG (Zero) has been set, RETurn to the caller.
Original Source Code Comment: RET IF OKAY
5B10
Exit to the exit handler via a JUMP to 5B04H.
Original Source Code Comment: ELSE REPORT ERROR

5B12H - RLTABL - MESSAGE and STORAGE AREA for the RELO COMMAND.

5B12-5B17RLTABL
DEFM 'ADD ' 41 44 44 20 20 20
RLTABL: the option name 'ADD' padded to 6 characters, for SWITCH.
5B18-5B19
DEFW 5A27H 27 5A
Where SWITCH stores the ADD= value: 5A27H (RLADD), the operand of the LD HL at 5A26H.
5B1A
DEFB 00H 00
00H ends the table.
5B1B-5B1CSAVE
DEFS 2
SAVE: 2 bytes, the RELO offset (the new address minus the old load address), stored at 5A5DH. Not in the file.
5B1D-5B1ESAVE1
DEFS 2
SAVE1: 2 bytes, the end of the rebuilt file in BUFER2, stored at 5AC7H. Not in the file.

5B1FH - Main Routine - "FORMS".

5B1FFORMS
LD BC,0000HLD BC,0 01 00 00
Let Register Pair BC equal 0000H for the next two instructions.
Original Source Code Comment: CLEAR OUT ANY OLD COUNTS
5B22
LD (5B44H),BCLD (CHAR),BC ED 43 44 5B
Clear the operand at 5B44H-5B45H (CHAR) of the LD HL at 5B43H, where SWITCH stores the WIDTH= value.
5B26
LD (5B51H),BCLD (FLINE),BC ED 43 51 5B
Clear the operand at 5B51H-5B52H (FLINE) of the LD HL at 5B50H, where SWITCH stores the LINES= value.
5B2A
Get the next non-space COMMAND LINE character via a GOSUB to 5F8EH.
Original Source Code Comment: GET NEXT NON-BLANK CHAR
5B2D
CP 0DH FE 0D
Compare the value held in Register A against 0DH (ASCII: CARRIAGE RETURN). Results: If Register A equals CARRIAGE RETURN, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: FORMS BY ITSELF?
5B2F
If we did NOT get a CARRIAGE RETURN, then we got more than just the FORMS command alone as a command and the NZ FLAG (Not Zero) will have been set, JUMP to 5B36H.
Original Source Code Comment: NO, CONTINUE
5B31
LD A,0CHLD A,12 3E 0C
Let Register A equal 0CH which is the FORM FEED.
Original Source Code Comment: YES, DO A TOP OF FORM
5B33
JUMP to 003BH.
NOTE: 003BH is the Model III ROM routine to write the byte held in Register A to the printer, including waiting for the printer to be available OR getting a BREAK. Uses Register Pair DE. Since this was JUMPED to instead of CALLed, the RET at the end of this ROM routine will then RETurn to the caller of this subroutine instead of returning to this place.
Original Source Code Comment: AND RETURN

5B36H - FORMS1 - Continuation of the "FORMS" Routine. Jumped here if we determined that we actually got parameters on the COMMAND LINE.

5B36FORMS1
LD DE,5B5FHLD DE,FORCOM 11 5F 5B
Let Register Pair DE equal 5B5FH which is a pointer to the table of valid FORMS parameters.
Original Source Code Comment: DE => FORMS COMMANDS
5B39
GOSUB to 4454H.
NOTE: 4454H is the SYS0 vector SWITCH (SYS1 entry 6, PARAM): it matches the options in parentheses at Register Pair HL against the table at Register Pair DE and stores each value (FFFFH for a name alone) in the two bytes the matching table entry points to; NZ = an option that is not in the table.
Original Source Code Comment: DO THE CHECK ON IT
5B3C
If the NZ FLAG (Not Zero) has been set, then the CALL produced an error, so JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: PARAMETER ERROR
5B3FFORMS2
LD IX,4025HLD IX,PDCB DD 21 25 40
Let Special Index Register Pair IX equal 4025H, which is the PRINTER DCB.
Original Source Code Comment: IX => PRINTER DCB
5B43
LD HL,0000HLD HL,0 21 00 00
Let Register Pair HL equal the WIDTH= value. The operand at 5B44H-5B45H (CHAR) is cleared at 5B22H and stored by SWITCH through the DEFW CHAR of the table at 5B5FH.
Original Source Code Comment: USER CHARACTER COUNT
5B46
Convert the value (typed as decimal digits, which SWITCH stores as hex digits) into binary via a GOSUB to 6086H (CONVHX).
Original Source Code Comment: CONVERT TO HEX
5B49
LD A,H 7C
Copy Register H into Register A ...
Original Source Code Comment: USER SELECT ANYTHING?
5B4A
OR L B5
... and OR it with Register L: the Z FLAG is set only when the value in Register Pair HL is 0 (no WIDTH= given).
5B4B
If the user didn't select anything (and the result of the hexidecimal conversion was a 00) the Z FLAG (Zero) will have been set; JUMP to 5B50H to try lines per page.
Original Source Code Comment: NO, TRY LINE PER PAGE
5B4D
LD (IX+06H),LLD (IX+6),L DD 75 06
Store the user count (held in Register L) into the memory location pointed to by Special Index Register Pair IX+06H.
Note: IX+06H = the position in the PRINTER DCB for LINE WIDTH.
Original Source Code Comment: STORE THE USER COUNT
5B50FORMS3
LD HL,0000HLD HL,0 21 00 00
Let Register Pair HL equal the LINES= value. The operand at 5B51H-5B52H (FLINE) is cleared at 5B26H and stored by SWITCH through the DEFW FLINE of the table at 5B5FH.
Original Source Code Comment: NUMBER OF LINES STORED HERE
5B53
Convert the value into binary via a GOSUB to 6086H (CONVHX).
Original Source Code Comment: CONVERT TO HEX
5B56
LD A,H 7C
Copy Register H into Register A ...
Original Source Code Comment: ANY NEW LINE?
5B57
OR L B5
... and OR it with Register L: the Z FLAG is set only when the value in Register Pair HL is 0 (no LINES= given).
5B58
RET Z C8
If there is no value held in HL then there is no line length to set, so exit via a RETurn to the caller.
Original Source Code Comment: NO, EXIT
5B59
INC L 2C
INCrement Register L (the source: correct for the offset of 1).
Original Source Code Comment: CORRECT FOR 1'S OFFSET
5B5A
RET Z C8
If Register L is now 0 (the value was FFH, 255) the Z FLAG is set: RETurn without changing the printer DCB.
Original Source Code Comment: EXIT IF WAS 255
5B5B
LD (IX+03H),LLD (IX+3),L DD 75 03
Store the new lines per page value (held in Register L) into the memory location pointed to by Special Index Register Pair IX+03H.
Note: IX+03H = the position in the PRINTER DCB for LINES PER PAGE.
Original Source Code Comment: YES, SAVE NEW LINES PER PAGE
5B5E
RET C9
RETurn to the caller.

5B5FH - FORCOM - Continuation of the "FORMS" Routine. MESSAGE and BYTE STORAGE.

5B5F-5B64FORCOM
DEFM 'WIDTH ' 57 49 44 54 48 20
FORCOM: the option name 'WIDTH' padded to 6 characters.
5B65-5B66
DEFW 5B44H 44 5B
Where SWITCH stores the WIDTH= value: 5B44H (CHAR).
5B67-5B6C
DEFM 'LINES ' 4C 49 4E 45 53 20
The option name 'LINES' padded to 6 characters.
5B6D-5B6E
DEFW 5B51H 51 5B
Where SWITCH stores the LINES= value: 5B51H (FLINE).
5B6F
DEFB 00H 00
00H ends the table.
Original Source Code Comment: END OF LIST

5B70H - COMPAR - General Subroutine. Compare DE and HL Strings.

5B70COMPAR
PUSH BCSAV3 C5
Save the contents of Register Pair BC to the top of the stack.
5B71
PUSH DE D5
Save the contents of Register Pair DE to the top of the stack.
5B72
PUSH HL E5
Save the contents of Register Pair HL to the top of the stack.
5B73COMPA1
LD A,(DE) 1A
Fetch the value held in the memory location pointed to by Register Pair DE and store it into Register A.
5B74
CP (HL) BE
Compare the value held in Register A against the value held in the memory location pointed to by Register Pair HL. Results: If Register A equals the value held in Register HL, the Z FLAG is set; otherwise the NZ FLAG is set.
5B75
If there is no match, then the NZ FLAG (Not Zero) will have been set, JUMP to 5B7CH.
5B77
LDI ED A0
Move to the 2nd character of both HL and DE via LDI command; which copies BC number of characters from (HL) to (DE), dropping BC each time. When BC hits 0, the PE flag is reset.
5B79
LOOP BACK to 5B73H until finished.
5B7CCOMPA2
POP HLEXI3 E1
Put the value held at the top of the STACK into Register Pair HL, and then remove the entry from the stack.
5B7D
POP DE D1
Put the value held at the top of the STACK into Register Pair DE, and then remove the entry from the stack.
5B7E
POP BC C1
Put the value held at the top of the STACK into Register Pair BC, and then remove the entry from the stack.
5B7F
RET C9
RETurn to the caller.

5B80H - PDATA - Display "MESSAGE" + " = ". HL must point to the message

5B80PDATA
GOSUB to 021BH.
NOTE: 021BH is the Model III ROM routine to display the characters at (HL) until a 03H or a 0DH (which is shown) is found.
Original Source Code Comment: DISPLAY MESSAGE
5B83
LD HL,5B96HLD HL,S9EQU 21 96 5B
Let Register Pair HL equal 5B96H to point to the message " = ".
Original Source Code Comment: HL => ' = ' MSG
5B86
JUMP to 021BH.
NOTE: 021BH is the Model III ROM routine to display the characters at (HL) until a 03H or a 0DH (which is shown) is found. Since this was JUMPED to instead of CALLed, the RET at the end of this ROM routine will then RETurn to the caller of this subroutine instead of returning to this place.
Original Source Code Comment: PRINT AND EXIT

5B89H - PDATA1 - Display "MESSAGE" + ", ". HL must point to the message

5B89PDATA1
GOSUB to 021BH.
NOTE: 021BH is the Model III ROM routine to display the characters at (HL) until a 03H or a 0DH (which is shown) is found.
Original Source Code Comment: DISPLAY MESSAGE
5B8CPDATA2
LD A,2CHLD A,',' 3E 2C
Let Register A equal 2CH (','). The operand at 5B8DH (PCHANG) is changed to 20H (a space) by SETCOM at 5CF1H, so after that this routine shows two spaces.
Original Source Code Comment: A COMMA
5B8E
GOSUB to 0033H.
NOTE: 0033H is the Model III ROM character print routine; displays the character held in Register A at the current cursor position.
5B91
LD A,20HLD A,' ' 3E 20
Let Register A equal SPACE.
Original Source Code Comment: AND A SPACE
5B93
JUMP to 0033H.
NOTE: 0033H is the Model III ROM character print routine; displays the character held in Register A at the current cursor position. Since this was JUMPED to instead of CALLed, the RET at the end of this ROM routine will then RETurn to the caller of this subroutine instead of returning to this place.
Original Source Code Comment: DISPLAY AND RETURN

5B96H - S9EQU - MESSAGE AND STORAGE AREA.

5B96-5B98S9EQU
DEFM ' = ' 20 3D 20
S9EQU: text ' = '.
5B99
DEFB 03H 03
03H ends the message.

5B9AH - ROUTE - The ROUTE command. Its first two instructions end it with error 31 (Program not found); the source comment calls them TEMP.

5B9AROUTE
LD A,1FHLD A,EPNF 3E 1F
Let Register A equal 1FH, error 31 (program not found). ROUTE is not available in this system.
Original Source Code Comment: TEMP... PROGRAM NOT FOUND ERROR
5B9C
JUMP to 4409H (ERROR) with the error code in Register A. Every ROUTE command ends here.
NOTE: 4409H is the SYS0 vector ERROR (PUSH AF, SYS4 entry 0).

5B9FH - ROUTE (continued) - The rest of the ROUTE code (5B9FH-5C74H), never reached: the JP 4409H at 5B9CH always exits first and only these instructions refer to their labels. It would check the DUAL flag (442FH), parse SOURCE= and DESTIN=, store the device names in the route fields at 4220H and 4222H and call the ROM's RO routine (006CH).

5B9F
Never reached: the JP 4409H at 5B9CH always exits first and nothing else jumps here. The JR Z tests the flags of a comparison that is no longer in the file; it would JUMP to 5BA5H (ROUTIT).
Original Source Code Comment: YES, IT'S OKAY
5BA1
OR A B7
Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
Original Source Code Comment: DUAL ON?
5BA2
If the DUAL flag in Register A is not zero (DUAL is on) the NZ FLAG is set: JUMP to 5C3AH (NOROTE).
Original Source Code Comment: YES, CAN'T ROUTE

If we are here then neither the ROUTE nor DUAL was set, so we need to actually process the command.

5BA5ROUTIT
Get the next non-space COMMAND LINE character via a GOSUB to 5F8EH.
Original Source Code Comment: SKIP ANY SPACES
5BA8
CP 20HCP ' ' FE 20
Compare the value held in Register A against 20H (ASCII: SPACE). Results:
  • If Register A equals SPACE, the Z FLAG is set.
  • If A < SPACE, the CARRY FLAG will be set.
  • if A >= SPACE, the NO CARRY FLAG will be set.

Original Source Code Comment: ROUTE BY ITSELF?
5BAA
If the COMMAND LINE character is < SPACE, meaning we got no valid parameter when the command was called, the C FLAG (Carry) will have been set, JUMP to 0069H to initialize the drivers.
Original Source Code Comment: YES, JUST RESET DCB
5BAD
CP 28HCP '(' FE 28
Compare the value held in Register A against 28H (ASCII: (). Results: If Register A equals (, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: START OF PARAMETERS?
5BAF
If we are here, then we need a valid command line, which would necessitate that the next character is a (. If we did not get the (, then the NZ FLAG (Not Zero) will have been set, JUMP to 521DH to exit with an error.
Original Source Code Comment: NO, MISSING PARAMETERS
5BB2
INC HL 23
Point to the next character on the command line, following the (, by INCrementing the value stored in Register Pair HL by 1.
Original Source Code Comment: BUMP PAST (
5BB3REROT
LD DE,5C5DHLD DE,S9SRC1 11 5D 5C
Let Register Pair DE equal 5C5DH, which points to the word "SOURCE".
Original Source Code Comment: DE => 'SOURCE'
5BB6
LD A,(DE) 1A
Fetch the parameter length (held in the memory location pointed to by Register Pair DE) and store it into Register A.
Original Source Code Comment: GET THE COUNT
5BB7
LD C,A 4F
Copy the length of the word (Register A) into Register C.
Original Source Code Comment: INTO BC
5BB8
LD B,00HLD B,0 06 00
Let Register B equal 00H: Register Pair BC = the length.
5BBA
INC DE 13
INCrement the value stored in Register Pair DE by 1 to now point to the word "SOURCE".
Original Source Code Comment: BUMP TO 1ST CHAR
5BBB
Compare HL and DE to see if they match via a GOSUB to 5B70H.
Original Source Code Comment: DO THE COMPARE
5BBE
If the text is not "SOURCE" the NZ FLAG is set: JUMP to 5BF4H (ROUTE5) to look for "DESTIN".
Original Source Code Comment: WASN'T SOURCE, TRY DEST
5BC0
ADD HL,BC 09
Point Register Pair HL to the next parameter by advancing HL by BC bytes so now the COMMAND LINE Pointer points to the "=".
Original Source Code Comment: ADD THE 'SOURCE' COUNT TO COMMAND LINE
5BC1
Get the device name from the COMMAND LINE via a GOSUB to 5C10H.
Original Source Code Comment: HL => '='. GET NEXT TOKEN
5BC4
If the NZ FLAG (Not Zero) has been set, then the CALL produced an error (which would be that the parameter didn't match any valid device), so JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: PARAMETER ERROR
5BC7
PUSH HL E5
Save the position on the COMMAND LINE (held in Register Pair HL) to the top of the stack.
Original Source Code Comment: SAVE COMMAND LINE POINTER
5BC8
EX DE,HL EB
EXchange the value stored in Register Pair HL (the position on the COMMAND LINE) with the value stored in Register Pair DE (the SOURCE name).
Original Source Code Comment: HL POINT TO TOKEN
5BC9
LD DE,4222HLD DE,DESTIN 11 22 42
Let Register Pair DE equal 4222H which points to the ROUTE DCB for the DESTINATION name.
Original Source Code Comment: DE => DESTIN IN ROUTE DCB
5BCCROUTE1
LD BC,0002HLD BC,2 01 02 00
Let Register Pair BC equal 0002H since there are 2 characters in a valid ROUTE source/destination.
Original Source Code Comment: NUMBER OF BYTES
5BCF
LDIR ED B0
Transfers a byte of data from the memory location pointed to by HL to the memory location pointed to by DE. Then HL and DE are incremented and BC is decremented. If BC is not zero, this operation is repeated. Interrupts can trigger while this instruction is processing.
Original Source Code Comment: MOVE TO THE DCB
5BD1
POP HL E1
Restore the position on the COMMAND LINE from the top of the stack into Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: GET COMMAND LINE POINTER BACK
5BD2
INC HL 23
INCrement Register Pair HL past the first character of the 2 character device name ...
Original Source Code Comment: BUMP PAST DESCRIPTOR
5BD3
INC HL 23
... and past the second.
5BD4ROUTE2
LD A,(HL) 7E
Fetch the next character on the COMMAND LINE from the memory location pointed to by Register Pair HL and store it into Register A.
Original Source Code Comment: GET NEXT CHAR ON COMMAND LINE
5BD5
CP 20HCP ' ' FE 20
Compare the value held in Register A against 20H (ASCII: SPACE). Results: If Register A equals SPACE, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: SPACE?
5BD7
If we got a SPACE then we need to keep looking for the next valid character on the COMMAND LINE and the Z FLAG (Zero) will have been set, JUMP to 5BF1H to point the next character on the COMMAND LINE and then JUMP to 5BD4H.
Original Source Code Comment: YES, CONTINUE
5BD9
CP 2CHCP ',' FE 2C
Compare the value held in Register A against ,. Results: If Register A equals ,, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: COMMA?
5BDB
If we got a , then we need to keep looking for the next valid character on the COMMAND LINE and the Z FLAG (Zero) will have been set, JUMP to 5BF1H to point the next character on the COMMAND LINE and then JUMP to 5BD4H.
Original Source Code Comment: YES
5BDD
CP 29HCP ')' FE 29
Compare the value held in Register A against 29H (ASCII: )). Results: If Register A equals ), the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: END OF LIST?
5BDF
If we got a ) then we are at the end of the command and the Z FLAG (Zero) will have been set, JUMP to 5BE5H.
Original Source Code Comment: YES, DO IT
5BE1
CP 0DH FE 0D
Compare the value held in Register A against 0DH (ASCII: CARRIAGE RETURN). Results: If Register A equals CARRIAGE RETURN, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: END OF LINE?
5BE3
If the next character was NOT a CARRIAGE RETURN then we have more COMMAND LINE to search. JUMP to 5BB3H.
Original Source Code Comment: MUST BE MORE ON THE LINE
5BE5ROUTE3
LD A,80H 3E 80
Let Register A equal 80H, which is the ROUTE/DUAL FLAG for "ROUTE ACTIVE".
Original Source Code Comment: SET THE DUAL/ROUTE FLAG
5BE7
LD (442FH),ALD (DULFLG),A 32 2F 44
Store the value held in Register A into memory location 442FH, which is the ROUTE/DUAL FLAG.
5BEA
GOSUB to 006CH to route the devices.
Original Source Code Comment: DO THE ROUTE
5BED
If the NZ FLAG (Not Zero) has been set, then the CALL produced an error, so JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: PARAM ERROR
5BF0
RET C9
RETurn to the caller.

5BF1H - ROUTE4 - ROUTINE inside the ROUTE COMMAND. Move the pointer to the current character on the COMMAND LINE by 1 and then JUMP to 5BD4H.

5BF1ROUTE4
INC HL 23
Point to the next character on the command line by INCrementing the value stored in Register Pair HL by 1.
Original Source Code Comment: BUMP TO NEXT CHAR
5BF2
JUMP BACK to 5BD4H.
Original Source Code Comment: AND CONTINUE

5BF4H - ROUTE5 - ROUTINE inside the ROUTE COMMAND. Process the DESTINATION.

5BF4ROUTE5
LD DE,5C64HLD DE,S9DES1 11 64 5C
Let Register Pair DE equal 5C64H, which points to the word "DESTIN".
Original Source Code Comment: HL => 'DESTIN'
5BF7
LD A,(DE) 1A
Fetch the parameter length (held in the memory location pointed to by Register Pair DE) and store it into Register A.
Original Source Code Comment: GET THE COUNT
5BF8
LD C,A 4F
Copy the length of the word (Register A) into Register C.
Original Source Code Comment: INTO BC
5BF9
LD B,00HLD B,0 06 00
Let Register B equal 00H: Register Pair BC = the length.
5BFB
INC DE 13
INCrement the value stored in Register Pair DE by 1 to now point to the word "DESTIN".
Original Source Code Comment: BUMP TO 1ST CHAR
5BFC
Compare HL and DE to see if they match via a GOSUB to 5B70H.
Original Source Code Comment: DO THE COMPARISON
5BFF
If they don't match, then we didn't get the correct parameter and the NZ FLAG (Not Zero) will have been set, so JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: WASN'T ANYTHING SUPPORTED
5C02
ADD HL,BC 09
Point Register Pair HL to the next COMMAND LINE character after DESTIN by advancing HL by BC bytes.
Original Source Code Comment: ADD THE COUNT TO COMMAND LINE
5C03
Get the device name from the COMMAND LINE via a GOSUB to 5C10H.
Original Source Code Comment: HL => '='. GET THE TOKEN
5C06
If the NZ FLAG (Not Zero) has been set, then the CALL produced an error, so JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: EXIT IF ERROR
5C09
PUSH HL E5
Save the position on the COMMAND LINE (held in Register Pair HL) to the top of the stack.
Original Source Code Comment: SAVE COMMAND LINE POINTER
5C0A
EX DE,HL EB
EXchange the value stored in Register Pair HL (the position on the COMMAND LINE) with the value stored in Register Pair DE (the DESTINATION name).
Original Source Code Comment: HL => TOKEN
5C0B
LD DE,4220HLD DE,SOURCE 11 20 42
Let Register Pair DE equal 4220H (SOURCE), the source field of the ROM's route DCB, for the DESTIN= device name (the source code stores the two names this way round).
Original Source Code Comment: DE => SOURCE IN DCB
5C0E
JUMP into the prior routine to move the bytes and then keep polling the COMMAND LINE.
Original Source Code Comment: SET IT

5C10H - GETTOK - Continuation of the ROUTE routine; process the actual source/destination device code.

5C10GETTOK
LD A,(HL) 7E
Fetch the next character from the command line (held in the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET NEXT CHAR ON COMMAND LINE
5C11
CP 3DHCP '=' FE 3D
Compare the value held in Register A against 3DH (ASCII: =).
Original Source Code Comment: EQUAL?
5C13
RET NZ C0
If the next character was NOT a (ASCII: =), the NZ FLAG (Not Zero) will have been set, RETurn to the caller.
Original Source Code Comment: NO, ERROR. EXIT
5C14
INC HL 23
Point to the next character on the command line, following the =, by INCrementing the value stored in Register Pair HL by 1.
Original Source Code Comment: BUMP TO NEXT CHAR
5C15
LD DE,5C6BHLD DE,DO1 11 6B 5C
Let Register Pair DE equal 5C6BH, which points to the word "DO" (meaning the DISPLAY).
Original Source Code Comment: SEE IF DISPLAY
5C18
LD BC,0002HLD BC,2 01 02 00
Let Register Pair BC equal 0002H.
5C1B
Compare HL and DE to see if they match via a GOSUB to 5B70H.
5C1E
RET Z C8
If command line pointed to "DO" then the Z FLAG (Zero) will have been set, RETurn to the caller.
Original Source Code Comment: YES, EXIT
5C1F
LD DE,5C6DHLD DE,KB1 11 6D 5C
Let Register Pair DE equal 5C6DH, which points to the word "KB" (meaning the KEYBOARD).
Original Source Code Comment: NO, TRY FOR KEYBOARD
5C22
Compare HL and DE to see if they match via a GOSUB to 5B70H.
5C25
RET Z C8
If command line pointed to "KB" then the Z FLAG (Zero) will have been set, RETurn to the caller.
Original Source Code Comment: YES, EXIT
5C26
LD DE,5C6FHLD DE,PR1 11 6F 5C
Let Register Pair DE equal 5C6FH, which points to the word "PR" (meaning the PRINTER).
Original Source Code Comment: NO, TRY FOR PRINTER
5C29
Compare HL and DE to see if they match via a GOSUB to 5B70H.
5C2C
RET Z C8
If command line pointed to "PR" then the Z FLAG (Zero) will have been set, RETurn to the caller.
Original Source Code Comment: YES, EXIT
5C2D
LD DE,5C71HLD DE,RO1 11 71 5C
Let Register Pair DE equal 5C71H, which points to the word "RO" (meaning the RS-232 OUT).
Original Source Code Comment: NO, TRY FOR RS-232 OUTPUT
5C30
Compare HL and DE to see if they match via a GOSUB to 5B70H.
5C33
RET Z C8
If command line pointed to "RO" then the Z FLAG (Zero) will have been set, RETurn to the caller.
Original Source Code Comment: YES, EXIT
5C34
LD DE,5C73HLD DE,RI1 11 73 5C
Let Register Pair DE equal 5C73H, which points to the word "RI" (meaning the RS-232 IN).
Original Source Code Comment: THEN IT HAS TO BE RS-232 INPUT
5C37
Compare HL and DE to see if they match via a JUMP (not GOSUB) to 5B70H.

5C3AH - NOROTE - Abort out of the ROUTE command via a "CAN'T ROUTE" Error.

5C3ANOROTE
LD HL,5C40HLD HL,RTMSG 21 40 5C
Let Register Pair HL equal 5C40H (RTMSG), the message 'Can't Route while DUAL is on' and 0DH.
Original Source Code Comment: HL => 'CANT ROUTE' MSG
5C3D
JUMP to 021BH.
NOTE: 021BH is the Model III ROM routine to display the characters at (HL) until a 03H or a 0DH (which is shown) is found. Since this was JUMPED to instead of CALLed, the RET at the end of this ROM routine will then RETurn to the caller of this subroutine instead of returning to this place.
Original Source Code Comment: DISPLAY AND RETURN

5C40H - RTMSG - MESSAGE and BYTE STORAGE AREA for the ROUTE COMMAND (used only by the ROUTE code that is never reached).

5C40-5C42RTMSG
DEFM 'Can' 43 61 6E
RTMSG: text 'Can' (only the unreachable ROUTE code uses this message).
5C43
DEFB 27H 27
27H, the apostrophe.
5C44-5C5B
DEFM 't Route while DUAL is on' 74 20 52 6F 75 74 65 20 77 68 69 6C 65 20 44 55 41 4C 20 69 73 20 6F 6E
Text 't Route while DUAL is on'.
5C5C
DEFB 0DH 0D
0DH ends the message.
5C5DS9SRC1
DEFB 06H 06
S9SRC1: 06H, the length of the text that follows.
5C5E-5C63
DEFM 'SOURCE' 53 4F 55 52 43 45
Text 'SOURCE'.
5C64S9DES1
DEFB 06H 06
S9DES1: 06H, the length of the text that follows.
5C65-5C6A
DEFM 'DESTIN' 44 45 53 54 49 4E
Text 'DESTIN'.
5C6B-5C6CDO1
DEFM 'DO' 44 4F
DO1: device name 'DO' (display).
5C6D-5C6EKB1
DEFM 'KB' 4B 42
KB1: device name 'KB' (keyboard).
5C6F-5C70PR1
DEFM 'PR' 50 52
PR1: device name 'PR' (printer).
5C71-5C72RO1
DEFM 'RO' 52 4F
RO1: device name 'RO' (RS-232 output).
5C73-5C74RI1
DEFM 'RI' 52 49
RI1: device name 'RI' (RS-232 input).

5C75H - "SETCOM" Command - Configure the RS-232.

5C75SETCOM
Get the next non-space COMMAND LINE character via a GOSUB to 5F8EH.
Original Source Code Comment: SKIP ANY SPACES ON COMMAND LINE
5C78
CP 20HCP ' ' FE 20
Compare the value held in Register A against 20H (ASCII: SPACE). Results:
  • If Register A equals SPACE, the Z FLAG is set.
  • If A < SPACE, the CARRY FLAG will be set.
  • if A >= SPACE, the NO CARRY FLAG will be set.

Original Source Code Comment: END OF LINE?
5C7A
If the character from the command line is >= SPACE, meaning we have an ALPHANUMERIC character, then the NC FLAG (No Carry) will have been set, JUMP to 5D1FH.
Original Source Code Comment: NO, GET PARAMETERS
5C7D
LD A,(41F9H)LD A,(UART) 3A F9 41
Fetch the value held in memory location 41F9H (which is where the RS-232 configuration is stored) and store it into Register A.
Original Source Code Comment: GET THE TRANSMIT FLAG
5C80
OR A B7
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
Original Source Code Comment: RS-232 OFF?
5C81
If the RS-232 Configuration Byte is zero, then the RS-232 is disabled; JUMP to 5D09H.
Original Source Code Comment: YES, JUST DISPLAY OFF MESSAGE
5C84SHOTEL
LD HL,5E9FHLD HL,BAUDMG 21 9F 5E
Let Register Pair HL equal 5E9FH, which is the pointer to the "BAUD = " message.
Original Source Code Comment: HL => 'BAUD = ' MSG
5C87
GOSUB to 5B80H to display the "BAUD = " message.
Original Source Code Comment: DISPLAY IT
5C8A
LD A,(41F8H)LD A,(BAUD) 3A F8 41
Fetch the value held in memory location 41F8H (which is where the RS-232 BAUD RATE is stored) and store it into Register A.
Original Source Code Comment: GET THE BAUD RATE
5C8D
AND 0FH E6 0F
MASK the value of Register A against 0FH (0000 1111). This has the effect of leaving only bits 3, 2, 1, 0 active, which hold the RECEIVE BAUD RATE.
Original Source Code Comment: MASK OFF XMIT BITS
5C8F
ADD A,A 87
LET Register A = Register A * 2, because each entry in the table is 2 bytes.
Original Source Code Comment: MULTIPLY BY 2
5C90
LD C,A 4F
Copy the doubled baud code (Register A) into Register C.
Original Source Code Comment: INTO BC
5C91
LD B,00HLD B,0 06 00
Let Register B equal 00H: Register Pair BC = the offset into the table.
5C93
LD HL,5E81HLD HL,TABLE2 21 81 5E
Let Register Pair HL equal 5E81H (TABLE2), the table of the addresses of the baud rate texts, one 2 byte entry per baud code.
Original Source Code Comment: HL => CONVERSION TABLE
5C96
ADD HL,BC 09
Move HL down the BAUD RATE LOOKUP TABLE by the OFFSET held in Register Pair BC.
5C97
LD E,(HL) 5E
Fetch the LSB of the location of the Baud Rate Text (held in the memory location pointed to by Register Pair HL) and store it into Register E.
Original Source Code Comment: GET THE ADDRESS THERE
5C98
INC HL 23
INCrement the value stored in Register Pair HL by 1 to as to point to the next byte of the BAUD RATE LOOKUP TABLE.
5C99
LD D,(HL) 56
Fetch the MSB of the address of the baud rate text (the byte at Register Pair HL) into Register D.
5C9A
EX DE,HL EB
EXchange the value stored in Register Pair HL (currently pointing to the 2nd byte of the 2 byte address for the BAUD RATE LOOKUP TABLE) with the value stored in Register Pair DE (the address of the desired BAUD RATE text).
Original Source Code Comment: HL => TEXT
5C9B
Display the baud rate and a comma via a GOSUB to 5B89H.
Original Source Code Comment: DISPLAY BAUD RATE
5C9E
LD HL,5EA4HLD HL,UARTMG 21 A4 5E
Let Register Pair HL equal 5EA4H (UARTMG), the text 'WORD'.
Original Source Code Comment: HL => 'UART = ' MSG
5CA1
Display 'WORD' and ' = ' via a GOSUB to 5B80H (PDATA).
Original Source Code Comment: DISPLAY IT
5CA4
LD A,(41F9H)LD A,(UART) 3A F9 41
Fetch the value held in memory location 41F9H (which is where the RS-232 Configuration Byte is stored) and store it into Register A.
Original Source Code Comment: GET THE BIT PATTERN
5CA7
AND 60H E6 60
MASK the value of Register A against 60H (0110 0000) leaving only bits 6 and 5 active.
Original Source Code Comment: MASK ALL BUF NUMBER OF BITS
5CA9
RLCA 07
Rotate Register A left (1 of 3) ...
Original Source Code Comment: MOVE THE BITS OVER TO LEAST SIG
5CAA
RLCA 07
Rotate Register A left one bit (2 of 3), bit 7 going into bit 0 and the CARRY FLAG.
5CAB
RLCA 07
Rotate Register A left one bit (3 of 3): bits 6 and 5 (the word length code) are now bits 1 and 0.
5CAC
ADD A,A 87
LET Register A = Register A * 2, because each entry in the table is 2 bytes.
Original Source Code Comment: TIMES 2
5CAD
LD C,A 4F
Copy the doubled word length code (Register A) into Register C.
Original Source Code Comment: INTO BC
5CAE
LD B,00HLD B,0 06 00
Let Register B equal 00H: Register Pair BC = the offset into the table.
5CB0
LD HL,5E79HLD HL,TABLE1 21 79 5E
Let Register Pair HL equal 5E79H (TABLE1), the table of the addresses of the word length texts (code 0 = 5, 1 = 7, 2 = 6, 3 = 8 bits).
Original Source Code Comment: HL => NUMBER OF BITS TABLE
5CB3
ADD HL,BC 09
Let Register Pair HL = the top of the lookup table (Register Pair HL) + an offset (Register BC).
Original Source Code Comment: HL => ADDRESS OF MESSAGE
5CB4
LD E,(HL) 5E
Fetch the LSB of the address of the word length text (the byte at Register Pair HL) into Register E.
Original Source Code Comment: GET THE ADDRESS
5CB5
INC HL 23
INCrement the value stored in Register Pair HL by 1 to as to point to the next byte of the WORD LENGTH LOOKUP TABLE.
5CB6
LD D,(HL) 56
Fetch the MSB of the address of the word length text into Register D.
5CB7
EX DE,HL EB
EXchange Register Pairs DE and HL: HL = the address of the word length text.
Original Source Code Comment: INTO HL
5CB8
Display the word length and a comma via a GOSUB to 5B89H.
Original Source Code Comment: DISPLAY IT
5CBB
LD HL,5EA9HLD HL,STOPMG 21 A9 5E
Let Register Pair HL equal 5EA9H, which is a pointer to the message "STOP = ".
Original Source Code Comment: HL => 'STOP = ' MSG
5CBE
Display the message "STOP = " via a GOSUB to 5B80H.
5CC1
LD A,(41F9H)LD A,(UART) 3A F9 41
Fetch the value held in memory location 41F9H (which is where the RS-232 configuration is stored) and store it into Register A.
Original Source Code Comment: GET THE BIT PATTERN
5CC4
BIT 4,A CB 67
Test Bit Number 4 (which is the STOP bit) of Register A. Z FLAG will be set if that bit is 0, and NZ FLAG will be set if that bit is 1.
Original Source Code Comment: 2 STOP BITS?
5CC6
LD A,31HLD A,'1' 3E 31
Let Register A equal 31H (ASCII: 1).
Original Source Code Comment: ASSUME 1
5CC8
If the Z FLAG (Zero) has been set, then there is ONE stop bit, so skip the next instrution (which sets up for a display of "2") and JUMP to 5CCBH.
Original Source Code Comment: YES, WAS 1 STOP BIT
5CCA
INC A 3C
INCrement the value stored in Register A by 1 to now be a 2.
Original Source Code Comment: MAKE IT '2'
5CCBSETNO1
GOSUB to 0033H.
NOTE: 0033H is the Model III ROM character print routine; displays the character held in Register A at the current cursor position.
Original Source Code Comment: DISPLAY IT ON THE SCREEN
5CCE
Display a "," via a GOSUB to 5B8CH.
Original Source Code Comment: OUTPUT COMMA AND SPACE
5CD1
LD HL,5EAEHLD HL,PARTMG 21 AE 5E
Let Register Pair HL equal 5EAEH, which is a pointer to the message "PARITY = ".
Original Source Code Comment: HL => 'PARITY = '
5CD4
Display the message "PARITY = " via a GOSUB to 5B80H.
Original Source Code Comment: DISPLAY IT
5CD7
LD A,(41F9H)LD A,(UART) 3A F9 41
Fetch the value held in memory location 41F9H (which is where the RS-232 Configuration Byte is stored) and store it into Register A.
Original Source Code Comment: GET THE UART FLAG AGAIN
5CDA
LD HL,5EB5HLD HL,NONE 21 B5 5E
Let Register Pair HL equal 5EB5H, which is a pointer to the message "NONE".
Original Source Code Comment: HL => 'NONE' IN CASE
5CDD
BIT 3,A CB 5F
Test Bit Number 3 of Register A to determine the PARITY status. Z FLAG will be set if that bit is 0 (which will mean PARITY IS ON), and NZ FLAG will be set if that bit is 1 (which will mean PARITY IS OFF).
Original Source Code Comment: PARITY OFF?
5CDF
If Parity is OFF then the NZ FLAG (Not Zero) will have been set. No need to determine ODD or EVEN so skip over all that via a JUMP to 5CECH.
Original Source Code Comment: YES, IT'S OFF. PRINT AND RETURN
5CE2S9NOT2
LD HL,5EBAHLD HL,ODD 21 BA 5E
Let Register Pair HL equal 5EBAH, which is a pointer to the message "ODD".
Original Source Code Comment: ASSUME ODD
5CE5
BIT 7,A CB 7F
Test Bit Number 7 of Register A to determine if the PARITY is odd or even. Z FLAG will be set if that bit is 0 (meaning ODD PARITY), and NZ FLAG will be set if that bit is 1 (meaning EVEN PARITY).
Original Source Code Comment: IS IT
5CE7
If Bit 7 was 0, then we have ODD PARITY and the Z FLAG (Zero) will have been set. No need to determine EVEN parity, so skip over that via a JUMP to 5CECH.
Original Source Code Comment: YES, IT'S ODD
5CE9
LD HL,5EBEHLD HL,EVEN 21 BE 5E
Let Register Pair HL equal 5EBEH, which is a pointer to the message "EVEN".
5CECS9NOT3
Display the message pointed to by Register Pair HL (either NONE, ODD, or EVEN) and a "," via a GOSUB to 5B89H.
Original Source Code Comment: DIAPLAY PARITY AND RETURN
5CEF
LD A,20HLD A,' ' 3E 20
Let Register A equal 20H (ASCII: SPACE).
Original Source Code Comment: CHANGE ',' TO A ' '
5CF1
LD (5B8DH),ALD (PCHANG),A 32 8D 5B
Store the 20H (Register A) into 5B8DH (PCHANG), the operand of the LD A,',' in PDATA2, so that PDATA1 now ends with two spaces instead of a comma and a space.
Original Source Code Comment: IN THE PRINT ROUTINE
5CF4
LD A,(41FAH)LD A,(WAIT) 3A FA 41
Fetch the RS-232 wait flag (41FAH, WAIT) into Register A: non zero = WAIT, 00H = NO WAIT.
Original Source Code Comment: GET THE WAIT/NO WAIT FLAG
5CF7
LD HL,5EC3HLD HL,WAITS 21 C3 5E
Let Register Pair HL equal 5EC3H, which is a pointer to the message "WAIT".
Original Source Code Comment: HL => 'WAIT'
5CFA
OR A B7
Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
5CFB
If the flag is not zero the NZ FLAG is set: JUMP to 5D00H (S9NOT4) to show 'WAIT'.
Original Source Code Comment: IS WAIT MODE. DISPLAY
5CFD
LD HL,5EC8HLD HL,NWAITS 21 C8 5E
Let Register Pair HL equal 5EC8H, which is a pointer to the message "NO WAIT".
Original Source Code Comment: NO WAIT MODE
5D00S9NOT4
Display the WAIT STATUS, whatever it is, via a GOSUB to 5B89H.
Original Source Code Comment: DISPLAY AND EXIT
5D03
LD HL,5ED0HLD HL,SMODE 21 D0 5E
Let Register Pair HL equal 5ED0H, which is a pointer to the message "MODE".
Original Source Code Comment: HL => MODE
5D06
Display the message "MODE" and RETurn via a JUMP to 5B89H.
Original Source Code Comment: DISPLAY AND EXIT

5D09H - SETOFF - SETCOM Routine - Turn the RS-232 Off.

5D09SETOFF
XOR A AF
Set Register A to ZERO and clear all Flags.
Original Source Code Comment: TURN RS-232 OFF
5D0A
LD (41F8H),ALD (BAUD),A 32 F8 41
Zero out the BAUD RATE by storing the value held in Register A into memory location 41F8H (RS-232 Baud Rate).
Original Source Code Comment: NO BAUD RATE
5D0D
LD (41F9H),ALD (UART),A 32 F9 41
Zero out the UART CONFIGURATION by storing the value held in Register A into memory location 41F9H (RS-232 Configuration Byte).
Original Source Code Comment: NO UART CONFIG
5D10
DEC A 3D
DECrement the value stored in Register A by 1 to now be FFH.
5D11
LD (41FAH),ALD (WAIT),A 32 FA 41
Store the FFH (Register A) into 41FAH (WAIT): wait mode.
Original Source Code Comment: SET 'WAIT' MODE
5D14
LD HL,5F22HLD HL,RSOFF 21 22 5F
Let Register Pair HL equal 5F22H (RSOFF), the message 'RS-232 is now off' and 0DH.
Original Source Code Comment: HL => 'RS-232 OFF' MSG
5D17SETOUT
PUSH HL E5
Save the pointer to 'RS-232 is now off' (Register Pair HL) to the STACK while the ROM's 005AH sets up the RS-232.
Original Source Code Comment: SAVE TEXT POINTER
5D18
GOSUB to 005AH, which is the Model III ROM routine to Initialize the RS-232-C Interface.
Original Source Code Comment: DO THE INIT
5D1B
POP HL E1
Restore the pointer to 'RS-232 is now off' from the STACK into Register Pair HL.
Original Source Code Comment: GET TEXT POINTER BACK
5D1C
JUMP to 021BH.
NOTE: 021BH is the Model III ROM routine to display the characters at (HL) until a 03H or a 0DH (which is shown) is found. Since this was JUMPED to instead of CALLed, the RET at the end of this ROM routine will then RETurn to the caller of this subroutine instead of returning to this place.
Original Source Code Comment: PRINT IT AND EXIT

5D1FH - SETCO1 - SETCOM Routine - Set up the RS-232 Channel.

5D1FSETCO1
CP 28HCP '(' FE 28
Check to see if we are at the start of a parameter list by comparing the value held in Register A against 28H (ASCII: (). Results: If Register A equals (, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: START OF PARAMETER LIST?
5D21
If Register A does NOT equal (, then we have a bad character, so JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: NO, PARAMETER ERROR
5D24
INC HL 23
Point HL to the next character (the one following the "(") on the COMMAND LINE by INCrementing the value stored in Register Pair HL by 1.
Original Source Code Comment: BUMP TO NEXT CHAR
5D25
LD A,(HL) 7E
Fetch the next character on the COMMAND LINE (held in the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET THE CHARACTER
5D26
CP 29HCP ')' FE 29
Compare the value held in Register A against 29H (ASCII: )). Results: If Register A equals 29H ), the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: SET DEFAULT FALUES?
5D28
If we didn't get a ")" then the NZ FLAG (Not Zero) will have been set, set the values by JUMPing to 5D3DH.
Original Source Code Comment: NO, SET THE VALUES
5D2A
LD A,0A4H 3E A4
Let Register A equal A4H (1010 0100), the default UART byte: bit 7 set even parity, bits 6-5 = 01 7 bits (TABLE1 order), bit 4 clear 1 stop bit, bit 3 clear parity on, bit 2 set (the source's transmit enable bit, as SETVA9 sets it).
Original Source Code Comment: SET THE UART CONFIG
5D2C
LD (41F9H),ALD (UART),A 32 F9 41
Store the bit pattern 1010 0100 (held in Register A) into memory location 41F9H.
5D2F
LD A,55H 3E 55
Let Register A equal 55H (0101 0101).
Original Source Code Comment: SET FOR 300 BAUD
5D31
LD (41F8H),ALD (BAUD),A 32 F8 41
Store the bit pattern 0101 0101 (held in Register A) into memory location 41F8H to set the SEND and RECEIVE BAUD RATE to 300.
5D34
LD (41FAH),ALD (WAIT),A 32 FA 41
Store the 55H (Register A) into 41FAH (WAIT): not zero, so wait mode.
Original Source Code Comment: SET FOR WAIT MODE
5D37
GOSUB to 005AH, which is the Model III ROM routine to Initialize the RS-232-C Interface.
Original Source Code Comment: DO THE INIT
5D3A
JUMP back to the RS-232 display status at 5C84H.
Original Source Code Comment: DISPLAY THE VALUES

5D3DH - SETVAL - SETCOM Routine - Set up the RS-232 Channel - Jumped to when the character after the "(" is not ")": the options are parsed and applied.

5D3DSETVAL
DEC HL 2B
DECrement Register Pair HL back to the "(" for SWITCH.
Original Source Code Comment: BACK UP TO THE '('
5D3E
LD DE,5E11HLD DE,SETSWT 11 11 5E
Let Register Pair DE equal 5E11H which is the PARSER TABLE for valid SETCOM commands.
Original Source Code Comment: DE => SYNTAX TABLE
5D41
GOSUB to 4454H.
NOTE: 4454H is the SYS0 vector SWITCH (SYS1 entry 6, PARAM): it matches the options in parentheses at Register Pair HL against the table at Register Pair DE and stores each value (FFFFH for a name alone) in the two bytes the matching table entry points to; NZ = an option that is not in the table.
Original Source Code Comment: CHECK THE VALUES
5D44
If the NZ FLAG (Not Zero) has been set, then the CALL produced an error, so JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: EXIT IF ERROR
5D47
LD HL,(5E03H)LD HL,(SOFF) 2A 03 5E
Fetch the value held in memory location 5E03H (the RS-232 ON/OFF FLAG) and store it into Register Pair HL.
Original Source Code Comment: SEE IF RS-232 OFF
5D4A
LD A,H 7C
Copy Register H into Register A ...
5D4B
OR L B5
... and OR it with Register L: NZ when OFF was given.
5D4C
If OFF was given the NZ FLAG is set: JUMP to 5D09H (SETOFF).
Original Source Code Comment: YES, DO IT
5D4E
LD HL,(5E0DH)LD HL,(SWAIT) 2A 0D 5E
Fetch the WAIT value SWITCH stored (5E0DH, SWAIT; FFFFH when WAIT was given, 0000H when not) into Register Pair HL.
Original Source Code Comment: SEE IF WAIT MODE
5D51
LD A,H 7C
Copy Register H into Register A ...
5D52
OR L B5
... and OR it with Register L: NZ when WAIT was given (Register A is then FFH).
5D53
If WAIT was not given the Z FLAG is set: JUMP to 5D5AH (SETVA1) to look for NOWAIT.
Original Source Code Comment: NO, TRY FOR NO WAIT
5D55SETWAT
LD (41FAH),ALD (WAIT),A 32 FA 41
Store Register A into 41FAH (WAIT): non zero (FFH from WAIT) = wait mode, 00H (from NOWAIT) = no wait.
Original Source Code Comment: SET WAIT/NO WAIT MODE
5D58
Set the value and continue by JUMPing to 5D64H.
Original Source Code Comment: AND CONTINUE

5D5AH - SETVA1 - SETCOM Routine - Reset WAIT Mode.

5D5ASETVA1
LD HL,(5E0FH)LD HL,(SSWAIT) 2A 0F 5E
Fetch the value held in memory location 5E0FH (the "NO WAIT" FLAG) and store it into Register Pair HL.
Original Source Code Comment: SEE IF NO WAIT MODE
5D5D
LD A,H 7C
Copy Register H into Register A ...
5D5E
OR L B5
... and OR it with Register L: NZ when NOWAIT was given.
5D5F
If NOWAIT was not given either the Z FLAG is set: JUMP to 5D64H (SETVA2) and leave the wait flag as it is.
Original Source Code Comment: NO, CONTINUE
5D61
XOR A AF
Set Register A to 00H (no wait mode).
Original Source Code Comment: CLEAR THE WAIT FLAG
5D62
JUMP to 5D55H to continue.

5D64H - SETVA2 - SETCOM Routine - Set the Baud Rate and Stop Bits.

5D64SETVA2
LD BC,(5E05H)LD BC,(SBAUD) ED 4B 05 5E
Fetch the value held in memory location 5E05H (the BAUD RATE FLAG) and store it into Register Pair BC.
Original Source Code Comment: GET THE BAUD RATE
5D68
LD A,B 78
Copy Register B into Register A ...
Original Source Code Comment: ANY BAUD RATE GIVEN
5D69
OR C B1
... and OR it with Register C: NZ when BAUD= was given.
5D6A
If BAUD= was not given the Z FLAG is set: JUMP to 5D86H (SETVA4).
Original Source Code Comment: NO, CONTINUE
5D6C
LD HL,5E4AHLD HL,BADTAB 21 4A 5E
Let Register Pair HL equal 5E4AH, which is the top of the BAUD RATE LOOKUP TABLE.
Original Source Code Comment: HL => BAUD RATE TABLE
5D6FSETVA3
LD A,(HL) 7E
Fetch the character in the BAUD RATE LOOKUP TABLE (held in the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET THE BYTE
5D70
CP 0FFHCP -1 FE FF
Compare the value held in Register A against the end of table terminator byte (i.e., 0FFH). Results: If Register A equals 0FFH, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: END OF TABLE
5D72
If we ran out of entries then the Z FLAG (Zero) will have been set, so JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: YES, PARAMETER ERROR
5D75
LD E,(HL) 5E
Fetch the LSB of the 2 byte baud rate code (held in the memory location pointed to by Register Pair HL) and store it into Register E.
Original Source Code Comment: GET THE VALUE
5D76
INC HL 23
INCrement the table pointer (stored in Register Pair HL) by 1. HL should now be pointing to the MSB of the baud rate code.
5D77
LD D,(HL) 56
Fetch the MSB of the baud rate value in the table (the byte at Register Pair HL) into Register D.
5D78
INC HL 23
INCrement the table pointer (stored in Register Pair HL) by 1. HL should now be pointing to the value associated with that baud rate.
Original Source Code Comment: BUMP TO BYTE VALUE
5D79
INC HL 23
INCrement the value stored in Register Pair HL by 1. HL should now be pointing to the LSB of the next baud rate in the table.
Original Source Code Comment: BUMP TO NEXT BAUD RATE
5D7A
OR A B7
Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
Original Source Code Comment: CLEAR CARRY
5D7B
EX DE,HL EB
EXchange the value stored in Register Pair HL (the pointer to the next entry in the BAUD RATE TABLE) with the value stored in Register Pair DE (the last decoded baud rate).
Original Source Code Comment: HL = VALUE FROM TABLE
5D7C
SBC HL,BC ED 42
Check to see if the table entry matches what the user entered via subtracting the value stored in Register Pair BC and the carry flag from the value stored in Register Pair HL.
Original Source Code Comment: BC = DESIRED VALUE
5D7E
EX DE,HL EB
EXchange the value stored in Register Pair HL (the last decoded baud rate) with the value stored in Register Pair DE (the pointer to the next entry in the BAUD RATE TABLE).
5D7F
If there was no match, then the NZ FLAG (Not Zero) will have been set, JUMP to 5D6FH to look at the next entry in the table.
Original Source Code Comment: NO MATCH
5D81
DEC HL 2B
DECrement the value stored in Register Pair HL by 1 to now point to the value associated with the match (which is the BAUD RATE in the table entry).
Original Source Code Comment: BACK UP TO THE BAUD RATE
5D82
LD A,(HL) 7E
Fetch the value held in the memory location pointed to by Register Pair HL and store it into Register A.
Original Source Code Comment: GET IT
5D83
LD (41F8H),ALD (BAUD),A 32 F8 41
Store the value from the table which matched the selected baud rate (held in Register A) into memory location 41F8H (which is the Model III storage location for the TRANSMIT and RECEIVE Baud Rate).
Original Source Code Comment: SET IT INTO THE RS-232 DCB
5D86SETVA4
LD HL,(5E09H)LD HL,(SSTOP) 2A 09 5E
Fetch the value held in memory location 5E09H (i.e., the NUMBER OF STOP BITS) and store it into Register Pair HL.
Original Source Code Comment: GET THE STOP BITS
5D89
LD A,H 7C
Copy Register H into Register A ...
Original Source Code Comment: ANY STOP GIVEN
5D8A
OR L B5
... and OR it with Register L: NZ when STOP= was given.
5D8B
If the Z FLAG (Zero) has been set, then no stop bits were given, so JUMP to 5D96H to continue.
Original Source Code Comment: NO, CONTINUE
5D8D
DEC L 2D
Start testing to see if ONE stop bit was given by DECrementing the LSB of the STOP BIT value stored in Register L by 1.
Original Source Code Comment: SEE IF 1 STOP BIT
5D8E
LD B,10H 06 10
Let Register B equal a mask of 10H (0001 0000).
Original Source Code Comment: SET BIT 4
5D90
If Register L was already at 0, then we had ONE STOP BIT, and we need to clear that bit via a GOSUB to 5DFAH.
Original Source Code Comment: UNSET BIT 4 IF SET
5D93
If result from that GOSUB set the NZ FLAG -or- Register L was not already at 0, then we have two stop bits, and we need to set that bit via a GOSUB to 5DF1H.
Original Source Code Comment: ELSE SET IT
5D96SETVA5
LD HL,(5E0BH)LD HL,(SPAR) 2A 0B 5E
Fetch the value held in memory location 5E0BH (i.e., the PARITY) and store it into Register Pair HL.
Original Source Code Comment: SEE IF ANY PARITY
5D99
LD A,H 7C
Copy Register H into Register A ...
5D9A
OR L B5
... and OR it with Register L: NZ when PARITY= was given.
5D9B
LD B,08HLD B,8 06 08
Let Register B equal a mask of 08H (0000 1000).
Original Source Code Comment: SET FOR BIT 3
5D9D
If PARITY= was not given the Z FLAG is set: JUMP to 5DB5H (SETVA6).
Original Source Code Comment: NO, CONTINUE
5D9F
LD A,L 7D
Copy the Parity Value (held in Register L) into Register A.
Original Source Code Comment: GET THE VALUE
5DA0
CP 03HCP 3 FE 03
Compare the value held in Register A against 03H. Results: If Register A equals 03H (Parity = NONE), the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: PARITY 'NONE'?
5DA2
If the NO PARITY set has NOT been set, the NZ FLAG (Not Zero) will have been set, JUMP to 5DA9H to set the parity.
Original Source Code Comment: NO, SET IT
5DA4
GOSUB to 5DF1H to set the Parity = NONE bit.
Original Source Code Comment: TURN THE PARITY OFF
5DA7
JUMP to 5DB5H to continue.
Original Source Code Comment: AND CONTINUE

5DA9H - SETV50 - SETCOM Routine - Set the Parity and Word Length.

5DA9SETV50
Reset the PARITY BIT via a GOSUB to 5DFAH.
5DAC
DEC L 2D
DECrement the parity value (Register L): Z when PARITY=1 (odd).
Original Source Code Comment: SEE IF PARITY ODD
5DAD
LD B,80H 06 80
Let Register B equal a mask of 80H (1000 0000).
Original Source Code Comment: SET FOR BIT 7
5DAF
If the DEC resulted in a 0, then clear the bit via a GOSUB to 5DFAH.
Original Source Code Comment: UNSET IF ODD
5DB2
If the NZ FLAG (Not Zero) has been set, then set the bit via a GOSUB to 5DF1H.
Original Source Code Comment: ELSE EVEN
5DB5SETVA6
LD HL,(5E07H)LD HL,(SWORD) 2A 07 5E
Fetch the WORD LENGTH (held in memory location 5E07H) and store it into Register Pair HL.
Original Source Code Comment: SEE IF ANY WORD GIVEN
5DB8
LD A,H 7C
Copy Register H into Register A ...
5DB9
OR L B5
... and OR it with Register L: NZ when WORD= was given.
5DBA
If the WORD LENGTH storage location was a 0, JUMP to 5DE1H.
Original Source Code Comment: NO
5DBC
LD B,60H 06 60
Let Register B equal a mask of 60H (0110 0000).
Original Source Code Comment: GO UNSET PRESENT WORD
5DBE
Clear the word length bits via a GOSUB to 5DFAH.
5DC1
LD A,L 7D
Copy the contents of Register L (the length) into Register A.
Original Source Code Comment: GET THE WORD LENGTH
5DC2
SUB 05HSUB 5 D6 05
SUBtract the value 05H from Register A to leave A in the range of 00-03.
Original Source Code Comment: LOWEST IS 5 BITS
5DC4
If the starting value was too low, then the C FLAG (Carry) has been set, so JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: PARAMETER ERROR IF LESS
5DC7
If the resulting value is 00, then we have 5 bits so JUMP to 5DE1H.
Original Source Code Comment: WAS 5. ALREADY SET
5DC9
LD L,A 6F
Copy the subtracted contents of Register A back into Register L.
Original Source Code Comment: PUT THE VALUE BACK INTO L
5DCA
DEC L 2D
DECrement the value stored in Register L by 1. IF L is 0 then we have 6 bits.
5DCB
If we have MORE than 6 bits, the NZ FLAG (Not Zero) will have been set, so JUMP to 5DD1H.
Original Source Code Comment: NOT 6
5DCD
LD B,40H 06 40
Let Register B equal a mask of 40H (0100 0000).
Original Source Code Comment: SET BIT 6
5DCF
Set the mask of 6 bits via a JUMP to 5DDEH.

5DD1H - SETVA7 - SETCOM Routine - Set the Word Length if 7 Bits.

5DD1SETVA7
DEC L 2D
DECrement the value stored in Register L by 1. IF L is 0 then we have 7 bits.
Original Source Code Comment: HOW ABOUT 7
5DD2
If we don't have 7 bits the NZ FLAG (Not Zero) will have been set, JUMP to 5DD8H.
5DD4
LD B,20H 06 20
Let Register B equal a mask of 20H (0010 0000).
Original Source Code Comment: SET BIT 5
5DD6
Set a mask of 7 bits via a JUMP to 5DDEH.

5DD8H - SETVA8 - SETCOM Routine - Set the Word Length if 8 Bits.

5DD8SETVA8
DEC L 2D
DECrement the value stored in Register L by 1. IF L is 0 then we have 8 bits.
Original Source Code Comment: HOW ABOUT 8
5DD9
If we don't have 8 bits then the NZ FLAG (Not Zero) will have been set, so JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: NO, PARAMETER ERROR
5DDC
LD B,60H 06 60
Let Register B equal a mask of 60H (0110 0000).
Original Source Code Comment: SET BIT 5 AND 6
5DDESETVAA
Set a mask of 8 bits via a GOSUB to 5DF1H.
5DE1SETVA9
LD A,(41F9H)LD A,(UART) 3A F9 41
Fetch the RS-232 Configuration Byte (in memory location 41F9H) and store it into Register A.
Original Source Code Comment: GET THE BUILT UART BYTE
5DE4
AND 0FCH E6 FC
Mask Register A with FCH (1111 1100) to clear bits 1 and 0 of the UART byte.
Original Source Code Comment: INUSRE LSB'S OFF
5DE6
OR 04HOR 4 F6 04
OR Register A with 04H to set bit 2 (the source: transmit enable on).
Original Source Code Comment: INSURE XMIT ENABLE ON
5DE8
LD (41F9H),ALD (UART),A 32 F9 41
Store the revised value held in Register A into memory location 41F9H.
5DEB
GOSUB to 005AH, which is the Model III ROM routine to Initialize the RS-232-C Interface.
Original Source Code Comment: DO THE INIT
5DEE
Display the resulting revised RS-232 settings and RETurn via a JUMP to 5C84H.
Original Source Code Comment: AND DISPLAY VALUE

5DF1H - SETBYT - SETCOM Routine - Set the configuration bits of the RS-232 based on the mask held in Register B.

5DF1SETBYT
LD A,(41F9H)LD A,(UART) 3A F9 41
Fetch the RS-232 Configuration Byte (held in memory location 41F9H) and store it into Register A.
Original Source Code Comment: GET THE UART BYTE WE'RE BUILDING
5DF4
OR B B0
Apply the mask held in Reigster B via ORing Register B against Register A. The results are stored in Register A.
Original Source Code Comment: ADD IN THE NEW VALUE
5DF5SETBY1
LD (41F9H),ALD (UART),A 32 F9 41
Store the revised RS-232 Configuration Byte (value held in Register A) into memory location 41F9H.
Original Source Code Comment: SAVE FOR NEXT TIME
5DF8
XOR A AF
Set Register A to ZERO and clear all Flags.
Original Source Code Comment: SET 'Z'
5DF9
RET C9
RETurn to the caller.

5DFAH - UNSET - SETCOM Routine - Reset the configuration bits of the RS-232 based on the mask held in Register B.

5DFAUNSET
LD A,B 78
Copy the mask (held in Register B on entry) into Register A.
Original Source Code Comment: GET THE VALUE
5DFB
CPL 2F
Reverse each bit in Register A (which is the same as NOT).
Original Source Code Comment: FLIP IT THE OTHER WAY
5DFC
LD B,A 47
Put the modified mask back into Register B.
Original Source Code Comment: SAVE IT
5DFD
LD A,(41F9H)LD A,(UART) 3A F9 41
Fetch the RS-232 Configuration Byte (held in memory location 41F9H) and store it into Register A.
Original Source Code Comment: GET THE BYTE WE'RE BUILDING
5E00
AND B A0
MASK the value of Register A against the value held in Register B to turn off all the undesired bits.
Original Source Code Comment: TURN OFF DESIRED BITS
5E01
JUMP to 5DF5H to finish.
Original Source Code Comment: AND SAVE IT

5E03H - SOFF - MESSAGE and BYTE STORAGE for SETCOM.

5E03-5E04SOFF
DEFW 0000H 00 00
SOFF: where SWITCH stores the OFF option (FFFFH when given).
5E05-5E06SBAUD
DEFW 0000H 00 00
SBAUD: the BAUD= value, as typed digits in hex form (300 is 0300H).
5E07-5E08SWORD
DEFW 0000H 00 00
SWORD: the WORD= value (5 to 8).
5E09-5E0ASSTOP
DEFW 0000H 00 00
SSTOP: the STOP= value (1 or 2).
5E0B-5E0CSPAR
DEFW 0000H 00 00
SPAR: the PARITY= value (1 odd, 2 even, 3 none).
5E0D-5E0ESWAIT
DEFW 0000H 00 00
SWAIT: FFFFH when WAIT is given.
5E0F-5E10SSWAIT
DEFW 0000H 00 00
SSWAIT: FFFFH when NOWAIT is given.

5E11H - SETSWT - PARSER TABLE for SETCOM.

5E11-5E16SETSWT
DEFM 'OFF ' 4F 46 46 20 20 20
SETSWT: option name 'OFF' padded to 6 characters.
5E17-5E18
DEFW 5E03H 03 5E
Where SWITCH stores it: 5E03H (SOFF).
5E19-5E1E
DEFM 'BAUD ' 42 41 55 44 20 20
Option name 'BAUD'.
5E1F-5E20
DEFW 5E05H 05 5E
Stored at 5E05H (SBAUD).
5E21-5E26
DEFM 'WORD ' 57 4F 52 44 20 20
Option name 'WORD'.
5E27-5E28
DEFW 5E07H 07 5E
Stored at 5E07H (SWORD).
5E29-5E2E
DEFM 'STOP ' 53 54 4F 50 20 20
Option name 'STOP'.
5E2F-5E30
DEFW 5E09H 09 5E
Stored at 5E09H (SSTOP).
5E31-5E36
DEFM 'PARITY' 50 41 52 49 54 59
Option name 'PARITY'.
5E37-5E38
DEFW 5E0BH 0B 5E
Stored at 5E0BH (SPAR).
5E39-5E3E
DEFM 'WAIT ' 57 41 49 54 20 20
Option name 'WAIT'.
5E3F-5E40
DEFW 5E0DH 0D 5E
Stored at 5E0DH (SWAIT).
5E41-5E46
DEFM 'NOWAIT' 4E 4F 57 41 49 54
Option name 'NOWAIT'.
5E47-5E48
DEFW 5E0FH 0F 5E
Stored at 5E0FH (SSWAIT).
5E49
DEFB 00H 00
00H ends the table.

5E4AH - BADTAB - BAUD RATE TABLE for SETCOM.

5E4A-5E4BBADTAB
DEFW 0050H 50 00
BADTAB: Baud rate 50: 0050H, the value SWITCH stores for BAUD=50 (the typed digits in hex form).
5E4C
DEFB 00H 00
The byte SETVA3 stores into 41F8H (BAUD) for 50 baud: code 0H in both nybbles (the source: transmit and receive).
5E4D-5E4E
DEFW 0075H 75 00
Baud rate 75: 0075H, the value SWITCH stores for BAUD=75 (the typed digits in hex form).
5E4F
DEFB 11H 11
The byte SETVA3 stores into 41F8H (BAUD) for 75 baud: code 1H in both nybbles (the source: transmit and receive).
5E50-5E51
DEFW 0110H 10 01
Baud rate 110: 0110H, the value SWITCH stores for BAUD=110 (the typed digits in hex form).
5E52
DEFB 22H 22
The byte SETVA3 stores into 41F8H (BAUD) for 110 baud: code 2H in both nybbles (the source: transmit and receive).
5E53-5E54
DEFW 0134H 34 01
Baud rate 134.5: 0134H, the value SWITCH stores for BAUD=134 (the typed digits in hex form).
5E55
DEFB 33H 33
The byte SETVA3 stores into 41F8H (BAUD) for 134.5 baud: code 3H in both nybbles (the source: transmit and receive).
5E56-5E57
DEFW 0150H 50 01
Baud rate 150: 0150H, the value SWITCH stores for BAUD=150 (the typed digits in hex form).
5E58
DEFB 44H 44
The byte SETVA3 stores into 41F8H (BAUD) for 150 baud: code 4H in both nybbles (the source: transmit and receive).
5E59-5E5A
DEFW 0300H 00 03
Baud rate 300: 0300H, the value SWITCH stores for BAUD=300 (the typed digits in hex form).
5E5B
DEFB 55H 55
The byte SETVA3 stores into 41F8H (BAUD) for 300 baud: code 5H in both nybbles (the source: transmit and receive).
5E5C-5E5D
DEFW 0600H 00 06
Baud rate 600: 0600H, the value SWITCH stores for BAUD=600 (the typed digits in hex form).
5E5E
DEFB 66H 66
The byte SETVA3 stores into 41F8H (BAUD) for 600 baud: code 6H in both nybbles (the source: transmit and receive).
5E5F-5E60
DEFW 1200H 00 12
Baud rate 1200: 1200H, the value SWITCH stores for BAUD=1200 (the typed digits in hex form).
5E61
DEFB 77H 77
The byte SETVA3 stores into 41F8H (BAUD) for 1200 baud: code 7H in both nybbles (the source: transmit and receive).
5E62-5E63
DEFW 1800H 00 18
Baud rate 1800: 1800H, the value SWITCH stores for BAUD=1800 (the typed digits in hex form).
5E64
DEFB 88H 88
The byte SETVA3 stores into 41F8H (BAUD) for 1800 baud: code 8H in both nybbles (the source: transmit and receive).
5E65-5E66
DEFW 2000H 00 20
Baud rate 2000: 2000H, the value SWITCH stores for BAUD=2000 (the typed digits in hex form).
5E67
DEFB 99H 99
The byte SETVA3 stores into 41F8H (BAUD) for 2000 baud: code 9H in both nybbles (the source: transmit and receive).
5E68-5E69
DEFW 2400H 00 24
Baud rate 2400: 2400H, the value SWITCH stores for BAUD=2400 (the typed digits in hex form).
5E6A
DEFB AAH AA
The byte SETVA3 stores into 41F8H (BAUD) for 2400 baud: code AH in both nybbles (the source: transmit and receive).
5E6B-5E6C
DEFW 3600H 00 36
Baud rate 3600: 3600H, the value SWITCH stores for BAUD=3600 (the typed digits in hex form).
5E6D
DEFB BBH BB
The byte SETVA3 stores into 41F8H (BAUD) for 3600 baud: code BH in both nybbles (the source: transmit and receive).
5E6E-5E6F
DEFW 4800H 00 48
Baud rate 4800: 4800H, the value SWITCH stores for BAUD=4800 (the typed digits in hex form).
5E70
DEFB CCH CC
The byte SETVA3 stores into 41F8H (BAUD) for 4800 baud: code CH in both nybbles (the source: transmit and receive).
5E71-5E72
DEFW 7200H 00 72
Baud rate 7200: 7200H, the value SWITCH stores for BAUD=7200 (the typed digits in hex form).
5E73
DEFB DDH DD
The byte SETVA3 stores into 41F8H (BAUD) for 7200 baud: code DH in both nybbles (the source: transmit and receive).
5E74-5E75
DEFW 9600H 00 96
Baud rate 9600: 9600H, the value SWITCH stores for BAUD=9600 (the typed digits in hex form).
5E76
DEFB EEH EE
The byte SETVA3 stores into 41F8H (BAUD) for 9600 baud: code EH in both nybbles (the source: transmit and receive).
5E77-5E78
DEFW FFFFH FF FF
FFFFH ends the table (SETVA3 tests the first byte for FFH).
Original Source Code Comment: END OF LIST

5E79H - TABLE1 - Word Length Text Pointer Table.

5E79-5E7ATABLE1
DEFW 5ED6H D6 5E
TABLE1 entry for word length code 0: the text 5 (5ED6H).
5E7B-5E7C
DEFW 5EDAH DA 5E
Code 1 (bits 6-5 = 01): the text 7 (5EDAH).
5E7D-5E7E
DEFW 5ED8H D8 5E
Code 2: the text 6 (5ED8H).
5E7F-5E80
DEFW 5EDCH DC 5E
Code 3: the text 8 (5EDCH).

5E81H - TABLE2 - Baud Rate Text Pointer Table.

5E81-5E82TABLE2
DEFW 5EDEH DE 5E
TABLE2: Baud code 0H: the address of the text 50 (5EDEH).
5E83-5E84
DEFW 5EE1H E1 5E
Baud code 1H: the address of the text 75 (5EE1H).
5E85-5E86
DEFW 5EE4H E4 5E
Baud code 2H: the address of the text 110 (5EE4H).
5E87-5E88
DEFW 5EE8H E8 5E
Baud code 3H: the address of the text 134.5 (5EE8H).
5E89-5E8A
DEFW 5EEEH EE 5E
Baud code 4H: the address of the text 150 (5EEEH).
5E8B-5E8C
DEFW 5EF2H F2 5E
Baud code 5H: the address of the text 300 (5EF2H).
5E8D-5E8E
DEFW 5EF6H F6 5E
Baud code 6H: the address of the text 600 (5EF6H).
5E8F-5E90
DEFW 5EFAH FA 5E
Baud code 7H: the address of the text 1200 (5EFAH).
5E91-5E92
DEFW 5EFFH FF 5E
Baud code 8H: the address of the text 1800 (5EFFH).
5E93-5E94
DEFW 5F04H 04 5F
Baud code 9H: the address of the text 2000 (5F04H).
5E95-5E96
DEFW 5F09H 09 5F
Baud code AH: the address of the text 2400 (5F09H).
5E97-5E98
DEFW 5F0EH 0E 5F
Baud code BH: the address of the text 3600 (5F0EH).
5E99-5E9A
DEFW 5F13H 13 5F
Baud code CH: the address of the text 4800 (5F13H).
5E9B-5E9C
DEFW 5F18H 18 5F
Baud code DH: the address of the text 7200 (5F18H).
5E9D-5E9E
DEFW 5F1DH 1D 5F
Baud code EH: the address of the text 9600 (5F1DH).

5E9FH - BAUDMG - MESSAGE DISPLAY for SETCOM CONFIGURATION.

5E9F-5EA2BAUDMG
DEFM 'BAUD' 42 41 55 44
BAUDMG: text 'BAUD'.
5EA3
DEFB 03H 03
03H ends the text.
5EA4-5EA7UARTMG
DEFM 'WORD' 57 4F 52 44
UARTMG: text 'WORD'.
5EA8
DEFB 03H 03
03H ends the text.
5EA9-5EACSTOPMG
DEFM 'STOP' 53 54 4F 50
STOPMG: text 'STOP'.
5EAD
DEFB 03H 03
03H ends the text.
5EAE-5EB3PARTMG
DEFM 'PARITY' 50 41 52 49 54 59
PARTMG: text 'PARITY'.
5EB4
DEFB 03H 03
03H ends the text.
5EB5-5EB8NONE
DEFM 'NONE' 4E 4F 4E 45
NONE: text 'NONE'.
5EB9
DEFB 03H 03
03H ends the text.
5EBA-5EBCODD
DEFM 'ODD' 4F 44 44
ODD: text 'ODD'.
5EBD
DEFB 03H 03
03H ends the text.
5EBE-5EC1EVEN
DEFM 'EVEN' 45 56 45 4E
EVEN: text 'EVEN'.
5EC2
DEFB 03H 03
03H ends the text.
5EC3-5EC6WAITS
DEFM 'WAIT' 57 41 49 54
WAITS: text 'WAIT'.
5EC7
DEFB 03H 03
03H ends the text.
5EC8-5ECENWAITS
DEFM 'NO WAIT' 4E 4F 20 57 41 49 54
NWAITS: text 'NO WAIT'.
5ECF
DEFB 03H 03
03H ends the text.
5ED0SMODE
DEFB 08H 08
SMODE: 08H, backspace over the space PDATA1 put after the last item.
Original Source Code Comment: BACKSPACE
5ED1-5ED4
DEFM 'MODE' 4D 4F 44 45
Text 'MODE'.
5ED5
DEFB 0DH 0D
0DH ends the line.
5ED6S5
DEFM '5' 35
S5: text '5'.
5ED7
DEFB 03H 03
03H ends the text.
5ED8S6
DEFM '6' 36
S6: text '6'.
5ED9
DEFB 03H 03
03H ends the text.
5EDAS7
DEFM '7' 37
S7: text '7'.
5EDB
DEFB 03H 03
03H ends the text.
5EDCS8
DEFM '8' 38
S8: text '8'.
5EDD
DEFB 03H 03
03H ends the text.
5EDE-5EDFS50
DEFM '50' 35 30
S50: text '50'.
5EE0
DEFB 03H 03
03H ends the text.
5EE1-5EE2S75
DEFM '75' 37 35
S75: text '75'.
5EE3
DEFB 03H 03
03H ends the text.
5EE4-5EE6S110
DEFM '110' 31 31 30
S110: text '110'.
5EE7
DEFB 03H 03
03H ends the text.
5EE8-5EECS134
DEFM '134.5' 31 33 34 2E 35
S134: text '134.5'.
5EED
DEFB 03H 03
03H ends the text.
5EEE-5EF0S150
DEFM '150' 31 35 30
S150: text '150'.
5EF1
DEFB 03H 03
03H ends the text.
5EF2-5EF4S300
DEFM '300' 33 30 30
S300: text '300'.
5EF5
DEFB 03H 03
03H ends the text.
5EF6-5EF8S600
DEFM '600' 36 30 30
S600: text '600'.
5EF9
DEFB 03H 03
03H ends the text.
5EFA-5EFDS1200
DEFM '1200' 31 32 30 30
S1200: text '1200'.
5EFE
DEFB 03H 03
03H ends the text.
5EFF-5F02S1800
DEFM '1800' 31 38 30 30
S1800: text '1800'.
5F03
DEFB 03H 03
03H ends the text.
5F04-5F07S2000
DEFM '2000' 32 30 30 30
S2000: text '2000'.
5F08
DEFB 03H 03
03H ends the text.
5F09-5F0CS2400
DEFM '2400' 32 34 30 30
S2400: text '2400'.
5F0D
DEFB 03H 03
03H ends the text.
5F0E-5F11S3600
DEFM '3600' 33 36 30 30
S3600: text '3600'.
5F12
DEFB 03H 03
03H ends the text.
5F13-5F16S4800
DEFM '4800' 34 38 30 30
S4800: text '4800'.
5F17
DEFB 03H 03
03H ends the text.
5F18-5F1BS7200
DEFM '7200' 37 32 30 30
S7200: text '7200'.
5F1C
DEFB 03H 03
03H ends the text.
5F1D-5F20S9600
DEFM '9600' 39 36 30 30
S9600: text '9600'.
5F21
DEFB 03H 03
03H ends the text.
5F22-5F32RSOFF
DEFM 'RS-232 is now off' 52 53 2D 32 33 32 20 69 73 20 6E 6F 77 20 6F 66 66
RSOFF: text 'RS-232 is now off'.
5F33
DEFB 0DH 0D
0DH ends the message.

5F34H - "DUAL" Routine - Output to BOTH the Printer and the Display

First, check to see if ROUTE is on.

5F34DUAL
LD A,(442FH)LD A,(DULFLG) 3A 2F 44
Fetch the DUAL status byte (held in memory location 442FH) and store it into Register A. 80H=ROUTE, FFH=DUAL, 00H=Neither.
Original Source Code Comment: GET THE DUAL FLAG
5F37
CP 80H FE 80
Compare the value held in Register A against 80H. Results: If Register A equals 80H, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: IS ROUTE IN EFFECT?
5F39
If A = 80H then ROUTE is active and the the Z FLAG (Zero) will have been set, JUMP to 5F88H.
Original Source Code Comment: YES, CAN'T WHILE ROUTE IS ON
5F3B
Look at the option after DUAL via a GOSUB to 5081H (CHKFLG in SYS1): NZ = ON or no option, Z = OFF.
Original Source Code Comment: SYS 1 ON/OFF CHECK
5F3E
If the CALL returned with the Z FLAG set, the "OFF" parameter was provided; JUMP to 5F64H.

Next, check to see if DUAL is already on.

5F40
LD A,(442FH)LD A,(DULFLG) 3A 2F 44
Fetch the DUAL status byte (held in memory location 442FH) and store it into Register A. 80H=ROUTE, FFH=DUAL, 00H=Neither.
Original Source Code Comment: GET THE FLAG ONCE AGAIN
5F43
OR A B7
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
Original Source Code Comment: IS DUAL ALREADY ON?
5F44
If the DUAL status was already on the NZ FLAG (Not Zero) will have been set, just display the DUAL ON message again via a JUMP to 5F5FH.
Original Source Code Comment: YES, JUST DISPLAY MESSAGE AGAIN

If we're here, then we actually need to process the DUAL command.

5F46
DEC A 3D
DECrement the value stored in Register A by 1 to go from the 00H to FFH.
Original Source Code Comment: MAKE IT 'NZ'
5F47
LD (442FH),ALD (DULFLG),A 32 2F 44
Store the FFH (DUAL mode ON) (held in Register A into memory location 442FH.
5F4A
LD HL,(401EH)LD HL,(DDCB+1) 2A 1E 40
Fetch the video driver address (held in memory location 401EH) and store it into Register Pair HL.
Original Source Code Comment: GET THE DRIVER ADDR
5F4D
LD (4CE7H),HLLD (DDVER1),HL 22 E7 4C
Store the video driver address (held in Register Pair HL) into the system memory location for DUAL's video driver (i.e., 4CE7H).
Original Source Code Comment: SAVE IT IN 'RES' DUAL ROUTINE
5F50
LD HL,(4026H)LD HL,(PDCB+1) 2A 26 40
Fetch the printer driver address (held in memory location 4026H) and store it into Register Pair HL.
Original Source Code Comment: GET THE DRIVER ADDR
5F53
LD (4CF8H),HLLD (DDVER2),HL 22 F8 4C
Store the printer driver address (held in Register Pair HL) into the system memory location for DUAL's printer driver (i.e., 4CF8H).
Original Source Code Comment: SAVE IT IN DUAL ROUTINE
5F56
LD HL,4CE1HLD HL,DUALIT 21 E1 4C
Let Register Pair HL equal 4CE1H, which is the code for the DUAL routine.
Original Source Code Comment: ADDRESS OF THE DUAL ROUTINE
5F59
LD (401EH),HLLD (DDCB+1),HL 22 1E 40
Store 4CE1H (Register Pair HL) as the driver address of the display DCB (401EH-401FH), so that display output goes through DUALIT.
Original Source Code Comment: INTO VIDEO
5F5C
LD (4026H),HLLD (PDCB+1),HL 22 26 40
Store 4CE1H (Register Pair HL) as the driver address of the printer DCB (4026H-4027H) as well.
Original Source Code Comment: INTO PRINTER
5F5FDUALON
LD HL,5FD2HLD HL,ON 21 D2 5F
Let Register Pair HL equal 5FD2H, to point to the message "ON".
Original Source Code Comment: HL => 'ON' MSG
5F62
JUMP to 5F7DH.
Original Source Code Comment: OUTPUT THE MESSAGE

5F64H - DUALOF - "DUAL" Routine - Restore

5F64DUALOF
LD A,(442FH)LD A,(DULFLG) 3A 2F 44
Fetch the DUAL status byte (held in memory location 442FH) and store it into Register A. 80H=ROUTE, FFH=DUAL, 00H=Neither.
Original Source Code Comment: GET THE DUAL ON/OFF FLAG
5F67
OR A B7
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
Original Source Code Comment: DUAL ALREADY OFF?
5F68
If DUAL was already off (i.e., A was already 00), then there is nothing to process, so just display the DUAL OFF message via a JUMP to 5F7AH.
Original Source Code Comment: YES, JUST DISPLAY MESSAGE

If we are here, then we need to process a DUAL OFF command.

5F6A
LD HL,(4CE7H)LD HL,(DDVER1) 2A E7 4C
Copy the video driver address (held in memory location 4CE7H for safe keeping) in Register Pair HL.
Original Source Code Comment: GET THE SAVED VIDEO DRIVER ADDR
5F6D
LD (401EH),HLLD (DDCB+1),HL 22 1E 40
Store the backed-up video driver address (held in HL) and into the video driver address (held in memory location 401EH).
Original Source Code Comment: RESTORE
5F70
LD HL,(4CF8H)LD HL,(DDVER2) 2A F8 4C
Copy the printer driver address (held in memory location 4CF8H for safe keeping) in Register Pair HL.
Original Source Code Comment: GET THE SAVED PRINTER DRIVER ADDR
5F73
LD (4026H),HLLD (PDCB+1),HL 22 26 40
Store the backed-up printer driver address (held in HL) and into the printer driver address (held in memory location 4026H).
Original Source Code Comment: RESTORE
5F76
XOR A AF
Set Register A to ZERO and clear all Flags.
Original Source Code Comment: CLEAR THE DUAL FLAG
5F77
LD (442FH),ALD (DULFLG),A 32 2F 44
Set the DUAL status byte (held in memory location 442FH) and to 00H. 80H=ROUTE, FFH=DUAL, 00H=Neither.
5F7ADUALO1
LD HL,5FD5HLD HL,OFF 21 D5 5F
Let Register Pair HL equal 5FD5H, to point to the message "OFF".
Original Source Code Comment: HL => 'OFF' MSG
5F7DDULPRT
PUSH HL E5
Save the contents of Register Pair HL to the top of the stack.
Original Source Code Comment: SAVE ON/OFF MSG
5F7E
LD HL,5FC5HLD HL,DULMSG 21 C5 5F
Let Register Pair HL equal 5FC5H (DULMSG), the message 'Dual is now ' and 03H (no new line, so 'On' or 'Off' follows on the same line).
Original Source Code Comment: HL => 'DUAL IS NOW' MSG
5F81
GOSUB to 021BH.
NOTE: 021BH is the Model III ROM routine to display the characters at (HL) until a 03H or a 0DH (which is shown) is found.
Original Source Code Comment: DISPLAY IT
5F84
POP HL E1
Put the value held at the top of the STACK into Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: RESTORE FINAL MSG
5F85
JUMP to 021BH.
NOTE: 021BH is the Model III ROM routine to display the characters at (HL) until a 03H or a 0DH (which is shown) is found. Since this was JUMPED to instead of CALLed, the RET at the end of this ROM routine will then RETurn to the caller of this subroutine instead of returning to this place.
Original Source Code Comment: DISPLAY AND RETURN

5F88H - NODUAL - "DUAL" Routine - Abort if DUAL is engaged while ROUTE is engaged.

5F88NODUAL
LD HL,5F95HLD HL,NODMSG 21 95 5F
Let Register Pair HL equal 5F95H (NODMSG), the message 'Can't Activate Dual while ROUTE is in Operation' and 0DH.
Original Source Code Comment: HL => 'CANT DUAL WHILE ROUTE' MSG
5F8B
JUMP to 021BH.
NOTE: 021BH is the Model III ROM routine to display the characters at (HL) until a 03H or a 0DH (which is shown) is found. Since this was JUMPED to instead of CALLed, the RET at the end of this ROM routine will then RETurn to the caller of this subroutine instead of returning to this place.
Original Source Code Comment: DISPLAY AND RETURN

5F8EH - SKIPSP - Get the next COMMAND LINE character.

5F8ESKIPSP
LD A,(HL) 7E
Fetch the value held in the memory location pointed to by Register Pair HL and store it into Register A.
Original Source Code Comment: GET A CHRACTER
5F8F
CP 20HCP ' ' FE 20
Compare the value held in Register A against 20H (0010 0000) / (Decimal: 32)(ASCII: SPACE).
Original Source Code Comment: SPACE?
5F91
RET NZ C0
If the NZ FLAG (Not Zero) has been set, RETurn to the caller.
Original Source Code Comment: NO, EXIT
5F92SKIPS1
INC HL 23
INCrement the value stored in Register Pair HL by 1.
Original Source Code Comment: BUMP TO NEXT CHAR
5F93
Loop back to the top of this routine.
Original Source Code Comment: LOOP TILL NON-SPACE FOUND

5F95H - NODMSG - MESSAGE and BYTE STORAGE for DUAL.

5F95-5F97NODMSG
DEFM 'Can' 43 61 6E
NODMSG: text 'Can'.
5F98
DEFB 27H 27
27H, the apostrophe.
5F99-5FC3
DEFM 't Activate Dual while ROUTE is in Operation' 74 20 41 63 74 69 76 61 74 65 20 44 75 61 6C 20 77 68 69 6C 65 20 52 4F 55 54 45 20 69 73 20 69 6E 20 4F 70 65 72 61 74 69 6F 6E
Text 't Activate Dual while ROUTE is in Operation'.
5FC4
DEFB 0DH 0D
0DH ends the message.
5FC5-5FD0DULMSG
DEFM 'Dual is now ' 44 75 61 6C 20 69 73 20 6E 6F 77 20
DULMSG: text 'Dual is now '.
5FD1
DEFB 03H 03
03H ends the message.
5FD2-5FD3ON
DEFM 'On' 4F 6E
ON: text 'On'.
5FD4
DEFB 0DH 0D
0DH ends the message.
5FD5-5FD7OFF
DEFM 'Off' 4F 66 66
OFF: text 'Off'.
5FD8
DEFB 0DH 0D
0DH ends the message.

5FD9H - WPROT - "WP" Routine - Set a drive as write protected.

5FD9WPROT
Get the next non-space COMMAND LINE character via a GOSUB to 5F8EH.
Original Source Code Comment: SKIP ANY SPACES
5FDC
CP 0DH FE 0D
Compare the value held in Register A against 0DH (ASCII: CARRIAGE RETURN). Results: If Register A equals CARRIAGE RETURN, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: END OF LINE?
5FDE
If there were parameters on the COMMAND LINE (which would be a drive number) the NZ FLAG (Not Zero) will have been set, so skip over the next 2 instructions which set the value if no disk drive is given.
Original Source Code Comment: NO, HAVE A DRIVE
5FE0
LD A,0FFHLD A,-1 3E FF
Let Register A equal 0FFH.
Original Source Code Comment: AN IMPOSSIBLE DRIVE NUMBER
5FE2
JUMP to 600CH to set the drive number held in Register A into the middle of an opcode in SYS00/SYS which checks for write protect against FFH before permitting a write.
Original Source Code Comment: SET IT

5FE4H - WPROT1 - "WP" Routine - Jumped here if there were parameters given.

5FE4WPROT1
LD DE,6010HLD DE,WPSW 11 10 60
Let Register Pair DE equal 6010H to point to the COMMAND PARSER TABLE for the WP COMMAND.
Original Source Code Comment: DE => DRIVE SYNTAX
5FE7
GOSUB to 4454H.
NOTE: 4454H is the SYS0 vector SWITCH (SYS1 entry 6, PARAM): it matches the options in parentheses at Register Pair HL against the table at Register Pair DE and stores each value (FFFFH for a name alone) in the two bytes the matching table entry points to; NZ = an option that is not in the table.
Original Source Code Comment: GET THE SYNTAX AND VALUE
5FEA
If the NZ FLAG (Not Zero) has been set, then the CALL produced an error, so JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: EXIT IF ERROR
5FED
LD BC,0000HLD BC,0 01 00 00
Let Register Pair BC equal the DRIVE= value. The operand at 5FEEH-5FEFH (WPDRV) is 0000H in the file; SWITCH stores the value there through the DEFW WPDRV of the table at 6010H.
Original Source Code Comment: DRIVE NUMBER STORED HERE
5FF0
LD A,(4413H)LD A,(MAXDRV) 3A 13 44
Fetch the maximum number of drives in the system (held in memory location 4413H) and store it into Register A.
Original Source Code Comment: SEE IF ALLOWABLE DRIVE
5FF3
CP C B9
Compare the drive number given (held in Register C) against the highest drive number on the system (held in Register A). Results:
  • If Register A equals the value held in Register C, the Z FLAG is set.
  • If A < C, the CARRY FLAG will be set.
  • if A >= C, the NO CARRY FLAG will be set.
5FF4
If the drive number given (Register C) is above the highest drive number (MAXDRV) the C FLAG is set: JUMP to 5221H (ERR9) to report error 2 (disk drive not in system).
Original Source Code Comment: NO, REPORT ERROR
5FF7
LD A,C 79
Copy the requested drive number from Register C into Register A.
Original Source Code Comment: GET THE DRIVE
5FF8
ADD A,30HADD A,'0' C6 30
LET Register A = Register A + 30H. Note: Adding 30H to from Register A will convert decimal number 0-9 into its ASCII equivalent (i.e., 6 + 30H = 36H, which, in ASCII, is 6.
Original Source Code Comment: MAKE IT ASCII
5FFA
LD (6024H),ALD (WPDR),A 32 24 60
Store the ASCII drive digit (Register A) into 6024H (WPDR), the digit of the message 'Disk Drive 0 is now '.
Original Source Code Comment: SET IT INTO MESSAGE
5FFD
PUSH BC C5
Save the drive number (held in Register Pair BC) to the top of the stack.
Original Source Code Comment: SAVE THE DRIVE NUMBER
5FFE
LD HL,6019HLD HL,WPDMSG 21 19 60
Let Register Pair HL equal 6019H (WPDMSG), the message 'Disk Drive n is now ' and 03H (no new line).
Original Source Code Comment: HL => 'DRIVE X PROTECTED' MSG
6001
GOSUB to 021BH.
NOTE: 021BH is the Model III ROM routine to display the characters at (HL) until a 03H or a 0DH (which is shown) is found.
Original Source Code Comment: DISPLAY IT
6004
LD HL,602EHLD HL,FINMSG 21 2E 60
Let Register Pair HL equal 602EH (FINMSG), the message 'Write Protected' and 0DH.
Original Source Code Comment: FINAL PORTION OF MSG
6007
GOSUB to 021BH.
NOTE: 021BH is the Model III ROM routine to display the characters at (HL) until a 03H or a 0DH (which is shown) is found.
600A
POP BC C1
Restore the drive number from the top of the STACK into Register Pair BC, and then remove the entry from the stack.
Original Source Code Comment: GET DRIVE BACK
600B
LD A,C 79
Copy the drive number from Register C into Register A.
Original Source Code Comment: GET THE DRIVE
600CWPROT3
LD (45F8H),ALD (WPD),A 32 F8 45
Store the value held in Register A into memory location 45F8H which in the middle of an opcode in the SYS00/SYS routine which checks for write protect before doing a write.
Original Source Code Comment: SET IT IN DOS
600F
RET C9
RETurn to the caller.

6010H - WPSW - PARSER TABLE for WP COMMAND.

6010-6015WPSW
DEFM 'DRIVE ' 44 52 49 56 45 20
WPSW: option name 'DRIVE' padded to 6 characters (WP and MASTER).
6016-6017
DEFW 5FEEH EE 5F
Where SWITCH stores the DRIVE= value: 5FEEH (WPDRV), the operand of the LD BC at 5FEDH.
6018
DEFB 00H 00
00H ends the table.
6019-6023WPDMSG
DEFM 'Disk Drive ' 44 69 73 6B 20 44 72 69 76 65 20
WPDMSG: text 'Disk Drive '.
6024-602CWPDR
DEFM '0 is now ' 30 20 69 73 20 6E 6F 77 20
WPDR: the drive digit ('0' at load), stored by WP (5FFAH) and MASTER (605FH), and the text ' is now '.
602D
DEFB 03H 03
03H ends the message.
602E-603CFINMSG
DEFM 'Write Protected' 57 72 69 74 65 20 50 72 6F 74 65 63 74 65 64
FINMSG: text 'Write Protected'.
603D
DEFB 0DH 0D
0DH ends the message.

603EH - "MASTER" Routine. This routine re-assigns the master drive number.

603EMASTER
Get the next non-space COMMAND LINE character via a GOSUB to 5F8EH.
Original Source Code Comment: SKIP ANY SPACES
6041
CP 0DH FE 0D
Compare the value held in Register A against 0DH (ASCII: CARRIAGE RETURN). Results: If Register A equals CARRIAGE RETURN then we got the command but no parameters (i.e., just typed in MASTER), the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: END OF LINE?
6043
If parameters (which would be a drive number) were given, then the NZ FLAG (Not Zero) will have been set, so skip over the next 2 instructions which put in a default drive number.
Original Source Code Comment: NO, GET MASTER DRIVE NUMBER
6045
XOR A AF
Set Register A to ZERO and clear all Flags, thus setting Register A to a default of DRIVE 0.
Original Source Code Comment: SET MASTER DRIVE AS DRIVE 0
6046
JUMP to 6071H to put a 0 into the system storage location of the MASTER DRIVE NUMBER.
Original Source Code Comment: SET IT

6048H - MAST1 - "MASTER" Routine - Jumped here if there were parameters given.

6048MAST1
LD DE,6010HLD DE,WPSW 11 10 60
Let Register Pair DE equal 6010H which is the parser table for the WP command, focusing on the drive number.
Original Source Code Comment: DE => SYNTAX TABLE
604B
GOSUB to 4454H.
NOTE: 4454H is the SYS0 vector SWITCH (SYS1 entry 6, PARAM): it matches the options in parentheses at Register Pair HL against the table at Register Pair DE and stores each value (FFFFH for a name alone) in the two bytes the matching table entry points to; NZ = an option that is not in the table.
Original Source Code Comment: GET THE DRIVE NUMBER
604E
If the NZ FLAG (Not Zero) has been set, then the CALL produced an error, so JUMP to 5219H to report error 11 (illegal command parameter) and ABORT.
Original Source Code Comment: NOTHING SUPPORTED
6051
LD BC,(5FEEH)LD BC,(WPDRV) ED 4B EE 5F
Fetch the drive number (held in memory location 5FEEH) and store it into Register Pair BC.
Original Source Code Comment: GET THE DRIVE NUMBER
6055
LD A,(4413H)LD A,(MAXDRV) 3A 13 44
Fetch the maximum number of drives in the system (held in memory location 4413H) and store it into Register A.
Original Source Code Comment: SEE IF LEGAL DRIVE
6058
CP C B9
Compare the drive number given (held in Register C) against the highest drive number on the system (held in Register A). Results:
  • If Register A equals the value held in Register C, the Z FLAG is set.
  • If A < C, the CARRY FLAG will be set.
  • if A >= C, the NO CARRY FLAG will be set.
6059
If the drive number given (Register C) is above the highest drive number (MAXDRV) the C FLAG is set: JUMP to 5221H (ERR9) to report error 2 (disk drive not in system).
Original Source Code Comment: NO, DRIVE NOT IN SYSTEM
605C
LD A,C 79
Copy the requested drive number from Register C into Register A.
Original Source Code Comment: GET THE DRIVE
605D
ADD A,30HADD A,'0' C6 30
LET Register A = Register A + 30H. Note: Adding 30H to from Register A will convert decimal number 0-9 into its ASCII equivalent (i.e., 6 + 30H = 36H, which, in ASCII, is 6.
Original Source Code Comment: MAKE IT ASCII
605F
LD (6024H),ALD (WPDR),A 32 24 60
Store the ASCII drive digit (Register A) into 6024H (WPDR), the digit of the message 'Disk Drive 0 is now '.
Original Source Code Comment: SET IT IN MESSAGE
6062
PUSH BC C5
Save the drive number (held in Register Pair BC) to the top of the stack.
Original Source Code Comment: SAVE DRIVE NUMBER
6063
LD HL,6019HLD HL,WPDMSG 21 19 60
Let Register Pair HL equal 6019H (WPDMSG), the message 'Disk Drive n is now ' and 03H (no new line).
Original Source Code Comment: HL => 'DISK DRIVE X' MSG
6066
GOSUB to 021BH.
NOTE: 021BH is the Model III ROM routine to display the characters at (HL) until a 03H or a 0DH (which is shown) is found.
Original Source Code Comment: DISPLAY IT
6069
LD HL,6075HLD HL,MSTMSG 21 75 60
Let Register Pair HL equal 6075H (MSTMSG), the message 'the Master Drive' and 0DH.
Original Source Code Comment: HL => 'IS MASTER DRIVE' MSG
606C
GOSUB to 021BH.
NOTE: 021BH is the Model III ROM routine to display the characters at (HL) until a 03H or a 0DH (which is shown) is found.
Original Source Code Comment: DISPLAY IT
606F
POP BC C1
Restore the drive number from the top of the STACK into Register Pair BC, and then remove the entry from the stack.
Original Source Code Comment: GET THE DRIVE NUMBER BACK
6070
LD A,C 79
Copy the drive number from Register C into Register A.
Original Source Code Comment: GET IT
6071MAST2
LD (42B3H),ALD (DIFULT),A 32 B3 42
Store the disk drive (held in Register A) into memory location 42B3H which is the storage location for the MASTER DRIVE NUMBER.
Original Source Code Comment: SET THE MASTER INTO DOS
6074
RET C9
RETurn to the caller.

6075H - MSTMSG - MESSAGE and BYTE STORAGE for MASTER.

6075-6084MSTMSG
DEFM 'the Master Drive' 74 68 65 20 4D 61 73 74 65 72 20 44 72 69 76 65
MSTMSG: text 'the Master Drive'.
6085
DEFB 0DH 0D
0DH ends the message.

6086H - CONVHX - Convert Binary Coded Decimal into a Binary Value. On entry HL = a number of up to four decimal digits held as hex digits (SWITCH stores 80 as 0080H); on exit HL = its binary value.

6086CONVHX
EX DE,HL EB
EXchange the value stored in Register Pair HL (the number to convert) with the value stored in Register Pair DE (irrelevant).
Original Source Code Comment: PUT THE VALUE INTO DE
6087
LD A,D 7A
Copy the MSB of the number to convert (held in Register D) into Register A.
Original Source Code Comment: GET THE MSB
6088
Move the high nybble of Register A (the thousands digit) into the low nybble via a GOSUB to 60B5H (SHIFT).
Original Source Code Comment: DO THE SHIFTS
608B
LD L,A 6F
Copy the digit (Register A) into Register L.
Original Source Code Comment: INTO HL
608C
LD H,00HLD H,0 26 00
Let Register H equal 00H: Register Pair HL = the digit.
608E
PUSH HL E5
Save Register Pair HL to the STACK ...
Original Source Code Comment: HL = HL * 10
608F
POP BC C1
... and fetch it into Register Pair BC: BC = HL, as ADDHL needs.
6090
Multiply the high nybble of the MSB by 10 via a GOSUB to 60B0H.
Original Source Code Comment: MULTIPLY IT BY 10

Now the high nybble of the MSB has been shifted over to the 10's spot, so that the low nybble of the MSB can occupy the 1's spot.

6093
LD A,0FH 3E 0F
Let Register A equal a mask of 0FH (0000 1111).
Original Source Code Comment: GET THE 2ND DIGIT
6095
AND D A2
MASK the value of Register A against the MSB of the number to convert (held in Register D) to isolate the low nybble.
6096
LD C,A 4F
Let Register C = the low nybble of the MSB of the requested value (held in Register A).
Original Source Code Comment: INTO BC
6097
ADD HL,BC 09
LET Register Pair HL = 10 * the High Nybble of the MSB + the Low Nybble of the MSB.
6098
PUSH HL E5
LET Register Pair BC = 10 * the High Nybble of the MSB + the Low Nybble of the MSB. First, save HL to stack to transfer value to BC
Original Source Code Comment: HL = HL * 10
6099
POP BC C1
Then load value from stack into BC register pair
609A
Multiply that by 10 via a GOSUB to 60B0H (results in HL).
Original Source Code Comment: MULTIPLY IT BY 10

Now the converted MSB has been shifted over to the 10's spot, so that the LSB can occupy the 1's spot.

609D
LD A,E 7B
Copy the LSB of the number to convert (Register E) into Register A.
Original Source Code Comment: DO THE LSB
609E
Move the high nybble of Register A (the tens digit) into the low nybble via a GOSUB to 60B5H (SHIFT).
60A1
LD C,A 4F
Copy the tens digit (Register A) into Register C.
Original Source Code Comment: INTO BC
60A2
LD B,00HLD B,0 06 00
Let Register B equal 00H: Register Pair BC = the tens digit.
60A4
ADD HL,BC 09
LET Register Pair HL = the prior total (held in Register Pair HL) + the high nybble of the LSB (held in Register BC).
60A5
PUSH HL E5
Save Register Pair HL (the total so far) to the STACK ...
60A6
POP BC C1
... and fetch it into Register Pair BC: BC = HL, as ADDHL needs.

Now the high nybble of the LSB has been added to the converted MSB.

60A7
Multiply that by 10 via a GOSUB to 60B0H (results in HL).
Original Source Code Comment: MULTIPLY IT BY 10

Now everything has been pushed over one level, leaving just the 1's spot empty.

60AA
LD A,0FH 3E 0F
Let Register A equal a mask of 0FH (0000 1111).
Original Source Code Comment: MASK FOR LSD
60AC
AND E A3
MASK the value of Register A against the LSB of the number to convert (held in Register E) to isolate the low nybble of the LSB.
60AD
LD C,A 4F
Let Register Pair BC = the low nybble of the LSB of the value to convert.
Original Source Code Comment: INTO BC
60AE
ADD HL,BC 09
LET Register Pair HL = Register Pair HL + Register BC.
60AF
RET C9
RETurn to the caller.

60B0H - ADDHL - Routine to Multiply HL by 10. Requires HL = BC.

60B0ADDHL
ADD HL,HL 29
LET Register Pair HL = Register Pair HL + Register HL.
Original Source Code Comment: TIMES 2
60B1
ADD HL,HL 29
LET Register Pair HL = Register Pair HL + Register HL.
Original Source Code Comment: TIMES 4
60B2
ADD HL,BC 09
LET Register Pair HL = Register Pair HL + Register BC.
Original Source Code Comment: TIMES 5
60B3
ADD HL,HL 29
LET Register Pair HL = Register Pair HL + Register HL.
Original Source Code Comment: TIMES 10
60B4
RET C9
RETurn to the caller.

60B5H - SHIFT - Move the high nybble of Register A into the low nybble (four SRL A).

60B5SHIFT
SRL A CB 3F
Shift Register A right one bit (1 of 4), a 0 going into bit 7 ...
Original Source Code Comment: GET THE HIGHEST NIBBLE
60B7
SRL A CB 3F
Shift Register A right one bit (2 of 4), a 0 going into bit 7.
60B9
SRL A CB 3F
Shift Register A right one bit (3 of 4), a 0 going into bit 7.
60BB
SRL A CB 3F
... (4 of 4): the high nybble is now the low nybble, the high nybble is 0.
60BD
RET C9
RETurn to the caller.
END 5200HEND BEGIN

60BEH - DCBS & BUFFERS - Work areas above the end of the file (not loaded).

60BE-60EFS9DCB3
DEFS 50
S9DCB3: 50 bytes for a DCB (DCBSIZ). Nothing in this file uses it. Not in the file.
60F0-612FBUFER3
DEFS 64
BUFER3: 64 bytes. Nothing in this file uses it. Not in the file.
6130-6161S9DCB
DEFS 50
S9DCB: the DCB RELO uses (50 bytes). Not in the file.
6162-6193S9DCB1
DEFS 50
S9DCB1: the DCB of the source file (COPY, KILL, PATCH; 50 bytes). Not in the file.
6194-61FFS9DCB2
DEFS 108
S9DCB2: the DCB of the destination file (COPY). The source gives it no size (S9DCB2 EQU $); ORG $,256 moves the next buffer to 6200H, which leaves these 108 bytes. Not in the file.
6200-62FFBUFER4
DEFS 256
BUFER4: 256 bytes, the record buffer for a copy of a file whose LRL is not 256. Not in the file.
6300-63FFBUFER1
DEFS 256
BUFER1: 256 bytes, the sector buffer of the source file; a single drive copy fills memory from here up to MEM2. Not in the file.
6400-64FFBUFER2
DEFS 256
BUFER2: 256 bytes, the sector buffer of the destination file; RELO builds the whole new file from here up. Not in the file.