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

Program Overview

SYS11/SYS handles the TAPE, PURGE, and LIST library commands.

It is loaded by SYS1 (the library command dispatcher) when one of these commands is requested. After loading, BEGIN at 5200H clears the "CLEAR RAM" flag (CFLAG=42B4H), the OVERLAY flag (FLAG1=4414H), the protection-override switch (SCAFLG=42FFH), and BASICG (427AH=−1 to indicate BASIC is no longer in RAM), then dispatches via the GETTAB / TABLE jump table to the requested command handler. Recognized command codes are SSYST (23H, → SYSTEN/TAPE), PUR (1EH, → PURGE), and LISTT (18H, → LIST); any other code falls through to ERR2 with an ILLEGAL PARAMETER error.

Memory Map

Address RangeLabelContents
5200H–5217HBEGINOverlay entry point: clear flags, lookup command in TABLE, dispatch.
5218H–5225HNOCMD / ERR2 / ERR3 / ERR9 / ERRXCommon error exits to ERROR (4409H).
5226H–523DHGETTAB / GETTA1 / GETTA2 / GETTA3Linear-search command-code lookup over TABLE.
523EH–5247HTABLEThree-entry DCF jump table: SSYST/PUR/LISTT → SYSTEN/PURGE/LIST, terminated by 00H.
5248H–5257HCOMPAR / COMPA1 / COMPA2Block-compare DE-bytes against HL-bytes (LDI-driven).
5258H–525EHSKIPSP / SKIPS1Advance HL past spaces.
525FH–526EHHLDPAT / HLDPA1Pause if "@" key is held; resume on ENTER.
526FH–5285HPDATAOutput a character to screen and (if LPFLAG≠0) to printer; expand TAB via SPACIT.
5286H–5292HPRINTTOutput a 03H-terminated string at (HL).
5293H–529CHHEXCConvert low nibble of A to ASCII and call PDATA.
529DH–52A8HDECBIN / DECBI1Convert binary value in A to two ASCII decimal digits at (HL).
52A9H–5377HSYSTEN / SYSPAR / RDYCASTAPE command parser: parse (S=…,D=…) syntax, branch to DSRC / TSRC / TRAM.
5378H–53BBHRDYCMG / DISK / TAPE / RAM / TSRCT / CMEXTTAPE command message table (CR2/03H-terminated).
53BCH–5499HDSRC / TDES / TDES1…6TAPE: source=DISK, destination=TAPE.
54B3H–54CCHGETBYT / WRIBYTTAPE: read/write one byte from/to disk file with error trap.
54D3H–55ACHTSRC / DDESTAPE: source=TAPE, destination=DISK.
55ADH–560CHTRAMTAPE: source=TAPE, destination=RAM (load and run a SYSTEM tape).
560DH–5864HPURGE et al.PURGE library command: scan HIT, prompt Y/N/Q per file, kill confirmed; optional "*" system-files variant rebuilds GAT/HIT and writes the "Not a SYSTEM Disk" stub at track 0 sector 2.
5865H–58A4HMSPW / SYSMSG / SY4MSG / QUERYPURGE prompt strings.
58A5H–58CAHPURSWT / PSYS / PINV / PALL / STAR / PUDRV / PDRV / PWPURGE switch table and option storage.
58CCH–5B03HLIST et al.LIST library command: open file, display LRL, print 60-char rows in three passes (ASCII / hex high / hex low).
5B04H–5BA0HRCNUM / ASCFLG / SLWFLG / DATA1 / FILNAM /
FILSAV / FILLRL / LRLSAV / RECNUM /
LRL256 / EOFMSG / CR2 / DOTSTR / SWTCH1
LIST workspace, header strings, and option-switch table.
5BA2H–5C01HSDCB1 / SDCB2Two 48-byte file DCBs (DEFS SIZDIR each).
5D00H–5EFFHBUFER1 / BUFER2Two 256-byte file buffers (DEFS SECTOR each, page-aligned via ORG $,256 at source line 1426).
5F00H–5F26HSYST / SEC3 / NOSYS / SYSTMGPre-built load-file image written to disk track 0 sector 2 by PURGE * to display "Not a SYSTEM Disk" on a non-bootable diskette. Assembled with SETLOC BUFF2 (4D00H) so the embedded code runs at 4D00H even though it is stored at 5F04H+.

Self-Modifying Variables and Workspace

The following addresses inside SYS11's own code space are used as self-modifying operand bytes (the byte after a 3E/01/21 opcode). They are not added to the site-wide RAM JSON because SYS11 is a transient overlay and its self-modifying targets do not persist across overlay loads — they are documented here for readers of the disassembly.

AddressLabelDescription
5277HLPFLAGOperand byte of LD BC,0000H at 5276H. Holds the line-printer flag tested by PDATA at 527CH and PRTHED at 5AF3H. A non-zero value routes output to PRT (3BH).
56A2HBUFPNTOperand byte of LD HL,BUFER1 at 56A1H. Tracks PURGE's position as it walks the in-memory HIT table looking for files to purge.
5B05HASCFLGDEFW 0 in storage section. Set by "ASCII" LIST option; tested at 594DH and 5AC4H to switch LIST output to plain-text mode.
5B07HSLWFLGDEFW 0 in storage section. Set by "SLOW" LIST option; tested at 5990H and 5A7AH to insert PAUSE delays between rows.
5B09HDATA1DEFW 0. Currently unused workspace word.
5B03HRCNUMDEFW 0. Holds the current record number being displayed by LIST; bumped at 5A02H.
58BEHPSYSDEFW 0. PURGE "SYS" option flag; written by SWITCH at 5654H, tested at 56F0H.
58C0HPINVDEFW 0. PURGE "INV" option flag.
58C2HPALLDEFW 0. PURGE "ALL" option flag; if set, all files (including SYS/INV) are eligible.
58C4HSTARDEFB 0. Set non-zero when the user issued PURGE *; gates the system-files purge path.
58C5H–58C7HPUDRVDEFM ':0' + DEFB 3. Three-byte drive specifier appended to file names during PURGE; the '0' byte at 58C6H is patched at CKCOLN (562DH) when the user supplies a drive.
58C8HPDRVDEFB 0. Drive number used by PURGE for HIT/GAT/DIR I/O.
58C9HPWDEFW 0. Holds the trap-door-encoded master password supplied by the user, compared against the disk password at BUFF2+DPASS.

Major Routines

AddressLabelFunction and entry/exit
5200HBEGINOverlay entry. Entry: HL=command-line pointer, C=command code. Exit: by RET to the dispatched routine, or fall-through to NOCMD with C set on lookup failure.
5218HNOCMDRecover stack and exit with ILLEGAL PARAMETER (0BH) via ERRX.
5219HERR2Load A=ERICP (0BH = ILLEGAL PARAMETER) and fall through to ERRX.
521DHERR3Load A=ERCPM (0AH = MISSING PARAMETER) and fall through to ERRX.
5221HERR9Load A=EDNS (02H = DRIVE NOT IN SYSTEM) and fall through to ERRX.
5223HERRXJP ERROR (4409H) to display A and abort.
5226HGETTABLinear-search TABLE for command code in C. Exit: CY=1 if not found, else HL=destination address.
523EHTABLEDCF jump table (DEFB code + DEFW addr): 23H/SYSTEN, 1EH/PURGE, 18H/LIST, 00H terminator.
5248HCOMPARCompare BC bytes at (DE) vs (HL). Saves BC/DE/HL on entry, restores and returns; Z=match/!Z=mismatch.
5258HSKIPSP / SKIPS1Advance HL past space characters; on first non-space, return.
525FHHLDPATPoll keyboard; if "@" held, wait for ENTER then return.
526FHPDATAOutput A to screen via DSP (33H), and to printer via PRT (3BH) when LPFLAG≠0; expand TAB via SPACIT.
5286HPRINTTOutput 03H-terminated text string at (HL).
5293HHEXCConvert low nibble of A to one ASCII hex digit and PDATA it.
529DHDECBINConvert A (0–99) to two ASCII decimal digits at (HL),(HL+1).
52A9HSYSTENTAPE command top-level: zero out two DCBs, parse (S=…,D=…), dispatch to DSRC, TSRC, or TRAM.
531FHSYSPARParse one S=spec or D=spec clause into the DCB at (BC).
5348HRDYCASDisplay "Press ANY key when Cassette ready", wait for key, output CR.
53BCHDSRCTAPE source=DISK, destination=TAPE: read disk file (load-file format), write to cassette.
54B3HGETBYTRead one byte from the disk file via GET (13H); JP NZ,ERROR on failure.
54BDHWRIBYTSave all registers, PUT one byte to disk via PUT (1BH); restore and return.
54D3HTSRCTAPE source=TAPE, destination=DISK: read cassette, write disk file in load-file format.
55ADHTRAMTAPE source=TAPE, destination=RAM: load a SYSTEM tape into RAM with checksum verification, then JP (HL) to the transfer address (or RET to DOS if zero).
560DHPURGEPURGE library command: parse drive/options, prompt for master password, scan HIT, kill confirmed files; if "*" given, also delete system files via PURSYS.
57A4HTRAPEight-round trap-door (one-way) hash of the 8-character password at (DE), result in HL.
57D4HPURSYSConfirm and execute the "system files" portion of PURGE *: clear the SYS extents in the HIT, clear the system tracks in the GAT, write the NOSYS stub to track 0 sector 2.
58CCHLISTLIST library command: parse filespec and switches, open file, scroll-protect 2 lines, display ASCII or hex output.
5A17HDSPROWDisplay one B-byte row in three passes (ASCII / hex MSB / hex LSB).
5A90HSPACITExpand a TAB by outputting spaces up to the next 8-column boundary, computed from the cursor LSB at CURSOR (4020H).
5AA5HPRTHEDDisplay the LIST page header (file name + LRL + REC) and reset the cursor to the screen origin.

Command Code Jump Table

TABLE at 523EH is a three-entry DCF table consulted by GETTAB at overlay entry. Each entry is a 3-byte tuple (1-byte command code + 2-byte little-endian address); a zero command-code byte terminates the list.

AddressCode (label)Handler (label)
523EH23H (SSYST)52A9H (SYSTEN) — TAPE command
5241H1EH (PUR)560DH (PURGE) — PURGE command
5244H18H (LISTT)58CCH (LIST) — LIST command
5247H00H(table terminator)

Disassembly:

 
ORG 5200H
5200BEGIN
LD A,55H
Let Register A equal 55H.
Original Source Code Comment: SET THE 'CLEAR RAM' FLAG
5202
LD (42B4H),ALD (CFLAG),A
Store the value held in Register A into memory location 42B4H.
NOTE: 42B4H is the storage location for the PROGRAM PROTECT 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
Store the value held in Register A into memory location 4414H.
NOTE: 4414H is the storage location for the NUMBER OF THE OVERLAY CURRENTLY IN MEMORY.
Original Source Code Comment: CLEAR THE OVERLAY FLAG
5209
LD (42FFH),ALD (SCAFLG),A
Store the value held in Register A into 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.
Original Source Code Comment: MAKE A -1
520D
LD (427AH),ALD (BASICG),A
Store the value held in Register A into memory location 427AH.
NOTE: 427AH is the storage location for the EXECUTE FILE FLAG.
Original Source Code Comment: SHOW BASIC NO LONGER IN RAM
5210
PUSH HL
Save the COMMAND LINE (pointed to by Register Pair HL) to the top of the stack.
Original Source Code Comment: SAVE COMMAND LINE POINTER
5211
Identify the executor which called the Overlay via a GOSUB to 5226H.
Original Source Code Comment: GET ADDRESS OF COMMAND
5214
If the C FLAG (Carry) has been set then that routine wound up with an error, so exit via a JUMP to 5218H.
Original Source Code Comment: NOT ANY OF THESE COMMANDS. EXIT
5216
EX (SP),HL
Put the executor address (held in Register Pair HL) in the memory address representing the top of the stack.
Original Source Code Comment: HL=> COMMAND LINE, SP=COMMAND ADDRESS
5217
RET
RETurn to the the executor address.
Original Source Code Comment: EXIT TO THE COMMAND

5218H - NOCMD - Exit with a ILLEGAL PARAMETER error.

5218NOCMD
POP HL
Clear the stack.
Original Source Code Comment: GET COMMAND LINE POINTER OFF STACK
5219ERR2
LD A,0BHLD A,ERICP
Let Register A equal 0BH to point to an ILLEGAL PARAMETER error.
Original Source Code Comment: BAD PARAMETER
521B
Display the ILLEGAL PARAMETER error and exit via a JUMP to 5223H.

521DH - ERR3 - Exit with a PARAMETER NOT FOUND error.

521DERR3
LD A,0AHLD A,ERCPM
Let Register A equal 0AH to point to a PARAMETER NOT FOUND error.
Original Source Code Comment: MISSING PARAMETER
521F
Display the PARAMETER NOT FOUND error and exit via a JUMP to 5223H.

5221H - ERR9 - Exit with an error of DISK DRIVE NOT ON.

5221ERR9
LD A,02HLD A,EDNS
Let Register A equal 02H to point to a DISK DRIVE NOT ON error.
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 - Decode the COMMAND LINE.

5226GETTAB
Let Register Pair HL equal 523EH, which is the top of the COMMAND TABLE.
Original Source Code Comment: HL => COMMAND TABLE
5229GETTA1
LD A,(HL)
Fetch the first byte on the current row of the COMMAND TABLE and store it into Register 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 have not run out of table entries, so continue by JUMPing to 522FH.
Original Source Code Comment: NO, LOOK IT UP
522D
SCF
We ran out of table entries without a match, so we 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 - Scan the COMMAND TABLE for a match.

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 they match, then the Z FLAG (Zero) will have been set, JUMP to 5237H to process the rest of the command.
Original Source Code Comment: YES, GET THE ADDRESS
5232
INC HL
INCrement the value stored in Register Pair HL by 3 to move to the next line of the COMMAND TABLE.
Original Source Code Comment: HL => LSB OF ADDRESS
5233
INC HL
...
Original Source Code Comment: HL => MSB OF ADDRESS
5234
INC HL
...
Original Source Code Comment: HL => NEXT COMMAND BYTE
5235
Process the next table entry vi a JUMP back to 5229H.
Original Source Code Comment: LOOP TILL FOUND

5237H - GETTA3 - Determine the JUMP POINT from a MATCHING ENTRY of the COMMAND TABLE.

5237GETTA3
INC HL
INCrement the value stored in Register Pair HL by 1 to point to the LSB byte of the address of the command.
Original Source Code Comment: HL => LSB OF ADDRESS
5238
LD E,(HL)
Fetch the LSB byte of the address of the command (held in the memory location pointed to by Register Pair HL) and store it into Register E.
Original Source Code Comment: GET IT
5239
INC HL
INCrement the value stored in Register Pair HL by 1 to point to the MSB byte of the address of the command.
Original Source Code Comment: HL => MSB OF ADDRESS
523A
LD D,(HL)
Fetch the MSB byte of the address of the command (held in the memory location pointed to by Register Pair HL) and store it into Register D.
Original Source Code Comment: GET IT
523B
EX DE,HL
EXchange the value stored in Register Pair HL (the pointer to the COMMAND TABLE) with the value stored in Register Pair DE (the jump address for the matched 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.

523EH - COMMAND TABLE.

523ETABLE
DEFB 23H
Code for the TAPE command
523F
DEFW 52A9H
Jump location of 52A9H
5241
DEFB 1EH
Code for the PURGE command
5242
DEFW 560DH
Jump location of 560DH
5244
DEFB 18H
Code for the LIST command
5245
DEFW 58CCH
Jump location of 58CCH
5247
DEFB 00H
End of Table Delimeter.
Original Source Code Comment: END OF LIST

5246H - Compare the first "BC" number of bytes of the string at (DE) againg the String at (HL).

5248COMPAR
PUSH BCSAV3
Save the contents of Register Pair BC to the top of the stack.
5249
PUSH DE
Save the contents of Register Pair DE to the top of the stack.
524A
PUSH HL
Save the contents of Register Pair HL to the top of the stack.
524BCOMPA1
LD A,(DE)
Fetch a character from the memory location pointed to by Register Pair DE and store it into Register A.
524C
CP (HL)
Compare the fetched character against the character from the memory location pointed to by Register Pair HL.
524D
If they don't match then the NZ FLAG (Not Zero) will have been set and we are done, so JUMP to 5254H to restore the registers from the stack with NZ set.
524F
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.
5251
If the PARITY/OVERFLOW FLAG has been SET, loop back to 524BH.
5254COMPA2
POP HLEXI3
Put the value held at the top of the STACK into Register Pair HL, and then remove the entry from the stack.
5255
POP DE
Put the value held at the top of the STACK into Register Pair DE, and then remove the entry from the stack.
5256
POP BC
Put the value held at the top of the STACK into Register Pair BC, and then remove the entry from the stack.
5257
RET
RETurn to the caller.

5258H - SKIPSP - Position HL to the next non-space character.

5258SKIPSP
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
5259
CP 20HCP 'SPACE'
Compare the value held in Register A against 20H (ASCII: SPACE) and set the NZ flag if it isn't a SPACE.
Original Source Code Comment: SPACE?
525B
RET NZ
If it isn't a SPACE then the the NZ FLAG (Not Zero) will have been set, RETurn to the caller.
Original Source Code Comment: NO, EXIT
525CSKIPS1
INC HL
INCrement HL by 1 to point to the next character to check.
Original Source Code Comment: BUMP TO NEXT CHAR
525D
JUMP to 5258H to check that character against a space.
Original Source Code Comment: LOOP TILL NON-SPACE FOUND

525FH - HLDPAT - Pause if "@" is Pressed.

525FHLDPAT
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
5262
OR A
Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
Original Source Code Comment: ANY CHAR?
5263
RET Z
If no key was pressed then the Z FLAG (Zero) will have been set, RETurn to the caller.
Original Source Code Comment: NO, EXIT
5264
CP 40HCP '@'
Compare the value held in Register A against 40H (ASCII: @).
Original Source Code Comment: HOLD KEY?
5266
RET NZ
If the key pressed was anything other than a @, the NZ FLAG (Not Zero) will have been set, RETurn to the caller.
Original Source Code Comment: NO, EXIT

If we are here, then we got a @ so now we are going to sit and wait for an ENTER.

5267HLDPA1
GOSUB to 0049H which is the Model III ROM routine to scan the keyboard and wait until a key is pressed, and then return with the key pressed in Register A. BREAK returns 01H.
Original Source Code Comment: GET A KEYBOARD CHAR
526A
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: ENTER KEY?
526C
If the key we received was not a ENTER then the NZ FLAG (Not Zero) will have been set, so loop back to 5267H.
Original Source Code Comment: NO, STAY IN LOOP
526E
RET
If we're here, then an ENTER was received, so RETurn to the caller.
Original Source Code Comment: YES, EXIT

526FH - PDATA - Output a Byte held in Register A to the Screen and, if 5277H is set to 0000H, to the Printer.

526FPDATA
CP 09HCP 9
Compare the value held in Register A against 09H (ASCII: TAB). Results: If Register A equals TAB, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: TAB?
5271
If a TAB was found, the Z FLAG (Zero) will have been set, so JUMP to 5A91H to process a TAB.
Original Source Code Comment: YES, EXPAND TO SPACES
5274
PUSH DE
Save the contents of Register Pair DE to the top of the stack.
Original Source Code Comment: SAVE DE
5275
PUSH BC
Save the contents of Register Pair BC to the top of the stack.
Original Source Code Comment: SAVE BC
5276
LD BC,(*5277H*)LD BC,0
Let Register Pair BC equal the value placed into memory location 5277H elsewhere in this overlay.
Original Source Code Comment: LINE PRINTER FLAG STORED HERE
5279
527A
INC C
DEC CINC C
We need to test BC against 0 and, for some reason, the authors decided to do this by INCrementing and then DECrementing the value stored in Register C by 1.
Original Source Code Comment: SEE IF LINE PRINTER OPTION
527B
PUSH AF
Save the byte being processed (held in Register Pair AF) to the top of the stack.
Original Source Code Comment: SAVE THE CHARACTER
527C
If the NZ FLAG (Not Zero) has been set, PRINT the character via a GOSUB 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.
Original Source Code Comment: GO LINE PRINT
527F
POP AF
Restore the byte being processed (held at the top of the stack) into Register Pair AF.
Original Source Code Comment: GET THE CHARACTER BACK
5280
Display the character via a 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 ALSO
5283
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 REGISTERS
5284
POP DE
Put the value held at the top of the STACK into Register Pair DE, and then remove the entry from the stack.
5285
RET
RETurn to the caller.

5286H - PRINTT - Output a text string pointed to by Register Pair HL to the Screen and, if 5277H is set to 0000H, to the Printer as well.

5286PRINTT
LD A,(HL)
Fetch a character from the memory location pointed to by Register Pair HL and store it into Register A.
Original Source Code Comment: GET A CHARACTER
5287
CP 03HCP 3
Compare the value held in Register A against 03H, which is one of the standard END OF STRING delimiters.
Original Source Code Comment: TERMINATOR
5289
RET Z
If we are at the end of the string then the Z FLAG (Zero) will have been set, RETurn to the caller.
Original Source Code Comment: YES, EXIT
528A
Outputting the character held in Register A to the screen and, if applicable, the printer, via a GOSUB to 526FH.
Original Source Code Comment: OUTPUT IT
528D
CP 0DH
Compare the value held in Register A against 0DH (ASCII: ENTER), which is one of the standard END OF STRING delimiters.
Original Source Code Comment: END OF LINE?
528F
RET Z
If we are at the end of the string then the Z FLAG (Zero) will have been set, RETurn to the caller.
Original Source Code Comment: YES, EXIT
5290
INC HL
INCrement the pointer to the current character to deal with (held in Register Pair HL) by 1.
Original Source Code Comment: BUMP TO NEXT CHAR
5291
LOOP back to the top of this routine (i.e., 5286H).
Original Source Code Comment: LOOP TILL END

5293H - HEXC - Output the low nybble of Register A in Hexadecimal to the Screen and, if 5277H is set to 0000H, to the Printer.

5293HEXC
AND 0FH
Turn off the high nybble by MASKing the value of Register A against 0FH (0000 1111), turning off bits 7, 6, 5, 4.
Original Source Code Comment: MASK ALL BUT LSB

The DAA opcode is mysterious, but the first step is to move the value to process into a certain range.

5295
ADD A,90H
LET Register A = Register A + 90H, so that 0-9=90H-99H and A-F=01H-05H.
5297
DAA
Adjust Register A for BCD addition and subtraction operations. DAA is way too complicated to go into here, but if the low 4 bits are greater than 9, the H FLAG is set and 06H is addded to Register A and if the high 4 bits are greater than 9, the C FLAG is set and 60H is added to Register A. The explanation for this is that there are 6 ASCII characters between 9 and A, so adding 6H (for the ones digit) or 60H (for the tens digit), changes A-F into 10-15 in decimal.

The next step in processing a DAA opcode is to adjust the values again.

5298
ADC A,40H
Let Register A = Register A + 40H (plus carry), so that 0-9=30H-39H and A-F=40H-45H)
529A
DAA
Adjust Register A for BCD addition and subtraction operations. DAA is way too complicated to go into here, but if the low 4 bits are greater than 9, the H FLAG is set and 06H is addded to Register A and if the high 4 bits are greater than 9, the C FLAG is set and 60H is added to Register A. The explanation for this is that there are 6 ASCII characters between 9 and A, so adding 6H (for the ones digit) or 60H (for the tens digit), changes A-F into 10-15 in decimal.
529B
JUMP to 526FH to output the character held in Register A to the screen and, if applicable, the printer, via a GOSUB to 526FH.
Original Source Code Comment: OUTPUT THE ASCII

529DH - DECBIN - Encode a Two Digit Decimal Number in Text at (HL).

529DDECBIN
LD (HL),2FHLD (HL),'0'-1
Initialize the routine by starting (HL), which is the first digit, at one character below "0".
Original Source Code Comment: SET THE TEN'S
529FDECBI1
INC (HL)
INCrement the first digit (stored in the memory location pointed to by Register Pair HL) by 1.
Original Source Code Comment: BUMP THE 10'S
52A0
SUB 0AHSUB 10
Let the first character (held in Register A) = that character - 10.
Original Source Code Comment: NOT THE UNITS
52A2
As long as that SUB didn't go below 0, the NC flag will be set. In that case, loop back to 529FH and increase the digit held in the memory location pointed to by Register Pair HL by 1 and subtract another 10 from Register A.
Original Source Code Comment: LOOP TILL NEGATIVE
52A4
ADD A,3AHADD A,'0'+10
LET Register A = Register A + 3AH to convert the remainder (i.e., the 2nd digit) to ASCII.
Original Source Code Comment: CORRECT AND MAKE ASCII
52A6
INC HL
INCrement the value stored in Register Pair HL by 1 to point to the second digit.
Original Source Code Comment: BUMP TO NEXT SLOT
52A7
LD (HL),A
Store the converted 2nd digit (held in Register A) into the memory location pointed to by Register Pair HL.
Original Source Code Comment: STORE THE UNITS
52A8
RET
RETurn to the caller.

52A9H - SYSTEN - "TAPE" Routine.

52A9SYSTEN
PUSH HL
Save the pointer to the COMMAND LINE (poinetd to by Register Pair HL) to the top of the stack.
Original Source Code Comment: SAVE COMMAND LINE POINTER

The next 5 instructions are a standard way of clearing a memory region. HL is the base, DE = HL + 1, BC = the bytes to move. Then (HL) is set to 00H, which means 00H is then successively copied from one location to the next location, BC number of times.

52AA
LD HL,5BA2HLD HL,SDCB1
Let Register Pair HL equal 5BA2H, which will be the base of a buffer 97 characters long to hold a file control block.
Original Source Code Comment: HL => DISK DCB 1
52AD
LD DE,5BA3HLD DE,SDCB1+1
Let Register Pair DE equal 5BA3H.
52B0
LD BC,0060HLD BC,SIZDIR*2
Let Register Pair BC equal 0060H.
Original Source Code Comment: SIZE OF 2 DCB'S
52B3
LD (HL),00HLD (HL),0
Store the value held in 00H into the memory location pointed to by Register Pair HL.
Original Source Code Comment: FILL THE DCB'S WITH ZEROS
52B5
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.

Now 97 bytes of a buffer starting at 5BA2H has been zero'ed.

52B7
POP HL
Restore the pointer to the COMMAND LINE from the stack back into Register Pair HL.
Original Source Code Comment: GET COMMAND LINE POINTER BACK
52B8
GOSUB to 5258H to position HL to the next non-space character on the COMMAND LINE.
Original Source Code Comment: SKIP ANY SPACES
52BB
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?
52BD
We hit a ENTER, which menas we did not get parameters, the Z FLAG (Zero) will have been set and we JUMP to 521DH to exit with an error.
Original Source Code Comment: PARAMETER ERROR
52C0
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?
52C2
If Register A does NOT equal ( then we have a bad COMMAND LINE and the NZ FLAG (Not Zero) will have been set, so JUMP to 5219H to display an ILLEGAL PARAMETER error and exit via a JUMP to 5223H.
Original Source Code Comment: NO, PARAMETER
52C5
GOSUB to 525CH to fetch the next non-space character (pointed to by Register Pair HL) into Register A.
Original Source Code Comment: SKIP ANY SPACES
52C8
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 PARAMETERS
52CA
If we hit a ) which means we have a bad COMMAND LINE, the Z FLAG (Zero) will have been set and we JUMP to 521DH to exit with an error.
Original Source Code Comment: YES, HAVE TO HAVE SOMETHING
52CDSYSTE1
CP 53HCP 'S'
Compare the value held in Register A against 53H (ASCII: S). Results: If Register A equals S, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: SET UP SOURCE?
52CF
If we didn't get a S (for SOURCE) then the NZ FLAG (Not Zero) will have been set, JUMP to 52D9H to look for the destination spec.
Original Source Code Comment: NO, TRY DESTINATION
52D1
LD BC,5BA2HLD BC,SDCB1
If we're here then we are ready to process the SOURCE filename, so set Register Pair BC to the SOURCE FILE buffer at 5BA2H.
Original Source Code Comment: BC => SOURCE FILE
52D4
GOSUB to 531FH to get the source device name.
Original Source Code Comment: PARSE THE LINE
52D7
LOOP BACK 5 instructions to 52CDH to get the next spec.
Original Source Code Comment: GET NEXT COMMAND

52D9H - SYSTE2 - Continuation of "TAPE" Routine. Jumped here to process the command line looking for the Destination spec.

52D9SYSTE2
CP 44HCP 'D'
Compare the value held in Register A against 44H (ASCII: D). Results: If Register A equals D, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: SET UP DESTINATION?
52DB
If we didn't get a D (for DESTINATION) then the NZ FLAG (Not Zero) will have been set, JUMP to 52E5H.
Original Source Code Comment: NO, TRY FOR DESTIN
52DD
LD BC,5BD2HLD BC,SDCB2
Let Register Pair BC equal 5BD2H to point to the DESTINATION NAME buffer.
Original Source Code Comment: BC => DESTINATION FILE
52E0
GOSUB to 531FH to get the destination device name.
Original Source Code Comment: PARSE THE LINE
52E3
LOOP back to 52CDH to get the next spec.
Original Source Code Comment: AND GET NEXT COMMAND

52E5H - SYSTE3 - Continuation of "TAPE" Routine. Jumped here if we didn't get a destination spec.

52E5SYSTE3
CP 20HCP 'SPACE'
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?
52E7
If the character was so low in the ASCII range that the C FLAG (Carry) has been set, then we will assume we hit the end of the COMMAND LINE and JUMP to 52EEH.
Original Source Code Comment: YES, EXECUTE THE COMMANDS
52E9
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?
52EB
If Register A does NOT equal ) then we have a bad COMMAND LINE and the NZ FLAG (Not Zero) will have been set, so JUMP to 5219H to display an ILLEGAL PARAMETER error and exit via a JUMP to 5223H.
Original Source Code Comment: PARAMETER ERROR
52EESYSTE4
LD A,(5BA2H)LD A,(SDCB1)
Fetch a first character in the SOURCE FCB Buffer (held in the buffer starting at 5BA2H) and store it into Register A.
Original Source Code Comment: GET SOURCE OPERATOR
52F1
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 SOURCE GIVEN?
52F2
If there is no character, the Z FLAG (Zero) will have been set, so exit with an error via a JUMP to 521DH.
Original Source Code Comment: NO, MISSING PARAM
52F5
LD B,A
Copy the source filename character (held in Register A) into Register B.
Original Source Code Comment: SAVE IT IN B
52F6
LD A,(5BD2H)LD A,(SDCB2)
Fetch a character in the destination filename (held in the buffer starting at 5BD2H) and store it into Register A.
Original Source Code Comment: GET DESTINATION OPERATOR
52F9
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 DESTINATION GIVEN?
52FA
If the Z FLAG (Zero) has been set, JUMP to 521DH, so exit with an error via a JUMP to 521DH.
Original Source Code Comment: NO, MISSING PARAM
52FD
CP B
Compare the source filename charcter and the destination filename character (held in Register B. Results): If Register A equals the value held in Register B, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: SAME OPERATOR?
52FE
If the Z FLAG (Zero) has been set, so JUMP to 5219H to display an ILLEGAL PARAMETER error and exit via a JUMP to 5223H.
Original Source Code Comment: YES, BAD PARAM
5301
PUSH AF
Save the contents of Register Pair AF to the top of the stack.
Original Source Code Comment: SAVE THE VALUE
5302
PUSH BC
Save the contents of Register Pair BC to the top of the stack.
5303
GOSUB to 3042H, which is a routine in the Model III ROM to set the tape transfer speed.
5306
LD HL,53ADHLD HL,TSRCT
Let Register Pair HL equal 53ADH, to point to the message "DEVICE = ".
Original Source Code Comment: HL => 'SOURCE = ' MSG
5309
GOSUB to 021BH.
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
530C
POP BC
Put the value held at the top of the STACK into Register Pair BC, and then remove the entry from the stack.
530D
POP AF
Put the value held at the top of the STACK into Register Pair AF, and then remove the entry from the stack.
530E
PUSH AF
Save the destination filespec (held in Register A) to the top of the stack.
Original Source Code Comment: SAVE DESTINATION
530F
LD A,B
Copy the source filespec (held in Register B) into Register A.
Original Source Code Comment: GET THE SOURCE
5310
CP 44HCP 'D'
Compare the value held in Register A against 44H (ASCII: D) to see if the source spec is the DISK.
Original Source Code Comment: DISK AS SOURCE?
5312
POP BC
Put the destination spec (held at the top of the STACK) into Register Pair BC, and then remove the entry from the stack.
Original Source Code Comment: GET DESTINATION BACK
5313
If the Z FLAG (Zero) has been set, then the source spec was a "D"isk, so JUMP to 53BCH.
Original Source Code Comment: YES, DO IT
5316
LD A,B
Copy the destination spec (held in Register B) into Register A.
Original Source Code Comment: GET THE DESTINATION
5317
CP 44HCP 'D'
Compare the value held in Register A against 44H (ASCII: D) to see if the destination spec is "D"ISK.
Original Source Code Comment: IS IT DISK AS DES?
5319
If the destination spec is "D"ISK then the Z FLAG (Zero) will have been set, so JUMP to 54D3H.
Original Source Code Comment: YES, DO IT
531C
Continue the routine via a JUMP to 55ADH.
Original Source Code Comment: NO, HAS TO BE RAM THEN

531FH - SYSPAR - Continuation of "TAPE" Routine. Evaluate the Parameter in a Given String.

531FSYSPAR
GOSUB to 525CH to fetch the next non-space character (pointed to by Register Pair HL) into Register A.
Original Source Code Comment: SKIP SPACES
5322
CP 3DHCP '='
Compare the value held in Register A against 3DH (ASCII: =). Results: If Register A equals =, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: EQUAL?
5324
If the character was not an =, then we have a problem and the NZ FLAG (Not Zero) will have been set; so, so JUMP to 5219H to display an ILLEGAL PARAMETER error and exit via a JUMP to 5223H.
Original Source Code Comment: NO, ERROR
5327
GOSUB to 525CH to fetch the next non-space character (pointed to by Register Pair HL) into Register A.
Original Source Code Comment: SKIP SPACES
532A
LD (BC),A
Store the parameter character (held in Register A) into the memory location pointed to by Register Pair BC.
Original Source Code Comment: PUT THE LETTER AT THE FRONT OF THE DCB
532B
CP 54HCP 'T'
Compare the value held in Register A against 54H (ASCII: T) to see if TAPE was chosen; Z FLAG will be set it they match.
Original Source Code Comment: TAPE?
532D
If the Z FLAG (Zero) has been set, skip the rest of the tests via a JUMP to 5338H.
Original Source Code Comment: YES, EXIT
532F
CP 44HCP 'D'
Compare the value held in Register A against 44H (ASCII: D) to see if DISK was chosen; Z FLAG will be set it they match.
Original Source Code Comment: DISK?
5331
If the Z FLAG (Zero) has been set, skip the rest of the tests via a JUMP to 5338H.
Original Source Code Comment: YES, EXIT
5333
CP 52HCP 'R'
Compare the value held in Register A against 52H (ASCII: R) to see if RAM was chosen; Z FLAG will be set it they match.
Original Source Code Comment: RAM?
5335
If the NZ FLAG (Not Zero) has been set, JUMP to 5219H to display an ILLEGAL PARAMETER error and exit via a JUMP to 5223H.
Original Source Code Comment: NO, ERROR
5338SYSPA0
GOSUB to 525CH to fetch the next non-space character (pointed to by Register Pair HL) into Register A.
Original Source Code Comment: SKIP TO NEXT CHAR
533B
CP 2CHCP ','
Compare the value held in Register A against 2CH (0010 1100) (ASCII: ,). Results: If Register A equals ,, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: COMMA?
533D
If the Z FLAG (Zero) has been set, JUMP to 525CH to fetch the next non-space character (pointed to by Register Pair HL) into Register A. Since this is a JP rather than a CALL, this will RETurn to the caller.
Original Source Code Comment: YES, SKIP OVER IT AND RETURN
5340
CP 29HCP ')'
Compare the value held in Register A against 29H (ASCII: )); if they match the Z FLAG will be set.
Original Source Code Comment: END OF PARAM?
5342
RET Z
If the Z FLAG (Zero) has been set then we are done! RETurn to the caller with the Z FLAG set.
Original Source Code Comment: YES, EXIT
5343
CP 20HCP 'SPACE'
Compare the value held in Register A against 20H. If A < 20H, the CARRY FLAG will be set. This is to trap all the usable characters below 20H and we will assume it means we are at the end of line.
Original Source Code Comment: OTHER CONTROL CHAR?
5345
RET C
If the C FLAG (Carry) has been set then we have a bad character, so RETurn to the caller with the C FLAG set.
Original Source Code Comment: YES, EXIT
5346
If we're here then we will continue via a JUMP to 5338H.
Original Source Code Comment: CONTINUE

5348H - RDYCAS - Continuation of "TAPE" Routine. Prompt the user to insert a cassette and wait for a key.

5348RDYCAS
LD HL,5356HLD HL,RDYCMG
Let Register Pair HL equal 5356H, to point to the message 'Press Any key when Cassette ready' + 0DH.
Original Source Code Comment: HL => 'READY CASSETTE' MSG
534B
GOSUB to 021BH.
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
534E
Wait for a key press via a GOSUB to the MODEL III ROM Routine at 0049H which is is the Model III ROM routine to scan the keyboard and wait until a key is pressed, and then return with the key pressed in Register A. BREAK returns 01H.
Original Source Code Comment: WAIT FOR RESPONCE
5351
LD A,0DH
Let Register A equal 0DH (ASCII: ENTER).
Original Source Code Comment: OUTPUT A CR
5353
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.

5356H - RDYCMG - "TAPE" Routine - Message and Byte Storage.

5356RDYCMG
DEFM 'Press Any key when Cassette ready' + 0DH
5378DISK
DEFM 'Disk to Tape - Filespec? ' + 03H
5392TAPE
DEFM 'Tape to Disk' + 0DH
539FRAM
DEFM 'Tape into Ram' + 0DH
53ADTSRCT
DEFM 'Device = ' + 03H
53B7CMEXT
DEFM '/CMD' + 03H

53CBH - Contination of "TAPE" Routine. Read file from disk into RAM to TAPE save.

53BCDSRC
LD HL,5378HLD HL,DISK
Let Register Pair HL equal 5378H, to point to the message 'Disk to Tape - Filespec? ' + 03H.
Original Source Code Comment: HL => 'DISK' MSG
53BF
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
53C2
LD HL,5BA2HLD HL,SDCB1
Let Register Pair HL equal 5BA2H which is the SOURCE FCB Buffer.
Original Source Code Comment: HL => DCB 1
53C5
LD B,18HLD B,24
Let Register B equal 18H for a loop of 24 characters.
Original Source Code Comment: MAX CHARS IN A FILESPEC
53C7
GOSUB to 0040H.
NOTE: 0040H is the Model III ROM routine to get a full line from the keyboard. In this routine, a line is terminated by a carriage return or BREAK, and characters typed are echoed to the display. On entry, B must be the maximum length of line to be accepted and (HL) must be the storage buffer which should be set to B+1. On Exit, CARRY will be set if the BREAK key was hit, Register B will contain the number of characters entered, and (HL) will contain the line from the keyboard followed by the terminating character. Register paid DE is altered in this routine.
Original Source Code Comment: GET THE ANSWER
53CA
RET C
If the C FLAG (Carry) has been set then a BREAK was pressed; RETurn to the caller.
Original Source Code Comment: EXIT IF BREAK KEY
53CB
LD A,B
Copy the number of the characters received (held in Register B) into Register A.
Original Source Code Comment: GET THE CHAR COUNT
53CC
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?
53CD
RET Z
If NO characters were received then the Z FLAG (Zero) will have been set, RETurn to the caller.
Original Source Code Comment: NO, EXIT
53CE
53CF
LD C,B
LD B,00HLD C,B
Copy the number of the characters received (held in Register B) into Register Pair BC.
Original Source Code Comment: GET THE CHARACTER COUNT
53D1
LD DE,5BD2HLD DE,SDCB2
Let Register Pair DE equal 5BD2H to point to the DESTINATION buffer.
Original Source Code Comment: DE => DESTINATION DCB
53D4
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: SAVE A COPY OF IT
53D6
LD A,0DH
Let Register A equal 0DH so that a ENTER can be put at the end of the filename.
Original Source Code Comment: TERMINATE THE FILESPEC
53D8
LD (DE),A
Store the ENTER held in Register A at the end of the filename (i.e., the memory location pointed to by Register Pair DE).
53D9
LD HL,5D00HLD HL,BUFER1
Let Register Pair HL equal 5D00H for a FILE BUFFER.
Original Source Code Comment: HL => BUFFER
53DC
LD DE,5BA2HLD DE,SDCB1
Let Register Pair DE equal 5BA2H which is the SOURCE FCB Buffer.
Original Source Code Comment: DE => DCB
53DF
LD B,00HLD B,0
Let Register B equal 00H so that the next routine will set for FULL SECTOR I/O.
Original Source Code Comment: SET FOR LRL 256
53E1
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 2 in OVERLAY 3.
Original Source Code Comment: OPEN THE FILE
53E4
If the NZ FLAG (Not Zero) has been set, JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.
Original Source Code Comment: EXIT IF ERROR
53E7
LD HL,5E00HLD HL,BUFER2
Let Register Pair HL equal 5E00H for a FILE BUFFER / DATA STORAGE BUFFER.
Original Source Code Comment: WHERE TO STORE THE DATA
53EADSRC1
LD DE,5BA2HLD DE,SDCB1
Let Register Pair DE equal 5BA2H which is the SOURCE FCB Buffer.
Original Source Code Comment: DE => DCB
53ED
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: GET A BYTE FROM DISK
53F0
If the NZ FLAG (Not Zero) has been set, JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.
Original Source Code Comment: EXIT IF ERROR
53F3DSRC2
CP 01HCP 1
Compare the value held in Register A against 01H, which would be an executable file CODE BLOCK. Results: If Register A equals 01H the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: BEGIN OF LOAD FILE HEADER?
53F5
If the Z FLAG (Zero) has been set, JUMP to 540FH.
Original Source Code Comment: YES, GET DATA
53F7
CP 02HCP 2
Compare the value held in Register A against 02H, which would be an executable file 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 DATA
53F9
If the Z FLAG (Zero) has been set, JUMP to 542CH.
Original Source Code Comment: YES, GET TRANSFER ADDRESS
53FB
CP 06HCP 6
Compare the value held in Register A against 06H, which would be an executable file COMMENT BLOCK. Results:
  • If Register A equals 06H.
  • If A < 06H, the CARRY FLAG will be set.
  • if A >= 06H, the NO CARRY FLAG will be set.

Original Source Code Comment: COMMENT?
53FD
If the C FLAG (Carry) has been set, JUMP to 5404H.
Original Source Code Comment: YES, STALL
53FFBADLFE
LD A,22HLD A,ELFFE
Let Register A equal 22H for a INVALID FILE FORMAT error..
Original Source Code Comment: LOAD FILE FORMAT ERROR
5401
JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.
Original Source Code Comment: EXIT

5404H - DSRC3 - Contination of "TAPE" Routine. Routine to handle a COMMENT BLOCK.

5404DSRC3
Fetch the COMMENT BLOCK size byte into Register A via a GOSUB to 54B3H, which reads a byte from diskettte.
Original Source Code Comment: GET A BYTE FROM DISK
5407
LD B,A
Copy the COMMENT BLOCK size byte (held in Register A) into Register B.
Original Source Code Comment: SET AS COUNTER
5408DSRC4
Get the comment byte into Register A via a GOSUB to 54B3H, which reads a byte from diskettte.
Original Source Code Comment: GET A BYTE
540B
LOOP back to 5408H, 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
540D
Get the file's next block by JUMPing back to to 53EAH.
Original Source Code Comment: GET PROGRAM

540FH - DSRC5 - Contination of "TAPE" Routine. Routine to handle a CODE BLOCK.

540FDSRC5
LD (HL),A
Store BLOCK MARKER (currently held in Register A) into the memory location pointed to by Register Pair HL.
Original Source Code Comment: PUT THE '1' IN MEMORY
5410
INC HL
Move to the next space in the buffer by INCrementing the value stored in Register Pair HL by 1.
5411
Fetch the CODE BLOCK size byte into Register A via a GOSUB to 54B3H, which reads a byte from diskettte.
Original Source Code Comment: GET A BYTE FROM DISK
5414
LD B,A
Copy the CODE BLOCK LENGTH byte (held in Register A) into Register B.
Original Source Code Comment: SET AS A COUNTER
5415
LD (HL),A
Store the CODE BLOCK LENGTH (held in Register A) into the buffer (pointed to by Register Pair HL).
Original Source Code Comment: SET IT IN MEMORY
5416
INC HL
Move to the next space in the buffer by INCrementing the value stored in Register Pair HL by 1.
Original Source Code Comment: BUMP TO NEXT SLOT
5417
Fetch the LSB of the CODE BLOCK ADDRESS into Register A via a GOSUB to 54B3H, which reads a byte from diskettte.
Original Source Code Comment: GET LSB OF ADDRESS
541A
DEC B
DECrement the bytes-left-to-process value stored in Register B by 1.
Original Source Code Comment: DEC THE COUNTER
541B
LD (HL),A
Store the LSB of the CODE BLOCK ADDRESS (held in Register A) into the buffer (pointed to by Register Pair HL).
Original Source Code Comment: PUT IT INTO MEMORY
541C
INC HL
Move to the next space in the buffer by INCrementing the value stored in Register Pair HL by 1.
Original Source Code Comment: BUMP TO NEXT SLOT
541D
Fetch the MSB of the CODE BLOCK ADDRESS into Register A via a GOSUB to 54B3H, which reads a byte from diskettte.
Original Source Code Comment: GET MSB OF ADDRESS
5420
DEC B
DECrement the bytes-left-to-process value stored in Register B by 1.
Original Source Code Comment: DEC THE COUNTER
5421
LD (HL),A
Store the MSB of the CODE BLOCK ADDRESS (held in Register A) into the buffer (pointed to by Register Pair HL).
Original Source Code Comment: PUT IT INTO MEMORY
5422
INC HL
Move to the next space in the buffer by INCrementing the value stored in Register Pair HL by 1.
Original Source Code Comment: BUMP TO NEXT SLOT
5423DSRC6
Fetch a CODE BYTE into Register A via a GOSUB to 54B3H, which reads a byte from diskettte.
Original Source Code Comment: GET A BYTE
5426
LD (HL),A
Store the CODE BYTE (held in Register A) into the buffer (pointed to by Register Pair HL).
Original Source Code Comment: PUT IT IN MEMORY
5427
INC HL
Move to the next space in the buffer by INCrementing the value stored in Register Pair HL by 1.
Original Source Code Comment: BUMP TO NEXT SLOT
5428
Keep processing the entire CODE BLOCK by LOOPing back to 5423H, 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
542A
Get the file's next block by JUMPing back to to 53EAH.
Original Source Code Comment: GO GET MORE

542CH - DSRC7 - Contination of "TAPE" Routine. Routine to handle a EXECUTION ADDRESS BLOCK.

542CDSRC7
LD (HL),A
Store BLOCK MARKER (currently held in Register A) into the memory location pointed to by Register Pair HL.
Original Source Code Comment: PUT THE '2' INTO MEMORY
542D
INC HL
Move to the next space in the buffer by INCrementing the value stored in Register Pair HL by 1.
542E
Fetch the LENGTH BYTE of the CODE BLOCK ADDRESS into Register A via a GOSUB to 54B3H. This is not going to get preserved.
Original Source Code Comment: GET THE COUNT AND IGNORE IT
5431
Fetch the LSB of the EXECUTION ADDRESS into Register A via a GOSUB to 54B3H, which reads a byte from diskettte.
Original Source Code Comment: GET THE LSB OF XFER ADDRESS
5434
LD (HL),A
Store the LSB of the EXECUTION ADDRESS (held in Register A) into the buffer (pointed to by Register Pair HL).
Original Source Code Comment: INTO MEMORY
5435
INC HL
Move to the next space in the buffer by INCrementing the value stored in Register Pair HL by 1.
5436
Fetch the MSB of the EXECUTION ADDRESS into Register A via a GOSUB to 54B3H, which reads a byte from diskettte.
Original Source Code Comment: GET THE MSB OF XFER ADDRESS
5439
LD (HL),A
Store the MSB of the EXECUTION ADDRESS (held in Register A) into the buffer (pointed to by Register Pair HL).
Original Source Code Comment: INTO MEMORY

543AH - Contination of "TAPE" Routine. Passed through from the above routine, this code writes the file from RAM to TAPE.

543A
Prompt the user to insert a cassette and wait for a key via a GOSUB to 5348H.
Original Source Code Comment: TELL USER TO READY CASSETTE
543D
Write the TAPE LEADER via a GOSUB to 0287H.
Original Source Code Comment: START UP THE CASSETTE - WRITE SYNC
5440
LD A,55H
Let Register A equal 55H to designate the file as a SYSTEM file.
Original Source Code Comment: OUTPUT THE 'SYSTEM' BYTE
5442
GOSUB to 0264H which is the Model III ROM routine to output a byte held in Register A to cassette. This routine must be called often enough to keep up with the baud rate.
Original Source Code Comment: TO CASSETTE
5445
LD HL,5BD2HLD HL,SDCB2
Let Register Pair HL equal 5BD2H to point to the DESTINATION NAME buffer.
Original Source Code Comment: HL => FILE NAME
5448
LD B,06HLD B,6
Since SYSTEM file filenames are 6 characters, set Register B equal 06H.
Original Source Code Comment: SET FOR MAX OF 6 CHARACTERS
544ATDES
LD A,(HL)
Fetch a byte from the DESTINATION BUFFER (pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET A FILE NAME CHAR
544B
CP 2FHCP '/'
Test the character to see if we have hit the extension by comparing 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: EXT DELIMETER?
544D
If the Z FLAG (Zero) has been set then we will skip writing the rest of the filename via a JUMP to 545FH.
Original Source Code Comment: YES, EXIT
544F
CP 3AHCP ':'
Test the character to see if we have hit a drivespec by comparing 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?
5451
If the Z FLAG (Zero) has been set then we will skip writing the rest of the filename via a JUMP to 545FH.
Original Source Code Comment: YES, EXIT
5453
CP 30HCP '0'
Test the character to see it is below the lowest permitted character in a filespec (i.e., "0") by comparing the value held in Register A against 30H (ASCII: 0). Results:
  • If Register A equals 0, the Z FLAG is set.
  • If A < 30H 0, the CARRY FLAG will be set.
  • if A >= 30H 0, the NO CARRY FLAG will be set.

Original Source Code Comment: ILLEGAL CHAR?
5455
If the CARRY FLAG has been set then we will skip writing the rest of the filename via a JUMP to 545FH.
Original Source Code Comment: YES, EXIT
5457
GOSUB to 0264H which is the Model III ROM routine to output a byte held in Register A to cassette. This routine must be called often enough to keep up with the baud rate.
Original Source Code Comment: OUTPUT THE CHARACTER
545A
INC HL
Move to the next space in the buffer by INCrementing the value stored in Register Pair HL by 1.
Original Source Code Comment: BUMP TO NEXT POSITION
545B
Process up to 6 bytes for a filename by LOOPing back to 544AH, 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
545D
If 6 characters found, continue by JUMPing to 5466H.
Original Source Code Comment: AND CONTINUE

545FH - TDES1 - Contination of "TAPE" Routine. Jumped to when less than 6 characters of the filename has been written.

First we need to output the remaining characters in the filename as spaces. Register B holds the number of filename characters left to output.

545FTDES1
LD A,20HLD A,' '
Let Register A equal 20H which is a SPACE character.
Original Source Code Comment: OUTPUT A BLANK
5461
GOSUB to 0264H which is the Model III ROM routine to output a byte held in Register A to cassette. This routine must be called often enough to keep up with the baud rate.
5464
LOOP back to 545FH, 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 REMAINDER OF COUNT
5466TDES2
LD HL,5E00HLD HL,BUFER2
Let Register Pair HL equal 5E00H for a FILE BUFFER / DATA STORAGE BUFFER.
Original Source Code Comment: HL => START OF DATA
5469TDES3
LD A,(HL)
Fetch a character from the FILE DATA BUFFER (held held in the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET A LOAD FILE HEADER
546A
CP 02HCP 2
Compare the value held in Register A against 02H, which would be an executable file 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?
546C
If the current character is an EXECUTION ADDRESS BLOCK, then the Z FLAG (Zero) will have been set, JUMP to 54A1H to write the execution address block and exit.
Original Source Code Comment: YES, EXIT
546E
CP 01HCP 1
Compare the value held in Register A against 01H, which would be an executable file CODE BLOCK. Results: If Register A equals 01H the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: START OF LOAD FILE HEADER
5470
If the current character is NOT a CODE BLOCK ADDRESS, the NZ FLAG (Not Zero) will have been set, JUMP BACK to 53FFH.
Original Source Code Comment: NO, SOMETHING WRONG
5473
INC HL
Point HL to the next byte in the file by INCrementing the value stored in Register Pair HL by 1.
Original Source Code Comment: YES, BUMP TO NEXT CHAR
5474
LD A,(HL)
Fetch a character from the FILE DATA BUFFER (held held in the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET THE COUNT BYTE
5475
SUB 02HSUB 2
Adjust the block by SUBtracting the value 02H from Register A.
Original Source Code Comment: SUBTRACT THE ADDRESS FROM IT
5477
LD B,A
Copy the adjusted block length (held in Register A) into Register B.
Original Source Code Comment: SET AS A COUNTER
5478
INC HL
Point HL to the next byte in the file by INCrementing the value stored in Register Pair HL by 1.
Original Source Code Comment: BUMP TO LSB OF ADDR
5479
Write the entire block via a GOSUB to 547EH.
Original Source Code Comment: DO THE CASSETTE WRITE
547C
LOOP BACK to 5469H to keep processing data blocks.
Original Source Code Comment: LOOP TILL END

547EH - TDES4 - Subroutine in the "TAPE" Routine - Write an entire code block to tape, with checksum. Register B holds the data block length and Register C will calculate the checksum.

547ETDES4
LD A,3CH
Prepare to write the DATA BLOCK IDENTIFIER by setting Register A to 3CH.
Original Source Code Comment: OUTPUT THE 'START' BYTE
5480
GOSUB to 0264H which is the Model III ROM routine to output a byte held in Register A to cassette. This routine must be called often enough to keep up with the baud rate.
Original Source Code Comment: TO CASSETTE
5483
LD A,B
Copy the DATA BLOCK LENGTH from Register B into Register A.
Original Source Code Comment: GET THE COUNT
5484
GOSUB to 0264H which is the Model III ROM routine to output a byte held in Register A to cassette. This routine must be called often enough to keep up with the baud rate.
Original Source Code Comment: OUTPUT TO CASS
5487
LD A,(HL)
Fetch a data byte (held in the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET THE LSB OF THE ADDRESS
5488
LD C,A
Initialize the checksum counter by copying the contents of Register A into Register C.
Original Source Code Comment: START A CHECKSUM
5489
GOSUB to 0264H which is the Model III ROM routine to output a byte held in Register A to cassette. This routine must be called often enough to keep up with the baud rate.
Original Source Code Comment: OUTPUT THE LSB
548C
INC HL
Point HL to the next byte in the data block by INCrementing the value stored in Register Pair HL by 1.
Original Source Code Comment: BUMP TO MSB
548D
LD A,(HL)
Fetch a data byte (held in the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET THE MSB
548E
GOSUB to 0264H which is the Model III ROM routine to output a byte held in Register A to cassette. This routine must be called often enough to keep up with the baud rate.
Original Source Code Comment: OUTPUT IT
5491
ADD A,C
Update the checksum by setting Register A = Register A + Register C.
Original Source Code Comment: ADD TO CHECKSUM
5492
LD C,A
Copy the updated checksum (held in Register A) into Register C.
Original Source Code Comment: SAVE NEW CHECKSUM
5493TDES5
INC HL
Point HL to the next byte in the data block by INCrementing the value stored in Register Pair HL by 1.
Original Source Code Comment: BUMP TO NEXT DATA BYTE
5494
LD A,(HL)
Fetch a data byte (held in the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET IT
5495
GOSUB to 0264H which is the Model III ROM routine to output a byte held in Register A to cassette. This routine must be called often enough to keep up with the baud rate.
Original Source Code Comment: WRITE IT OUT
5498
ADD A,C
Update the checksum by setting Register A = Register A + Register C.
Original Source Code Comment: ADD TO CHECKSUM
5499
LD C,A
Copy the updated checksum (held in Register A) into Register C.
Original Source Code Comment: SAVE NEW CHECKSUM
549A
LOOP back to 5493H for the entire data block length, 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
549C
INC HL
Point HL to the next byte in the data block by INCrementing the value stored in Register Pair HL by 1.
Original Source Code Comment: BUMP TO NEXT LOADER BYTE
549D
LD A,C
Copy the checksum (held in Register C) into Register A.
Original Source Code Comment: GET THE CHECKSUM
549E
JUMP to 0264H which is the Model III ROM routine to output a byte held in Register A to cassette. This routine must be called often enough to keep up with the baud rate. Since this is a JUMP instead of a GOSUB, the RET inside that JUMP will return to the caller.
Original Source Code Comment: OUTPUT IT AND RETURN

54A1H - TDES6 - Contination of "TAPE" Routine. Jumped to when we have an EXECUTION ADDRESS BLOCK. This routine will write the block and then exit the routine.

54A1TDES6
INC HL
Point HL to the next byte in the data block by INCrementing the value stored in Register Pair HL by 1.
Original Source Code Comment: BUMP TO THE ADDRESS
54A2
LD A,78H
Prepare to write the EXECUTION ADDRESS IDENTIFIER by setting Register A to 78H.
Original Source Code Comment: LOAD THE 'STOP' BYTE
54A4
GOSUB to 0264H which is the Model III ROM routine to output a byte held in Register A to cassette. This routine must be called often enough to keep up with the baud rate.
Original Source Code Comment: OUTPUT TO CASSETTE
54A7
LD A,(HL)
Fetch a data byte (held in the memory location pointed to by Register Pair HL) and store it into Register A. This will be the LSB of the execution address.
Original Source Code Comment: GET LSB OF ADDRESS
54A8
GOSUB to 0264H which is the Model III ROM routine to output a byte held in Register A to cassette. This routine must be called often enough to keep up with the baud rate.
Original Source Code Comment: OUTPUT IT
54AB
INC HL
Point HL to the next byte in the data block by INCrementing the value stored in Register Pair HL by 1.
Original Source Code Comment: BUMP TO MSB
54AC
LD A,(HL)
Fetch a data byte (held in the memory location pointed to by Register Pair HL) and store it into Register A. This will be the MSB of the execution address.
Original Source Code Comment: GET IT
54AD
GOSUB to 0264H which is the Model III ROM routine to output a byte held in Register A to cassette. This routine must be called often enough to keep up with the baud rate.
Original Source Code Comment: OUTPUT TO CASS
54B0
JUMP to the Model III ROM Routine at 01F8H to turn off the cassette motor. Since this is a JUMP instead of a GOSUB, the RET inside that JUMP will return to the caller.
Original Source Code Comment: SHUT CASSETTE OFF AND RETURN

54B3H - GETBYT - Subroutine in the "TAPE" Routine. Read a Byte from the Disk File.

54B3GETBYT
LD DE,5BA2HLD DE,SDCB1
Let Register Pair DE equal 5BA2H which is the SOURCE FCB Buffer.
Original Source Code Comment: DE => DISK DCB
54B6
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: GET A BYTE FROM DISK
54B9
If the NZ FLAG (Not Zero) has been set, JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.
Original Source Code Comment: EXIT IF ERROR
54BC
RET
RETurn to the caller.

54BDH - WRIBYT - Subroutine in the "TAPE" Routine. Write a Byte to the Disk File.

54BDWRIBYT
PUSH AF
Save the contents of Register Pair AF to the top of the stack.
54BE
PUSH BC
Save the contents of Register Pair BC to the top of the stack.
54BF
PUSH DE
Save the contents of Register Pair DE to the top of the stack.
54C0
PUSH HL
Save the contents of Register Pair HL to the top of the stack.
54C1
PUSH IY
Save the contents of Special Index Register IY to the top of the stack.
54C3
LD DE,5BA2HLD DE,SDCB1
Let Register Pair DE equal 5BA2H which is the SOURCE FCB Buffer.
Original Source Code Comment: DE => DISK DCB
54C6
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: PUT A BYTE TO DISK
54C9
If the NZ FLAG (Not Zero) has been set, JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.
Original Source Code Comment: EXIT IF ERROR
54CC
POP IY
Put the value held at the top of the STACK into Special Index Register IY, and then remove the entry from the stack.
54CE
POP HL
Put the value held at the top of the STACK into Register Pair HL, and then remove the entry from the stack.
54CF
POP DE
Put the value held at the top of the STACK into Register Pair DE, and then remove the entry from the stack.
54D0
POP BC
Put the value held at the top of the STACK into Register Pair BC, and then remove the entry from the stack.
54D1
POP AF
Put the value held at the top of the STACK into Register Pair AF, and then remove the entry from the stack.
54D2
RET
RETurn to the caller.

54D3H - TSRC - Part of "TAPE" Routine. Transfer a File from Tape to RAM for Disk Save.

54D3TSRC
LD HL,5392HLD HL,TAPE
Let Register Pair HL equal 5392H, which points to the message "TAPE TO DISK".
Original Source Code Comment: HL => TAPE
54D6
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
54D9
Prompt the user to insert a cassette and wait for a key via a GOSUB to 5348H.
Original Source Code Comment: TELL USER TO READY CASSETTE
54DC
GOSUB to 0243H which is the Model III ROM Routine to start the tape and read the header.
Original Source Code Comment: READ IN THE SYNC
54DF
GOSUB to 0235H which is the Model III ROM Routine to read one byte from the cassette drive specified in register A, and returns the byte in register A.
Original Source Code Comment: READ IN THE 'SYSTEM' BYTE
54E2
CP 55H
Compare the byte which was just read from cassette (held in Register A) against 55H, which is the SYSTEM TAPE identifier. Results: If Register A equals 55H, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: IS IT CORRECT
54E4
If the byte read was not a SYSTEM TAPE identifier, then we have a problem; JUMP to 5219H to display an ILLEGAL PARAMETER error and exit via a JUMP to 5223H.
Original Source Code Comment: NO, NOT A SYSTEM TAPE
54E7
LD HL,(4020H)LD HL,(CURSOR)
Fetch the value held in memory location 4020H and store it into Register Pair HL.
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
Original Source Code Comment: GET PRESENT CURSOR POSITION
54EA
LD IY,5BA2HLD IY,SDCB1
Let Special Index Register IY equal 5BA2H which is the SOURCE FCB Buffer.
Original Source Code Comment: PLACE TO STORE THE FILENAME
54EE
LD B,06HLD B,6
Since a maching language file's filename is 6 characters, set Register B equal 06H.
Original Source Code Comment: SET A COUNTER
54F0TSRC1
GOSUB to 0235H which is the Model III ROM Routine to read one byte from the cassette drive specified in register A, and returns the byte in register A.
Original Source Code Comment: READ A FILE CHAR
54F3
LD (HL),A
Store byte which was just read from cassette (held in Register A) into the screen location pointed to by Register Pair HL.
Original Source Code Comment: PUT IT ON THE SCREEN
54F4
INC HL
INCrement the screen location (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP TO NEXT SLOT
54F5
CP 21HCP 'SPACE'+1
Compare the value held in Register A against 21H (ASCII: SPACE + 1). If Register A < SPACE + 1, the CARRY FLAG will be set.
Original Source Code Comment: SPACE OR CONTROL CHAR?
54F7
If the byte is a SPACE or lower, then we are at the end of the filename and the C FLAG (Carry) will have been set, JUMP to 54FEH.
Original Source Code Comment: YES, BYPASS IT
54F9
LD (IY+00H),ALD (IY),A
Store the byte read from tape (which is part of the filename) into the filename buffer pointed to by Special Index Register IY+00H.
Original Source Code Comment: PUT IT IN THE DCB
54FC
INC IY
INCrement Special Index Register IY by 1 to point to the next available spot in the filename buffer.
54FETSRC11
LOOP back to 54F0H, 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
5500
LD (4020H),HLLD (CURSOR),HL
Store the value held in Register Pair HL into memory location 4020H.
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
Original Source Code Comment: MAKE IT THE CURRENT CURSOR POSITION
5503
PUSH IY
POP DEPUSH IY
Let Register Pair DE = Special Register Index IY. At this point DE will the 1 byte beyond the filename.
Original Source Code Comment: MOVE DCB POINTER TO DE
5506
LD HL,53B7HLD HL,CMEXT
Let Register Pair HL equal 53B7H to point to the message "/CMD + 03H".
Original Source Code Comment: HL => '/CMD' EXTENSION
5509
LD BC,0005HLD BC,5
We have 5 bytes to move so set Register Pair BC equal 0005H.
Original Source Code Comment: 5 CHARACTERS
550C
LDIR
Add the "/CMD + 03H" to the end of the filename by 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: COMPLETE THE FILESPEC
550E
LD HL,5E00HLD HL,BUFER2
Let Register Pair HL equal 5E00H for a FILE BUFFER / DATA STORAGE BUFFER.
Original Source Code Comment: PLACE TO STORE DATA

Top of a loop (ending at 5544H) to read the entire file from tape.

5511TSRC2
GOSUB to 0235H which is the Model III ROM Routine to read one byte from the cassette drive specified in register A, and returns the byte in register A.
Original Source Code Comment: GET THE 'START' or 'STOP' BYTE
5514
CP 78H
Check to see if the byte is an EXECUTION ADDRESS IDENTIFIER by comparing the value held in Register A against 78H. Results: If Register A equals 78H, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: STOP?
5516
If we are at an EXECUTION ADDRESS IDENTIFIER BYTE, the Z FLAG (Zero) will have been set, so JUMP to 5546H.
Original Source Code Comment: YES, GET TRANSFER ADDRESS
5518
CP 3CH
Check to see if the byte is a CODE BLOCK IDENTIFIER by comparing the value held in Register A against 3CH. Results: If Register A equals 3CH, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: START BYTE?
551A
If the byte read was NOT a CODE BLOCK IDENTIFIER then loop back to 5511H and keep reading.
Original Source Code Comment: NO, KEEP LOOKING

If we are here, then the byte read from the cassette was a CODE BLOCK identifier.

551C
LD (HL),01HLD (HL),1
Store a CODE BLOCK MARKER (01H) into the FILE BUFFER (pointed to by Register Pair HL).
Original Source Code Comment: SET A LOAD FILE FORMAT
551E
INC HL
INCrement the FILE BUFFER POINTER (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP TO NEXT SLOT

Next, process the BLOCK LENGTH.

551F
GOSUB to 0235H which is the Model III ROM Routine to read one byte from the cassette drive specified in register A, and returns the byte in register A.
Original Source Code Comment: GET THE BYTE COUNT
5522
LD B,A
Register A should be holding the BLOCK LENGTH BYTE. Copy that into Register B.
Original Source Code Comment: SAVE IT AS A COUNTER
5523
ADD A,02HADD A,2
Adjust the BLOCK LENGTH by 2 to deal with diskette, by setting Register A = Register A + 02H.
Original Source Code Comment: ADD IN THE ADDRESS
5525
LD (HL),A
Store the adjusted BLOCK LENGTH into the FILE BUFFER (pointed to by Register Pair HL).
Original Source Code Comment: STORE IT IN MEMORY
5526
INC HL
INCrement the FILE BUFFER POINTER (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP TO NEXT SLOT

Next, process the LSB of the CODE ADDRESS.

5527
GOSUB to 0235H which is the Model III ROM Routine to read one byte from the cassette drive specified in register A, and returns the byte in register A.
Original Source Code Comment: GET THE LSB OF THE ADDRESS
552A
LD C,A
Prepare to calculate the file's checksum by copying the contents of Register A (i.e., the LSB of the CODE ADDRESS) into Register C.
Original Source Code Comment: START A CHECKSUM
552B
LD (HL),A
Store the value held in Register A (which is the LSB of the CODE ADDRESS) into the memory location pointed to by Register Pair HL.
Original Source Code Comment: INTO MEMORY
552C
INC HL
INCrement the FILE BUFFER POINTER (stored in Register Pair HL) by 1.

Next, process the MSB of the CODE ADDRESS.

552D
GOSUB to 0235H which is the Model III ROM Routine to read one byte from the cassette drive specified in register A, and returns the byte in register A.
Original Source Code Comment: GET THE MSB OF THE ADDRESS
5530
LD (HL),A
Store the value held in Register A (which is the MSB of the CODE ADDRESS) into the memory location pointed to by Register Pair HL.
Original Source Code Comment: INTO MEMORY
5531
INC HL
INCrement the FILE BUFFER POINTER (stored in Register Pair HL) by 1.
5532
ADD A,C
LET Register A = Register A + Register C.
Original Source Code Comment: ADD TO THE CHECKSUM
5533
LD C,A
Copy the contents of Register A (i.e., the checksum which now includes the MSB of the CODE ADDRESS) into Register C.
Original Source Code Comment: SAVE IT

Next, loop to read the block

5534TSRC3
GOSUB to 0235H which is the Model III ROM Routine to read one byte from the cassette drive specified in register A, and returns the byte in register A.
Original Source Code Comment: READ A DATA BYTE
5537
LD (HL),A
Store the value held in Register A (i.e., a data byte) into the FILE BUFFER at the location pointed to by Register Pair HL.
Original Source Code Comment: INTO MEMORY
5538
INC HL
INCrement the FILE BUFFER POINTER (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP TO NEXT SLOT
5539
ADD A,C
LET Register A = Register A + Register C.
Original Source Code Comment: ADD TO CHECKSUM
553A
LD C,A
Copy the contents of Register A (i.e., the checksum which now includes the most recently read data byte) into Register C.
Original Source Code Comment: SAVE IT
553B
LOOP back to 5534H, 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

The block is now read into the buffer at HL, and Register C now holds the checksum. So next, verify the checksum.

553D
GOSUB to 0235H which is the Model III ROM Routine to read one byte from the cassette drive specified in register A, and returns the byte in register A.
Original Source Code Comment: GET THE CHECKSUM BYTE
5540
CP C
Compare the the checksum as read from the tape (held in Register A) against the checksum as just calculated (held in Register C). Results: If the checksums match, the the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: MATCH OURS?
5541
If the NZ FLAG (Not Zero) has been set, JUMP to 5219H to display an ILLEGAL PARAMETER error and exit via a JUMP to 5223H.
Original Source Code Comment: NO, BAD PARAMETER
5544
JUMP to 5511H.
Original Source Code Comment: GO GET MORE DATA

5546H - TSRC4 - Contination of "TAPE" Routine. Jumped to when we have an EXECUTION ADDRESS to write that block and finish.

5546TSRC4
LD (HL),02HLD (HL),2
Store an EXECUTE ADDRESS MARKER (02H) into the FILE BUFFER at the location pointed to by Register Pair HL.
Original Source Code Comment: SET THE 'TRA' INDENTIFIER INTO RAM
5548
INC HL
INCrement the FILE BUFFER POINTER (stored in Register Pair HL) by 1.
5549
LD (HL),02HLD (HL),2
Store the length of a EXECUTE ADDRESS, which is ALWAYS 2 bytes, into the FILE BUFFER at the location pointed to by Register Pair HL.
Original Source Code Comment: BYTE COUNT
554B
INC HL
INCrement the FILE BUFFER POINTER (stored in Register Pair HL) by 1.
554C
PUSH HL
Save the current location in the FILE BUFFER (held in Register Pair HL) to the top of the stack.
Original Source Code Comment: SAVE THE POINTER TO RAM
554D
Read the execution address from the tape via a GOSUB to 0314H which reads 2 bytes from the cassette and puts them into HL and 40DFH and then turns off the cassette motor.
Original Source Code Comment: GET THE TRA ADDRESS
5550
POP DE
Restore the current location in the FILE BUFFER (held at the top of the stack) into Register Pair DE.
Original Source Code Comment: GET RAM POINTER BACK
5551
EX DE,HL
EXchange the value stored in Register Pair HL (i.e., the execution address from the CALL 0314H) with the value stored in Register Pair DE (i.e., the current location in the FILE BUFFER).
Original Source Code Comment: DE = TRANSFER ADDR, HL = RAM POINTER
5552
5552
LD A,D
OR ELD A,D
Since the Z-80 cannot test Register Pair DE against zero, the common trick is to set Register A to equal to Register D, and then OR A against Register E. Only if both Register D and Register E were zero can the Z FLAG be set.
Original Source Code Comment: SEE IF ANY GIVEN
5554
If that OR showed that DE was NOT empty, then we have an execution address then the NZ FLAG (Not Zero) will have been set, so skip the next instruction which (sets a default) and JUMP to 5559H.
Original Source Code Comment: YES, HAVE ADDRESS
5556
LD DE,402DHLD DE,SYS1IN
Since DE was empty, set a default EXECUTION ADDRESS at 402DH, which is the address to transfer to DOS.
Original Source Code Comment: NO, SET DOS ENTRY AS TRA ADDRESS
5559YESADD
LD (HL),E
Store the LSB of the EXECUTION ADDRESS (held in Register E) into the memory location pointed to by Register Pair HL.
Original Source Code Comment: SET THE TRANSFER ADDRESS
555A
INC HL
INCrement the FILE BUFFER POINTER (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP TO NEXT SLOT
555B
LD (HL),D
Store the MSB of the EXECUTION ADDRESS (held in Register D) into the memory location pointed to by Register Pair HL.
Original Source Code Comment: SET MSB
555C
Turn off the cassette player via a GOSUB to 01F8H.
Original Source Code Comment: SHUT THE CASSETTE OFF

555FH - Contination of "TAPE" Routine. Write a File from RAM to Diskette.

555F
LD HL,5D00HLD HL,BUFER1
Let Register Pair HL equal 5D00H for a FILE BUFFER.
Original Source Code Comment: HL => DISK BUFFER
5562
LD DE,5BA2HLD DE,SDCB1
Let Register Pair DE equal 5BA2H for a SOURCE FCB Buffer.
Original Source Code Comment: DE => FILESPEC
5565
LD B,00HLD B,0
Let Register B equal 00H so that the next routine will set for FULL SECTOR I/O.
Original Source Code Comment: LRL = 256
5567
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 THE FILE
556A
If the NZ FLAG (Not Zero) has been set, JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.
Original Source Code Comment: EXIT IF ERROR
556D
LD HL,5E00HLD HL,BUFER2
Let Register Pair HL equal 5E00H for a FILE BUFFER / DATA STORAGE BUFFER.
Original Source Code Comment: HL => DATA
5570DDES
LD A,(HL)
Fetch a byte from the FILE BUFFER (the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET A BYTE OF DATA
5571
CP 02HCP 2
Compare the value held in Register A against 02H, which would be an executable file EXECUTION ADDRESS BLOCK indicator. Results: If Register A equals 02H the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: END OF FILE?
5573
If the Z FLAG (Zero) has been set, JUMP to 5599H to deal with an EXECUTION ADDRESS BLOCK.
Original Source Code Comment: YES, EXIT
5575
CP 01HCP 1
Compare the value held in Register A against 01H, which would be an executable file CODE BLOCK. Results: If Register A equals 01H the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: START OF LOAD FILE HEADER?
5577
If the NZ FLAG (Not Zero) has been set, JUMP to 5219H to display an ILLEGAL PARAMETER error and exit via a JUMP to 5223H.
Original Source Code Comment: NO, EXIT
557A
Write the byte held in Register A to the disk file via a GOSUB to 54BDH.
Original Source Code Comment: WRITE IT OUT
557D
INC HL
INCrement the FILE BUFFER POINTER (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP TO COUNT BYTE
557E
LD A,(HL)
Fetch the CODE BLOCK LENGTH (the next byte from the FILE BUFFER) and store it into Register A.
Original Source Code Comment: GET THE COUNT
557F
LD B,A
Copy the contents of Register A into Register B, because B is the DJNZ LOOP counter.
Original Source Code Comment: INTO B
5580
Write the CODE BLOCK LENGTH (i.e., the byte held in Register A) to the disk file via a GOSUB to 54BDH.
Original Source Code Comment: WRITE IT OUT
5583
INC HL
INCrement the FILE BUFFER POINTER (stored in Register Pair HL) by 1 to point to the LSB of the Execution Address.
Original Source Code Comment: BUMP TO ADDRESS
5584
LD A,(HL)
Fetch the the LSB of the Execution Address (the next byte in the FILE BUFFER) and store it into Register A.
Original Source Code Comment: GET THE LSB
5585
Write the LSB of the Execution Address (the byte held in Register A) to the disk file via a GOSUB to 54BDH.
5588
INC HL
INCrement the FILE BUFFER POINTER (stored in Register Pair HL) by 1 to point to the MSB of the Execution Address.
5589
LD A,(HL)
Fetch the the MSB of the Execution Address (the next byte in the FILE BUFFER) and store it into Register A.
Original Source Code Comment: GET THE MSB
558A
Write the MSB of the Execution Address (the byte held in Register A) to the disk file via a GOSUB to 54BDH.
558D
558E
DEC B
DEC BDEC B
DECrement the BLOCK LENGTH (stored in Register B) by 2.
Original Source Code Comment: DEC FOR THE ADDRESS
558FDDES1
INC HL
INCrement the FILE BUFFER POINTER (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP TO NEXT BYTE
5590
LD A,(HL)
Fetch a byte from the FILE BUFFER (the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET IT
5591
Write the byte held in Register A to the disk file via a GOSUB to 54BDH.
Original Source Code Comment: WRITE IT OUT
5594
LOOP back to 558FH, 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
5596
INC HL
INCrement the FILE BUFFER POINTER (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP TO NEXT CHAR
5597
Process the next block by JUMPing BACK to 5570H.
Original Source Code Comment: AND REPTEAT TILL END OF FILE

5599H - DDES2 - Contination of Write a File from RAM to Diskette portion of the "TAPE" Routine. Jumped here if an EXECUTE ADDRESS BLOCK was found.

5599DDES2
Write the EXECUTE ADDRESS MARKER (which is 02H) held in Register A to the disk file via a GOSUB to 54BDH.
Original Source Code Comment: WRITE OUT THE '2'
559C
Write the BLOCK LENGTH BYTE (which is always 02H) held in Register A to the disk file via a GOSUB to 54BDH.
Original Source Code Comment: WRITE OUT THE COUNT
559F
INC HL
INCrement the FILE BUFFER POINTER (stored in Register Pair HL) by 1. Note: This byte gets thrown away.
Original Source Code Comment: HL => BYTE COUNT
55A0
INC HL
INCrement the FILE BUFFER POINTER (stored in Register Pair HL) by 1.
Original Source Code Comment: HL => LSB OF TRA ADDR
55A1
LD A,(HL)
Fetch the LSB of the EXECUTE ADDRESS (held in the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET IT
55A2
Write the LSB of the EXECUTE ADDRESS held in Register A to the disk file via a GOSUB to 54BDH.
Original Source Code Comment: WRITE IT OUT
55A5
INC HL
INCrement the FILE BUFFER POINTER (stored in Register Pair HL) by 1.
55A6
LD A,(HL)
Fetch the MSB of the EXECUTE ADDRESS (held in the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: HL => MSB OF TRA ADDR
55A7
Write the MSB of the EXECUTE ADDRESS held in Register A to the disk file via a GOSUB to 54BDH.
Original Source Code Comment: WRITE IT OUT
55AA
JUMP to 4428H.
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

55ADH - TRAM - Continuation of the "TAPE" Routine. Load a SYSTEM Tape into RAM and RUN IT.

55ADTRAM
LD HL,539FHLD HL,RAM
Let Register Pair HL equal 539FH, to point to the message "TAPE INTO RAM".
Original Source Code Comment: HL => 'RAM' MSG
55B0
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
55B3
Prompt the user to insert a cassette and wait for a key via a GOSUB to 5348H.
Original Source Code Comment: TELL USER TO READY CASSETTE
55B6
Turn on the CASSETTE TAPE and READ THE FILE HEADER via a GOSUB to 0243H.
Original Source Code Comment: READ IN THE SYNC BYTE
55B9
GOSUB to 0235H which is the Model III ROM Routine to read one byte from the cassette drive specified in register A, and returns the byte in register A.
Original Source Code Comment: READ IN THE 'SYSTEM' BYTE
55BC
CP 55H
Compare the byte which was just read from cassette (held in Register A) against 55H, which is the SYSTEM TAPE identifier. Results: If Register A equals 55H, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: IS IT SYSTEM
55BE
If the byte read was not a SYSTEM TAPE identifier, then we have a problem; JUMP to 5219H to display an ILLEGAL PARAMETER error and exit via a JUMP to 5223H.
Original Source Code Comment: NO, PARAMETER ERROR
55C1
LD HL,(4020H)LD HL,(CURSOR)
Fetch the value held in memory location 4020H and store it into Register Pair HL.
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
Original Source Code Comment: GET PRESENT CURSOR LOCATION
55C4
LD B,06HLD B,6
Since a maching language file's filename is 6 characters, set Register B equal 06H.
Original Source Code Comment: SET FOR 6 CHARS
55C6HTRAM1
GOSUB to 0235H which is the Model III ROM Routine to read one byte from the cassette drive specified in register A, and returns the byte in register A.
Original Source Code Comment: GET A BYTE OF NAME
55C9
LD (HL),A
Store byte which was just read from cassette (held in Register A) into the screen location pointed to by Register Pair HL.
Original Source Code Comment: PUT IT ON THE SCREEN
55CA
INC HL
INCrement the FILE BUFFER POINTER (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP TO NEXT SLOT
55CB
LOOP back to 55C6H, 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
55CDTRAM2
GOSUB to 0235H which is the Model III ROM Routine to read one byte from the cassette drive specified in register A, and returns the byte in register A. This will be a BLOCK MARKER.
Original Source Code Comment: GET THE 1ST BYTE
55D0
CP 78H
Check to see if the BLOCK MARKER just read was an EXECUTION ADDRESS BLOCK by comparing the value held in Register A against 78H. Results: If Register A equals 78H, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: END OF TAPE?
55D2
If the byte was an EXECUTION ADDRESS BLOCK then the Z FLAG (Zero) will have been set, JUMP to 5601H.
Original Source Code Comment: YES, GET THE TRANSFER ADDRESS
55D4
CP 3CH
Check to see if the BLOCK MARKER just read was a CODE BLOCK by comparing the value held in Register A against 3CH. Results: If Register A equals 3CH, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: START OF DATA BYTE?
55D6
If the byte was NOT a CODE BLOCK then the NZ FLAG (Zero) will have been set; LOOP BACK to 55CDH to keep reading bytes.
Original Source Code Comment: NO, TRY ANOTHER
55D8
GOSUB to 0235H which is the Model III ROM Routine to read one byte from the cassette drive specified in register A, and returns the byte in register A. This should be the CODE BLOCK LENGTH BYTE.
Original Source Code Comment: GET THE BYTE COUNT
55DB
LD B,A
Copy the CODE BLOCK LENGTH BYTE (held in Register A) into Register B.
Original Source Code Comment: INTO B
55DC
GOSUB to 0235H which is the Model III ROM Routine to read one byte from the cassette drive specified in register A, and returns the byte in register A. This should be the LSB of the CODE ADDRESS.
Original Source Code Comment: GET THE LSB OF THE ADDRESS
55DF
LD C,A
Copy the LSB of the CODE ADDRESS (held in Register A) into Register C.
Original Source Code Comment: START A CHECKSUM
55E0
LD L,A
Copy the LSB of the CODE ADDRESS (held in Register A) into Register L.
Original Source Code Comment: SET AS LSB OF BUFFER POINTER
55E1
GOSUB to 0235H which is the Model III ROM Routine to read one byte from the cassette drive specified in register A, and returns the byte in register A. This should be the MSB of the CODE ADDRESS.
Original Source Code Comment: GET THE MSB OF THE ADDRESS
55E4
LD H,A
Copy the MSB of the CODE ADDRESS (held in Register A) into Register H.
Original Source Code Comment: SET AS MSB OF BUFFER POINTER
55E5
ADD A,C
LET Register A = the MSB of the CODE ADDRESS (held in Register A) + the LSB of the CODE ADDRESS (held in Register C).
Original Source Code Comment: ADD TO CHECKSUM
55E6
LD C,A
Copy the results of that addition into Register C.
Original Source Code Comment: SAVE IT
55E7TRAM3
GOSUB to 0235H which is the Model III ROM Routine to read one byte from the cassette drive specified in register A, and returns the byte in register A.
Original Source Code Comment: GET A DATA BYTE
55EA
LD (HL),A
Store the byte just read from tape (held in Register A) into the FILE BUFFER location pointed to by Register Pair HL.
Original Source Code Comment: PUT IT INTO MEMORY
55EB
CP (HL)
Verify that the byte was properly written by comparing the value held in Register A against the value held in the memory location pointed to by the value held in Register Pair HL. Results: If they match, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: MEMORY THERE?
55EC
If the write was verified successfully the Z FLAG (Zero) will have been set, JUMP to 55F3H.
Original Source Code Comment: YES, CONTINUE
55EE
LD A,23HLD A,EMFLT
Let Register A equal 23H for a DOS ERROR of MEMORY FAULT.
Original Source Code Comment: NO, MEMORY FAULT
55F0
JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.
Original Source Code Comment: EXIT TO ERROR HANDLER

55F3H - TRAM4 - Continuation of the SYSTEM Tape into RAM and RUN IT portion of the "TAPE" Routine. Jumped here if there was no memory fault.

55F3TRAM4
ADD A,C
LET Register A = Register A + the checksum (held in Register C).
Original Source Code Comment: ADD TO THE CHECKSUM
55F4
LD C,A
Copy the checksum (held in Register A) into Register C.
Original Source Code Comment: SAVE IT
55F5
INC HL
INCrement the FILE BUFFER POINTER (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP TO NEXT SLOT
55F6
Process the entire code block (length of B) by LOOPing back to 55E7H, 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
55F8
GOSUB to 0235H which is the Model III ROM Routine to read one byte from the cassette drive specified in register A, and returns the byte in register A. This should be the CODE BLOCK's CHECKSUM
Original Source Code Comment: GET THE CHECKSUM
55FB
CP C
Compare the CODE BLOCK's CHECKSUM which was just calculated (held in Register C) against rhe CODE BLOCK's CHECKSUM read from cassette (held in Register A): If they match, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: MATCH OUR'S?
55FC
If they don't match, then we had a bad read and the NZ FLAG (Not Zero) will have been set, JUMP to 5219H to display an ILLEGAL PARAMETER error and exit via a JUMP to 5223H.
Original Source Code Comment: NO, PARAMETER ERROR
55FF
If they did match, then LOOP BACK to 55CDH to read the next block.
Original Source Code Comment: GO FOR MORE

5601H - TRAM5 - Continuation of the SYSTEM Tape into RAM and RUN IT portion of the "TAPE" Routine. Jumped here if the we just got a EXECUTION ADDRESS BLOCK.

5601TRAM5
Read the EXECUTION ADDRESS via a GOSUB to the Model III ROM Routine at 0314H.
Original Source Code Comment: LET THE ROM GET THE TRANSFER ADDR
5604
PUSH HL
Save the EXECUTION ADDRESS (held in Register Pair HL from that CALL) to the top of the stack.
Original Source Code Comment: SAVE TRA ADDR
5605
Turn off the cassette via a call to the MODEL III ROM Routine at 01F8H.
Original Source Code Comment: TURN CASSETTE OFF
5608
POP HL
Restore the EXECUTION 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 TRA ADDR BACK
5609
LD A,H
We want to see if HL is 0. However, 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: SEE IF TRANSFER ADDRESS GIVEN
560A
OR L
... Part 2
560B
RET Z
If we didn't get an execution address then the Z FLAG (Zero) will have been set, RETurn to the caller.
Original Source Code Comment: NO, EXIT TO DOS
560C
JP (HL)
If we are here then we have an execution address stored in Register Pair HL. So JUMP to it!.
Original Source Code Comment: JP TO PROGRAM

560DH - "PURGE" Library Command.

560DPURGE
GOSUB to 5258H to position HL to the next non-space character on the COMMAND LINE.
Original Source Code Comment: SKIP SPACES
5610
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?
5612
If all we got was a ENTER, then we will assume that this is a request to delete user files from Drive 0; so JUMP to 5647H.
Original Source Code Comment: YES, USER FILES ONLY
5614
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: PURGE SYS?
5616
If we didn't get a * (for DELETE DOS), JUMP to 561DH.
Original Source Code Comment: NO, CHECK FOR NORMAL

If we are here, then we got a * and need to delete DOS.

5618
LD (58C5H),ALD (STAR),A
Store a * unto the CP instruction at 58C5H.
Original Source Code Comment: SET AS A FLAG
561B
INC HL
BUMP the pointer to the COMMAND LINE by 1.
Original Source Code Comment: BUMP PAST '*'
561C
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 THE CHAR
561DCKCOLN
CP 3AHCP ':'
Compare the value held in Register A against 3AH (ASCII: :) to see if we were given a drivespec. Results: If Register A equals :, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: DRIVE SPECIFIER?
561F
If we were not given a :, then skip the drivespec checking and JUMP to 563AH.
Original Source Code Comment: NO, CONTINUE

If we are here, then we got a : and need to check for a drive letter after the :

5621
INC HL
BUMP the pointer to the COMMAND LINE by 1.
Original Source Code Comment: BUMP TO DRIVE NUMBER
5622
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. A drive number is expected to be here.
Original Source Code Comment: GET IT
5623
LD (58C7H),ALD (PUDRV+1),A
Store the drive spec held in Register A (which should be a drive number) into memory location 58C7H.
Original Source Code Comment: SAVE IT FOR FILESPECS
5626
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: SEE IF LEGAL DRIVE NUMBER
5628
If value on the command line was below "0" the C FLAG (Carry) will have been triggered; JUMP to 5221H.
Original Source Code Comment: WAS PARAMETER ERROR
562B
LD B,A
Copy the ASCII value of the drive number (held in Register A) into Register B.
Original Source Code Comment: INTO B FOR MOMENT
562C
LD A,(4413H)LD A,(MAXDRV)
Fetch the value held in memory location 4413H and store it into Register A.
NOTE: 4413H is the storage location for the NUMBER OF DISK DRIVES in the system.
Original Source Code Comment: GET MAX DRIVE IN SYSTEM
562F
CP B
Compare the NUMBER OF DISK DRIVES in the system (held in Register A) against the ASCII value of the user supplied drive number (held in Register B). If A < B then we have a BAD drive number, and the CARRY FLAG will be set.
Original Source Code Comment: LEGAL DRIVE?
5630
If the user supplied a bad drive number, JUMP to 5221H.
Original Source Code Comment: NO, ILLEGAL DRIVE NUMBER
5633
LD A,B
Copy the ASCII value of the drive number (held in Register B) into Register A.
Original Source Code Comment: GET THE DRIVE BACK
5634
LD (58C9H),ALD (PDRV),A
Store the drive number (in ASCII) into memory location 58C9H.
Original Source Code Comment: SAVE IT
5637
GOSUB to 525CH to fetch the next non-space character (pointed to by Register Pair HL) into Register A.
Original Source Code Comment: SKIP TO NEXT CHARACTER
563APURGE1
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: PARAMETER LIST?
563C
If the next character on the command line was not "(" then the NZ FLAG (Not Zero) will have been set; JUMP to 5647H.
Original Source Code Comment: NO, ASSUME USER FILES ONLY
563E
LD DE,58A6HLD DE,PURSWT
Let Register Pair DE equal 58A6H to point to the PURGE command parameter table.
Original Source Code Comment: DE => SYNTAX TABLE
5641
GOSUB to 4454H.
NOTE: 4454H is the DOS PARAMETER STRING PARSE routine. It decodes DOS LIBRARY parameters.
Original Source Code Comment: TO THE SYNTAX
5644
If the CALL resulted in an error the NZ FLAG (Not Zero) will have been set, JUMP to 521DH.
Original Source Code Comment: EXIT IF ERROR
5647PURGE2
LD HL,5866HLD HL,MSPW
Let Register Pair HL equal 5866H to point to the message "MASTER PASSWORD?" .
Original Source Code Comment: HL => 'ENTER MASTER PW' MSG
564A
GOSUB to 021BH.
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
564D
LD HL,5BA2HLD HL,SDCB1
Let Register Pair HL equal 5BA2H which will be a buffer for the MASTER PASSWORD.
Original Source Code Comment: SCRATCH PAD AREA
5650
LD B,08HLD B,8
Since a password is 8 characters or less, set Register B equal 08H.
Original Source Code Comment: MAX NUMBER OF CHARS IN PW
5652
GOSUB to 0040H.
NOTE: 0040H is the Model III ROM routine to get a full line from the keyboard. In this routine, a line is terminated by a carriage return or BREAK, and characters typed are echoed to the display. On entry, B must be the maximum length of line to be accepted and (HL) must be the storage buffer which should be set to B+1. On Exit, CARRY will be set if the BREAK key was hit, Register B will contain the number of characters entered, and (HL) will contain the line from the keyboard followed by the terminating character. Register paid DE is altered in this routine.
Original Source Code Comment: GET THE ANSWER
5655
PUSH HL
Save the MASTER PASSWORD BUFFER ADDRESS (held in Register Pair HL) to the top of the stack.
Original Source Code Comment: SAVE POINTER
5656
LD B,08HLD B,8
Since a password is 8 characters or less, set Register B equal 08H.
Original Source Code Comment: MAX NUMBER OF CHARACTERS
5658PURGE3
LD A,(HL)
We are in a loop here. Fetch a character from the MASTER PASSWORD BUFFER (i.e., held in the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET A CHAR
5659
CP 20HCP 'SPACE'
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 STRING?
565B
If the character from the MASTER PASSWORD BUFFER (held in Register A) < SPACE, we are at the end of the password and the C FLAG (Carry) will have been set; so JUMP to 5662H to stop processing characters.
Original Source Code Comment: YES, EXIT
565D
INC HL
BUMP HL by 1 to point to the next character in the MASTER PASSWORD BUFFER.
Original Source Code Comment: NO, BUMP TO NEXT CHAR
565E
LOOP back to 5658H, 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
5660
If we are here, then 8 characters were processed for the Master Password. Continue via a JUMP to 5667H.

5662H - PURGE4 - Continuation of "PURGE". Jumped here if the MASTER PASSWORD provided by the user was less than 8 characters. Register B will hold the number of characters received and Register Pair HL will be pointing to the first non-valid character in the Master Password Buffer.

5662PURGE4
LD (HL),20HLD (HL),' '
Overwrite whatever may be in the MASTER PASSWORD CHARACTER BUFFER at HL with a SPACE.
Original Source Code Comment: FILL WITH SPACES
5664
INC HL
BUMP HL by 1 to point to the next character in the MASTER PASSWORD BUFFER.
5665
LOOP back to 5662H, 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 REMAINDER OF COUNT
5667PURGE5
POP DE
Put the MASTER PASSWORD BUFFER ADDRESS (held at the top of the STACK into Register Pair DE), and then remove the entry from the stack.
Original Source Code Comment: GET POINTER BACK
5668
Encode the password pointed to by Register Pair DE into Register Pair HL via GOSUB to 57A4H.
Original Source Code Comment: DO A TRAP DOOR CODE ON IT
566B
LD (58CAH),HLLD (PW),HL
Store hashed master password (held in Register Pair HL into) memory location 58CAH.
Original Source Code Comment: SAVE FOR LATER
566E
LD A,(58C9H)LD A,(PDRV)
Fetch the drive number from memory location 58C9H and store it into Register A.
Original Source Code Comment: GET THE DRIVE NUMBER
5671
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: INTO C
5672
GOSUB to 4A93H.
NOTE: 4A93H is the SYS00/SYS routine to READ THE GAT sector into RAM (Buffer at 4D00H).
Original Source Code Comment: READ IN THE GAT TABLE
5675
If that CALL resulted in an error the NZ FLAG (Not Zero) will have been set, JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.
Original Source Code Comment: EXIT IF ERROR
5678
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
567B
If that CALL resulted in an error the NZ FLAG (Not Zero) will have been set, JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.
567E
LD HL,4300HLD HL,BUFF1
Let Register Pair HL equal 4300H.
NOTE: 4300H is a memory buffer (referred to as Memory Buffer 1) where HIT TABLE was stored in RAM.
Original Source Code Comment: WHERE HASH TABLE IS
5681
LD DE,5D00HLD DE,BUFER1
Let Register Pair DE equal 5D00H, which will be a memory buffer for the HIT SAVE AREA.
Original Source Code Comment: WHERE I WANT IT
5684
LD BC,0100HLD BC,SECTOR
Let Register Pair BC equal 0100H, which is a full disk sector of data.
Original Source Code Comment: NUMBER OF BYTES
5687
LDIR
Copy 256 bytes from 4300H to 5D00H via a 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: MOVE THE HASH TABLE
5689
LD HL,(4DCEH)LD HL,(BUFF2+DPASS)
Fetch the actual hashed master password from the HIT (held in memory location 4DCEH) and store it into Register Pair HL.
Original Source Code Comment: GET THE USER DISK PASSWORD
568C
LD DE,(58CAH)LD DE,(PW)
Fetch the user provided hashed master password (held in memory location 58CAH) and store it into Register Pair DE.
Original Source Code Comment: ONE USER SUPPLIED
5690
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
5691
SBC HL,DE
Compare the actual password (HL) with the user provided password (DE) by subtracting them.
Original Source Code Comment: THEY THE SAME?
5693
If the two password match, the subtraction will be 0 and the Z FLAG (Zero) will have been set; JUMP to 569AH.
Original Source Code Comment: YES, CONTINUE
5695
LD A,19HLD A,EFAD
Let Register A equal 19H to set up for a FILE ACCESS DENIED error.
Original Source Code Comment: FILE ACCESS DENIED
5697
JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.
Original Source Code Comment: EXIT

569AH - PURG6 - Continuation of "PURGE". Jumped here if the MASTER PASSWORD provided by the user was correct.

569APURG6
LD A,(58C5H)LD A,(STAR)
Check to see if the user requested to delete all of DOS by fetching the value held in memory location 58C5H and store it into Register A.
Original Source Code Comment: WAS THIS A PURGE SYSTEM FILES?
569D
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).
569E
If the NZ FLAG (Not Zero) has been set, then the user wants to delete DOS so GOSUB to 57D4H.
Original Source Code Comment: YES, DO IT
56A1PURGE6
LD HL, ~~ the value placed into 56A2 ~~LD HL,BUFER1
Let Register Pair HL equal a value placed here from other locations in this Overlay. The hope here is that HL points to the HASH TABLE ENTRY for the file to be deleted.
Original Source Code Comment: HL => HIT TABLE
56A4
LD A,L
Isolate the position in the HIT into Register A by copying the contents of Register L into Register A.
Original Source Code Comment: GET THE LSB
56A5
CP 51HCP MAXFIL+1
Check to see if we are at the end of the HIT by comparing the value held in Register A against 51H. Results: If Register A equals 51H, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: WE DONE WITH THE DISK?
56A7
If Register A = 51H then we are past the end of the HIT and the Z FLAG (Zero) will have been set; JUMP to 5791H to finish.
Original Source Code Comment: YES, EXIT
56AA
LD A,(HL)
Fetch the HIT entry (held in the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET THE HASH CODE
56AB
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 FILE HERE?
56AC
If the HIT entry is NOT ZERO, then there is a file there to be processed, so JUMP to 56B4H.
Original Source Code Comment: YES, CONTINUE
56AE
INC HL
Point to the next entry in the HIT TABLE by INCrementing the value stored in Register Pair HL by 1.
Original Source Code Comment: NO, BUMP TO NEXT FILE
56AF
LD (56A2H),HLLD (BUFPNT),HL
Store the HIT TABLE pointer (which was just incremented) into the LD HL,nnnn instruction at 56A1 and then ...
Original Source Code Comment: SAVE IT
56B2
... JUMP to 56A1H.
Original Source Code Comment: GET NEXT FILE

56B4H - PURGE7 - Continuation of "PURGE". Jumped here if HL points to a HIT entry that needs to be deleted.

56B4PURGE7
LD B,L
Copy the Logical File Number (held in Register L) into Register B.
Original Source Code Comment: SET AS LFN
56B5
LD A,(58C9H)LD A,(PDRV)
Fetch the drive number from memory location 58C9H and store it into Register A.
Original Source Code Comment: GET THE DRIVE NUMBER
56B8
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: INTO C
56B9
GOSUB to 4A67H.
NOTE: 4A67H is the SYS00/SYS routine to read the directory entry into RAM (Buffer at 4300H)
Original Source Code Comment: READ THE DIRECTORY FOR THIS FILE
56BC
If that CALL resulted in an error, the NZ FLAG (Not Zero) will have been set, JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.
Original Source Code Comment: EXIT IF ERROR
56BF
LD A,(HL)
Fetch the file attributes (held in the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET THE ATTRIB BYTE OF THE FILE
56C0
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 THERE A FILE?
56C1
If the NZ FLAG (Not Zero) has been set then the file is active, so skip the next routine and JUMP to 56E3H.
Original Source Code Comment: YES. CHECK IT OUT
56C3
PUSH BCSAVE
Save the contents of Register Pair BC to the top of the stack.
Original Source Code Comment: SAVE ALL OF THE REGISTERS
56C4
PUSH DE
Save the contents of Register Pair DE to the top of the stack.
56C5
PUSH HL
Save the contents of Register Pair HL to the top of the stack.
56C6
PUSH AF
Save the contents of Register Pair AF to the top of the stack.
56C7
PUSH BC
Save the contents of Register Pair BC to the top of the stack.
Original Source Code Comment: SAVE THE LFN WHERE WE CAN GET TO IT
56C8
LD A,(58C9H)LD A,(PDRV)
Fetch the drive number from memory location 58C9H and store it into Register A.
Original Source Code Comment: GET THE DRIVE NUMBER
56CB
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: INTO C
56CC
GOSUB to 4ABAH.
NOTE: 4ABAH is the SYS00/SYS routine to read the HIT sector into RAM.
Original Source Code Comment: READ IN THE HASH TABLE
56CF
If that CALL resulted in an error, the NZ FLAG (Not Zero) will have been set, JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.
56D2
POP BC
Restore the Logical File 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 LFN BACK
56D3
LD L,B
Set HL to point to the applicable file by copying the logical file number (held in Register B) into the LSB of the HIT pointer (i.e. Register L).
Original Source Code Comment: LFN INTO HL FOR POINTER
56D4
LD (HL),00HLD (HL),0
Place a 00H into the HIT at the location of the logical file number being cleared.
Original Source Code Comment: CLEAR OUT THIS HASH CODE
56D6
GOSUB to 4AC2H.
NOTE: 4AC2H is the SYS00/SYS routine to write the HIT sector from RAM to diskette.
Original Source Code Comment: WRITE OUT THE HASH TABLE
56D9
If that CALL resulted in an error, the NZ FLAG (Not Zero) will have been set, JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.
56DC
POP AFRSTR
Put the value held at the top of the STACK into Register Pair AF, and then remove the entry from the stack.
Original Source Code Comment: RESTORE ALL REGISTERS
56DD
POP HL
Put the value held at the top of the STACK into Register Pair HL, and then remove the entry from the stack.
56DE
POP DE
Put the value held at the top of the STACK into Register Pair DE, and then remove the entry from the stack.
56DF
POP BC
Put the value held at the top of the STACK into Register Pair BC, and then remove the entry from the stack.
56E0
Continue the routine via a JUMP to 5750H.
Original Source Code Comment: AND BUMP TO NEXT FILE

56E3H - PURG07 - Continuation of "PURGE". Jumped here if the file is active.

56E3PURG07
LD A,(58C3H)LD A,(PALL)
Check to see if the user requested to purge all files by fetching the value held in memory location 58C3H and store it into Register A.
Original Source Code Comment: SEE IF 'ALL' FILES
56E6
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).
56E7
If the user requested to purge CALL files, then the NZ FLAG (Not Zero) will hav been set, JUMP to 5701H.
Original Source Code Comment: YES, DO IT
56E9
BIT 6,(HL)BIT SYSTEM,(HL)
Test for a system file by checking Bit Number 6 of Register HL. 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: SYSTEM FILE?
56EB
If Bit 6 is 0, then this is not a SYSTEM file and the Z FLAG (Zero) will been set, so skip this file by JUMPing to 56F6H to continue checking the file.
Original Source Code Comment: NO, HOW ABOUT INVISIBLE
56ED
LD A,(58BFH)LD A,(PSYS)
Check to see if the user requested to purge SYSTEM FILES by fetching the value held in memory location 58BFH and store it into Register A.
Original Source Code Comment: USER WANT SYSTEM FILES?
56F0
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).
56F1
If the user did not request to purge system files the Z FLAG (Zero) will have been set, JUMP to 5750H.
Original Source Code Comment: NO, CONTINUE TO NEXT FILE
56F4
JUMP to 5701H to continue.
Original Source Code Comment: YES, DO IT

56F6H - NOTSYS - Continuation of "PURGE".

56F6NOTSYS
BIT 3,(HL)BIT INV,(HL)
Check to see if the selected file is invisible by testing Bit Number 3 of Register HL. 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: INVISIBLE FILE?
56F8
If the Z FLAG (Zero) has been set, then the file is not invisible, so JUMP to 5701H.
Original Source Code Comment: NO, DO IT
56FA
LD A,(58C1H)LD A,(PINV)
If we are here, the file is invisible, so check to see if the user requested to purge invisible files by fetching the value held in memory location 58C1H and store it into Register A.
Original Source Code Comment: USER WANT 'INV' FILES
56FD
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).
56FE
If the user did not request to kill invisible files, then the Z FLAG (Zero) will have been set, JUMP to 5750H since we aren't going to kill the current (invisible) file.
Original Source Code Comment: NO, DO NEXT FILE
5701GETFIL
Get the filename to be killed from the directory entry via a GOSUB to 575AH.
Original Source Code Comment: COMPRESS THE FILE NAME
5704GETFI0
LD HL,5BA2HLD HL,SDCB1
Let Register Pair HL equal 5BA2H so as to point to the filename.
Original Source Code Comment: HL => 'FILESPEC'
5707
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
570A
LD HL,589AHLD HL,QUERY
Let Register Pair HL equal 589AH so as to point to the message " (Y/N/Q) ? ".
Original Source Code Comment: HL => '(Y/N/Q)' MSG
570D
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
5710
LD HL,5BD2HLD HL,SDCB2
Let Register Pair HL equal 5BD2H to point to a buffer.
Original Source Code Comment: SCRATCH PAD AREA
5713
LD B,03HLD B,3
Fetch 3 characters from the keyboard by setting Register B equal 03H.
Original Source Code Comment: SET FOR 3 CHARS
5715
GOSUB to 0040H.
NOTE: 0040H is the Model III ROM routine to get a full line from the keyboard. In this routine, a line is terminated by a carriage return or BREAK, and characters typed are echoed to the display. On entry, B must be the maximum length of line to be accepted and (HL) must be the storage buffer which should be set to B+1. On Exit, CARRY will be set if the BREAK key was hit, Register B will contain the number of characters entered, and (HL) will contain the line from the keyboard followed by the terminating character. Register paid DE is altered in this routine.
Original Source Code Comment: GET THE ANSWER
5718
If the C FLAG (Carry) has been set then a BREAK was hit, JUMP to 5791H.
Original Source Code Comment: EXIT IF BREAK KEY
571B
LD A,(HL)
Fetch the response received from the user to the Y/N/Q question (held in the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET THE ANSWER
571C
CP 51HCP 'Q'
Compare the value held in Register A against 51H (ASCII: Q). Results: If Register A equals Q, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: QUIT?
571E
If the user entered Q to quit, the Z FLAG (Zero) will have been set, JUMP to 5791H.
Original Source Code Comment: EXIT IF QUIT
5721
CP 59HCP 'Y'
Compare the value held in Register A against 59H (ASCII: Y). Results: If Register A equals Y, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: YES?
5723
If the user entered Y to kill that file, the Z FLAG (Zero) will have been set, JUMP to 572BH.
Original Source Code Comment: YES, KILL THE FILE
5725
CP 4EHCP 'N'
Compare the value held in Register A against 4EH (ASCII: N). Results: If Register A equals N, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: NO?
5727
If the user did not enter a "N", then we have an unacceptable character as that was the only valid response left, so JUMP to 5704H.
Original Source Code Comment: TRY IT AGAIN SAM!!
5729
JUMP to 5750H to NOT delete the file and continue looping through the files.
Original Source Code Comment: DO THE NEXT FILE

572BH - GETFI1 - Continuation of "PURGE". Jumped here if we found a file to delete, and the user confirmed to delete it.

572BGETFI1
LD HL,5E00HLD HL,BUFER2
Let Register Pair HL equal 5E00H for a FILE BUFFER / DATA STORAGE BUFFER.
Original Source Code Comment: BUFFER TO USE
572E
LD DE,5BA2HLD DE,SDCB1
Let Register Pair DE equal 5BA2H which is the File Control Block area in RAM.
Original Source Code Comment: WHERE THE FILESPEC IS
5731
LD B,00HLD B,0
Let Register B equal 00H so that the next routine will set for FULL SECTOR I/O.
Original Source Code Comment: LRL = 256
5733
LD IYL,00FH
LD IYH,42HLD YL,SCAFLG.LSB.
Let Special Index Register IY = 4200H
Original Source Code Comment: SET THE PROTECTION OVER-RIDE FLAG
5739
DEC (IY+00H)DEC (IY)
DECrement the value stored in the memory location pointed to by Special Index Register IY by 1.
573C
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 2 in OVERLAY 3.
Original Source Code Comment: OPEN THE FILE
573F
If the NZ FLAG (Not Zero) has been set, meaning that the prior CALL routine returned with an ERROR, then JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.
Original Source Code Comment: EXIT IF ERROR
5742GETFI2
LD A,(5BA3H)LD A,(SDCB1+PROT)
Fetch OPTIONS BYTE from the FILE CONTROL BLOCK (held in memory location 5BA3H) and store it into Register A.
Original Source Code Comment: GET THE ATTRIB
5745
AND 0F8H
MASK the OPTIONS BYTE held in Register A against 0F8H (1111 1000). This has the effect of turning off bits 2, 1, 0, thus setting the file to UNLIMITED ACCESS.
Original Source Code Comment: MASK OFF ANY PRIV
5747
LD (5BA3H),ALD (SDCB1+PROT),A
Store the OPTIONS BYTE held in Register A back into the FILE CONTROL BLOCK (held in memory location 5BA3H).
Original Source Code Comment: PUT IT BACK
574A
LD DE,5BA2HLD DE,SDCB1
Let Register Pair DE equal 5BA2H to point to the FILE CONTROL BLOCK.
Original Source Code Comment: DE => DCB
574D
GOSUB to 442CH.
NOTE: 442CH is the SYS00/SYS routine to KILL A DISK FILE. On Entry DE mus tpoint to th ememory location identifying if the file is open or not.
Original Source Code Comment: KILL THE FILE
5750NXTFIL
LD HL,(56A2H)LD HL,(BUFPNT)
Fetch the HIT POINTER (held in memory location 56A2H) and store it into Register Pair HL.
Original Source Code Comment: GET THE BUFFER POINTER
5753
INC HL
INCrement the HIT POINTER to the next entry by BUMPING HL by 1.
Original Source Code Comment: BUMP TO NEXT FILE
5754
LD (56A2H),HLLD (BUFPNT),HL
Store HIT POINTER into memory location 56A2H.
Original Source Code Comment: SAVE IT
5757
Loop to the next file by JUMPing to 56A1H.
Original Source Code Comment: DO NEXT FILE

575AH - COMPRS - SUBroutine in the "PURGE" command which will get the FILESPEC from a DIRECTORY ENTRY.

575ACOMPRS
PUSH HL
Save the directory entry pointer (held in Register Pair HL) to the top of the stack.
Original Source Code Comment: SAVE FILE POINTER
575B
LD DE,0005HLD DE,DNAME
Since the filename of a file starts at the 5th byte of a directory entry, let Register Pair DE equal 0005H.
Original Source Code Comment: OFFSET TO THE NAME
575E
ADD HL,DE
Advance the pointer to the applicable byte of the directory in RAM (pointed to by Register Pair HL) by 5.
Original Source Code Comment: HL => FILE NAME
575F
LD DE,5BA2HLD DE,SDCB1
Let Register Pair DE equal 5BA2H to point to the File Control Block.
Original Source Code Comment: WHERE WE'LL PUT THE NAME
5762
LD B,08HLD B,8
Set up a loop of 8 characters by setting Register B equal to 08H.
Original Source Code Comment: SET FOR 8 CHARACTERS
5764COMPR1
LD A,(HL)
Start of loop. Fetch a filename character from the directory entry (held in the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET A CHARACTER
5765
CP 21HCP 'SPACE'+1
Check to see if there is actually a usable character there by comparing the character we just fetched (held in Register A) against 21H (ASCII: !). Results:
  • If Register A equals !, the Z FLAG is set.
  • If A < !, the CARRY FLAG will be set.
  • if A >= !, the NO CARRY FLAG will be set.

Original Source Code Comment: SPACE OR CONTROL?
5767
If the filename byte in the directory entry is less than ! then we are apparently at the end of the filename and the C FLAG (Carry) will have been set, JUMP to 576EH.
Original Source Code Comment: YES, DO THE EXT
5769
LD (DE),A
Store the filename character held in Register A into the file control block (the memory location pointed to by Register Pair DE).
Original Source Code Comment: PUT IT INTO THE DCB
576A
INC HL
INCrement the pointer in the directory entry (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP TO NEXT CHAR
576B
INC DE
INCrement the pointer in the file control block entry (stored in Register Pair DE) by 1.
576C
Process up to 8 characters of the filespec by LOOPing back to 5764H, 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.
576ECOMPR2
POP HL
End of loop. Restore the directory entry pointer (held at the top of the stack) into Register Pair HL.
Original Source Code Comment: GET POINTER BACK
576F
LD BC,000DHLD BC,DEXT
The filespec has been moved, time to process the extension. The extension is 13 bytes into a directory entry, so let Register Pair BC equal 000DH (Decimal: 13).
Original Source Code Comment: OFFSET TO THE EXT
5772
ADD HL,BC
Advance the pointer to the applicable byte of the directory in RAM (pointed to by Register Pair HL) by 13 to point to the file's extension.
Original Source Code Comment: HL => EXT
5773
LD A,(HL)
Fetch the first character of the file's extension (held in the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET A BYTE
5774
CP 20HCP 'SPACE'
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: ANY EXTENSION?
5776
If there is no extension because there was a SPACE as the first character and Z FLAG (Zero) has been set, JUMP to 5788H.
Original Source Code Comment: NO, PUT DRIVE NUMBER
5778
LD A,2FHLD A,'/'
If we are here then we know there is an extension, so add a slash into the file control block by setting Register A equal /.
Original Source Code Comment: ADD IN THE EXT SPECIFIER
577A
LD (DE),A
and then storing the / (held in Register A) into the file control block (the memory location pointed to by Register Pair DE).
577B
INC DE
Since we just put in another character into the File Control Block, we need to bump the File Control Block pointer (held in Register DE) by 1.
577C
LD B,03HLD B,3
Since there are 3 characters max in a filename extension, set Register B equal 03H.
Original Source Code Comment: SET FOR 3 CHARS
577ECOMPR3
LD A,(HL)
Start of a loop. Fetch a character from the filename's extension from the memory location pointed to by Register Pair HL and store it into Register A.
Original Source Code Comment: GET AN EXT CHAR
577F
CP 21HCP 'SPACE'+1
Check to see if there is actually a usable character there by comparing the character we just fetched (held in Register A) against 21H (ASCII: !). Results:
  • If Register A equals !, the Z FLAG is set.
  • If A < !, the CARRY FLAG will be set.
  • if A >= !, the NO CARRY FLAG will be set.

Original Source Code Comment: SPACE?
5781
If the filename's extension byte in the directory entry is less than ! then we are apparently at the end of the filename and the C FLAG (Carry) will have been set, JUMP to 5788H.
Original Source Code Comment: YES, EXIT
5783
LD (DE),A
We have a valid extension character in Register A so store it into the FCB at the memory location pointed to by Register Pair DE.
Original Source Code Comment: INTO THE DCB
5784
INC HL
INCrement the pointer in the directory entry (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP POINTERS
5785
INC DE
INCrement the pointer in the file control block entry (stored in Register Pair DE) by 1.
5786
Process up to 3 characters of the extension by LOOPing back to 577EH, 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
5788COMPR4
LD HL,58C6HLD HL,PUDRV
End of loop. Let Register Pair HL equal 58C6H to point to the drive number + terminator.
Original Source Code Comment: HL => DRIVE NUMBER
578B
LD BC,0003HLD BC,3
Since a drive number + terminator is 3 bytes, set Register Pair BC equal 0003H.
Original Source Code Comment: 3 CHARACTERS
578E
LDIR
Copy the drive number + terminator from the directory entry into the file control block 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: COMPLETE THE DCB
5790
RET
RETurn to the caller.

5791H - PUGEXT - Continuation of the "PURGE" Routine - Finish the routine and request system disk if needed.

5791PUGEXT
LD A,(58C5H)LD A,(STAR)
Check to see if the DOS was deleted by fetching the value held in memory location 58C5H and store it into Register A.
Original Source Code Comment: DID WE PURGE THE SYSTEM FILES?
5794
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).
5795
RET Z
If the Z FLAG (Zero) has been set then DOS was not deleted, so we are good to go. RETurn to the caller.
Original Source Code Comment: NO, EXIT
5796
LD A,(58C9H)LD A,(PDRV)
We now know that DOS was deleted, and need to get the drive number, so fetch the value held in memory location 58C9H and store it into Register A.
Original Source Code Comment: GET THE DRIVE NUMBER
5799
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: DRIVE 0?
579A
RET NZ
If the drive we just modified wasn't :0 then we don't really care if DOS was deleted or not, so as long as it wasn't :0 RETurn to the caller.
Original Source Code Comment: NO, EXIT
579B
LD HL,5885HLD HL,SY4MSG
We now know that DOS was deleted and from Drive :0 and that we need to prompt for a DOS disk, so first set Register Pair HL equal 5885H to point to the message "INSERT A SYSTEM DISK.".
Original Source Code Comment: HL => 'INSERT SYSTEM DISK' MSG
579E
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
57A1
Wait for a key press and then RETurn via JUMP to the Model III ROM routine at 0049H which is is the Model III ROM routine to scan the keyboard and wait until a key is pressed, and then return with the key pressed in Register A. BREAK returns 01H.
Original Source Code Comment: WAIT FOR KEYBOARD AND EXIT

57A4H - TRAP - Subroutine in the "PURGE" Routine - Encode the password stored in the memory location pointed to by Register Pair DE; results in Register Pair HL.

57A4TRAP
LD HL,0FFFFH
LET Register Pair HL = 0FFFFH (Decimal: -1) as the default.
57A7
LD B,08HLD B,8
LET Register B = 08H since a password is 8 characters.

The next few instructions skip to the end of the password (pointed to by Register Pair DE) by adding 7 to the LSB (i.e., Register E).

57A9
LD A,E
LET Register A = Register E.
57AA
ADD A,07HADD A,7
ADD the value 07H to Register A (Results held in Register A).
57AC
LD E,A
LET Register E = Register A.
57AD
If the NC FLAG (No Carry) is set then we did not move to a new memory page (i.e., need to update D as well), so skip over the next instruction which increments D, and JUMP to 5113H.
57AF
INC D
Bump the value stored in Register D by 1.

At this point, Register Pair DE is now pointing to the END of the password.

57B9
LD A,(DE)RRCA
Fetch the value stored at memory location pointed to by Register Pair DE (i.e., 1 character of the 8 character password) and put it into Register A.
57B1
PUSH DE
Save Register DE (i.e., the location in the password string where Register A got the character from) to the top of the stack.
57B2
LD D,A
LET Register D = Register A (i.e., the password character pointed to by (DE)).
57B3
LD E,H
LET Register E = Register H (i.e., the MSB of the password).
57B4
LD A,L
LET Register A = Register L (i.e., the LSB of the password).
57B5
AND 07HAND 7
MASK the value of Register A against 07H (0000 0111). This has the effect of turning off bits 7, 6, 5, 4, 3, leaving only bits 2, 1, 0 active.
57B7
57B8
57B9
RRCA
RRCA
RRCA
Move the bottom 3 bits (2, 1, and 0) to the top 3 bits (7, 6, and 5)
57BA
XOR L
eXclusive OR Register L against Register A to merge the masked Register A with the LSB. The results are stored in Register A.
57BB
LD L,A
LET Register L = Register A (i.e., the new LSB).
57BC
LD H,00HLD H,0
LET Register H = 00H so that the MSB = 0.
57BE
SBC HL,DE
Let PASSWORD = PASSWORD - DE by subtracting the value stored in Register Pair DE and the carry flag from the value stored in Register Pair HL.
57C0
ADD HL,HL
Let PASSWORD = PASSWORD * 2 by adding the value held in Register Pair HL to Register Pair HL. The results are held in Register Pair HL.
57C1
ADD HL,HL
Let PASSWORD = PASSWORD * 4 by doing that again.
57C2
XOR H
eXclusive OR Register H (i.e., the new MSB) against Register A (i.e., the old LSB). The results are stored in Register A.
57C3
XOR D
eXclusive OR Register D (i.e., the character) against Register A (i.e., the old LSB / new MSB combination). The results are stored in Register A.
57C4
LD D,A
LET Register D = Register A (i.e., the mishmash we just did).
57C5
LD A,L
LET Register A = Register L (i.e., the new MSB).
57C6
ADD HL,HL
Let PASSWORD = PASSWORD * 2 by adding the value held in Register Pair HL to Register Pair HL. The results are held in Register Pair HL.
57C7
XOR H
eXclusive OR Register H (i.e., the NEWER MSB) against Register A (i.e., the prior new MSB). The results are stored in Register A.
57C8
XOR E
eXclusive OR Register E (i.e., the old MSB) against Register A. The results are stored in Register A.
57C9
LD E,A
LET Register E = Register A.
57CA
EX DE,HL
EXchange the value stored in Register Pair HL with the value stored in Register Pair DE so that Register Pair HL now contains the newly encoded password.
57CB
POP DE
Restore Register Pair DE (i.e., the location in the pasword string for the character which was just processed) from the top of the STACK.
57CC
DEC DE
DECrement the value stored in Register Pair DE by 1 to point to the previous character in the password string.
57CD
LOOP back to 5113H until Register B is ZERO (i.e., all 8 characters of the password have been processed, in reverse).
57CE
57CF
LD A,H
OR L
The Z-80 does not have a way to check a register pair against 0 easily. So a common trick is to let Register A equal one part of the Register Pair and then to OR that against the other part of the Register Pair. Only if both parts of the register pair were 0 will A be 0.
57D1
RET NZ
If the NZ FLAG (Not Zero) is set, then Register Pair HL (i.e., the password) was not 0, so RETurn to the caller.
57D2
INC L
Bump the value stored in Register L by 1 so we don't have a password of 0.
Original Source Code Comment: NO 0'S ALLOWED
57D3
RET
RETurn to the caller.

57D4H - PURSYS - Subroutine in the "PURGE" Routine - Delete all System Files.

57D4PURSYS
LD HL,5878HLD HL,SYSMSG
Let Register Pair HL equal 5878H to point to the message "SYSTEM FILES".
Original Source Code Comment: HL => 'SYSTEM FILES:' MSG
57D7
GOSUB to 021BH.
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
57DA
LD HL,58C6HLD HL,PUDRV
Let Register Pair HL equal 58C6H to point to the drivespec in ASCII.
Original Source Code Comment: HL => DRIVE NUMBER
57DD
GOSUB to 021BH.
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
57E0
LD HL,589AHLD HL,QUERY
Let Register Pair HL equal 589AH to point to the message " (Y/N/Q) ?".
Original Source Code Comment: HL => 'Y/N/Q' MSG
57E3
GOSUB to 021BH.
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
57E6
LD HL,5BD2HLD HL,SDCB2
Let Register Pair HL equal 5BD2H to point to a buffer.
Original Source Code Comment: SCRATCH PAD AREA
57E9
LD B,03HLD B,3
Fetch 3 characters from the keyboard by setting Register B equal 03H.
Original Source Code Comment: SET FOR 3 CHARS MAX
57EB
GOSUB to 0040H.
NOTE: 0040H is the Model III ROM routine to get a full line from the keyboard. In this routine, a line is terminated by a carriage return or BREAK, and characters typed are echoed to the display. On entry, B must be the maximum length of line to be accepted and (HL) must be the storage buffer which should be set to B+1. On Exit, CARRY will be set if the BREAK key was hit, Register B will contain the number of characters entered, and (HL) will contain the line from the keyboard followed by the terminating character. Register paid DE is altered in this routine.
Original Source Code Comment: GET THE ANSWER
57EE
LD A,(HL)
Fetch the response received from the user to the Y/N/Q question (held in the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET THE ANSWER
57EF
CP 4EHCP 'N'
Compare the value held in Register A against 4EH (ASCII: N). Results: If Register A equals N, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: NO?
57F1
If the user entered "N" then the Z FLAG (Zero) will have been set, JUMP to 580AH to skip this file.
Original Source Code Comment: YES, EXIT
57F3
CP 51HCP 'Q'
Compare the value held in Register A against 51H (ASCII: Q). Results: If Register A equals Q, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: QUIT?
57F5
If the user did not enter a "Q" then skip the next few instructions (which return) and JUMP to 57FAH.
Original Source Code Comment: NO, TRY NEXT
57F7
57F8
INC SP
INC SPPOP
INCrement the value stored in Register Pair SP by 1 to affect the RETurn.
Original Source Code Comment: GET THE CALLER OFF THE STACK
57F9
RET
RETurn to the caller.
Original Source Code Comment: RETURN TO DOS

57FAH - PURSY1 - Continuation of the "PURGE" subroutine to Delete all System Files.

57FAPURSY1
CP 59HCP 'Y'
Compare the value held in Register A against 59H (ASCII: Y). Results: If Register A equals Y, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: YES?
57FC
If the user didn't enter a Y either, then we received no valid response to the Y/N/Q inquiry and the NZ FLAG (Not Zero) will have been set, JUMP back to 57D4H to display the Y/N/Q prompt again.
Original Source Code Comment: NO, TRY IT AGAIN
57FE
LD HL,43E0HLD HL,BUFF1+SYSOFF
Let Register Pair HL equal 43E0H to point to the SYSTEM FILE DESCRIPTORS.
Original Source Code Comment: HL => SYSTEM EXT POINTERS
5801
LD E,(HL)LD DE,(HL)
Fetch the first byte of the SYSTEM FILE DESCRIPTORS (held in the memory location pointed to by Register Pair HL) and store it into Register E.
Original Source Code Comment: GET SYS 0 POINTER
5802
INC HL
Point HL to the next byte of the SYSTEM FILE DESCRIPTORS.
5803
LD D,(HL)
Fetch the second byte of the SYSTEM FILE DESCRIPTORS (held in the memory location pointed to by Register Pair HL) and store it into Register E.
5804
DEC HL
Point HL to the first byte of the SYSTEM FILE DESCRIPTORS.
Original Source Code Comment: BACK TO THE FRONT OF THE EXTENTS
5805
INC DE
INCrement the two-byte SYSTEM FILE DESCRIPTOR held in Register Pair DE by 1.
Original Source Code Comment: SEE IF IT'S ON DISK
5806
LD A,D
Since the Z-80 cannot test Register Pair DE against zero, the common trick is to set Register A to equal to Register D, and then OR A against Register E. Only if both Register D and Register E were zero can the Z FLAG be set.
5807
OR E
... Part 2
5808
If descriptor was FF (exists) the NZ FLAG (Not Zero) will have been set, JUMP to 580FH to continue.
Original Source Code Comment: YES, DELETE THEM
580ACLRSTR
XOR A
Set Register A to ZERO and clear all Flags.
Original Source Code Comment: CLEAR OUT THE SYSTEM FLAG
580B
LD (58C5H),ALD (STAR),A
Store the a 00H into memory location 58C5H to clear the SYSTEM DELETE FLAG.
580E
RET
RETurn to the caller.

580FH - PRSYS0 - Continuation of the "PURGE" subroutine to Delete all System Files.

580FPRSYS0
LD DE,43E1HLD DE,BUFF1+SYSOFF+1
Let Register Pair DE equal 43E1H which is the pointer to the SYSTEM FILE DESCRIPTORs.
Original Source Code Comment: CLEAR OUT THE SYSTEM EXT POINTERS
5812
LD BC,001FHLD BC,31
Let Register Pair BC equal 001FH to clear 31 sets of descriptors.
Original Source Code Comment: NUMBER OF BYTES TO CLEAR
5815
LD (HL),0FFHLD (HL),-1
Store 0FFH's into the memory location pointed to by Register Pair HL.
Original Source Code Comment: THE CLEAR BYTE
5817
LDIR
Set all 31 descriptors to FFH 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: CLEAR IT OUT
5819
LD A,(58C9H)LD A,(PDRV)
Fetch the drive number (held in memory location 58C9H) and store it into Register A.
Original Source Code Comment: GET THE DRIVE NUMBER
581C
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: INTO C
581D
GOSUB to 4AC2H.
NOTE: 4AC2H is the SYS00/SYS routine to write the HIT sector from RAM to diskette.
Original Source Code Comment: WRITE OUT THE HIT TABLE W/NO SYSTEM EXTS
5820
If the NZ FLAG (Not Zero) has been set, meaning that the prior CALL routine returned with an ERROR, then 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.
Original Source Code Comment: EXIT IF ERROR
5823
LD IX,4D00HLD IX,BUFF2
Let Special Index Register Pair IX equal 4D00H.
NOTE: 4D00H is a memory buffer (referred to as Memory Buffer 2) where the GAT TABLE is stored in RAM.
Original Source Code Comment: WHERE THE GAT IS
5827
LD (IX+00H),01H
Free the entire track 0, except the BOOT sector, by storing a 00H into 1st byte of the GAT Table in RAM (pointed to by Special Index Register Pair IX+00H).
Original Source Code Comment: CLEAR OUT ALL BUT BOOT SECTOR
582B
LD (IX+01H),00H
Free the entire track 1 by storing a 00H into the 2nd byte of the GAT in RAM (pointed to by Special Index Register Pair IX+01H).
Original Source Code Comment: TRACK 1
582F
LD A,(IX+02H)
To clear track 2 we need to do a little math because it isn't entirely a SYSTEM track. Fetch the value of the 3rd byte of the GAT in RAM (pointed to by Special Index Register Pair IX+02H).
5832
AND 0FCH
MASK the 3rd byte of the GAT against 0FCH (1111 1100). This has the effect of turning off bits 1, 0.
5834
LD (IX+02H),A
Free the system parts on track 2 by storing a the masked byte into the 3rd byte of the GAT in RAM (pointed to by Special Index Register Pair IX+02H).
Original Source Code Comment: TRACK 2
5837
LD (IX+0FH),00H
Free the entire track 15 by storing a 00H into the 16th byte of the GAT in RAM (pointed to by Special Index Register Pair IX+0FH).
Original Source Code Comment: TRACK 15
583B
LD (IX+10H),00H
Free the entire track 16 by storing a 00H into the 17th byte of the GAT in RAM (pointed to by Special Index Register Pair IX+10H).
Original Source Code Comment: TRACK 16
583F
LD (IX+12H),00H
Free the entire track 18 by storing a 00H into the 19th byte of the GAT in RAM (pointed to by Special Index Register Pair IX+12H).
Original Source Code Comment: TRACK 18
5843
LD (IX+13H),00H
Free the entire track 19 by storing a 00H into the 20th byte of the GAT in RAM (pointed to by Special Index Register Pair IX+13H).
Original Source Code Comment: TRACK 19
5847
LD (IX+14H),00H
Free the entire track 20 by storing a 00H into the 21st byte of the GAT in RAM (pointed to by Special Index Register Pair IX+13H).
Original Source Code Comment: TRACK 20
584B
LD A,(IX+15H)
To clear track 21 we need to do a little math because it isn't entirely a SYSTEM track. Fetch the value of the 22nd byte of the GAT in RAM (pointed to by Special Index Register Pair IX+15H).
584E
AND 0F0H
MASK the 22nd byte of the GAT against 0FCH (1111 1100). This has the effect of turning off bits 1, 0.
5850
LD (IX+15H),ALD (IX+21),A
Free the system parts on track 21 by storing a the masked byte into the 22nd byte of the GAT in RAM (pointed to by Special Index Register Pair IX+15H).
Original Source Code Comment: TRACK 21
5853
GOSUB to 4A9BH.
NOTE: 4A9BH is the SYS00/SYS routine to to write the GAT sector from RAM to diskette.
Original Source Code Comment: WRITE OUT THE GAT
5856
If the NZ FLAG (Not Zero) has been set, meaning that the prior CALL routine returned with an ERROR, then JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.
Original Source Code Comment: EXIT IF ERROR

We now need to write out the DUMMY system (to display the need for a SYSTEM disk).

5859
LD DE,0002HLD DE,2
Let Register Pair DE equal 0002H since a call to 47F7H requires DE point to the TRACK and SECTOR to be written.
Original Source Code Comment: SET FOR TRACK 0, SECTOR 2
585C
LD HL,5F00HLD HL,SYST
Let Register Pair HL equal 5F00H since a call to 47F7H requires HL point to a buffer.
Original Source Code Comment: HL => 'NOT A SYSTEM DISK' PGM
585F
GOSUB to 45F7H which is the SYS00/SYS routine to WRITE A SECTOR TO DISK.
Original Source Code Comment: WRITE IT OUT
5862
If the NZ FLAG (Not Zero) has been set, meaning that the prior CALL routine returned with an ERROR, then JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.
Original Source Code Comment: EXIT IF ERROR
5865
RET
RETurn to the caller.
Original Source Code Comment: ELSE RETURN

5866H - MSPW - "PURGE" Command Message and Byte Storage.

5866MSPW
DEFM 'Master Password? ' + 03H
5878SYSMSG
DEFM 'System Files' + 03H
5885SY4MSG
DEFM 'Insert a SYSTEM disk' + 0DH
589AQUERY
DEFM ' (Y/N/Q) ? ' + 03H

5866H - MSPW - "PURGE" Command Parameter Table.

58A6PURSWT
DEFM 'SYS '
58AE
DEFM 'INV '
58B6
DEFM 'ALL '
58BE
DEFB 00H
End of table delimeter

58BFH - PSYS - "PURGE" Command Message and Byte Storage.

58BFPSYS
DEFW 0000H
Flag for SYS Option
58C1PINV
DEFW 0000H
Flag for INV Option
58C3PALL
DEFW 0000H
Flag for ALL Option
58C5STAR
DEFB 00H
Flag for DELETE ALL DOS SYSTEM Files
58C6PUDRV
DEFM ":N" + 0DH
58C9PDRV
DEFB 00H
Drive Number for the PURGE Command
58CAPW
DEFW 0000H
Hashed Master Password Supplied by the User

58CCH - "LIST" Command.

58CCLIST
LD DE,5BA2HLD DE,SDCB1
Let Register Pair DE equal 5BA2H, which will be a buffer to hold a file control block.
Original Source Code Comment: PLACE TO STORE THE FILE NAME
58CF
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 THE NAME
58D2
If the NZ FLAG (Not Zero) has been set, meaning that the prior CALL routine returned with an ERROR, then JUMP to 521DH.
Original Source Code Comment: EXIT IF ERROR
58D5
PUSH HL
Save the pointer to the current character of the COMMAND LINE (Register Pair HL) to the top of the stack.
Original Source Code Comment: SAVE COMMAND LINE POINTER
58D6
LD HL,0000HLD HL,0
Let Register Pair HL equal 0000H to zero the current record number.
Original Source Code Comment: CLEAR THE RECORD NUMBER
58D9
LD (5B04H),HLLD (RCNUM),HL
Store the 0000H (held in Register Pair HL) into memory location 5B04H to zer the current record number.
58DC
LD DE,5BA2HLD DE,SDCB1
Let Register Pair DE equal 5BA2H, which will be a buffer to hold a file control block.
Original Source Code Comment: DE => FILENAME
58DF
LD HL,5B13HLD HL,FILSAV
Let Register Pair HL equal 5B13H which will be a buffer to hold a filename.
Original Source Code Comment: HL => FILE SAVE AREA
58E2
LD B,19HLD B,25
Prepare for a loop of 25 characters by setting Register B to 19H.
Original Source Code Comment: SET A COUNTER
58E4LIST1
LD A,(DE)
Fetch a character from the FCB (which will be the filename portion of the FCB) held in the memory location pointed to by Register Pair DE and store it into Register A.
Original Source Code Comment: GET A CHARACTER
58E5
CP 20HCP 'SPACE'
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: CONTROL CHAR?
58E7
If the current character of the filename held in the FCB < SPACE then we have run out of valid characters to process and the C FLAG (Carry) will have been set, JUMP to 58EEH.
Original Source Code Comment: YES, EXIT
58E9
LD (HL),A
Store the validated character from the filename from the FCB (held in Register A) into the filename buffer (i.e., the memory location pointed to by Register Pair HL).
Original Source Code Comment: PUT IT IN SAVE AREA
58EA
INC HL
INCrement the filename buffer pointer (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP POINTERS
58EB
INC DE
INCrement the pointer to the filename in the FCB (stored in Register Pair DE) by 1.
58EC
LOOP back to 58E4H, 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 TILL FOUND

We are here either because of a pass through completion of 25 characters or because we hit a character which was not valid.

58EELIST2
LD (HL),09HLD (HL),9
Store an ASCII TAB into the filename buffer pointed to by Register Pair HL.
Original Source Code Comment: STORE A TAB
58F0
INC HL
INCrement the filename buffer pointer (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP TO NEXT SLOT
58F1
LD (HL),03HLD (HL),3
Store an 03H terminator into the filename buffer pointed to by Register Pair HL.
Original Source Code Comment: SET TERMINATOR
58F3
POP HL
Save the pointer to the current character of the COMMAND LINE (held at the top of the stack) into Register Pair HL.
Original Source Code Comment: GET COMMAND LINE POINTER BACK
58F4
LD DE,5B89HLD DE,SWTCH1
Let Register Pair DE equal 5B89H to point to the valid parameter table for LIST command parameters.
Original Source Code Comment: POINT TO LIST OPTION TABLE
58F7
GOSUB to 4454H.
NOTE: 4454H is the DOS PARAMETER STRING PARSE routine. It decodes DOS LIBRARY parameters.
Original Source Code Comment: CHECK SYNTAX
58FA
If the NZ FLAG (Not Zero) has been set, meaning that the prior CALL routine returned with an ERROR, then JUMP to 5219H to display an ILLEGAL PARAMETER error and exit via a JUMP to 5223H.
Original Source Code Comment: EXIT IF SYNTAX ERROR
58FD
LD DE,5BA2HLD DE,SDCB1
Let Register Pair DE equal 5BA2H, which will be a buffer to hold a file control block.
Original Source Code Comment: DE => FILESPEC
5900
LD HL,5D00HLD HL,BUFER1
Let Register Pair HL equal 5D00H for a FILE BUFFER.
Original Source Code Comment: PLACE TO STORE DATA
5903
LD B,00HLD B,0
Let Register B equal 00H so that the next routine will set for FULL SECTOR I/O.
Original Source Code Comment: SET FOR LRL OF 256
5905
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 2 in OVERLAY 3.
Original Source Code Comment: OPEN THE FILE
5908
If the NZ FLAG (Not Zero) has been set, meaning that the prior CALL routine returned with an ERROR, then JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.
Original Source Code Comment: EXIT IF ERROR
590B
LD A,(5BABH)LD A,(SDCB1+LRL)
Fetch the LOGICAL RECORD LENGTH of the selected file (held in memory location 5BABH) and store it into Register A.
Original Source Code Comment: GET THE LRL
590E
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?
590F
If we were NOT set for FULL SECTOR I/O the the NZ FLAG (Not Zero) will have been set, skip the next few instrutions which prepare for a 256 byte LRL by JUMPing over them to 591EH.
Original Source Code Comment: NO, PROCESS IT
5911
LD HL,5B42HLD HL,LRL256
Let Register Pair HL equal 5B42H to point to the text "256".
Original Source Code Comment: HL => '256' MSG
5914
LD DE,5B32HLD DE,LRLSAV
Let Register Pair DE equal 5B32H to point to the middle of the "LRL = nnn" message.
Original Source Code Comment: PLACE TO STORE IT
5917
LD BC,0003HLD BC,3
Let Register Pair BC equal 0003H to loop for the 3 characters of "256".
Original Source Code Comment: NUMBER OF CHARS
591A
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
591C
JUMP to 5938H to continue.
Original Source Code Comment: AND DISPLAY IT

591EH - LIST3 - Continuation "LIST" Command; jumped here if the LRL is not 256.

591ELIST3
LD HL,5B32HLD HL,LRLSAV
Let Register Pair DE equal 5B32H to point to the middle of the "LRL = nnn" message.
Original Source Code Comment: PLACE TO STORE IT
5921
CP 0C8HCP 200
Compare the value held in Register A against C8H (Decimal: 200). Results:
  • If Register A equals a LRL of 200, the Z FLAG is set.
  • If A < a LRL of 200, the CARRY FLAG will be set.
  • if A >= a LRL of 200, the NO CARRY FLAG will be set.

Original Source Code Comment: .GT. LRL OF 200?
5923
If the LRL is less than 200, JUMP to 592CH.
Original Source Code Comment: NO, CONTINUE
5925
LD (HL),32HLD (HL),'2'
Since the LRL is at least 200, fill the first slot of the "nnn" with a "2".
Original Source Code Comment: SET A 2 INTO THE MSG
5927
INC HL
INCrement HL to point to the 2nd n character in the "LRL = nnn" message.
5928
SUB 0C8HSUB 200
SUBtract 200 from Register A so that any additional routine processing the LRL is working with a number less than 200.
Original Source Code Comment: ELIMINATE THE 200 FROM VALUE
592A
JUMP to 5935H.
Original Source Code Comment: AND CONTINUE

592CH - LIST31 - Continuation "LIST" Command; jumped here if the LRL is less than 200.

592CLIST31
CP 64HCP 100
Compare the value held in Register A against 64H (Decimal: 100). Results:
  • If the LRL (held in Register A) equals 100, the Z FLAG is set.
  • If the LRL (held in Register A) < 100, the CARRY FLAG will be set.
  • if If the LRL (held in Register A) >= 100 the NO CARRY FLAG will be set.

Original Source Code Comment: .GT. LRL OF 100?
592E
If the LRL is less than 100, JUMP to 5935H.
Original Source Code Comment: NO, CONTINUE
5930
LD (HL),31HLD (HL),'1'
Since the LRL is at least 100, fill the first slot of the "nnn" with a "1".
Original Source Code Comment: SET A 1 INTO THE MSG
5932
INC HL
INCrement HL to point to the 2nd n character in the "LRL = nnn" message.
Original Source Code Comment: BUMP TO NEXT SLOT
5933
SUB 64HSUB 100
SUBtract 100 from Register A so that any additional routine processing the LRL is working with a number less than 100.
Original Source Code Comment: ELIMINATE THE 100 FROM VALUE

5935H - LIST33 - Continuation "LIST" Command; jumped here if first digit of the LRL was "1" or "2".


5935LIST33
Store the remaining 2 digits of the LRL via a GOSUB to 529DH.
Original Source Code Comment: MAKE IT ASCII

5938H - LIST4 - Continuation "LIST" Command; jumped here to deal with the tens and ones position number of the LRL.


5938LIST4
LD BC,(5B06H)LD BC,(ASCFLG)
Fetch the value held in memory location 5B06H and 5B07H to see if the LIST command is to be output in ASCII and store it into Register Pair BC.
Original Source Code Comment: SEE IF ASCII MODE
593C
593C
LD A,B
OR CCR BC
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.
593E
If the Z FLAG (Zero) has been set, then we are not outputting in ASCII FORMAT, so JUMP to 594BH.
Original Source Code Comment: NO, CONTINUE
5940
LD HL,5B89HLD HL,AMSG
Let Register Pair HL equal 5B89H, to point to the word "ASCII".
Original Source Code Comment: HL => 'ASCII' MSG
5943
LD DE,5B3CHLD DE,RECNUM
Let Register Pair DE equal 5B3CH, to point to the message "REC = 00000".
Original Source Code Comment: DE => SCREEN MSG
5946
LD BC,0005HLD BC,5
Since there are 5 0's to replace, set Register Pair BC equal 0005H.
Original Source Code Comment: NUMBER OF BYTES
5949
LDIR
Replace the "00000" with "ASCII" via a 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: MOVE IT IN
594BLIST41
GOSUB to 01C9H.
NOTE: 01C9H is the Model III ROM routine to to CLEAR THE SCREEN and RETurn.
Original Source Code Comment: CLEAR THE SCREEN
594E
Generate the LIST header via a GOSUB to 5AA5H.
Original Source Code Comment: PRINT THE HEADING
5951
LD A,02HLD A,2
We will want to protect the top 2 lines of the screen during the LIST so set Register A equal 02H.
Original Source Code Comment: SET TO SCROLL PROTECT 2 LINES
5953
LD (4214H),ALD (SCRLCT),A
Scroll protect the top 2 lines of the screen by storing a 2 (held in Register A) into memory location 4214H.
5956
LD BC,(5B06H)LD BC,(ASCFLG)
Fetch the value held in memory location 5B06H and 5B07H to see if the LIST command is to be output in ASCII and store it into Register Pair BC.
Original Source Code Comment: SEE IF ASCII OUTPUT OR REGULAR
595A
595A
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.
595C
If the Z FLAG (Zero) has been set, then we are not outputting in ASCII FORMAT, so JUMP to 59B5H.
Original Source Code Comment: IS REGULAR OUTPUT

If we are here then we are outputting in ASCII Format.

595E
LD HL,5B49HLD HL,CR2
Prepare the LIST to go to a new line by first setting Register Pair HL equal 5B49H.
Original Source Code Comment: OUTPUT 2 CR'S
5961
Move to the new line via a GOSUB to 5286H which outputs a text string pointed to by Register Pair HL to the Screen and, if 5277H is set to 0000H, to the Printer as well.
5964L6OP8
LD DE,5BA2HLD DE,SDCB1
Let Register Pair DE equal 5BA2H, which will be a buffer to hold a file control block.
Original Source Code Comment: POINT TO FILE DCB
5967
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 FROM THE FILE
596A
If the NZ FLAG (Not Zero) has been set, meaning that the prior CALL routine returned with an ERROR, then JUMP to 5998H.
Original Source Code Comment: EXIT IF END OR ERROR
596D
AND 7FH
Turn off the highest bit in Register A by MASKing the value of Register A against 7FH (0111 1111).
Original Source Code Comment: MASK OFF GRAPHICS
596FL6OP8D
CP 09HCP 9
Compare the value held in Register A against 09H (ASCII: TAB). Results: If Register A equals TAB, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: TAB CHAR?
5971
If the character is a TAB then display it and skip to the next via a JUMP to 597FH.
Original Source Code Comment: YES, OUTPUT IT
5973
CP 20HCP 'SPACE'
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: CONTROL CHAR?
5975
If A >= SPACE then display it and skip to the next via a JUMP to 597FH.
Original Source Code Comment: NO, OKAY TO PRINT
5977
CP 0DHCP 13
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: CR?
5979
If the character is a ENTER then display it and skip to the next via a JUMP to 597FH.
Original Source Code Comment: YES, OUTPUT IT
597B
CP 0AHCP 10
Compare the value held in Register A against 0AH (ASCII: LINE FEED). Results: If Register A equals LINE FEED, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: LINE FEED?
597D
If the character is a LINE FEED skip (and do not display it) via a JUMP to 598FH.
Original Source Code Comment: NO, DON'T OUTPUT IT
597FL6OPC8
Output the character held in Register A to the screen and, if applicable, the printer, via a GOSUB to 526FH.
Original Source Code Comment: OUTPUT THE CHAR
5982
CP 0DHCP 13
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?
5984
If the character is NOT a ENTER then JUMP to 598FH.
Original Source Code Comment: NO, CONTINUE
5986
LD BC,(5B08H)LD BC,(SLWFLG)
Fetch the value held in memory location 5B08H-5B09H (which indicate if a SLOW display was requested) and store it into Register Pair BC.
Original Source Code Comment: SEE IF SLOW OUTPUT IS WANTED
598A
598A
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.
598C
If 5B08H does not equal 0, meaning that the user requested a SLOW display, trigger a delay via a GOSUB to 0060H.
Original Source Code Comment: YES, DELAY
598FL6OP8B
GOSUB to 028DH.
NOTE: 028DH is the Model III ROM routine to CHECK FOR BREAK. On exit, the NZ FLAG will be set if BREAK was detected.
Original Source Code Comment: USER HITTING BREAK KEY?
5992
RET NZ
If the BREAK was hit (and the NZ FLAG (Not Zero) has been set), RETurn to the caller.
Original Source Code Comment: EXIT IF SO
5993
Check for a shift-"@" PAUSE via a GOSUB to 525FH.
Original Source Code Comment: SEE IF USER WANTS TO STOP
5996
LOOP BACK to 5964H to process more data.
Original Source Code Comment: AND CONTINUE OUTPUT

5998H - END1 - Continuation "LIST" Command; jumped here if we got an error retrieving the file from disk. Register A will contain the error code.

5998END1
CP 1CHCP EEOF
Compare the value held in Register A against 1CH (END OF FILE ERROR). Results: If the error (held in Register A) equals 1CH (for END OF FILE ERROR), the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: EOF ERROR?
599A
If the Z FLAG (Zero) has been set, handle the ERROR CODE held in Register A via a JUMP to 59A3H.
Original Source Code Comment: YES, EXIT
599C
CP 1DHCP ENRF
Compare the value held in Register A against 1DH (END OF FILE ERROR). Results: If the error (held in Register A) equals 1CH (for END OF FILE ERROR), the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: REC OUT OF RNGE ERROR?
599E
If the Z FLAG (Zero) has been set, handle the ERROR CODE held in Register A via a JUMP to 59A3H.
Original Source Code Comment: YES, EXIT
59A0
JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.
Original Source Code Comment: REPORT ERROR

59A3H - END2 - Continuation "LIST" Command; jumped here if the error we got error retrieving the file from disk was 1CH or 1DH.

.
59A3END2
LD A,(4020H)LD A,(CURSOR)
Fetch the value held in memory location 4020H and store it into Register A.
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
Original Source Code Comment: GET THE CURSOR POSITION
59A6
AND 3FH
Isolate the column number of where the cursor is on screen by MASKing the value of Register A against 3FH (0011 1111), turning off bits 7 and 6.
Original Source Code Comment: MASK FOR ROW ONLY
59A8
If masked cursor position is at the left margin, the Z FLAG (Zero) will have been set, skip the next instructions which move to the left margin via a JUMP to 59AFH.
Original Source Code Comment: BYPASS IF POSITION 0
59AA
LD A,0DH
Let Register A equal 0DH (ASCII: ENTER).
Original Source Code Comment: OUTPUT A CR
59AC
Move to a new line by outputting the character held in Register A to the screen and, if applicable, the printer, via a GOSUB to 526FH.
59AFEND3
LD HL,5B45HLD HL,EOFMSG
Let Register Pair HL equal 5B45H which points to the message "EOF".
Original Source Code Comment: HL => 'EOF' MSG
59B2
Display the "EOF" and exit via a JUMP to 5286H which outputs a text string pointed to by Register Pair HL to the Screen and, if 5277H is set to 0000H, to the Printer as well.
Original Source Code Comment: PRINT AND EXIT

59B5H - LREG - Continuation "LIST" Command; jumped here if the file is to be listed in hex.

59B5LREG
LD HL,5B4BHLD HL,DOTSTR
Let Register Pair HL equal 5B4BH to point to the message "1...5....10...15...20 ..."
Original Source Code Comment: HL => '1...5...10' MSG
59B8
Display that message via a GOSUB to 5286H which outputs a text string pointed to by Register Pair HL to the Screen and, if 5277H is set to 0000H, to the Printer as well.
Original Source Code Comment: DISPLAY IT
59BB
LD A,0DH
Let Register A equal 0DH (ASCII: ENTER).
Original Source Code Comment: OUTPUT ANOTHER CR
59BD
Move to a new line by outputting the character held in Register A to the screen and, if applicable, the printer, via a GOSUB to 526FH.
59C0
LD A,03HLD A,3
We need to scroll protect three lines at the top of the screen so set Register A to equal 03H.
Original Source Code Comment: SET SCROLL TO 3 LINES INSTEAD
59C2
LD (4214H),ALD (SCRLCT),A
Scroll protect the top 3 lines of the display by storing a 3 into memory location 4214H.
59C5LREG1
LD DE,5BA2HLD DE,SDCB1
Let Register Pair DE equal 5BA2H, which will be a buffer to hold a file control block.
Original Source Code Comment: DE => DCB1
59C8
LD HL,5E00HLD HL,BUFER2
Let Register Pair HL equal 5E00H for a FILE BUFFER / DATA STORAGE BUFFER.
Original Source Code Comment: HL => DATA BUFFER IF NOT LRL OF 256
59CB
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
59CE
If the NZ FLAG (Not Zero) has been set, JUMP to 5998H.
Original Source Code Comment: EXIT IF ERROR
59D0
Generate the LIST header via a GOSUB to 5AA5H.
Original Source Code Comment: DISPLAY THE HEADING
59D3
LD HL,(5B04H)LD HL,(RCNUM)
Fetch the record number (held in memory location 5B04H) and store it into Register Pair HL.
Original Source Code Comment: GET THE RECORD NUMBER
59D6
INC HL
INCrement the record number (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP IT
59D7
LD (5B04H),HLLD (RCNUM),HL
Store the bumped record number (held in Register Pair HL) into memory location 5B04H.
Original Source Code Comment: SAVE NEW ONE
59DA
LD A,(5BABH)LD A,(SDCB1+LRL)
Fetch the LRL (held in memory location 5BABH) and store it into Register A.
Original Source Code Comment: GET THE LRL
59DD
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?
59DE
If we are not looking at a FULL SECTOR I/O because the LRL was not 0, JUMP to 59F0H.
Original Source Code Comment: NO, HANDLE SEPERATLY
59E0
LD HL,5D00HLD HL,BUFER1
Let Register Pair HL equal 5D00H for a FILE BUFFER.
Original Source Code Comment: HL => BUFFER
59E3LREG2
LD B,3CHLD B,60
Since a data line is 60 characters, set Register B to 3CH (Decimal: 60).
Original Source Code Comment: SET FOR 60 BYTES PER LINE
59E5
Output Register B number of characters from the FILE BUFFER via a GOSUB to 5A18H.
Original Source Code Comment: OUTPUT A ROW
59E8
If the Z FLAG (Zero) has been set the we need to move to a new disk sector, so JUMP to 59C5H.
Original Source Code Comment: GET ANOTHER BUFFER IF EMPTY
59EA
LD DE,003CHLD DE,60
Let Register Pair DE equal 003CH for the next block of 60 characters.
Original Source Code Comment: NUMBER OF BYTES WE JUST DISPLAYED
59ED
ADD HL,DE
Position HL to the next 60 character block in the 5D00H file buffer.
Original Source Code Comment: HL => NEXT BLOCK TO DISPLAY
59EE
Loop back to 59E3H.
Original Source Code Comment: AND DO IT

59F0H - LREG3 - Continuation "LIST" Command; jumped here if the file is to be listed in hex BUT we are not in FULL SECTOR I/O mode because the LRL was not 256.

59F0LREG3
CP 3DHCP 61
Compare the value held in Register A against 3DH (Decimal: 61). Results:
  • If Register A equals 61, the Z FLAG is set.
  • If A < 61, the CARRY FLAG will be set.
  • if A >= 61, the NO CARRY FLAG will be set.

Original Source Code Comment: GREATER THAN 60?
59F2
If the LRL is at least 61 (meaning, at least one more line), JUMP to 59FDH.
Original Source Code Comment: YES, HANDLE IT
59F4
LD HL,5E00HLD HL,BUFER2
Let Register Pair HL equal 5E00H for a FILE BUFFER / DATA STORAGE BUFFER.
Original Source Code Comment: HL => DATA
59F7LREG4
LD B,A
Let Register B = the number of bytes left in the LRL (which we know is 60 or less).
Original Source Code Comment: NO. USE LRL FOR COUNTER
59F8
Output Register B number of characters via a GOSUB to 5A18H.
Original Source Code Comment: DISPLAY IT
59FB
Loop Back to 59C5H for the next record.
Original Source Code Comment: GO GET THE NEXT RECORD

59FDH - LREG5 - Continuation "LIST" Command; jumped here if the file is to be listed in hex BUT we are not in FULL SECTOR I/O mode AND the LRL is at least 61 characters.

59FDLREG5
LD HL,5E00HLD HL,BUFER2
Let Register Pair HL equal 5E00H for a FILE BUFFER / DATA STORAGE BUFFER.
Original Source Code Comment: HL => DATA TO DISPLAY
5A00LREG6
PUSH AF
Save the remaining byte count (held in Register A) to the top of the stack.
Original Source Code Comment: SAVE THE LRL
5A01
LD B,3CHLD B,60
Let Register B equal 3CH (Decimal: 60).
Original Source Code Comment: SET FOR 60
5A03
Output Register B number of characters via a GOSUB to 5A18H.
Original Source Code Comment: DISPLAY IT
5A06
POP AF
Restore the remaining byte count from the top of the STACK back into Register Pair AF, and then remove the entry from the stack.
Original Source Code Comment: GET THE LRL BACK
5A07
SUB 3CHSUB 60
SUBtract the value 3CH from Register A.
Original Source Code Comment: ELIMINATE THE COUNT WE JUST OUTPUT
5A09
If the C FLAG (Carry) has been set, JUMP to 59C5H.
Original Source Code Comment: WE'RE DONE THIS ONE
5A0C
PUSH AF
Save the remaining byte count (held in Register A) to the top of the stack.
Original Source Code Comment: SAVE THE VALUE
5A0D
5A0F
5A10
LD A,3CH
ADD A,L
LD L,ALD A,60
Let the location in the file buffer (held in HL) = HL + 60 bytes.
Original Source Code Comment: NUMBER WE JUST DID
5A11
POP AF
Restore the remaining byte count from the top of the STACK back into Register Pair AF, and then remove the entry from the stack.
Original Source Code Comment: GET THE LRL BACK
5A12
CP 3DHCP 61
Compare the remaining byte count (held in Register A) against 3DH (Decimal: 61). Results:
  • If Register A equals 61, the Z FLAG is set.
  • If A < 61, the CARRY FLAG will be set.
  • if A >= 61, the NO CARRY FLAG will be set.

Original Source Code Comment: 60 OR LESS NOW?
5A14
If there is 61 bytes or less left, the C FLAG (Carry) will have been set, JUMP to 59F7H to deal with that.
Original Source Code Comment: YES, DISPLAY LAST BUFFER
5A16
If there are at least 61 bytes, LOOP back to to 5A00H to keep processing bytes.
Original Source Code Comment: DO ANOTHER ONE

5A18H - DSPROW - Output Register B number of characters in ALPHA and HEX. On Entry: HL = the position in the FILE BUFFER to display, B = the number of characters to output

5A18DSPROW
LD C,03HLD C,3
We are going to need to make 3 passes so set Register C equal 03H.
Original Source Code Comment: SET FOR 3 PASSES
5A1ADSPRO1
PUSH BC
Save the number of characters to output (held in Register B) to the top of the stack.
Original Source Code Comment: SAVE THE NUMBER OF BYTES PER LINE
5A1B
PUSH HL
Save the position in the FILE BUFFER to display (held in Register Pair HL) to the top of the stack.
Original Source Code Comment: SAVE BUFFER POINTER
5A1C
LD A,C
Copy the pass counter (held in Register C) into Register A.
Original Source Code Comment: GET THE PASS COUNT
5A1D
CP 03HCP 3
Check to see if this is the FIRST pass by compare the pass counter (held in Register A) against 03H. Results: If Register A equals 03H, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: PASS 3?
5A1F
If this is NOT the first pass, JUMP to 5A36H.
Original Source Code Comment: NO, TRY PASS 2
5A21DSPRO2
LD A,(HL)
Fetch the character to output from (HL) into Register A.
Original Source Code Comment: GET THE CHARACTER
5A22
CP 20HCP 'SPACE'
Test if this is a control character by comparing it against 20H. If the character is < 20H, the CARRY FLAG will be set ...
Original Source Code Comment: CONTROL CHAR
5A24
... and we will JUMP to 5A2AH to display a ".".
Original Source Code Comment: YES, DO A DOT
5A26
CP 7BHCP 'z'+1
Test if this is a regular character by comparing it against 7BH. If the character is < 7BH, the CARRY FLAG will be set ...
Original Source Code Comment: LEGAL ASCII?
5A28
... and we will JUMP to 5A2AH to display the character held in Register A.
Original Source Code Comment: YES, OUTPUT IT
5A2ADOT
LD A,2EHLD A,'.'
Let Register A equal to a ..
Original Source Code Comment: CHANGE IT TO A DOT
5A2CNODOT
Outputting the character held in Register A to the screen and, if applicable, the printer, via a GOSUB to 526FH.
Original Source Code Comment: OUTPUT THE BYTE
5A2F
INC L
Move to the next character by INCrementing the value stored in Register L by 1.
Original Source Code Comment: BUMP TO NEXT CHARACTER
5A30
Did we move past the end of the sector? If Register L hit 0 then we did, and so we must jump to 5A56H.
Original Source Code Comment: EXIT IF END OF BUFFER
5A32
LOOP back to 5A21H for "B" characters, 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
5A34
Continue the routine by JUMPing to 5A56H.
Original Source Code Comment: DO NEXT PASS

5A36H - DSPRO3 - Output Register B number of characters in ALPHA and HEX; SECOND PASS.

5A36DSPRO3
CP 02HCP 2
Check to see if this is the FIRST pass by compare the pass counter (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: PASS 2?
5A38
If this is NOT the second pass, JUMP to 5A4DH.
Original Source Code Comment: NO, DO PASS 1
5A3ADSPRO4
LD A,(HL)
Fetch the character to output from (HL) into Register A.
Original Source Code Comment: GET THE BYTE
5A3B
5A3D
5A3F
5A41
SRL A
SRL A
SRL A
SRL ASRL A
Shift the LEFT NYBBLE (xxxx nnnn) to the RIGHT NYBBLE (0000 xxxx).
Original Source Code Comment: PUT MSB INTO LSB
5A43
Output Register A (which will be the prior LEFT NYBBLE) in HEX via a GOSUB to 5293H.
Original Source Code Comment: CONVERT IT TO ASCII
5A46
INC L
Move to the next character by INCrementing the value stored in Register L by 1.
Original Source Code Comment: BUMP TO NEXT CHAR
5A47
Did we move past the end of the sector? If Register L hit 0 then we did, and so we must jump to 5A56H.
Original Source Code Comment: EXIT IF END OF BUFFER
5A49
LOOP back to 5A3AH for "B" characters, 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
5A4B
Continue the routine by JUMPing to 5A56H.
Original Source Code Comment: DO NEXT BLOCK

5A4DH - DSPRO5 - Output Register B number of characters in ALPHA and HEX; THIRD PASS.

5A4DDSPRO5
LD A,(HL)
Fetch the character to output from (HL) into Register A.
Original Source Code Comment: GET A BYTE
5A4E
Output Register A (which will be the RIGHT NYBBLE) in HEX via a GOSUB to 5293H.
Original Source Code Comment: CONVERT IT TO ASCII
5A51
INC L
Move to the next character by INCrementing the value stored in Register L by 1.
Original Source Code Comment: BUMP TO NEXT CHAR
5A52
Did we move past the end of the sector? If Register L hit 0 then we did, and so we must jump to 5A56H.
Original Source Code Comment: EXIT IF END OF BUFFER
5A54
LOOP back to 5A4DH for "B" characters, 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

We have done the 3 passes - the letter, the left nybble, and the right nybble.

5A56DSPRO6
LD A,0DH
Let Register A equal 0DH (ASCII: ENTER).
Original Source Code Comment: OUTPUT A NEW LINE
5A58
Output the character held in Register A to the screen and, if applicable, the printer, via a GOSUB to 526FH.
5A5B
POP DE
Put the DATA ADDRESS (held at the top of the STACK) into Register Pair DE, and then remove the entry from the stack.
Original Source Code Comment: GET THE BUFFER POINTER BACK
5A5C
POP BC
Put the BYTE TO DISPLAY COUNT and PASS 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 COUNT BACK
5A5D
DEC C
DECrement the pass counter (stored in Register C) by 1.
Original Source Code Comment: DEC THE PASS NUMBER
5A5E
If we have done all passes, JUMP to 5A63H.
Original Source Code Comment: TIME TO EXIT
5A60
EX DE,HL
Put the DATA ADDRESS into Register Pair HL.
Original Source Code Comment: BUFFER POINTER TO HL
5A61
LOOP back to 5A1AH for another pass.
Original Source Code Comment: AND DO IT AGAIN

5A63H - DSPRO7 - Output Register B number of characters in ALPHA and HEX; after 3 passes.

5A63DSPRO7
LD A,L
Copy the position in the DATA RECORD (held in Register L) into Register A.
Original Source Code Comment: GET THE LSB OF BUFFER POINTER
5A64
EX DE,HL
Reset the DATA RECORD address.
Original Source Code Comment: OLD POINTER TO HL
5A65
OR A
Determine if we are at the end of the sector by setting the FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
Original Source Code Comment: SET THE FLAGS 'Z' OR 'NZ'
5A66DSPRO9
PUSH BCSAVE 4
Save the contents of Register Pair BC to the top of the stack.
Original Source Code Comment: SAVE THE REGISTERS
5A67
PUSH DE
Save the contents of Register Pair DE to the top of the stack.
5A68
PUSH HL
Save the contents of Register Pair HL to the top of the stack.
5A69
PUSH AF
Save the contents of Register Pair AF to the top of the stack.
5A6A
LD B,3CHLD B,60
We want to output 60 "-"'s so Let Register B equal 3CH (Decimal: 60).
Original Source Code Comment: SET A COUNTER
5A6CDSPROA
LD A,2DHLD A,'-'
Let Register A equal 2DH (ASCII: -).
Original Source Code Comment: OUTPUT A DASH
5A6E
PUSH BC
Save the dash counter (held in Register B) to the top of the stack.
Original Source Code Comment: SAVE THE COUNTER
5A6F
Output the character held in Register A to the screen and, if applicable, the printer, via a GOSUB to 526FH.
Original Source Code Comment: OUTPUT IT
5A72
POP BC
Put the dash 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 THE COUNTER
5A73
LOOP back to 5A6CH, 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
5A75
LD A,0DH
Let Register A equal 0DH (ASCII: ENTER).
Original Source Code Comment: NEW LINE
5A77
Output the character held in Register A to the screen and, if applicable, the printer, via a GOSUB to 526FH.
5A7A
LD BC,(5B08H)LD BC,(SLWFLG)
Fetch the value held in memory location 5B08H-5B09H (which indicate if a SLOW display was requested) and store it into Register Pair BC.
Original Source Code Comment: USER WANT SLOW FUNCTION?
5A7E
5A7E
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.
5A80
If 5B08H does not equal 0, meaning that the user requested a SLOW display, trigger a delay via a GOSUB to 0060H.
Original Source Code Comment: YES, GIVE IT TO HIM
5A83
Check for a shift-"@" PAUSE via a GOSUB to 525FH.
Original Source Code Comment: SEE IF HOLDING '@' KEY DOWN
5A86
GOSUB to 028DH.
NOTE: 028DH is the Model III ROM routine to CHECK FOR BREAK. On exit, the NZ FLAG will be set if BREAK was detected.
Original Source Code Comment: USER HITTING BREAK KEY?
5A89
If the BREAK was hit then the NZ FLAG (Not Zero) will have been set, JUMP to 4030H.
NOTE: 4030H is the OPERATION ABORTED routine. Routine runs, displays an error, and returns to the DOS PROMPT.
Original Source Code Comment: YES, EXIT
5A8C
POP AFEXIT 4
Put the value held at the top of the STACK into Register Pair AF, and then remove the entry from the stack.
Original Source Code Comment: RESTORE AND EXIT
5A8D
POP HL
Put the value held at the top of the STACK into Register Pair HL, and then remove the entry from the stack.
5A8E
POP DE
Put the value held at the top of the STACK into Register Pair DE, and then remove the entry from the stack.
5A8F
POP BC
Put the value held at the top of the STACK into Register Pair BC, and then remove the entry from the stack.
5A90
RET
RETurn to the caller.

5A91H - SPACIT - Part of the routine to output a Byte held in Register A to the Screen and, if 5277H is set to 0000H, to the Printer; JUMPED to if we have a TAB character.

5A91SPACIT
LD A,(4020H)LD A,(CURSOR)
Fetch the value held in memory location 4020H and store it into Register A.
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
Original Source Code Comment: GET THE CURSOR LSB

The next 3 instructions are fancy math to take a screen position and determine how many spaces are needed to get to the next tab stop.

5A94
CPL
Reverse each bit in Register A (which is the same as NOT).
Original Source Code Comment: GET THE COMPLIMENT
5A95
AND 07HAND 7
Isolate the lowest 3 bits by MASKing the value of Register A against 07H (0000 0111).
Original Source Code Comment: MASK FOR BOUNDARY OF 8
5A97
INC A
INCrement the value stored in Register A by 1.
Original Source Code Comment: ZERO NOT ALLOWED
5A98
PUSH BC
Save the contents of Register Pair BC to the top of the stack.
Original Source Code Comment: SAVE BC
5A99
LD B,A
Set the tab counter by copying the contents of Register A into Register B.
Original Source Code Comment: PUT INTO B FOR COUNTER
5A9ASPACI0
PUSH BC
Save the counter (held in Register Pair BC) to the top of the stack.
Original Source Code Comment: SAVE COUNT
5A9B
LD A,20HLD A,' '
Let Register A equal 20H (ASCII: SPACE).
Original Source Code Comment: LOAD A SPACE CHAR
5A9D
Output the character held in Register A to the screen and, if applicable, the printer, via a GOSUB to 526FH.
Original Source Code Comment: OUTPUT IT
5AA0
POP BC
Restore the 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 COUNT BACK
5AA1
LOOP back to 5A9AH, 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
5AA3
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: GET BC BACK
5AA4
RET
RETurn to the caller.

5AA5H - PRTHED - Generate the LIST header.

5AA5PRTHED
PUSH BCSAV3
Save the contents of Register Pair BC to the top of the stack.
5AA6
PUSH DE
Save the contents of Register Pair DE to the top of the stack.
5AA7
PUSH HL
Save the contents of Register Pair HL to the top of the stack.
5AA8
LD HL,(4020H)LD HL,(CURSOR)
Fetch the value held in memory location 4020H and store it into Register Pair HL.
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
Original Source Code Comment: GET THE CURSOR POSITION
5AAB
LD A,H
Copy the MSB of the cursor position (held in Register H) into Register A.
Original Source Code Comment: GET THE MSB
5AAC
CP 3CH
Check to see if the cursor is in the first quarter of the screen by comparing the value held in Register A against 3CH. NZ will be set if NOT ...
Original Source Code Comment: WE AT TOP OF SCREEN?
5AAE
... at which point we skip the next instructions and JUMP to 5AB9H.
Original Source Code Comment: NO, CONTINUE
5AB0
LD A,L
Copy the line number that the cursor is on (held in the LSB of the cursor position) into Register A.
Original Source Code Comment: GET THE LSB
5AB1
CP 30H
See if the cursor is after column 48 by comparing the value held in Register A against 30H (Decimal: 48). NC will be set if the column >= 48 ...
Original Source Code Comment: TOP ROW?
5AB3
... and we will skip the next instructions and also JUMP to 5AB9H.
Original Source Code Comment: NO, CONTINUE
5AB5
LD DE,0040HLD DE,64
Set Register Pair DE to a full screen line by setting to 0040H (Decimal: 64).
Original Source Code Comment: BUMP TO NEXT ROW
5AB8
ADD HL,DE
Move the cursor one line down by adding a full screen line (held in DE) to the cursor position (held in HL).
5AB9PRTHE1
PUSH HL
Save the new cursor position (held in Register Pair HL) to the top of the stack.
Original Source Code Comment: SAVE IT
5ABA
LD HL,3C00H
Home the cursor by letting Register Pair HL equal 3C00H.
Original Source Code Comment: START OF SCREEN
5ABD
LD (4020H),HLLD (CURSOR),HL
Store the value held in Register Pair HL into memory location 4020H.
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
Original Source Code Comment: NEW CURSOR
5AC0
LD BC,(5B06H)LD HL,(ASCFLG)
Fetch the value held in memory location 5B06H and 5B07H to see if the LIST command is to be output in ASCII and store it into Register Pair BC.
Original Source Code Comment: WE IN ASCII MODE?
5AC3
5AC4
LD A,B
OR CCR HL
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.
5AC5
If ASCII was requested, skip the next instructions and JUMP to 5AE1H.
Original Source Code Comment: YES, DON'T PUT UP RECORD NUMBER
5AC7
LD HL,(5B04H)LD HL,(RCNUM)
Fetch the record number (held in memory location 5B04H) and store it into Register Pair HL.
Original Source Code Comment: GET THE RECORD NUMBER
5ACA
INC HL
INCrement the value stored in Register Pair HL by 1.
Original Source Code Comment: CORRECT FOR 1'S OFFSET
5ACB
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: LET BASIC CONVERT TO ASCII
5ACE
XOR A
Set Register A to ZERO and clear all Flags.
5ACF
GOSUB to 1034H.
NOTE: 0A9AH is the Model III ROM routine to initializes the input buffer for an ASCII conversion.
5AD2
OR (HL)
Set the NZ Flag.
5AD3
GOSUB to 0FD9H..
NOTE: 0A9AH is the Model III ROM routine to convert the integer value in REG 1 to an ASCII string. Return with register pair HL pointing to the result.
5AD6
LD HL,4131H
Let Register Pair HL equal 4131H which is where the ASCII converted text is stored.
Original Source Code Comment: HL => ASCII NUMBER
5AD9
LD DE,5B3CHLD DE,RECNUM
Let Register Pair DE equal 5B3CH, to point to the message "REC = 00000".
Original Source Code Comment: DE => WHERE IT BELONGS
5ADC
LD BC,0005HLD BC,5
Since there are 5 0's to replace, set Register Pair BC equal 0005H.
Original Source Code Comment: 5 CHARS
5ADF
LDIR
Replace the "00000" with the ASCII converted text via a 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: MOVE IT
5AE1PRTH11
LD HL,5B0CHLD HL,FILNAM
Let Register Pair HL equal 5B0CH to point to the filename and a TAB.
Original Source Code Comment: HL => SAVED FILE NAME
5AE4
GOSUB to 5286H which outputs a text string pointed to by Register Pair HL to the Screen and, if 5277H is set to 0000H, to the Printer as well.
Original Source Code Comment: DISPLAY IT
5AE7
LD HL,3C20HLD HL,3C00H+32
Position the cursor to position 32 by setting Register Pair HL equal 3C20H.
Original Source Code Comment: SET FOR MIDDLE OF SCREEN
5AEA
LD (4020H),HLLD (CURSOR),HL
Store the value held in Register Pair HL into memory location 4020H.
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
5AED
LD HL,5B2CHLD HL,FILLRL
Let Register Pair HL equal 5B2CH to point to "LRL = NNNN REC = NNNNN".
Original Source Code Comment: HL => LRL AND REC NUMBER
5AF0
GOSUB to 5286H which outputs a text string pointed to by Register Pair HL to the Screen and, if 5277H is set to 0000H, to the Printer as well.
Original Source Code Comment: DISPLAY IT
5AF3
LD A,(5277H)LD A,(LPFLAG)
Fetch the send-List-to-printer-too flag (held in memory location 5277H) and store it into Register A.
Original Source Code Comment: GET THE LINE PRINTER FLAG
5AF6
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: OUTPUT TO LINE PRINTER?
5AF7
LD A,0DH
Let Register A equal 0DH (ASCII: ENTER).
Original Source Code Comment: LOAD A CR IN CASE
5AF9
If the NZ FLAG (Not Zero) has been set, GOSUB 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.
Original Source Code Comment: YES. OUTPUT THE CR
5AFC
POP HL
Restore the cursor position (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 CURSOR POSITION BACK
5AFD
LD (4020H),HLLD (CURSOR),HL
Store the value held in Register Pair HL into memory location 4020H.
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
5B00
POP HLEXI3
Put the value held at the top of the STACK into Register Pair HL, and then remove the entry from the stack.
5B01
POP DE
Put the value held at the top of the STACK into Register Pair DE, and then remove the entry from the stack.
5B02
POP BC
Put the value held at the top of the STACK into Register Pair BC, and then remove the entry from the stack.
5B03
RET
RETurn to the caller.

5B04H - RCNUM - "LIST" command MESSAGE and BYTE STORAGE.

5B04RCNUM
DEFW 0000H
Record Number storage space during a HEX dump.
Original Source Code Comment: RECORD NUMBER
5B06ASCFLG
DEFW 0000H
ASCII Format Flag
Original Source Code Comment: FLAG FOR ASCII OUTPUT
5B08SLWFLG
DEFW 0000H
Slow List Flag
Original Source Code Comment: FLAG FOR SLOW OUTPUT
5B0ADATA1
DEFW 0000H
Doesn't seem to be used.
Original Source Code Comment: NRN STORED HERE
5B0CFILNAM
DEFM "FILE = FILENAME/EXT:D" + 09H + 03H
5B2CFILLRL
DEFM "LRL = 00 " + 09H + "REC = 00000" + 03H
5B42LRL256
DEFM "256"
Full Sector LRL
5B45EOFMSG
DEFM "EOF" + 0DH
End of Text File Message
5B49CR2
DEFW 0AH 0DH
Line Feed / Carriage Return.
5B4C
DEFM "1...5....10...15...20...25...30 ... 60" + 0DH

5B89H - AMSG - "LIST" command PARAMETER TABLE.

5B89AMSG
DEFM "ASCII "
5B91
DEFM "SLOW "
5B99
DEFM "PRT "
5BA1
DEFB 00H
End of Table

5BA2H - RCNUM - General BYTE STORAGE.

5BA2SDCB1
DEFS 60H
97 byte storage location, used mostly for File Control Block storage.
Original Source Code Comment: DCB 1
5D00BUFER1
DEFS FFH
256 byte storage location, used mostly as a Disk I/O Buffer for SYSTEM Use.
Original Source Code Comment: BUFFER 1
5E00BUFER2
DEFS FFH
256 byte storage location, used mostly as a Disk I/O Buffer for Program Use.
Original Source Code Comment: BUFFER 2

5F00H - SYST - Dummy image for a system if PURGE killed all the system files.

5F00SYST
LD BC,0021H
Set up for a code block of 33 bytes
5F02
ORG 4D00H
Loading address will be 4D00H
5F04NOSYS
(4D00H) LD A,17HLD A,23
Prepare to LARGE CHARACTERS
Original Source Code Comment: MAKE 32 CHARACTER MODE
5F06
(4D02H) CALL 0033HCALL DSP
Display the 17H held in Register A
Original Source Code Comment: DISPLAY IT
5F09
(4D05H) LD HL, 4D0DHLD HL,SYSTMG
Point to "NOT A SYSTEM DISK" message
Original Source Code Comment: HL => NO SYSTEM MSG
5F0C
(4D08H) CALL 021BHCALL PRINT
Display "NOT A SYSTEM DISK" message
Original Source Code Comment: PRINT IT ON THE SCREEN
5F0FNOSYS1
(4D0BH) JR 4D0FHJR NOSYS1
Infinite Loop
Original Source Code Comment: LOOP
5F11SYSTMG
(4D0DH) DEFM "NOT A SYSTEM DISK" + 0DH
5F23RIGHT
02H 02H
EXECUTION ADDRESS of 2 BYTES follows
5F25
00 4DH
Execute at 4D00H