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 into the SYSHI overlay area at 5200H by the DOS command interpreter when the user invokes one of its ten commands. Each command receives control with HL pointing at the rest of the command line (the text after the command name and a separating space).

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 an illegal-parameter error.

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–5664HSLANT helpersDrive-spec parsing, GETDIR helper, totals tracking (used by COPY and KILL).
5669H–570DHS9KILL commandKILL logic: walk directory, kill matching files, count totals.
570EH–597AHPATCH commandPATCH logic: parse (ADD=, FIND=, CHG=) directives, hex conversion, write-back.
597BH–5A0FHHEXGET / patch helpersHex string parser, error/success messages for PATCH.
5A14H–5B1AHRELO commandRELO logic: relocate a /CMD file to a new load address.
5B1FH–5B99HFORMS commandFORMS logic: forms-control device parameter setting.
5B9AH–5C74HROUTE commandROUTE logic: route a device to/from RS-232.
5C75H–5F33HSETCOM commandSETCOM logic: set RS-232 communication parameters (baud, parity, stop bits, etc.).
5F34H–5FD8HDUAL commandDUAL logic: toggle dual-display flag.
5FD9H–603DHWPROT commandWP (Write Protect) command logic.
603EH–60BDHMASTER commandMASTER command: set the system master password.
60BEH–6493HDCB / buffer storageS9DCB3, BUFER3, S9DCB, S9DCB1, S9DCB2, BUFER4, BUFER1, BUFER2 (uninitialized DEFS storage; not in 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 (ASCII > '!') until terminator.
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. Routes a device to/from RS-232.
5C75HSETCOMSETCOM command. Sets RS-232 parameters (BAUD, WORD, STOP, PARITY, WAIT, etc.).
5F34HDUALDUAL command. Toggles dual-display mode flag.
5FD9HWPROTWP (Write Protect) command. Sets the write-protect flag for a drive.
603EHMASTERMASTER command. Sets the system master password.

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; these are not persistent across overlay loads (a different overlay loaded into 5200H+ will overwrite them) and therefore do not appear in the site's RAM-addresses JSON, which catalogues only stable, persistent locations.

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).
5567HS9TRKDirectory track number storage (DEFB 0).
5648HTOTCHG †Self-mod target inside the totals-update routine.
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.
56F7HCHAG9932-byte buffer for the PATCH CHG= string.
5717HCHGFLGFlag: did the user supply CHG=? (0=no, non-0=yes).
5718HFNDFLGFlag: did the user supply FIND=? (0=no, non-0=yes).
5719HERNSAVSaved end-record-number for the PATCH operation (DEFW 0).
5897HPATEND †Self-mod target inside PATCH end-of-operation logic.
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).
5B1BHSAVE2-byte general-purpose storage (DEFS 2).
5B1DHSAVE12-byte general-purpose storage (DEFS 2).
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 inside ROUTE / PCHAR processing.
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).
60F0HBUFER340H-byte general-purpose buffer.
6130HS9DCBDCB#0 storage (DEFS DCBSIZ=50).
6162HS9DCB1DCB#1 storage (DEFS DCBSIZ=50).
6194HS9DCB2DCB#2 storage (EQU $ — aliased into BUFER4 area).
6200HBUFER4256-byte buffer (boundary-aligned via ORG $,256).
6300HBUFER1256-byte read buffer for COPY.
6400HBUFER2256-byte write buffer for COPY.

Disassembly:

5200H - Start.

ORG 5200H
5200BEGIN
LD A,55H
LET Register A = 55H (0101 0101).
Original Source Code Comment: SET THE 'CLEAR RAM' FLAG
5202
LD (42B4H),ALD (CFLAG),A
Store the value held in Register A into the memory location 42B4H.
NOTE: 42B4H is the storage location for the CLEAR RAM Flag.
5205
XOR A
Set Register A to ZERO and clear all Flags.
Original Source Code Comment: CLEAR A
5206
LD (4414H),ALD (FLAG1),A
Clear the system flag by storing a 0 (held in Register A) into the memory location 4414H.
NOTE: 4414H is the storage location for the NUMBER OF THE OVERLAY CURRENTLY IN MEMORY.
Original Source Code Comment: CLEAR THE SYSTEM FLAG
5209
LD (42FFH),ALD (SCAFLG),A
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
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
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
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
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
RETurn to the caller.
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
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
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
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
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
LET Register Pair HL = 523EH, which points to the lookup table.
Original Source Code Comment: HL => COMMAND TABLE
5229GETTA1
LD A,(HL)
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
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
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
RETurn to the caller.

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

522FGETTA2
CP C
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
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
INCrement HL (2 of 3) to skip to next table entry
Original Source Code Comment: HL => MSB OF ADDRESS
5234
INC HL
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
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)
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
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)
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
EXchange the value stored in Register Pair HL (i.e., the POINTER TO THE COMMAND LINE in RAM) with the value stored in Register Pair DE (i.e., the address of matching command).
Original Source Code Comment: HL = COMMAND ADDRESS
523C
OR A
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
RETurn to the caller with the CARRY FLAG off so that we indicate NO ERROR.

523EH - TABLE - Command Lookup Table.

523ETABLE
DEFB 09HDEFB CPY
09H = COPY command
523F
DEFW 525DHDEFW COPY
.. 525DH
5241
DEFB 0FHDEFB DUALT
0FH = DUAL command
5242
DEFW 5F34HDEFW DUAL
.. 5F34H
5244
DEFB 12HDEFB FORM
12H = FORMS command
5245
DEFW 5B1FHDEFW FORMS
.. 5B1FH
5247
DEFB 16HDEFB KILLL
16H = KILL command
5248
DEFW 5669HDEFW S9KILL
.. 5669H
524A
DEFB 1AHDEFB MAST
1AH = MASTER command
524B
DEFW 603EHDEFW MASTER
.. 603EH
524D
DEFB 1BHDEFB PAT
1BH = PATCH command
524E
DEFW 571BHDEFW PATCH
.. 571BH
5250
DEFB 1FHDEFB RELOO
1FH = RELO command
5251
DEFW 5A14HDEFW RELO
.. 5A14H
5253
DEFB 21HDEFB RUTE
21H = ROUTE command
5254
DEFW 5B9AHDEFW ROUTE
.. 5B9AH
5256
DEFB 22HDEFB SCOM
22H = SETCOM command
5257
DEFW 5C75HDEFW SETCOM
.. 5C75H
5259
DEFB 25HDEFB WPT
25H = WP command
525A
DEFW 5FD9HDEFW WPROT
.. 5FD9H
525C
DEFB 00H
END OF TABLE MARKER
Original Source Code Comment: END OF LIST

525DH - MAIN ROUTINE --- COPY COMMAND

525DCOPY
PUSH HL
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
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
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
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
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
Copy HL to DE (2 of 2): Load L into E
Original Source Code Comment: TO DE
5267
LD A,(DE)
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 '/'
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 an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: EXIT IF SYNTAX ERROR
5273GETTWO
PUSH DE
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
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 for 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
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 ':'
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 '.'
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 '/'
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 an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: ERROR IF NOT ONE OF THEM
528BCHECK
LD C,A
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
Set up Register B to be a counter by setting Register B to 00H.
Original Source Code Comment: CLEAR COUNTER
528E
DEC HL
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)
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
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
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
Point Register Pair DE to the next character in Filespec 2 by bumping DE by 1.
Original Source Code Comment: POINT TO NEXT CHARACTER
5298
INC B
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
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
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)
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
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
Save the contents of Register Pair BC to the top of the stack.
Original Source Code Comment: SAVE CALLER'S REGISTERS
52A4
PUSH DE
Save the contents of Register Pair DE to the top of the stack.
52A5
PUSH HL
Save the contents of Register Pair HL to the top of the stack.
52A6
LD HL,(52BAH)LD HL,(RECCS)
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
INCrement the record number (held in Register Pair HL) by 1.
Original Source Code Comment: BUMP IT
52AA
LD (52BAH),HLLD (RECCS),HL
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 to convert the new record number to ASCII and put it into the message "COPYING RECORD nnnnn".
Original Source Code Comment: MAKE IT ASCII
52B0
LD HL,52DCHLD HL,RECORD
Let Register Pair HL equal 52DCH, so as to point to the message "COPYING RECORD nnnn".
Original Source Code Comment: POINT TO COPY REC MSG
52B3
GOSUB to 021BH.
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
Original Source Code Comment: PRINT IT
52B6
POP HL
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
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
Put the value held at the top of the STACK into Register Pair BC, and then remove the entry from the stack.
52B9
RET
RETurn to the caller.

52BAH - RECCS - MESSAGE and STORAGE AREA.

52BARECCS
DEFB xx xx
Storage Area for the Record Number of the Record Currently Being Copied.

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
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)
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
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
Let Register Pair DE equal 52EDH, to point to the destination address in the message "COPYING RECORD nnnnn".
Original Source Code Comment: POINT TO SCREEN MSG
52CD
LD B,05HLD B,5
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)
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
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
Let Register A equal 30H (ASCII: 0).
Original Source Code Comment: CONVERT TO '0'
52D6ASCII2
LD (DE),A
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
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
INCrement the value stored in Register Pair DE by 1 to point to the next location in the message "COPYING RECORD nnnnn".
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
RETurn to the caller.

52DCH - RECORD - MESSAGE and STORAGE AREA.

52DCRECORD
DEFM 1DH + 1EH + 'COPYING RECORD '
52EDRECNUM
DEFM 'nnnnn' + 03H

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

52F3DISPLY
LD HL,531AHLD HL,COPMSG
Let Register Pair HL equal 531AH to point to the message "COPYING".
Original Source Code Comment: POINT TO 'COPYING' MSG
52F6
GOSUB to 021BH.
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
Original Source Code Comment: OUTPUT IT TO SCREEN
52F9
LD HL,6162HLD HL,S9DCB1
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
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 character at (HL) until a 03H is found.
Original Source Code Comment: SCREEN PRINT IT
5305
LD HL,6194HLD HL,S9DCB2
Let Register Pair DE equal 6194H to point to the DESTINATION FILE DCB, which starts with the filename.
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
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)
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 '!'
Compare the value held in Register A against / to see if we have reached the end of the filespec.
Original Source Code Comment: SPACE OR LESS?
5313
RET C
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
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
DEFM "COPYING" + 03H
5325TOO
DEFM "TO" + 03H.

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

532AS9WAIT
PUSH HL
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 character at (HL) until a 03H is found.
Original Source Code Comment: DISPLAY IT
532E
POP HL
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
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
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
DECrement the counter (stored in Register Pair BC) by 1.
Original Source Code Comment: DEC THE TIMER
533A
LD A,B
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
... Step 2
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)
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
Toggle the flag.
Original Source Code Comment: FLIP IT
5343
LD (54A7H),ALD (FSFLAG),A
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
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
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)
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
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
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
Determine the number of bytes left in RAM by subtracting the top of the buffer (6300H, stored in Register Pair DE) and the carry flag from the end of usable RAM (stored in Register Pair HL).
Original Source Code Comment: HL NOW CONTAINS NO. OF BYTES LEFT IN MEM
5360
LD DE,0100HLD DE,SECTOR
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
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
INCrement the block counter (stored in Register B) by 1.
Original Source Code Comment: INC THE # BLOCKS COUNTER
5366
OR A
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
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
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
Round down by 1 block via a DECrement of Register A.
Original Source Code Comment: DUMB ONE OFF
536D
LD (54A6H),ALD (FLFAG),A
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
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
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)
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)
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
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)
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
Store the byte of the EOF (held in Register A) into memory location 56D6H.
Original Source Code Comment: SAVE IT
538D
XOR A
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
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)
Fetch the value held in the memory location pointed to by Special Index Register Pair IX+0CH and store it into Register A.
Note: IX+0CH = the position in the DCB for the NMSB OF THE LAST SECTOR TO READ/EOF)
Original Source Code Comment: GET THE ERN
5394
LD (56D7H),ALD (FIND),A
Store the value held in Register A into memory location 56D7H.
Original Source Code Comment: SAVE IT
5397
LD A,(IX+0DH)LD A,(IX+ERNH)
Fetch the value held in the memory location pointed to by Special Index Register Pair IX+0DH and store it into Register A.
Note: IX+0DH = the position in the DCB for the MSB OF THE LAST SECTOR TO READ/EOF)
539A
LD (56D8H),ALD (FIND+1),A
Store the value held in Register A into memory location 56D8H.
539D
LD HL,5463HLD HL,S9DES
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
53A3LRLCHG
LD B,00HLD B,LRLCHG
Let Register B equal the LRL placed here at 538EH.
Original Source Code Comment: SET FOR LRL OF 256
53A5
LD DE,6194HLD DE,S9DCB2
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
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.
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: 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
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
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
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)
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
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
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
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 1 block via a GOSUB to 4436H.
NOTE: 4436H is the SYS00/SYS vector for 'READ', which reads the record that the disk drive is positioned over.
Original Source Code Comment: GO READ 1 BLOCK
53C8
POP BC
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
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
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,HL,(S9DCB1+BUFL)
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
Let Register Pair DE equal 0100H (Decimal: 256), which is 1 block.
Original Source Code Comment: LOAD 256 INTO DE
53DC
ADD HL,DE
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
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
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
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
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
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)
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
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
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
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 SYS00/SYS vector for 'WRITE with VERIFY', which will write verify a write with a retry count of 3. DE must point to the buffer to write.
Original Source Code Comment: WRITE WITH VERIFY
53FC
POP BC
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)
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
Let Register Pair DE equal 0100H (Decimal: 256), which is 1 block.
Original Source Code Comment: LOAD DE WITH 256
5406
ADD HL,DE
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
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)
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
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
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
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
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
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
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
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
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
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 SYS00/SYS vector for 'WRITE with VERIFY', which will write verify a write with a retry count of 3. DE must point to the buffer to write.
Original Source Code Comment: WRITE WITH VERIFY
5428
POP BC
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)
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
Let Register Pair DE equal 0100H (Decimal: 256), which is 1 block.
Original Source Code Comment: LOAD 256 INTO DE
5432
ADD HL,DE
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
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
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)
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
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)
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
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)
Fetch the LSB of the SECTOR EOF (held in memory location 56D7H) and store it into Register A.
Original Source Code Comment: GET THE ERN
544B
LD (IX+0CH),ALD (IX+ERNL),A
Store the value held in Register A into the memory location pointed to by Special Index Register Pair IX+0CH.
Note: IX+0CH = the position in the DCB for the NMSB OF THE LAST SECTOR TO READ/EOF)
544E
LD A,(56D8H)LD A,(FIND+1)
Fetch the MSB of the SECTOR EOF (held in memory location 56D8H) and store it into Register A.
5451
LD (IX+0DH),ALD (IX+ERNH),A
Store the value held in Register A 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 LAST SECTOR TO READ/EOF)
5454
LD DE,6194HLD DE,S9DCB2
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
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
DEFM 1DH + 'Insert DESTINATION Disk (ENTER) ' + 03H
5487S9SRC
DEFM 1DH + "'Insert SOURCE Disk (ENTER) ' + 03H
54A6FLFLAG
DEFB 00H
Number of blocks available in RAM to use for the copy.
Original Source Code Comment: NUM OF BLOCKS COUNT
54A7FSFLAG
DEFB 00H
Toggle for the flash in the flashing message.
Original Source Code Comment: FLASH FLAG

54B9H - COP91 - 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
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
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)
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 ':'
Compare the value held in Register A against 3AH (ASCII: :) to test for a drivespec.
Original Source Code Comment: DRIVE SPECIFIER?
54B0
INC HL
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'
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)
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
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
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)
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 ':'
Compare the value held in Register A against 3AH (ASCII: :) to test for a drivespec.
Original Source Code Comment: DRIVE SPECIFIER?
54C2
INC HL
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 we got a ":" then the Z FLAG (Zero) would have been set, so JUMP to 54B9H to test the drive.
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'
Let Register A equal 30H (ASCII: 0) as a default drive.
Original Source Code Comment: ASSUME DRIVE 0 THEN
54C9
JUMP to 54CCH to process the DESTINATION 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

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)
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
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 - Dual Drive copy roputine.

54D0COPY0
GOSUB to 52F3H to display the message COPYING filespec 1 TO filespec 2.
Original Source Code Comment: DISPLAY THE FILE NAMES
54D3
LD HL,0FFFFHLD HL,-1
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
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
54DFLRLCH1
LD B,00HLD B,LRLCH1
Let Register B equal the value put into 54E0H elsewhere, which, if 0, is a LRL of 256.
Original Source Code Comment: SET FOR LRL OF 256
54E1
LD DE,6194HLD DE,S9DCB2
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
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
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
Let Register Pair HL equal 6200H to point to the SOURCE FILE DCB at 6200H (which is used for non 256 LRL files).
Original Source Code Comment: HL => DATA BUFFER
54F6
Read a record from the SOUCE FILE into the buffer pointed to by Register Pair HL via a GOSUB to 4436H.
NOTE: 4436H is the SYS00/SYS vector for 'READ', which reads the record that the disk drive is positioned over.
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
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
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)
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
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
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
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
Let Register Pair DE equal 0100H (Decimal: 256) to prepare for a LDIR move of 256 bytes.
Original Source Code Comment: NUMBER OF BYTES TO MORE
5515
LDIR
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
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
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 out the record via a GOSUB to 4439H.
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)
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
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)
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
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
Let Special Index Register IX equal 6194H to point to the DESTINATION FILE DCB.
5535
LD L,(IX+0CH)LD L,(IX+ERNL)
Fetch the value held in the memory location pointed to by Special Index Register Pair IX+0CH and store it into Register L.
Note: IX+0CH = the position in the DCB for the LSB OF THE LAST SECTOR TO READ/EOF)
Original Source Code Comment: GET THE ERN
5538
LD H,(IX+0DH)LD H,(IX+ERNH)
Fetch the value held in the memory location pointed to by Special Index Register Pair IX+0DH and store it into Register H.
Note: IX+0DH = the position in the DCB for the MSB OF THE LAST SECTOR TO READ/EOF)
553B
DEC HL
DECrement the value stored in Register Pair HL by 1 to back up the EOF one record.
Original Source Code Comment: BACK UP TO LAST RECORD
553C
LD (IX+0CH),LLD (IX+ERNL),L
Store the adjusted EOF byte held in Register L into the memory location pointed to by Special Index Register Pair IX+0CH.
Note: IX+0CH = the position in the DCB for the NMSB OF THE LAST SECTOR TO READ/EOF)
Original Source Code Comment: STORE IT
553F
LD (IX+0DH),HLD (IX+ERNH),H
Store the adjusted EOF byte held in Register H 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 LAST SECTOR TO READ/EOF)
5542DONE1
LD A,(616AH)LD A,(S9DCB1+EOF)
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
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
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
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
RETurn to the caller.
Original Source Code Comment: RETURN TO DOS

555BH - DRIVE1 - MESSAGE and STORAGE AREA.

531ACOPMSG
DEFM ":0" + 0DH
Storage for the SOURCE DRIVESPEC.
Original Source Code Comment: MOVE TO BEG OF LINE CHAR
555EDRIVE2
DEFM ":1" + 0DH
Storage for the DESTINATION DRIVESPEC.
5561ZSLANT
DEFM "/"
Storage for an extension (part 1). This would also be thhe wild-card extension.
5562S9CMD
DEFM "BAS"
Storage for an extension (part 2).
5565SAVE3
DEFB 4300HDEFB BUFFER
Buffer Starting Address
5567S9TRK
DEFB 00H
Storage for the current/desired sector number in the directory sector.

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

5568GETDIR
LD A,(555CH)LD A,(DRIVE1 + 1)
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
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
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)
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
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
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
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)
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 ' '
Compare the value held in Register A against 20H (ASCII: SPACE).
Original Source Code Comment: IS IT A SPACE?
557F
POP IY
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 an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: YES, ILLEGAL
5584
PUSH IY
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),A
Store the character we read (held in Register A) into the memory location pointed to by Special Index Register Pair IX+00H.
Note: IX+00H = the position in the DCB for the TYPE of FCB byte. Bit 0: 1=Read Only, Bit 1: 1=Write Only, Bit 4: 1=The next 2 bytes are simply the address of another FCB, Bit 7=1: Then the next 50 bytes are the description of an open file.
Original Source Code Comment: SAVE THE CHAR
5589
INC DE
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
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
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
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)
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 ' '
Compare the value held in Register A against 20H (ASCII: SPACE).
Original Source Code Comment: SPACE?
5594
RET Z
If we got a SPACE then we are done; so RETURN.
Original Source Code Comment: YES, DONE
5595
LD (HL),A
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
INCrement the counter (Register C) by 1.
Original Source Code Comment: INC A COUNT
5597
INC HL
INCrement the pointer for the destination (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP THE POINTERS
5598
INC DE
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
RETurn to the caller.

559CH - MOVE3 - Routine to copy an extension 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 extension.

559CMOVE3
LD B,04HLD B,4
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)
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
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
INCrement the counter (Register C) by 1.
Original Source Code Comment: INC A COUNTER
55A1
INC HL
INCrement the pointer for the destination (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP THE POINTERS
55A2
INC DE
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
RETurn to the caller.

55A6H - MOVE4 - Routine to the drivespec from the directory entry (pointed to by DE) into the DCB (pointed to HL).

55A6MOVE4
LD B,03HLD B,3
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)
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
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
INCrement the pointer for the destination (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP THE POINTERS
55AB
INC DE
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
RETurn to the caller.

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

55AFSKSP
LD A,(DE)
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 ' '
Compare the value held in Register A against 20H (ASCII: SPACE).
Original Source Code Comment: SPACE?
55B2
RET NZ
If the NZ FLAG (Not Zero) has been set, RETurn to the caller.
Original Source Code Comment: NO, RET
55B3
INC DE
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
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
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
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)
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 ':'
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 an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: NO, ERROR THEN. MUST HAVE DRIVE NUM
55C6
LD IX,555BHLD IX,DRIVE1
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
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 ':'
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 an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: NO, ERROR THEN
55D7
LD IX,555EHLD IX,DRIVE2
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
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)
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'
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 is greater than or equal to A >= 4, we have a bad drive, and the If the NC FLAG (No Carry) will have been set, JUMP to 5221H to report the error "Drive not in System" and abort.
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
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
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)
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'
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 is greater than or equal to A >= 4, we have a bad drive, and the If the NC FLAG (No Carry) will have been set, JUMP to 5221H to report the error "Drive not in System" and abort.
Original Source Code Comment: YES, NO SUCH DRIVE
55F5
LD B,10HLD B,DLENGH
Let Register B equal 10H (Decimal: 16), which is the number of directory records, so that Register B can act as a counter.
Original Source Code Comment: LENGTH OF DIRECTORY RECORDS
55F7TOTAL
PUSH BC
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,BUFFERLD DE,4300H
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
Store the buffer start pointer (held in Register Pair DE) into memory location 5565H.
Original Source Code Comment: SAVE POINTER
5602TOTAL0
LD A,(DE)
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
Compare the value held in Register A against 10H (0001 0000) to see if it is protected in any way. Results: If Register A equals 10H, the Z FLAG is set; otherwise the NZ FLAG is set.
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
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
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
Copy the poiner to the extent (held in Register A) back into Register E.
Original Source Code Comment: PUT IT BACK
560B
LD HL,5562HLD HL,S9CMD
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
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)
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)
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
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
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)
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Copy/Kill (as set) the file via a GOSUB to 54D0H (COPY) or 5692H (KILL).
Original Source Code Comment: GO COPY THE FILE
564B
Read the Directory into 4300H via a GOSUB to 5568H.
Original Source Code Comment: GET NEXT FILE IN DIRECTORY
564ETOTNXT
LD DE,(5565H)LD DE,(SAVE3)
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
Advance 30 bytes in the buffer of the sector, thus moving to the next directory entry. Occurs over the next 3 instructions. First, Load E (the lower byte of the buffer pointer) into A
Original Source Code Comment: GET THE LSB OF POINTER
5653
ADD A,30HADD A,SIZDIR
Add 30H (48 decimal) to A to advance to the next directory entry
Original Source Code Comment: POINT TO NEXT FILE
5654
LD E,A
Store the updated pointer back into Register E
5656
LD (5565H),DELD (SAVE3),DE
Store the current location in the current directory sector (held in Register Pair DE) into memory location 5565H (which is a storage area for the current buffer address).
Original Source Code Comment: SAVE AS NEW POINTER
565A
CP 0F0H
Check for the end of directory sector location by comparing the first byte of the current directory sector entry (held in Register A) against 0F0H. Results:
  • If Register A equals 0F0H, the Z FLAG is set.
  • If A < 0F0H, the CARRY FLAG will be set.
  • if A >= 0F0H, the NO CARRY FLAG will be set.

Original Source Code Comment: AT END OF THIS DIRECTORY SECTOR?
565C
If A < 0F0H (meaning we are at the end of the directory sector) then the C FLAG (Carry) has been set, JUMP to 5602H to loop to the next sector.
Original Source Code Comment: NO, CONTINUE
565E
POP BC
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)
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
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
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
RETurn to the caller.
Original Source Code Comment: DONE, ALL FILES COPIED

5669H - S9KILL - "KILL" Routine.

5669S9KILL
566A
LD D,H
LD E,LLD D,H
LET Register Pair DE = Register Pair HL (the pointer to the COMMAND LINE).
Original Source Code Comment: MIRROR THE COMMAND LINE TO DE
566B
LD A,(DE)
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 '/'
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
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
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
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)
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 ':'
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 an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: NO, ERROR. MUST HAVE DRIVE NUM
5680
LD IX,555BHLD IX,DRIVE1
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
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
Set the vector to the action in the directory entry loop routine to "KILL" by first letting Register Pair HL equal 5692H (which is in the middle of a multi-purporse CALL routine).
Original Source Code Comment: SET LOOPER ROUTINE FOR KILL
568C
LD (5649H),HLLD (TOTCHG + 1),HL
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
Proceed to KILL the filed by JUMPing to 55E8H.
Original Source Code Comment: AND GO KILL

5692H - KILLIT - Continuation of the KILL ROUTINE.

5692KILLIT
GOSUB to 59ADH to set up for FULL SECTOR I/O and sets up registers B, DE, and HL for file action.
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 (Not Zero) has been set, then the CALL produced an error, so JUMP to 521DH.
Original Source Code Comment: EXIT IF SYNTAX ERROR
569DKILL0
PUSH HL
Save the contents of Register Pair HL to the top of the stack.
Original Source Code Comment: SAVE REGS
569E
PUSH DE
Save the contents of Register Pair DE to the top of the stack.
569F
LD HL,56BAHLD HL,KILMSG
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 character at (HL) until a 03H is found.
Original Source Code Comment: PRINT IT
56A5
LD HL,6162HLD HL,S9DCB1
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 after the , to point to the message "'KILLING '". message via a GOSUB to 5310H.
Original Source Code Comment: PRINT IT ALSO
56AB
POP DE
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
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.
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 3.
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.
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
RETurn to the caller.

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

56BAKILMSG
DEFM →
"1DH + 1EH + 'KILLING ' + 03H" Message.
Original Source Code Comment: MOVE TO BEG OF LINE CHAR

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

56C5ADDD
DEFM →
"04H + 'ADD='" message, which is the address label for the PATCH command.
56CAFINDD
DEFM →
"05H + 'FIND='" message, which is the find field label for the PATCH command.
56D0CHGG
DEFM →
"04H + 'CHG='" message, which is the new record label for the PATCH command.
56D5ADD1
DEFW 00H
Shared storage byte for either the logical record length (for COPY) or the patch address (for PATCH).
Original Source Code Comment: USER ADDRESS TO PATCH
56D6
DEFB 00H 00H 00H
Storage for 3 byte EOF
56D7FIND
DEFB 00H
Length of FIND FIELD in bytes
Original Source Code Comment: BUFFER FOR FIND STRING
56D8FIND
DEFS 32
FIND FIELD Storage Area. The first byte, like above, is the length of the data. The remaining 31 bytes is the data.
56F7CHAG99
DEFS 32
CHANGE FIELD Storage Area. The first byte, like above, is the length of the data. The remaining 31 bytes is the data.
Original Source Code Comment: BUFFER FOR CHANGE STRING
5718FNDFLG
DEFB 00H
"Requested Address Found " Flag
Original Source Code Comment: FLAG TO SHOW FIND ADDRESS OR NOT
5719ERNSAV
DEFB 00H
EOF Sector Number
Original Source Code Comment: END REC NUM SAVE

571BH - PATCH Main Routine.

571BPATCH
LD A,(HL)
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 '*'
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 (Not Zero) has been set, then the CALL produced an error, so JUMP to 521DH.
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
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 '('
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 an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: NO, ERROR
5734
INC HL
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
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)
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
Set Register C = length of the "ADD=" label (04H)
Original Source Code Comment: INTO BC
573A
LD B,00HLD B,0
Clear B to complete the BC register pair
573C
INC DE
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 an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: NO MATCH, PARAM ERROR
5743
ADD HL,BC
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
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
Restore HL into Register Pair IX.
5747
LD HL,0000HLD HL,0
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)
Fetch the first character of the address to be patched (held in the memory location pointed to by Special Index Register Pair IX+00H) and store it into Register A.
Note: IX+00H = the position in the DCB for the TYPE of FCB byte. Bit 0: 1=Read Only, Bit 1: 1=Write Only, Bit 4: 1=The next 2 bytes are simply the address of another FCB, Bit 7=1: Then the next 50 bytes are the description of an open file.
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'
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
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 A < 1 more than 9 then the C FLAG (Carry) will have been set to indicate that the character we got is less than "9" which is good, so JUMP to 575DH.
Original Source Code Comment: YES
5755
CP 41HCP 'A'
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 A < A 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 "A" and was not "0"-"9", JUMP to 5771H.
Original Source Code Comment: NO, EXIT
5759
CP 47HCP 'F'+1
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 A >= G then the NC FLAG (No Carry) will have been setto indicate that the character was too high to be a valid hex character (i.e., it is above "F"), JUMP to 5771H.

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

575DPLOOP2
ADD HL,HL
Need to shift the old address four bits to the left ... Part 1
Original Source Code Comment: HL:=HL*16
575E
ADD HL,HL
... again
575F
ADD HL,HL
... again
5760
ADD HL,HL
... again
5761
SUB 30HSUB '0'
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
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
SUBtract the value 07H from Register A which will reduce an ASCII character in the range of "A"-"F" into 11-15.
Original Source Code Comment: YES, CORRECT

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

5769PLOP2
LD E,A
At this point, Register A now is the decimal equivalent of the 2 characters given. Copy the contents of Register A into Register E.
Original Source Code Comment: NEW DIGIT INTO DE
576A
LD D,00HLD D,0
Let Register D equal 00H so that Register Pair DE = Register A.
576C
ADD HL,DE
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
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
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 ','
Compare the value held in Register A against a ,. Results: If Register A equals ,, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: COMMA?
5776
If the current character is not a , then the NZ flag would have been set and we have an invalid character. JUMP to 5219H to report an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: NO, BAD PARAM
5779
PUSH IX
POP HLPUSH IX
Let Register Pair HL = Special Index Register IX (which is the command line).
Original Source Code Comment: MOVE THE POINTER BACK TO HL
577C
INC HL
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
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)
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
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
Set C to length of "FIND=" (5 characters)
Original Source Code Comment: INTO BC
5783
LD B,00HLD B,0
Clear B to complete the BC register pair
5785
Check to see if the command line parameter 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
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 an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: EXIT IF NO MATCH
578B
ADD HL,BC
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,FIND + 1
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
Store the length of the "FIND=" field (i.e., 5 characters; held in Register A) into memory location 56D7H.
Original Source Code Comment: SAVE THE LENGTH
5795
LD A,(HL)
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 ','
Compare the value held in Register A against a ,. Results: If Register A equals ,, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: COMMA?
5798
If the current character is not a , then the NZ flag would have been set and we have an invalid character. JUMP to 5219H to report an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: EXIT IF NOT
579B
INC HL
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
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)
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
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
Set C to length of "CHG=" (4 characters)
Original Source Code Comment: PUT THE LENGTH INTO BC
57A2
LD B,00HLD B,0
Clear B to complete the BC register pair
57A4
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
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 an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: EXIT IF PARAM ERROR
57AA
ADD HL,BC
Advance Register Pair HL to the user provided value associated with a "CHG=" 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 => CHANGE STRING
57AB
LD DE,56F8HLD DE,CHAG99+1
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
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
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)
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
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 an ILLEGAL COMMAND PARAMETER error, 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
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
Store the value held in Register A into memory location 5717H (which points to the CHANGE REQUIRED flag).
Original Source Code Comment: SET FOR NO CHANGE MADE
57C0
LD (5718H),ALD (FNDFLG),A
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)
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
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.
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.
Set IY high byte to 42H, resulting in IY = 42FFH
57CF
DEC (IY+00H)DEC (IY)
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)
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
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
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)
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
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
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
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
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)
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
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
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)
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
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)
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
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
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
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
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
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
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)
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
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)
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
DECrement the field size/character count (held in Register B) by 1 byte.
Original Source Code Comment: BUMP COUNT FOR IT
581B
INC HL
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)
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
DECrement the field size/character count (held in Register B) by 1 byte.
Original Source Code Comment: BUMP COUNT FOR IT
581E
PUSH HL
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
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
If we are here then we know the sector is length is not 0 and is not 256, we have an error, so SET the CARRY FLAG to indicate as much.
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 read a CODE BLOCK routine; jumped here if there is more data to read in the code block than just the 3 bytes comprising the field size and data address.

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
5826
5827
LD A,E
ADD A,B
LD E,ALD A,E
Let Register E = the data address LSB (which was already in E) plus the data field size - 2.
Original Source Code Comment: PUT LSB INTO A
5828PATCH1
LD A,D
Let Register D = the data address MSB (which was already in D) + 1 byte if the addition of the LSB produced a carry. Start MSB adjustment: Load D into A
Original Source Code Comment: PUT MSB INTO A
5829
ADC A,00HADC A,0
Add carry from LSB addition to A
Original Source Code Comment: ANY CARRY, ADD IT
582B
LD D,A
Store result back in D to finalize MSB
Original Source Code Comment: DE => LOAD ADDRESS + COUNT
582C
LD HL,(56D5H)LD HL,(ADD1)
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
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
Subtracts the value stored in Register Pair DE (the size of the patch) and the carry flag from the value stored in Register Pair HL (the block to patch). This will tell us if the patch will be entirely within the single block.
Original Source Code Comment: SUBTRACT END ADD FROM ASKED
5832
POP DE
Restore the address of the block from the top of the STACK into Register Pair DE, and then remove the entry from the stack.
Original Source Code Comment: RESTORE STACK PROPERLY
5833
POP HL
Restore the field size from the top of the STACK into Register Pair HL, and then remove the entry from the stack.
5834
If the NC FLAG (No Carry) has been set then the load address is too low; so JUMP to 588AH.
Original Source Code Comment: IF NO CARRY, LOAD ADDRESS TOO LOW
5836
PUSH HL
Save the field size (held in Register Pair HL) to the top of the stack.
Original Source Code Comment: SAVE BUFFER ADD
5837
LD HL,(56D5H)LD HL,(ADD1)
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
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
Put the offset into the block inter Register Pair HL by subtracting the address of the block (stored in Register Pair DE) and the carry flag from the patch address (stored in Register Pair HL).
Original Source Code Comment: ASKED ADD - LOAD ADD
583D
LD B,L
Copy the LSB of the offset into the block (held in Register L) into Register B.
Original Source Code Comment: SAVE DIFFERENCE IN B
583E
POP HL
Restore the field size from the top of the STACK into Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: RESTORE BUFFER ADD
583F
If the subtraction triggered the CARRY FLAG, then we need to redo the math to see if we need to go BEFORE the current block. JUMP to 588AH.
Original Source Code Comment: IF CARRY, TOO LOW
5841
INC L
Bump Register L to point past the MSB of the LOAD ADDRESS by INCrementing the value stored in Register L by 1.
Original Source Code Comment: BUMP PAST THE MSB OF LOAD ADDRESS
5842
OR 01HOR 1
Since the address has been found, we need to OR Register A against 01H (0000 0001), to force Register A to be anything but a 0 for the next instruction.
Original Source Code Comment: FORCE NON-ZERO
5844
LD (5718H),ALD (FNDFLG),A
Store a non-zero (held in Register A) into memory location 5718H (which points to the ADDRESS FOUND flag).
Original Source Code Comment: SHOW WE'VE FOUND ADDRESS
5847
LD A,B
Copy the byte count offset a/k/a the remaining length (held in Register B) into Register A.
Original Source Code Comment: GET THE BYTE COUNT OFFSET
5848
OR A
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 Z FLAG (Zero) has been set then we are finally at the data! JUMP to 5851H. Otherwise fall through to keep looping.
Original Source Code Comment: NO, BYPASS DJNZ
584BPATCH2
INC L
If we didn't jump away, then we are not yet at the data so point to the next byte by INCrementing the value stored in Register L by 1.
Original Source Code Comment: NOW GET TO SPECIFIC ADD
584C
If the Z FLAG (Zero) has been set, meaning that L just spilled into the next sector and we ran out of buffer, GOSUB to 58B3H to read the next seector.
Original Source Code Comment: IF OUT OF BUFFER, READ NEXT SECTOR
584F
Keep looping back to 584BH until we get to the requested address, 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.
5851PATCH3
LD DE,56D7HLD DE,FIND
Let Register Pair DE equal 56D7H, which is the pointer to the storage location for the LENGTH OF THE FIND FIELD.
Original Source Code Comment: DE => FIND STRING
5854
LD A,(DE)
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
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
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
Let Register B equal 00H so that Register Pair BC will hold the field length.
5859
Check to see if we have found what we are looking for via a GOSUB to 5B70H.
Original Source Code Comment: DO THE COMPARISON
585C
If the NZ FLAG (Not Zero) has been set, then no match was found; JUMP to 59C2H to display a "STRING NOT FOUND" message and ABORT.
Original Source Code Comment: IF NOT, TELL USER SO
585F
LD DE,56F8HLD DE,CHAG99+1
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
Check to see if a change is really needed via a GOSUB to 5B70H.
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
EXchange the value stored in Register Pair HL (i.e., the data location to be changed) with the value stored in Register Pair DE (i.e., the CHANGE FIELD storage buffer).
Original Source Code Comment: SWAP POINTERS
5868
LDIR
Move the new string into the old location via a LDIR instuction, 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: MOVE IN THE NEW STRING
586A
OR 01HOR 1
We need a non-Zero put into the next memory location so OR Register A against 01H (0000 0001) to set the "CHANGE REQUIRED" flag to a non-zero number.
Original Source Code Comment: FORCE NON-ZERO
586C
LD (5717H),ALD (CHGFLG),A
Show that we have now made the requested change by storing the value held in Register A into memory location 5717H (which points to the CHANGE REQUIRED flag).
Original Source Code Comment: SHOW WE MADE CHANGE
586F
LD A,(599AH)LD A,(SYSFLG)
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
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
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
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
Set up for FILE I/O via a GOSUB to 59ADH to set up for FILL SECTOR I/O and sets up registers B, DE, and HL.
Original Source Code Comment: SET REGISTERS UP FOR WRITE AND CLOSE
587D
Back up to the proper sector via a GOSUB to 4445H.
Original Source Code Comment: BACK UP ON LRL
5880
Set up for FILE I/O via a GOSUB to 59ADH to set up for FILL SECTOR I/O and sets up registers B, DE, and HL.
5883
Write with Verify via a CALL to 443CH
NOTE: 443CH is the SYS00/SYS vector for 'WRITE with VERIFY', which will write verify a write with a retry count of 3. DE must point to the buffer to write.
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
Bypass the NO-USE byte and point to the next byte by INCrementing the value stored in Register Pair HL by 1.
Original Source Code Comment: BYPASS NO-USE DATA
5889
LD B,(HL)
Fetch the length byte (held in the memory location pointed to by Register Pair HL) and store it into Register B.
Original Source Code Comment: GET CHARACTER COUNT
588ADLYLO1
INC L
Point to the next byte by INCrementing the value stored in Register Pair L by 1.
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
Point to the next byte by INCrementing the value stored in Register Pair L by 1.
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)
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
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
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 character at (HL) until a 03H 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)
See if we actually made a change by fetching the value held in memory location 5717H (which points to the CHANGE REQUIRED flag) into Register A.
Original Source Code Comment: DID WE CHANGE IT?
58A6
OR A
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
Let Register Pair HL equal 59E4H to point to 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
Let Register Pair HL equal 59C8H to point to the message "PATCH MADE".
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
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 FILL 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 SYS00/SYS vector for 'READ', which reads the record that the disk drive is positioned over.
Original Source Code Comment: READ A RECORD
58BA
POP BC
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
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
If we are here, then there was an error in the read. Clear the stack.
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 abitrary 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
Let Register B equal 00H as it will be a length counter.
Original Source Code Comment: CLEAR A COUNTER
58C2MOVLT1
LD A,(HL)
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'
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
Copy the left nybble (held in Register A) into Register C.
Original Source Code Comment: SAVE IT IN C
58CB
INC HL
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)
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
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
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
INCrement the destination pointer to the next slot.
Original Source Code Comment: BUMP TO NEXT SLOT
58D3
INC HL
INCrement the source pointer to the next character.
Original Source Code Comment: BUMP TO NEXT CHARACTER
58D4
INC B
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 abitrary 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
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
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
RETurn to the caller.

58DDH - TCONV - Convert a Byte Contaning 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
58E2
58E4
58E6
SLA A
SLA A
SLA A
SLA ASLA A
Shift the bits in Register A left FOUR positions (to the MSB), with new bits being filled in with a 0.
Original Source Code Comment: MOVE IT TO THE MSB
58E8
RET
RETurn to the caller.

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

58E9TCONV1
SUB 30HSUB '0'
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 an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: EXIT IF PARAM ERROR
58EE
CP 0AHCP 10
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
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
If we're here then the character is greater than 10. SUBtract the value 07H from Register A since there are 7 characters between "9" and "A".
Original Source Code Comment: TRY ALPHA
58F3
CP 0AHCP 10
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 an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: NO, PARAM ERROR
58F8
CP 10HCP 16
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
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 an ILLEGAL COMMAND PARAMETER error, and ABORT.

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

58FEHSYS
INC HL
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
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
Let Register C equal 00H for a default drivespec of 0.
Original Source Code Comment: ASSUME DRIVE 0
5908
CP 3AHCP ':'
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
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)
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
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'
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 an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: EXIT IF SILLY DRIVE NUMBER
5914
LD C,A
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
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
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
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
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
Let Register Pair DE equal the second byte of the SOURCE FILE DCB.
591E
LD BC,0031HLD BC,DCBSIZ-1
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
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
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
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
Set IX+00H to 80H (1000 0000)to indicate that the file is open.
Note: IX+00H = the position in the DCB for the TYPE of FCB byte. Bit 0: 1=Read Only, Bit 1: 1=Write Only, Bit 4: 1=The next 2 bytes are simply the address of another FCB, Bit 7=1: Then the next 50 bytes are the description of an open file.
Original Source Code Comment: SET THE DISK DCB TYPE
592D
LD (IX+0CH),0FFHLD (IX+ERNL),-1
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 NMSB OF THE LAST SECTOR TO READ/EOF)
Original Source Code Comment: SET THE END RECORD NUMBER
5931
LD (IX+0DH),0FFHLD (IX+ERNH),-1
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 LAST SECTOR TO READ/EOF)
5935
LD (IX+03H),00HLD (IX+BUFL),BUFER1.LOW.
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.
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
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
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
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
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
Let the overlay number = the overlay number * 2 via a rotate, since each extent is 2 bytes long.
Original Source Code Comment: SYSTEM NUMBER TIMES 2
594D
LD A,0E0HLD A,SYSOFF
Let Register A equal 0E0H (1110 0000) to indicate an overlay.
Original Source Code Comment: OFFSET TO THE SYSTEM NUMBERS
594F
ADD A,E
LET Register A = Register A + Register E so that Register A now holds the overlay number * 2 AND the overlay designation bytes.
Original Source Code Comment: ADD IN THIS SYSTEM
5950
5951
LD L,A
LD H,43HLD L,A
Let Register Pair HL = 43xx where xx is the overlay number * 2, which is the extent element for the applicable overlay.
Original Source Code Comment: INTO HL
5953
LD D,(HL)
Fetch the MSB of the extent element (held in the memory location pointed to by Register Pair HL) and store it into Register D. Note that file extents are in MSB/LSB order.
Original Source Code Comment: GET THE STARTING GRAN
5954
INC HL
INCrement the value stored in Register Pair HL by 1.
Original Source Code Comment: BUMP TO TRACK NUMBER
5955
LD E,(HL)
Fetch the LSB of the extent element (held in the memory location pointed to by Register Pair HL) and store it into Register D.
5956
LD (6172H),DELD (S9DCB1+EXTBEG),DE
Store the extent element (the value held in Register Pair DE) into the FCB at memory location 6172H.
Original Source Code Comment: SET IT IN THE DCB
595A
LD A,0FFHLD A,-1
Let Register A equal 0FFH to flag a system file.
Original Source Code Comment: SET THE SYSTEM FLAG
595C
LD (599AH),ALD (SYSFLG),A
Put a 0FFH (held in Register A) into memory location 599AH (i.e., the SYSTEM OVERLAY FLAG for the PATCH routine; NZ if system file being patched) to mark the file as a SYSTEM FILE and store it into Register A.
595F
POP HL
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)
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
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
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
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
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 the "next" sector location via a GOSUB to 45F7H.
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
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
597C
LD B,H
LD C,LLD BC,HL
Let BC = HL (i.e., the pointer to the COMMAND LINE).
Original Source Code Comment: MOVE THE POINTER TO BC
597D
LD HL,0000HLD HL,0
Let Register Pair HL equal 0000H for upcoming math.
Original Source Code Comment: CLEAR AN ACCUM
5980HEXGE1
LD A,(BC)
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'
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 (Carry) has been set then the number fetched is below "0", which is bad, so JUMP to 5996H.
Original Source Code Comment: EXIT IF END OF NUMBER
5985
CP 0AHCP 10
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 (No Carry) has been set then the character is too high, which is bad, so JUMP to 5996H.
Original Source Code Comment: YES, EXIT
5989
INC BC
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
598B
LD D,H
LD E,LLD DE,HL
Let DE = the current math value of the number (held in Register Pair HL).
Original Source Code Comment: MIRROR THE VALUE TO DE
598C
598D
598E
598F
ADD HL,HL
ADD HL,HL
ADD HL,HL
ADD HL,HLADD HL,HL
LET Register Pair HL = Register Pair HL * 10 to move the value previously held in HL into the tens digit position.
Original Source Code Comment: TIMES 2
5990
5991
LD E,A
LD D,00HLD DE,A
Let Register Pair DE = 00nn where nn is the value of the next digit in binary.
Original Source Code Comment: NEW DIGIT INTO DE
5993
ADD HL,DE
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 the number found is less than 0 or more than 9.

5996HEXGE2
EX DE,HL
EXchange the value stored in Register Pair HL (i.e., the converted number) with the value stored in Register Pair DE (irrelevant).
Original Source Code Comment: VALUE TO DE
5997
5998
LD H,B
LD L,CLD HL,BC
Let HL = BC (i.e., the pointer to the COMMAND LINE).
Original Source Code Comment: MOVE THE COMMAND LINE BACK TO HL
5999
RET
RETurn to the caller.
Original Source Code Comment: DONE

599AH - SYSFLG - MESSAGE and STORAGE AREA.

599ASYSFLG
DEFB 00H
Storage location for the System Overlay Flag. If NZ then the user wants to patch a SYSTEM OVERLAY 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 FILL 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 3.
59A1
PUSH AF
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)
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
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
Store the value held in Register A into memory location 54E0H.
59AB
POP AF
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
RETurn to the caller.

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

59ADGETDCB
LD B,00HLD B,0
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
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
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
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 FILL 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
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 for 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
Let Register Pair HL equal 59D3H to point to the message "STRING NOT FOUND".
59C5
JUMP to 021BH.
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H 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.

59C8CHGMAD
DEFM →
"'PATCH MADE' + 0DH".
59D3NOFID1
DEFM →
"'STRING NOT FOUND' + 0DH".
59E4NOFIND
DEFM →
"'CAN'T FIND SPECIFIED ADDRESS' + 0DH".
5A01NOCHAG
DEFM →
"'NO CHANGE REQUIRED' + 0DH".

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

5A14RELO
LD DE,6130HLD DE,S9DCB
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 for 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 JUMP to 521DH.
Original Source Code Comment: EXIT IF ERROR
5A1D
LD DE,5B12HLD DE,RLTABL
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 DOS PARAMETER STRING PARSE routine. It decodes DOS LIBRARY parameters.
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 an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: EXIT IF ERROR
5A26
LD HL,(RLADD)LD HL,0
Let Register Pair HL equal the relocation address, which is a value placed into 5A27H elsewhere in this overlay.
Original Source Code Comment: RELO ADDRESS STORED HERE
5A29
PUSH HL
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
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
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
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 3.
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
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
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
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
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
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
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
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
Copy the MSB of the address (held in Register A) into Register L.
Original Source Code Comment: GOT ADDRESS
5A57
EX DE,HL
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
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
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
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
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
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
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
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
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
INCrement the value stored in Special Index Register IY by 1.
5A6B
LD (IY+00H),BLD (IY),B
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
INCrement the value stored in Special Index Register IY by 1.
5A70
LD (IY+00H),LLD (IY),L
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
INCrement the value stored in Special Index Register IY by 1.
5A75
LD (IY+00H),HLD (IY),H
Store the MSB of the address (held in Register L) into the memory location pointed to by Special Index Register Pair IY+00H.
Original Source Code Comment: STORE THE ADDRESS
5A78
DEC B
DECrement byte counter (1 of 2) for address
Original Source Code Comment: DEC FOR THE ADDRESS
5A79
DEC B
DECrement byte counter (2 of 2) for address
5A7A
INC IY
INCrement the value stored in Special Index Register IY by 1.
5A7CLOOP4
LD DE,6130HLD DE,S9DCB
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
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
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
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
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
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
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
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)
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
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
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
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
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
INCrement the value stored in Special Index Register IY by 1.
5ABA
LD (IY+00H),ALD (IY),A
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
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
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
INCrement the value stored in Special Index Register IY by 1.
5AC7
LD (5B1DH),IYLD (SAVE1),IY
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
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 JUMP to 5B04H.
Original Source Code Comment: EXIT IF ERROR
5AD4
LD HL,(5B1DH)LD HL,(SAVE1)
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
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
Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
5ADB
SBC HL,DE
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
5ADE
LD B,H
LD C,LLD B,H
Let Register Pair BC = the number of applicable bytes (held in Register Pair HL).
Original Source Code Comment: MOVE TO BC
5ADF
EX DE,HL
EXchange the buffer address (stored in Register Pair HL) with the number of bytes (stored in Register Pair DE).
Original Source Code Comment: GET THE BUFFER IN HL
5AE0
LD DE,6130HLD DE,S9DCB
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)
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
INCrement the buffer pointer (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP POINTER
5AE8
DEC BC
DECrement the byte counter (stored in Register Pair BC) by 1.
Original Source Code Comment: DEC THE COUNTER
5AE9
5AE9
LD A,B
OR CLD A,B
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 DONE?
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. Thgis routine reads a byte and puts it into Register A.

5AFBZREAD
PUSH DE
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
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
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
If the Z FLAG (Zero) has been set, RETurn to the caller.
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
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
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
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
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.

5B12RLTABL
DEFM 'ADD '
 
5B18
DEFW RLADD
A 2 byte storage location to hold the relocation address
5B1A
DEFB 00H
 
5B1BSAVE
DEFS 2
General storage location of 2 bytes.
5B1DSAVE1
DEFS 2
General storage location of 2 bytes.

5B1FH - Main Routine - "FORMS".

5B1FFORMS
LD BC,0000HLD BC,0
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
Clear the PRINTER WIDTH flag by putting a 00H into memory location 5B44H.
5B26
LD (5B51H),BCLD (FLINE),BC
Clear the PAGE LENGTH flag by putting a 00H into memory location 5B51H.
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
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
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
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 DOS PARAMETER STRING PARSE routine. It decodes DOS LIBRARY parameters.
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 an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: PARAMETER ERROR
5B3FFORMS2
LD IX,4025HLD IX,PDCB
Let Special Index Register Pair IX equal 4025H, which is the PRINTER DCB.
Original Source Code Comment: IX => PRINTER DCB
5B43
LD HL,(CHAR)LD HL,0
Let Register Pair HL equal the LINE WIDTH, placed elsewhere in this overlay.
Original Source Code Comment: USER CHARACTER COUNT
5B46
Convert the character held in Register Pair HL into hexadecimal via a GOSUB to 6086H.
Original Source Code Comment: CONVERT TO HEX
5B49
5B49
LD A,H
OR LLD A,H
Since the Z-80 cannot test Register Pair HL against zero, the common trick is to set Register A to equal to Register H, and then OR A against Register L. Only if both Register H and Register L were zero can the Z FLAG be set.
Original Source Code Comment: USER SELECT ANYTHING?
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
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,(FLINE)LD HL,0
Let Register Pair HL equal the PAGE LENGTH, placed elsewhere in this overlay.
Original Source Code Comment: NUMBER OF LINES STORED HERE
5B53
Convert the character held in Register Pair HL into hexadecimal via a GOSUB to 6086H.
Original Source Code Comment: CONVERT TO HEX
5B56
5B56
LD A,H
OR LLD A,H
Since the Z-80 cannot test Register Pair HL against zero, the common trick is to set Register A to equal to Register H, and then OR A against Register L. Only if both Register H and Register L were zero can the Z FLAG be set.
Original Source Code Comment: ANY NEW LINE?
5B58
RET Z
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
INCrement the value stored in Register L by 1, to see if THAT produces a zero (which means it was FF, or INDEFINITE).
Original Source Code Comment: CORRECT FOR 1'S OFFSET
5B5A
RET Z
If the Z FLAG (Zero) is STILL set, exit via a RETurn to the caller.
Original Source Code Comment: EXIT IF WAS 255
5B5B
LD (IX+03H),LLD (IX+3),L
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
RETurn to the caller.

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

5B5FFORCOM
DEFM 'WIDTH '
 
5B65
DEFW CHAR
 
5B67
DEFM 'LINES '
 
5B6D
DEFW FLINE
 
5B6F
DEFB 00H
End of Parameter List Terminator
Original Source Code Comment: END OF LIST

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

5B70COMPAR
PUSH BCSAV3
Save the contents of Register Pair BC to the top of the stack.
5B71
PUSH DE
Save the contents of Register Pair DE to the top of the stack.
5B72
PUSH HL
Save the contents of Register Pair HL to the top of the stack.
5B73COMPA1
LD A,(DE)
Fetch the value held in the memory location pointed to by Register Pair DE and store it into Register A.
5B74
CP (HL)
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
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
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
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
Put the value held at the top of the STACK into Register Pair BC, and then remove the entry from the stack.
5B7F
RET
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 character at (HL) until a 03H is found.
Original Source Code Comment: DISPLAY MESSAGE
5B83
LD HL,5B96HLD HL,S9EQU
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 character at (HL) until a 03H 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 character at (HL) until a 03H is found.
Original Source Code Comment: DISPLAY MESSAGE
5B8CPDATA2
LD A,PCHANGLD A,','
Let Register A equal ,. Note, this can be changed to a different character if the routine is to display with a space instead of a comma.
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,' '
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.

5B96S9EQU
DEFM " = " +03H
 

5B9AH - NEW "ROUTE" COMMAND. This was deprecated, and the below 2 instructions just throw an error.

5B9AROUTE
LD A,1FHLD A,EPNF
Let Register A equal 1FH to point to the error PROGRAM NOT FOUND.
Original Source Code Comment: TEMP... PROGRAM NOT FOUND ERROR
5B9C
JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.

5B9AH - OLD "ROUTE" COMMAND. Before the ROUTE command was deprecated, the code was ...

5B9AROUTE
LD A,(442FH)LD A,EPNF
Let Register A equal the contents of the memory location 442FH, which was the ROUTE/DUAL Flag.
Original Source Code Comment: TEMP... PROGRAM NOT FOUND ERROR
5B9C
CP 80HJP ERROR
Check to see if the ROUTE/DUAL Flag at 442FH was 80H (meaning that ROUTE was active).
5B9F
If the ROUTE command was already active, then the Z FLAG (Zero) will have been set, so JUMP to 5BA5H.
Original Source Code Comment: YES, IT'S OKAY
5BA1
OR A
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 command was already active, then the NZ FLAG (Zero) will have been set, so JUMP to 5C3AH.
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 ' '
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 '('
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
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
Let Register Pair DE equal 5C5DH, which points to the word "SOURCE".
Original Source Code Comment: DE => 'SOURCE'
5BB6
LD A,(DE)
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
5BB8
LD C,A
LD B,00HLD C,A
Let Register Pair BC = the parameter length.
Original Source Code Comment: INTO BC
5BBA
INC DE
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 they don't match, then we didn't get "SOURCE". Maybe we got "DEST" so JUMP to 5BF4H.
Original Source Code Comment: WASN'T SOURCE, TRY DEST
5BC0
ADD HL,BC
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 an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: PARAMETER ERROR
5BC7
PUSH HL
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
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
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
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
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
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
5BD3
INC HL
INC HLINC HL
Skip the 2 character device name on the COMMAND LINE by INCrementing the value stored in Register Pair HL by 2.
Original Source Code Comment: BUMP PAST DESCRIPTOR
5BD4ROUTE2
LD A,(HL)
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 ' '
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 ','
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 ')'
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
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
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
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 an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: PARAM ERROR
5BF0
RET
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
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
Let Register Pair DE equal 5C64H, which points to the word "DESTIN".
Original Source Code Comment: HL => 'DESTIN'
5BF7
LD A,(DE)
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
5BF9
LD C,A
LD B,00HLD C,A
Let Register Pair BC = the parameter length.
Original Source Code Comment: INTO BC
5BFB
INC DE
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 an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: WASN'T ANYTHING SUPPORTED
5C02
ADD HL,BC
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 an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: EXIT IF ERROR
5C09
PUSH HL
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
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
Let Register Pair DE equal 4220H which points to the ROUTE DCB for the DESTINATION name.
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)
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 '='
Compare the value held in Register A against 3DH (ASCII: =).
Original Source Code Comment: EQUAL?
5C13
RET NZ
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
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
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
Let Register Pair BC equal 0002H.
5C1B
Compare HL and DE to see if they match via a GOSUB to 5B70H.
5C1E
RET Z
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
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
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
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
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
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
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
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
Let Register Pair HL equal 5C40H, which points to the message "CAN'T ROUTE".
Original Source Code Comment: HL => 'CANT ROUTE' MSG
5C3D
JUMP to 021BH.
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H 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 COMMEND.

5C40RTMSG
DEFM →
"CAN'T ROUTE WHILE DUAL IS ON".
5C5DS9SRC1
DEFB 06H
Byte count for the word "SOURCE".
5C5E
DEFM "SOURCE"
 
5C64S9DES1
DEFB 06H
Byte count for the word "DESTIN".
5C65
DEFM "DESTIN"
 
5C6BDO1
DEFM "DO"
 
5C6DKB1
DEFM "KB"
 
5C6FPR1
DEFM "PR"
 
5C71RO1
DEFM "RO"
 
5C73RI1
DEFM "RI"
 

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 ' '
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)
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
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
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)
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
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
LET Register A = Register A * 2, because each entry in the table is 2 bytes.
Original Source Code Comment: MULTIPLY BY 2
5C90
5C91
LD C,A
LD B,00HLD C,A
Let Register Pair BC = The doubled, masked, RS-232 Baud Rate (held in Register A).
Original Source Code Comment: INTO BC
5C93
LD HL,5E81HLD HL,TABLE2
Let Register Pair HL equal 5E81H, which is the top of the BAUD RATE LOOKUP TABLE (which is a table of JUMP points, based on position, to the ASCII renditions of a BAUD Rate).
Original Source Code Comment: HL => CONVERSION TABLE
5C96
ADD HL,BC
Move HL down the BAUD RATE LOOKUP TABLE by the OFFSET held in Register Pair BC.
5C97
LD E,(HL)
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
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)
Fetch the MSB 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.
5C9A
EX DE,HL
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
Let Register Pair HL equal 5EA4H, which is a pointer to the message "WORD = ".
Original Source Code Comment: HL => 'UART = ' MSG
5CA1
Display the message "WORD = " via a GOSUB to 5B80H.
Original Source Code Comment: DISPLAY IT
5CA4
LD A,(41F9H)LD A,(UART)
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
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
5CAA
5CAB
RLCA
RLCA
RLCARLCA
Rotate the bits in A left (with Bit 7 going into Bit 0) three times so that the 2 bytes of the WORD code are in Bits 1 and 0.
Original Source Code Comment: MOVE THE BITS OVER TO LEAST SIG
5CAC
ADD A,A
LET Register A = Register A * 2, because each entry in the table is 2 bytes.
Original Source Code Comment: TIMES 2
5CAD
5CAE
LD C,A
LD B,00HLD C,A
Let Register Pair BC = The doubled, masked, RS-232 Word Length(held in Register A).
Original Source Code Comment: INTO BC
5CB0
LD HL,5E79HLD HL,TABLE1
Let Register Pair HL equal 5E79H, which is the top of the WORD LENGTH LOOKUP TABLE (which is a table of JUMP points, based on position, to the ASCII renditions of the WORD LENGTH).
Original Source Code Comment: HL => NUMBER OF BITS TABLE
5CB3
ADD HL,BC
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)
Fetch the LSB of the location of the WORD LENGTH LOOKUP TABLE (held in the memory location pointed to by Register Pair HL) and store it into Register E.
Original Source Code Comment: GET THE ADDRESS
5CB5
INC HL
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)
Fetch the MSB of the location of the WORD LENGTH LOOKUP TABLE (held in the memory location pointed to by Register Pair HL) and store it into Register E.
5CB7
EX DE,HL
EXchange the value stored in Register Pair HL (currently pointing to the 2nd byte of the 2 byte address for the WORD LENGTH LOOKUP TABLE) with the value stored in Register Pair DE (the address of the desired 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
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)
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
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'
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
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
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)
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
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
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
Let Register Pair HL equal 5EBAH, which is a pointer to the message "ODD".
Original Source Code Comment: ASSUME ODD
5CE5
BIT 7,A
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
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,' '
Let Register A equal 20H (ASCII: SPACE).
Original Source Code Comment: CHANGE ',' TO A ' '
5CF1
LD (5B8DH),ALD (PCHANG),A
Store the value held in Register A into memory location 5B8DH, which is where the "," has been for all the prior calls.
Original Source Code Comment: IN THE PRINT ROUTINE
5CF4
LD A,(41FAH)LD A,(WAIT)
Fetch the value held in memory location 41FAH (which is the RS-232 WAIT FLAG location) and store it into Register A. 0=Wait, 1=No Wait.
Original Source Code Comment: GET THE WAIT/NO WAIT FLAG
5CF7
LD HL,5EC3HLD HL,WAITS
Let Register Pair HL equal 5EC3H, which is a pointer to the message "WAIT".
Original Source Code Comment: HL => 'WAIT'
5CFA
OR A
Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
5CFB
If the byte means we have a WAIT then the NZ FLAG (Not Zero) will have been set, JUMP to 5D00H.
Original Source Code Comment: IS WAIT MODE. DISPLAY
5CFD
LD HL,5EC8HLD HL,NWAITS
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
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
Set Register A to ZERO and clear all Flags.
Original Source Code Comment: TURN RS-232 OFF
5D0A
LD (41F8H),ALD (BAUD),A
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
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
DECrement the value stored in Register A by 1 to now be FFH.
5D11
LD (41FAH),ALD (WAIT),A
Enbale WAIT MODE by storing a FFH (held in Register A) into memory location 41FAH (RS-232 Wait Flag).
Original Source Code Comment: SET 'WAIT' MODE
5D14
LD HL,5F22HLD HL,RSOFF
Let Register Pair HL equal 5F22H, which is a pointer to the message "RS-232 IS OFF".
Original Source Code Comment: HL => 'RS-232 OFF' MSG
5D17SETOUT
PUSH HL
Save the pointer to the message "RS-232 IS OFF" (held in Register Pair HL) to the top of the stack.
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
Restore the pointer to the message "RS-232 IS OFF" (held top of the stack) into Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: GET TEXT POINTER BACK
5D1C
JUMP to 021BH.
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H 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 '('
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 an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: NO, PARAMETER ERROR
5D24
INC HL
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)
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 ')'
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
Let Register A equal 0A4H (1010 0100). This would be Even Parity, Word Length = 7, 1 Stop Bit, Parity On, Send Break Signal, Request to Send On, Data Terminal Ready.
Original Source Code Comment: SET THE UART CONFIG
5D2C
LD (41F9H),ALD (UART),A
Store the bit pattern 1010 0100 (held in Register A) into memory location 41F9H.
5D2F
LD A,55H
Let Register A equal 55H (0101 0101).
Original Source Code Comment: SET FOR 300 BAUD
5D31
LD (41F8H),ALD (BAUD),A
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
Store the bit pattern 0101 0101 (held in Register A) into memory location 41FAH to turn on the WAIT FLAG.
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 if we didn't get an OPEN PARENTHESIS when we expected it.

5D3DSETVAL
DEC HL
Back HL up to point to the (ASCII: () on the COMMAND LINE.
Original Source Code Comment: BACK UP TO THE '('
5D3E
LD DE,5E11HLD DE,SETSWT
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 DOS PARAMETER STRING PARSE routine. It decodes DOS LIBRARY parameters.
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 an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: EXIT IF ERROR
5D47
LD HL,(5E03H)LD HL,(SOFF)
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
5D4A
LD A,H
OR LLD A,H
Since the Z-80 cannot test Register Pair HL against zero, the common trick is to set Register A to equal to Register H, and then OR A against Register L. Only if both Register H and Register L were zero can the Z FLAG be set.
5D4C
If RS-232 is off, then the NZ FLAG (Not Zero) will have been set, JUMP to 5D09H.
Original Source Code Comment: YES, DO IT
5D4E
LD HL,(5E0DH)LD HL,(S9WAIT)
Fetch the value held in memory location 5E0DH (the WAIT FLAG) and store it into Register Pair HL.
Original Source Code Comment: SEE IF WAIT MODE
5D51
5D51
LD A,H
OR LLD A,H
Since the Z-80 cannot test Register Pair HL against zero, the common trick is to set Register A to equal to Register H, and then OR A against Register L. Only if both Register H and Register L were zero can the Z FLAG be set.
5D53
If the WAIT FLAG is on, then the Z FLAG (Zero) will have been set, JUMP to 5D5AH.
Original Source Code Comment: NO, TRY FOR NO WAIT
5D55SETWAT
LD (WAIT),A
Store the value held in Register A into memory location 41FAH (which is the storage location for is the storage location for the RS-232 Wait Flag. 0=Wait, 1=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)
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
5D5D
LD A,H
OR LLD A,H
Since the Z-80 cannot test Register Pair HL against zero, the common trick is to set Register A to equal to Register H, and then OR A against Register L. Only if both Register H and Register L were zero can the Z FLAG be set.
5D5F
If it is already ZERO JUMP to 5D64H.
Original Source Code Comment: NO, CONTINUE
5D61
XOR A
Set Register A to ZERO and clear all Flags.
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)
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
5D68
LD A,B
OR CLD A,B
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: ANY BAUD RATE GIVEN
5D6A
If the BAUD RATE is already ZERO, JUMP to 5D86H.
Original Source Code Comment: NO, CONTINUE
5D6C
LD HL,5E4AHLD HL,BADTAB
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)
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
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 an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: YES, PARAMETER ERROR
5D75
LD E,(HL)
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
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)
Fetch the MSB of the 2 byte baud rate code (held in the memory location pointed to by Register Pair HL) and store it into Register E.
5D78
INC HL
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
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
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
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
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
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
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)
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
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)
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
5D89
LD A,H
OR LLD A,H
Since the Z-80 cannot test Register Pair HL against zero, the common trick is to set Register A to equal to Register H, and then OR A against Register L. Only if both Register H and Register L were zero can the Z FLAG be set.
Original Source Code Comment: ANY STOP 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
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
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)
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
5D99
LD A,H
OR LLD A,H
Since the Z-80 cannot test Register Pair HL against zero, the common trick is to set Register A to equal to Register H, and then OR A against Register L. Only if both Register H and Register L were zero can the Z FLAG be set.
5D9B
LD B,08HLD B,8
Let Register B equal a mask of 08H (0000 1000).
Original Source Code Comment: SET FOR BIT 3
5D9D
If the PARITY was already at 0, JUMP to 5DB5H.
Original Source Code Comment: NO, CONTINUE
5D9F
LD A,L
Copy the Parity Value (held in Register L) into Register A.
Original Source Code Comment: GET THE VALUE
5DA0
CP 03HCP 3
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
Check to see if the PARITY was set to ODD by DECrementing the value stored in Register L by 1 so bt the parity type (odd or even).
Original Source Code Comment: SEE IF PARITY ODD
5DAD
LD B,80H
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)
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
5DB8
LD A,H
OR LLD A,H
Since the Z-80 cannot test Register Pair HL against zero, the common trick is to set Register A to equal to Register H, and then OR A against Register L. Only if both Register H and Register L were zero can the Z FLAG be set.
5DBA
If the WORD LENGTH storage location was a 0, JUMP to 5DE1H.
Original Source Code Comment: NO
5DBC
LD B,60H
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
Copy the contents of Register L (the length) into Register A.
Original Source Code Comment: GET THE WORD LENGTH
5DC2
SUB 05HSUB 5
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 an ILLEGAL COMMAND PARAMETER error, 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
Copy the subtracted contents of Register A back into Register L.
Original Source Code Comment: PUT THE VALUE BACK INTO L
5DCA
DEC L
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
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
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
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
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 an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: NO, PARAMETER ERROR
5DDC
LD B,60H
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)
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
MASK the value of Register A against 0FCH (1111 1100). This has the effect of turning off bits 1 (Request to Send) and 0 (Data Terminal Ready).
Original Source Code Comment: INUSRE LSB'S OFF
5DE6
OR 04HOR 4
OR Register A against 04H (0000 0100). This has the effect of turning on bit 2 (TRANSMIT = Enable).
Original Source Code Comment: INSURE XMIT ENABLE ON
5DE8
LD (41F9H),ALD (UART),A
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)
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
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
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
Set Register A to ZERO and clear all Flags.
Original Source Code Comment: SET 'Z'
5DF9
RET
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
Copy the mask (held in Register B on entry) into Register A.
Original Source Code Comment: GET THE VALUE
5DFB
CPL
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
Put the modified mask back into Register B.
Original Source Code Comment: SAVE IT
5DFD
LD A,(41F9H)LD A,(UART)
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
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.

5E03SOFF
DEFW 0000H
RS-232 ON/OFF FLAG.
5E05SBAUD
DEFW 0000H
BAUD RATE FLAG.
5E07SWORD
DEFW 0000H
WORD LENGTH.
5E09SSTOP
DEFW 0000H
NUMBER OF STOP BITS.
5E0BSPAR
DEFW 0000H
PARITY SETTING.
5E0DSWAIT
DEFW 0000H
"WAIT" FLAG.
5E0FSSWAIT
DEFW 0000H
"NO WAIT" FLAG.

5E11H - SETSWT - PARSER TABLE for SETCOM.

5E11SETSWT
DEFM "OFF "
 
5El9
DEFM "BAUD "
 
5E21
DEFM "WORD "
 
5E29
DEFM "STOP "
 
5E31
DEFM "PARITY"
 
5E39
DEFM "WAIT "
 
5E41
DEFM "NOWAIT"
 
5E49
DEFB 00H
Table Terminator

5E4AH - BADTAB - BAUD RATE TABLE for SETCOM.

5E4ABADTAB
DEFB 50H 00H 00H
Baud Rate of 50
5E4D
DEFB 75H 00H 11H
Baud Rate of 75
5E50
DEFB 10H 01H 22H
Baud Rate of 110
5E53
DEFB 34H 01H 33H
Baud Rate of 134.5
5E56
DEFB 50H 01H 44H
Baud Rate of 150
5E59
DEFB 00H 03H 55H
Baud Rate of 300
5E5C
DEFB 00H 06H 66H
Baud Rate of 600
5E5F
DEFB 00H 12H 77H
Baud Rate of 1200
5E62
DEFB 00H 18H 88H
Baud Rate of 1800
5E65
DEFB 00H 20H 99H
Baud Rate of 2000
5E68
DEFB 00H 24H AAH
Baud Rate of 2400
5E6B
DEFB 00H 36H BBH
Baud Rate of 3600
5E6E
DEFB 00H 48H CCH
Baud Rate of 4800
5E71
DEFB 00H 72H DDH
Baud Rate of 7200
5E74
DEFB 00H 96H EEH
Baud Rate of 9600
5E77
DEFB FFH FFH
End of Table Designator
Original Source Code Comment: END OF LIST

5E79H - TABLE1 - Word Length Text Pointer Table.

5E79TABLE1
DEFW D6H 5EH
Pointer to the ASCII Text corresponding to a Word Length of 5
5E7B
DEFW D8H 5EH
Pointer to the ASCII Text corresponding to a Word Length of 6
5E7D
DEFW DAH 5EH
Pointer to the ASCII Text corresponding to a Word Length of 7
5E7F
DEFW DCH 5EH
Pointer to the ASCII Text corresponding to a Word Length of 8

5E81H - TABLE2 - Baud Rate Text Pointer Table.

5E81TABLE2
DEFW DEH 5EH
Pointer to the ASCII Text corresponding to a Baud Rate of 50
5E83
DEFW E1H 5EH
Pointer to the ASCII Text corresponding to a Baud Rate of 75
5E85
DEFW E4H 5EH
Pointer to the ASCII Text corresponding to a Baud Rate of 110
5E87
DEFW E8H 5EH
Pointer to the ASCII Text corresponding to a Baud Rate of 134.5
5E89
DEFW EEH 5EH
Pointer to the ASCII Text corresponding to a Baud Rate of 150
5E8B
DEFW F2H 5EH
Pointer to the ASCII Text corresponding to a Baud Rate of 300
5E8D
DEFW F6H 5EH
Pointer to the ASCII Text corresponding to a Baud Rate of 600
5E8F
DEFW FAH 5EH
Pointer to the ASCII Text corresponding to a Baud Rate of 1200
5E91
DEFW FFH 5EH
Pointer to the ASCII Text corresponding to a Baud Rate of 1800
5E93
DEFW 04H 5FH
Pointer to the ASCII Text corresponding to a Baud Rate of 2000
5E95
DEFW D9H 5FH
Pointer to the ASCII Text corresponding to a Baud Rate of 2400
5E97
DEFW 0EH 5FH
Pointer to the ASCII Text corresponding to a Baud Rate of 3600
5E99
DEFW 13H 5FH
Pointer to the ASCII Text corresponding to a Baud Rate of 4800
5E9B
DEFW 18H 5FH
Pointer to the ASCII Text corresponding to a Baud Rate of 7200
5E9E
DEFW 1DH 5FH
Pointer to the ASCII Text corresponding to a Baud Rate of 9600

5E9FH - BAUDMG - MESSAGE DISPLAY for SETCOM CONFIGURATION.

5E9FBAUDMG
DEFM "BAUD" + 03H
Configuration Element
5EA4UARTMG
DEFM "WORD" + 03H
Configuration Element
5EA9STOPMG
DEFM "STOP" + 03H
Configuration Element
5EAEPARTMG
DEFM "PARITY" + 03H
Configuration Element
5EB5NONE
DEFM "NONE" + 03H
Parity Classes
"ODD"

SEBA
DEFM "ODD" + 03H
Parity Classes
5EBEEVEN
DEFM "EVEN" + 03H
Parity Classes
5EC3WAITS
DEFM "WAIT" + 03H
Wait States
5EC8NWAITS
DEFM "NO WAIT" + 03H
Wait States
5ED0SMODE
DEFM "MODE" + 0DH
 
Original Source Code Comment: BACKSPACE
5ED6S5
DEFM "5" + 03H
Word Length
5ED8S6
DEFM "6" + 03H
Word Length
"S7"

SEDA
DEFM "7" + 03H
Word Length
5EDCS8
DEFM "8" + 03H
Word Length
5EDES50
DEFM "50" + 03H
Baud Rate Table
5EE1S75
DEFM "75" + 03H
Baud Rate Table
5EE4S110
DEFM "110" + 03H
Baud Rate Table
5EE8S134
DEFM "134.5" + 03H
Baud Rate Table
"S150"

SEEE
DEFM "150" + 03H
Baud Rate Table
5EF2S300
DEFM "300" + 03H
Baud Rate Table
5EF6S600
DEFM "600" + 03H
Baud Rate Table
"S1200"

SEFA
DEFM "1200" + 03H
Baud Rate Table
"S1800"

SEFF
DEFM "1800" + 03H
Baud Rate Table
5F04S2000
DEFM "2000" + 03H
Baud Rate Table
5F09S2400
DEFM "2400" + 03H
Baud Rate Table
"S3600"

SFOE
DEFM "3600" + 03H
Baud Rate Table
5Fl3S4800
DEFM "4800" + 03H
Baud Rate Table
5Fl8S7200
DEFM "7200" + 03H
Baud Rate Table
5FlDS9600
DEFM "9600" + 03H
Baud Rate Table
5F22RSOFF
DEFM "RS-232 IS NOW OFF" + 0DDH
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)
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
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
Evaluate the DUAL parameter via a GOSUB to 5081H.
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)
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
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
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
Store the FFH (DUAL mode ON) (held in Register A into memory location 442FH.
5F4A
LD HL,(401EH)LD HL,(DDCB+1)
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
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)
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
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
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
Store 4CE1H (held in Register Pair HL) into the DUAL routine's video driver address (held at memory location 401EH).
Original Source Code Comment: INTO VIDEO
5F5C
LD (4026H),HLLD (PDCB+1),HL
Store 4CE1H (held in Register Pair HL) into the DUAL routine's printer driver address (held at memory location 4026H).
Original Source Code Comment: INTO PRINTER
5F5FDUALON
LD HL,5FD2HLD HL,ON
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)
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
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)
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
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)
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
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
Set Register A to ZERO and clear all Flags.
Original Source Code Comment: CLEAR THE DUAL FLAG
5F77
LD (442FH),ALD (DULFLG),A
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
Let Register Pair HL equal 5FD5H, to point to the message "OFF".
Original Source Code Comment: HL => 'OFF' MSG
5F7DDULPRT
PUSH HL
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
Let Register Pair HL equal 5FC5H, to point to the message "DUAL IS NOW ".
Original Source Code Comment: HL => 'DUAL IS NOW' MSG
5F81
GOSUB to 021BH.
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
Original Source Code Comment: DISPLAY IT
5F84
POP HL
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 character at (HL) until a 03H 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
Let Register Pair HL equal 5F95H, to point to the message "CAN'T ACTIVATE DUAL WHILE ROUTE IS IN OPERATION".
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 character at (HL) until a 03H 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)
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 ' '
Compare the value held in Register A against 20H (0010 0000) / (Decimal: 32)(ASCII: SPACE).
Original Source Code Comment: SPACE?
5F91
RET NZ
If the NZ FLAG (Not Zero) has been set, RETurn to the caller.
Original Source Code Comment: NO, EXIT
5F92SKIPS1
INC HL
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.

5F95NODMSG
DEFM →
"CAN'T ACTIVATE DUAL WHILE ROUTE IS IN OPERATION".
5FC5DULMSG
DEFM →
"'DUAL IS NOW' + 03H".
5FD2ON
DEFM →
"'ON' + 0DH".
5FD5OFF
DEFM →
"'OFF' + 0DH".

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
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
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
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 DOS PARAMETER STRING PARSE routine. It decodes DOS LIBRARY parameters.
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 an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: EXIT IF ERROR
5FED
LD BC,(WPDRV)LD BC,0
Let Register Pair BC equal the drive number (which was put into 5FEE-5FEFH elsewhere in the overlay).
Original Source Code Comment: DRIVE NUMBER STORED HERE
5FF0
LD A,(4413H)LD A,(MAXDRV)
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
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 requested drive number (in C) is equal to or higher than the highest drive number (in A) the C FLAG (Carry) will have been set, JUMP to 5221H with an error.
Original Source Code Comment: NO, REPORT ERROR
5FF7
LD A,C
Copy the requested drive number from Register C into Register A.
Original Source Code Comment: GET THE DRIVE
5FF8
ADD A,30HADD A,'0'
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
Store the value held in Register A into memory location 6024H which is in the middle of the "DISK DRIVE _ IS NOW" message.
Original Source Code Comment: SET IT INTO MESSAGE
5FFD
PUSH BC
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
Let Register Pair HL equal 6019H, which is the message "DISK DRIVE _ IS NOW" + 03H.
Original Source Code Comment: HL => 'DRIVE X PROTECTED' MSG
6001
GOSUB to 021BH.
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
Original Source Code Comment: DISPLAY IT
6004
LD HL,602EHLD HL,FINMSG
Let Register Pair HL equal 602EH, which is the message "WRITE PROTECTED".
Original Source Code Comment: FINAL PORTION OF MSG
6007
GOSUB to 021BH.
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
600A
POP BC
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
Copy the drive number from Register C into Register A.
Original Source Code Comment: GET THE DRIVE
600CWPROT3
LD (45F8H),ALD (WPD),A
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
RETurn to the caller.

6010H - WPSW - PARSER TABLE for WP COMMAND.

6010WPSW
DEFM "DRIVE "
 
6016
DEFW EEH 5FH
This is the memory address in the middle of a LD BC,(____) OPCODE where the disk drive number is stored
6018
DEFB 00H
End of Table Delimiter.
6019WPDMSG
DEFM →
"'DISK DRIVE 0 IS NOW ' + 03H". Note that the "0" is "WPDR"
602EFINMSG
DEFM →
"'WRITE PROTECTED '".

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
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
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
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 DOS PARAMETER STRING PARSE routine. It decodes DOS LIBRARY parameters.
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 an ILLEGAL COMMAND PARAMETER error, and ABORT.
Original Source Code Comment: NOTHING SUPPORTED
6051
LD BC,(5FEEH)LD BC,(WPDRV)
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)
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
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 requested drive number (in C) is equal to or higher than the highest drive number (in A) the C FLAG (Carry) will have been set, JUMP to 5221H with an error.
Original Source Code Comment: NO, DRIVE NOT IN SYSTEM
605C
LD A,C
Copy the requested drive number from Register C into Register A.
Original Source Code Comment: GET THE DRIVE
605D
ADD A,30HADD A,'0'
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
Store the value held in Register A into memory location 6024H which is in the middle of the "DISK DRIVE _ IS NOW" message.
Original Source Code Comment: SET IT IN MESSAGE
6062
PUSH BC
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
Let Register Pair HL equal 6019H, which is the message "DISK DRIVE _ IS NOW" + 03H.
Original Source Code Comment: HL => 'DISK DRIVE X' MSG
6066
GOSUB to 021BH.
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
Original Source Code Comment: DISPLAY IT
6069
LD HL,6075HLD HL,MSTMSG
Let Register Pair HL equal 6075H, which is the pointer to the message "THE MASTER DRIVE".
Original Source Code Comment: HL => 'IS MASTER DRIVE' MSG
606C
GOSUB to 021BH.
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
Original Source Code Comment: DISPLAY IT
606F
POP BC
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
Copy the drive number from Register C into Register A.
Original Source Code Comment: GET IT
6071MAST2
LD (42B3H),ALD (DIFULT),A
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
RETurn to the caller.

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

6075MSTMSG
DEFM →
"'THE MASTER DRIVE' + 0DH".

6086H - CONVHX - Convert Binary Coded Decimal into a Binary Value. On Entry HL = a hex value and On Exit HL = the decimal value.

6086CONVHX
EX DE,HL
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
Copy the MSB of the number to convert (held in Register D) into Register A.
Original Source Code Comment: GET THE MSB
6088
Rotate Register A left 4 times to the HIGH NYBBLE via a GOSUB to 60B5H.
Original Source Code Comment: DO THE SHIFTS
608B
608C
LD L,A
LD H,00HLD L,A
Let Register Pair HL = the high nybble of the MSB of the requested value (held in Register A).
Original Source Code Comment: INTO HL
608E
608F
PUSH HL
POP BCPUSH HL
Let BC = the high nybble of the MSB of the requested value (held in Register Pair HL).
Original Source Code Comment: HL = HL * 10
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
Let Register A equal a mask of 0FH (0000 1111).
Original Source Code Comment: GET THE 2ND DIGIT
6095
AND D
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
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
LET Register Pair HL = 10 * the High Nybble of the MSB + the Low Nybble of the MSB.
6098
PUSH HL
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
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
Copy the LSB of the number to convert (held in Register D) into Register A.
Original Source Code Comment: DO THE LSB
609E
Rotate Register A left 4 times to the LOW NYBBLE via a GOSUB to 60B5H.
60A1
60A2
LD C,A
LD B,00HLD C,A
Let BC = the high nybble of the LSB of the requested value (held in Register Pair HL).
Original Source Code Comment: INTO BC
60A4
ADD HL,BC
LET Register Pair HL = the prior total (held in Register Pair HL) + the high nybble of the LSB (held in Register BC).
60A5
60A6
PUSH HL
PUSH HL
POP BC
LET Register Pair BC = 10 * that total.

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
Let Register A equal a mask of 0FH (0000 1111).
Original Source Code Comment: MASK FOR LSD
60AC
AND E
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
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
LET Register Pair HL = Register Pair HL + Register BC.
60AF
RET
RETurn to the caller.

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

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

60B5H - SHIFT - Get the high nybble.

60B5SHIFT
60B7
60B9
60BB
SRL A
SRL A
SRL A
SRL ASRL A

Original Source Code Comment: GET THE HIGHEST NIBBLE
60BD
RET
RETurn to the caller.
60BD
END 5200HRET

MISC - STORAGE BYTES.

S9DCB
6130S9DCB
DEFS 50
Storage of 50 bytes, which is the length of a disk DCB
S9DCB1
6162S9DCB1
DEFS 50
Storage of 50 bytes, which is the length of a disk DCB
S9DCB2
6194S9DCB2
DEFS 50
Storage of 50 bytes, which is the length of a disk DCB
BUFER1
6300BUFER1
DEFS 256
Storage of 256 bytes
BUFER2
6400BUFER2
DEFS 256
Storage of 256 bytes