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

Overview

1. Program Overview

SYS6 is the TRSDOS 1.3 DOS Command Handler overlay for the TRS-80 Model III. It is a demand-loaded overlay residing in the SYSHI (high-system) PSECT, mapped to addresses 5200H–623DH. SYS6 is not resident in memory at all times; it is loaded by SYS0 whenever the user invokes any of the nineteen DOS commands it services.

On entry, Register C holds the order number of the requested command (matched against the TABCOM jump table), and Register Pair HL points to the remainder of the command line supplied by the user. SYS6 dispatches to the appropriate command handler via GETTAB/TABCOM, then returns control to the caller or to the DOS error handler as appropriate.

The nineteen commands handled by SYS6 are: APPEND, ATTRIB, AUTO, BUILD, CLEAR, CLOCK, CREATE, DATE, DIR, DO, DUMP, ERROR, FREE, LIB, LOAD, PAUSE, PROT, RENAME, and TIME. CLOCK, CLOCKN, and CLOCKF are forwarded to ROM routines; LIB lists available SYS1-resident library commands from the TABCOM table. LOAD uses the SYS0 program loader (LDPGM). The DO command installs a replacement keyboard DCB driver in high RAM to replay a .BLD script file as simulated keyboard input.

2. Memory Map

Address RangeLabelDescription
5200H–623DHSYS6 / SYSHIEntire SYS6 overlay (assembled at ORG 5200H, END 5200H)
5200HBEGINEntry point — command dispatcher
529BHGETTABTable-search routine
52A8HTABCOMCommand jump table (19 DCF entries + terminator)
52F6H (approx.)AUTOAUTO command handler
S6BUF3S6BUF364-byte (40H) scratch buffer (DEFS 40H)
S6DCB1S6DCB1Primary file DCB (DEFS DCBSIZ)
S6DCB2S6DCB2Secondary file DCB (immediately follows S6DCB1)
S6BUF1S6BUF1256-byte sector buffer (ORG aligned to 256-byte boundary)
S6BUF2S6BUF2Second 256-byte sector buffer (S6BUF1 + 256)

3. Self-Modifying Code Variables and Workspace Locations

SYS6 makes heavy use of self-modifying code — immediate operand bytes within instructions serve as in-place storage for runtime values. These locations are internal to the overlay and are NOT recorded in the global RAM JSON. The table below documents all such locations identified from the source.

LabelSource PatternDescription
AUTDRVEQU $+1 / LD C,0Drive number for AUTO command (self-modifying byte in LD C,n)
LPFLAGEQU $+1 / LD BC,0Line-printer flag for DIR and FREE output routing
S6DLFNEQU $+1 / LD B,0DIR command: current directory LFN counter
S6DDRVEQU $+1 / LD C,0DIR command: current drive number
PNTBUFEQU $+1 / LD HL,0DIR command: rolling pointer into hash-code buffer
SYSEQU $+1 / LD DE,0DIR command: user's "show SYS files" switch
S6INVEQU $+1 / LD DE,0DIR command: user's "show invisible files" switch
SAVMTHEQU $+1 / LD A,0DIR: creation month saved for display
SAVYREQU $+1 / LD A,0DIR: creation year saved for display
LRL2EQU $+1 / LD A,0DIR: logical record length saved for record-count calculation
S6EOFEQU $+1 / LD L,0DIR: EOF byte saved for record-count calculation
DRV3EQU $+1 / LD C,0PROT command: drive number
INPPASEQU $+1 / LD DE,0PROT command: pointer to entered old password hash
PWEQU $+1 / LD DE,0PROT command: new password hash (from SWITCH parse)
LOCKEQU $+1 / LD DE,0PROT command: lock password hash
PASSWEQU $+1 / LD DE,0PROT command: user-supplied hash to write to directory
BUFSAVEQU $+1 / LD HL,0PROT command: rolling pointer through directory buffer
STATEQU $+1 / LD D,0ATTRIB command: attribute OR-mask to apply
STAT1EQU $+1 / OR 0ATTRIB command: protection-level value to OR in
ISTATEQU $+1 / OR 0ATTRIB command: invisible-bit OR-mask
ISTAT1EQU $+1 / AND 0FFHATTRIB command: invisible-bit AND-mask (for clearing)
RELO1 / STARTEQU $+1 / LD HL,0DUMP command: modified start address (self-modifying LD HL,nn)
RELOEQU $+2 / LD IY,0DUMP command: relocation base address (self-modifying LD IY,nn)
ENDEQU $+1 / LD HL,0DUMP command: ending address
TRAEQU $+1 / LD HL,0DUMP command: transfer address written to CMD file
TMPDCBEQU $+1 / LD DE,0DO command: temporary DCB pointer during setup
GODCBEQU $+1 / LD DE,0DO command: DCB pointer stored in the GOGO1 keyboard stub
LOWRAMEQU $+1 / LD DE,0CLEAR command: lower address of range to clear
HIGRAMEQU $+1 / LD HL,0CLEAR command: upper address of range to clear
NEWMEMEQU $+1 / LD HL,0CLEAR command: new MEMEND value if MEM option given
S6LRLEQU $+1 / LD BC,0CREATE command: parsed LRL value
NRECSEQU $+1 / LD BC,0CREATE command: parsed record count
HEXADD(label on DEFM '0000')CLEAR/DUMP: 4-byte ASCII hex address in "MEMORY FAULT AT X" message
DCOUNTDEFB 0DUMP command: residual byte count for partial sector
NAMFILDEFW 0 × 4 / DEFB 0DUMP command: 9-byte filename scratch area
BINDEFB 0 / DEFW 0DATE/TIME conversion: 3-byte binary result buffer
NAME1DEFS 10HRENAME command: 16-byte buffer for old filename
NAME2DEFS 10HRENAME command: 16-byte buffer for new filename
BUFPNTDEFW 0Miscellaneous buffer pointer (reserved word)
COUNTDEFB 0FREE command: current track counter
CDIRETDEFB 0FREE command: directory track number (from TRKGET)
DPRT1/DPRT2/DPRT3DEFM '00'/'00'/'00~'DATE/TIME display: three two-digit ASCII fields
DELIM1/DELIM2DEFM ':'DATE/TIME display: delimiter characters (patched to '/' for date)
GOSAVE(referenced in DO)DO command: saved original keyboard DCB driver address
DOFLAG(referenced in DO/CLEAR/PAUSE)DO active flag (FFH = active, 0 = inactive) — in external RAM

4. Major Routine List

LabelDescriptionEntry / Exit Conditions
BEGINMain entry point — command dispatcher. Saves command line pointer, clears FLAG1/SCAFLG/BASICG, calls GETTAB to look up command in TABCOM, then returns into the command via EX (SP),HL / RET.Entry: C = command order number, HL → command line. Exit: falls through to command, or jumps to error handler.
BEGIN1Continuation for "command not found" path — pops HL and falls into ERR2.Entry: called from BEGIN on C flag set by GETTAB.
ERR1FILE ALREADY EXISTS error (28H / EFAT).Loads A = 28H, jumps to ERRX → ERR (SYS0).
ERR2ILLEGAL PARAMETER error (0BH / ERICP).Loads A = 0BH, jumps to ERRX.
ERR3MISSING PARAMETER error (0AH / ERCPM).Loads A = 0AH, jumps to ERRX.
ERR4ACCESS DENIED error (19H / EFAD).Loads A = 19H, jumps to ERRX.
ERR5Displays "End less than Start" message.HL → MES5, jumps to ERRY → PRINT.
ERR6Displays "Start less than 6000~" message.HL → MES6, jumps to ERRY.
ERR7Displays "Memory fault at X nnnn" message.HL → BADRAM, jumps to ERRY. Address filled in by HEXS into HEXADD.
ERR9DISK DRIVE NOT IN SYSTEM error (02H / EDNS).Loads A = 02H, jumps to ERRX.
ERR13Displays "LRL of Files Do NOT Match~" message.HL → BADLRL, jumps to ERRY.
ERRXCommon error jump to SYS0 ERR routine.Entry: A = error code. JP ERR (SYS0 at 6132H).
ERRYCommon message print and return.Entry: HL → message. JP PRINT (SYS0).
GETTABSearches TABCOM for a matching command order number. Each entry is a 3-byte DCF record: [order-byte][addr-low][addr-high]. Scans sequentially until match or 0 terminator.Entry: C = order number, HL → TABCOM. Exit: NZ+NC with HL = command address on match; SCF (carry set) if not found.
TABCOMJump table — 19 DCF macro entries, each 3 bytes: command order code byte + 16-bit handler address. Terminated by DEFB 0.Read-only data; searched by GETTAB.
AUTOAUTO command — reads or writes the auto-start command in the disk GAT sector. Optionally accepts a drive specifier and a command name. Pads command to 32 bytes and writes via WRGAT.Entry: HL → command line. Uses RDGAT/WRGAT (SYS0). Displays "Auto = <command>" or "Auto = ~" if cleared.
S6DATEDATE command — displays current date or updates it. Parses MM/DD/YY via CONV1/DECBIN. Validates ranges. Stores into YEAR/DTSAVE (SYS0 RAM).Entry: HL → command line, C = '/'. Exit: RET or JP ERR2.
S6TIMETIME command — displays current time or updates it. Parses HH:MM:SS via CONV1/DECBIN. Validates ranges. Stores into SECOND (SYS0 RAM).Entry: HL → command line, C = ':'. Exit: RET or JP ERR2.
CLOCKCLOCK command — calls SYS1 CHKFLG to determine ON/OFF, then dispatches to ROM CLOCKF or CLOCKN.Entry: HL → command line. Forwards to ROM clock routines.
CONV1Decimal-to-binary conversion for 3-field values (date and time). Calls DECBIN twice per field, stores result into BIN+2 downward.Entry: HL → ASCII string, C = delimiter, DE → BIN+2. Exit: Z on success, NZ on syntax error.
DECBINConverts two ASCII decimal digits at (HL) to a binary value.Entry: HL → digit string. Exit: A = value (0–99), Z on success, NZ on error.
DECCHKReads one character from (HL), subtracts 30H. Returns NC if not a decimal digit.Entry: HL → character. Exit: A = digit value; carry clear if not numeric.
LIBLIB command — iterates through TABCOM and prints the first 6 characters of each command name, 8 per row.Entry: none. Calls DSP (SYS0) for each character.
S6PROTPROT command — changes the master disk password. Reads old password via MASINP/RDGAT, verifies it matches, prompts for new password, writes via WRGAT. Optionally locks all unprotected files.Entry: HL → command line. Uses RDGAT, WRGAT, SREAD, XWRITE (SYS0).
MASINPReads up to 8 characters of keyboard input into BUFF1, then calls TRAP to compute the trap-door hash.Exit: HL = computed hash code.
TRAP / SETTDCComputes a two-byte trap-door hash code from an 8-character password string. Used for master password and file access/update passwords.Entry: DE → password string, B = length. Exit: HL = hash. Returns NZ if hash would be zero (increments L).
RENAMERENAME command — checks protection level (must be < write = level 3), moves names to DCBs, verifies old file exists and new name does not, updates directory record and hash table.Entry: HL → command line. Calls GETSYN, OPEN, RDDIR, WRDIR, RDHIT, WRHIT, HASH, DSPNAM.
MOVNAMCopies a filename from a DCB (DE) into a buffer (HL) until a control character is encountered, then appends a 03H terminator.Entry: HL → dest, DE → DCB name field.
DSPNAMDisplays "oldname ---> newname CR" using PRINT (SYS0).Uses NAME1, NAMARO, NAME2 data strings.
APPENDAPPEND command — opens two files, verifies their LRLs match, positions to EOF of the destination, copies all bytes from source to destination.Entry: HL → command line. Calls GETSYN, SYNTAX, OPEN, OPENIT, POSEOF, GET, PUT, CLOSE.
DUMPDUMP command — creates a CMD-format load file containing a memory range. Accepts START, END, TRA, RELO parameters. Writes load-format records (type 01) followed by an end record (type 02). Includes a remark record (type 05) with filename and date.Entry: HL → command line. Uses SWITCH, GETSYN, INIT, CLOSE, PUTIT, PUT (SYS0).
PUTITIncrements the DCOUNT residual count and writes one byte to disk via PUT (SYS0).Entry: A = byte to write.
CREATECREATE command — initialises a new file with optional LRL and REC count parameters. Optionally pre-extends the file to the specified number of records.Entry: HL → command line. Calls GETSYN, SWITCH, CONVHX, INIT, POSN, WRITE, CLOSE.
CONVHXConverts a BCD value (from SWITCH parsing) to a 16-bit binary integer using a POWR10 lookup table.Entry: HL = BCD value. Exit: HL = binary value.
CLEARCLEAR command — with no parameters, tests and clears RAM from S6DCB1 to MEMEND; with START/END parameters, clears a specified range; with MEM parameter, resets MEMEND. Detects and reports bad RAM via ERR7.Entry: HL → command line. Calls SWITCH (SYS0), CLS (SYS0).
BUILDBUILD command — creates a .BLD script file by accepting keyboard input line by line (up to 63 chars per line) until BREAK is pressed, then writes a terminating FFH byte and closes the file.Entry: HL → command line. Uses GETSYN, PUTEXT, INITIT, KEYN (SYS0), PUT, CLOSE.
DODO command — sets up a .BLD file replay. Allocates high-RAM space, copies the GOGO1 keyboard stub there, redirects the keyboard DCB to it. Each subsequent keyboard read pulls one character from the DO file. Restores the original keyboard DCB on EOF.Entry: HL → command line. Modifies KDCB+1 (SYS0 keyboard DCB), MEMEND, MEM1.
GOGO1–GOGO4The DO keyboard stub — a small self-contained routine copied to high RAM. On each keyboard call it reads one byte from the DO file; on EOF it restores the original keyboard driver and clears DOFLAG.Relocated to high RAM by DO. Calls GET (SYS0) via the relocated DCB pointer (GODCB).
SPAUSEPAUSE command — prints "Press <ENTER> to continue~" then waits for ENTER. If the DO file is active it uses GETCR (keyboard matrix scan); otherwise it uses KEYN (SYS0).Entry: HL → command line.
GETCRWaits for the ENTER key by scanning memory location 3840H (keyboard matrix row).Exit: Z set when ENTER detected.
EZZORERROR command — converts a 1- or 2-digit decimal error number from the command line, ORs in 0C0H (detail bits), then falls into the ERR handler to display the corresponding error message.Entry: HL → command line after 'ERROR '. Uses DECCHK.
PDATAOutputs one character to the display via DSP (SYS0) or to the line printer via PRT (SYS0), depending on the LPFLAG self-modifying field.Entry: A = character to output.
PRT2Outputs a full message string via LPRINT (if LPFLAG set) and PRINT (SYS0).Entry: HL → message string.
LPRINTPrints a 03H-terminated string to the line printer via PRT (SYS0).Entry: HL → string. Stops on 03H or after 0DH.
INKEYChecks for BREAK (via BRKCHK / SYS0) then calls GETKBD. Supports hold-mode via HLDPAT.Exit: A = character (NZ), or A=0 (Z) if no key pressed.
GETKBDKeyboard scan — if DO is not active uses KBD (SYS0); if DO is active calls the keyboard DCB (KEYBDZ) via IX=KDCB.Exit: A = character or 0.
HEXSConverts one byte to two hex ASCII digits and stores them at (HL), advancing HL by 2. Used to fill HEXADD in the "MEMORY FAULT" message.Entry: A = byte. Entry at HEXS1 for low nibble only.
HEXAASConverts a binary value to two decimal ASCII digits and stores them at (HL), advancing HL by 2. Used in date/time display.Entry: A = value.
BINDECOutputs a 16-bit value as a right-justified decimal number preceded by two spaces. Calls ROM routines at 0A9AH / 1034H / 0FD9H and then prints digits from 4131H buffer.Entry: HL = value. Calls PDATA for each character.
MSGPRT / MSGPR0Formats date or time for display. Loads the delimiter into DELIM1/DELIM2 and fills DPRT1/DPRT2/DPRT3 with two-digit hex pairs from the date or time RAM variables, then calls PRINT.Entry: C = delimiter ('/' for date, ':' for time). IX → HOUR or MONTH (SYS0 RAM).
REDIT / OPENIT / INITIT / GETSYN / GETDCB / GETDC1Convenience wrappers that set up S6DCB1/S6BUF1 and call the SYS0 READ, OPEN, INIT, SYNTAX routines.Standardised DCB/buffer setup for all file operations in this overlay.
DIRDIR command — reads the GAT, HIT (hash index table), and directory records for a selected drive; displays filename, attributes, LRL, record count, granule count, extent count, EOF byte, and creation date for each visible file; then displays free-granule count.Entry: HL → command line. Supports :n (drive), SYS, INV, PRT options via SWITCH. Calls RDGAT, RDHIT, RDDIR, BRKCHK, INKEY, BINDEC, PDATA, PRT2, CLS (all SYS0).
S6FREEFREE command — reads the GAT for a selected drive and displays a graphical free-space map showing granule allocation status per track. Supports :n (drive) and PRT option.Entry: HL → command line. Calls RDGAT, TRKGET, HEXCOV, PDATA, PRT2, CLS (SYS0).
HEXCOVConverts a binary value to two decimal ASCII digits (BCD-style using repeated subtraction) and stores at (HL). Used to fill track numbers in the FREE map display.Entry: A = value, HL → destination. Advances HL by 2.
SETTDC (alias TRAP)Trap-door hash computation routine. Referenced in ATTRIB as SETTDC for file access/update password hashing.Same routine as TRAP above.
LOADLOAD command — calls GETSYN to parse the filename, sets IY to SYS1IN (return address), pushes IY, and jumps to LDPGM (SYS0 program loader).Entry: HL → command line. Returns to SYS1IN after program loads and runs.
ATTRIBATTRIB command — modifies protection attributes, visibility (I/N), access password, and update password of a file. Reads current directory record, patches attribute byte and password hash fields, writes directory back.Entry: HL → command line. Calls GETSYN, OPEN, RDDIR, WRDIR. Uses SETTDC for password hashing.
LEGAL / LEALCharacter-class tests. LEGAL: accepts 0–9 and A–F (hex digits). LEAL: accepts 0–9 and A–Z (alphanumeric). Called by DUMP's filename-copy loop.Entry: A = character. Exit: carry clear if character is in the accepted set.

5. Jump Table Mapping (TABCOM)

TABCOM is the command dispatch table searched by GETTAB. Each entry is produced by the DCF macro and consists of a 1-byte command order code followed by a 2-byte little-endian handler address (3 bytes total per entry). The table is terminated by a DEFB 0.

Order CodeLabelCommandHandler Label
01H (APP)APPAPPENDAPPEND
02H (ATT)ATTATTRIBATTRIB
03H (AUT)AUTAUTOAUTO
05H (BULD)BULDBUILDBUILD
06H (CLER)CLERCLEARCLEAR
07H (CLCK)CLCKCLOCKCLOCK
0AH (CRET)CRETCREATECREATE
0BH (DTE)DTEDATES6DATE
0DH (DIRE)DIREDIRDIR
0EH (DODO)DODODODO
10H (DMP)DMPDUMPDUMP
11H (RERR)RERRERROREZZOR
14H (FREEE)FREEEFREES6FREE
17H (LIBB)LIBBLIBLIB
19H (LOADD)LOADDLOADLOAD
1CH (PAU)PAUPAUSESPAUSE
1DH (PROTT)PROTTPROTS6PROT
20H (RENME)RENMERENAMERENAME
24H (TTIME)TTIMETIMES6TIME
00H(end of table)DEFB 0 terminator

6. Cross-References and Analysis Notes

ROM dependency: BINDEC calls three Model III ROM routines directly by address (0A9AH, 1034H, 0FD9H) and reads an ASCII result string from ROM address 4131H. These addresses are ROM-version specific and are not resolved through SYS0 vectors.

Keyboard matrix scan: GETCR reads address 3840H directly for the ENTER key row. This is a hardware-level dependency on the Model III keyboard matrix layout.

DO command high-RAM placement: The GOGO1–GOGO4 stub is copied to an address derived from MEMEND at runtime. The exact destination address is not fixed at assembly time; GODCB and GOSAVE within the stub are patched in place after the copy. The stub length is computed as GOGO4−GOGO1 in the source.

Self-modifying code note: Several locations (RELO1/START, END, TRA, RELO) use the EQU $+n pattern targeting the operand of multi-byte LD instructions. The disassembler mis-decodes some of these — most notably at the RELO/START/END cluster — rendering .BYTE 32H in place of LD (nnnn),A. The source is authoritative for byte counts and instruction boundaries in these regions.

LEAL vs. LEGAL: SYS6 defines two character-class predicates: LEGAL (hex digits 0–9, A–F) and LEAL (alphanumeric 0–9, A–Z). These are used in DUMP's filename copying loop. The near-identical names appear to be a deliberate abbreviation convention in the original source.

LIBCOM dependency: The LIB command iterates TABCOM treating each entry as a 3-byte record where the first 6 characters are the printable command name. However, the source label is LIBCOM, not TABCOM. Examination shows LIB starts at LIBCOM which in context resolves to the same table — the two labels may be aliases or LIBCOM may refer to a separate string-only table not present in the visible source. This warrants further investigation against the binary.

Disassembly:

 
ORG 5200H
5200BEGIN
PUSH HL
Save Register HL (i.e., the pointer to the command line entered by the USER after the library command itself) to the top of the stack.
Original Source Code Comment: SAVE COMMAND LINE POINTER
5201
XOR A
Set Register A to ZERO and clear all Flags.
Original Source Code Comment: CLEAR A
5202
LD (4414H),ALD (FLAG1),A
Indicate that no overlay is resident by storing the value held in Register A (i.e., a zero) into the memory location 4414H.
NOTE: 4414H is the storage location for the NUMBER OF THE OVERLAY CURRENTLY IN MEMORY.
Original Source Code Comment: SHOW NO OVERLAY IS RESIDENT
5205
LD (42FFH),ALD (SCAFLG),A
Clear the protection override switch by storing the value held in Register A (i.e., a zero) into the memory location 42FFH.
NOTE: 42FFH is the storage location for whether a password check is skipped or undertaken in an OPEN command. If Bit 0 is set, the check is skipped.
Original Source Code Comment: CLEAR THE PROTECTION OVER RIDE SWITCH
5208
DEC A
DECrement the value stored in Register A by 1 so that A will be FFH.
Original Source Code Comment: MAKE A -1
5209
LD (427AH),ALD (BASICG),A
Signify that BASIC is NOT in RAM flag by storing the value held in Register A (i.e., FFH) into the memory location 427AH.
NOTE: 427AH is the storage location for the EXECUTE FILE FLAG.
Original Source Code Comment: SHOW BASIC NO LONGER IN RAM
520C
GOSUB to 529BH to parse the table holding the execution addresses of the various commands looking for a match against the requested command number, held in Register C on entry to this overlay.
Original Source Code Comment: GET THE ADDRESS IF PRESENT
520F
If the C FLAG (Carry) is set then there was an error in finding a match between the routine requested (held in Register C) and the possible routine numbers held in the table, so JUMP to 5213H.
Original Source Code Comment: NOT FOUND, EXIT TO ERROR
5211
EX (SP),HL
EXchange the value stored in Register Pair HL with the value stored in Register Pair (SP).
Original Source Code Comment: SP=COMMAND ADDR, HL=COMMAND LINE POINTER
5212
RET
RETurn to the caller.
Original Source Code Comment: EXIT TO THE COMMAND

5213H - BEGIN1 - Continuation of the above initial processing routine. Jumped here if there was no routine match.

5213BEGIN1
POP HL
Restore the passed input line from the top of the stack into Register Pair HL.
Original Source Code Comment: GET COMMAND LINE POINTER OFF THE STACK
5214ERR2
LD A,0BLD A,ERICP
LET Register A = 0BH, which is the code for an ILLEGAL PARAMETER error.
Original Source Code Comment: BAD PARAMETER
5216
JUMP to 523AH to continue.

5218H - ERR3 - Process a PARAMETER NOT FOUND error.

5218ERR3
LD A,0ALD A,ERCPM
LET Register A = 0AH, which is the code for an PARAMETER NOT FOUND error.
Original Source Code Comment: MISSING PARAMETER
521A
JUMP to 523AH to continue.

521CH - ERR1 - Process a FILE ALREADY EXISTS error.

521CERR1
LD A,28LD A,EFAT
LET Register A = 28H, which is the code for an FILE ALREADY EXISTS error.
Original Source Code Comment: FILE ALREADY EXISTS
521E
JUMP to 523AH to continue.

5220H - ERR5 - Display "END LESS THAN START" and RETurn.

5220ERR5
LD HL,5240LD HL,MES5
LET Register Pair HL = 5240H which points to the message "END LESS THAN START" + 0DH.
Original Source Code Comment: DUMP COMMAND ERROR MSG
5223
JUMP to 523DH (which, in turn, jumps to 021BH in the ROM to display a message pointed to by HL and then RETurns), to continue.

5225H - ERR6 - Display "START LESS THAN 6000" and RETurn.

5225ERR6
LD HL,5254LD HL,MES6
LET Register Pair HL = 5254H which points to the message "START LESS THAN 6000" + 0DH.
Original Source Code Comment: DUMP COMMAND ERROR MSG
5228
JUMP to 523DH (which, in turn, jumps to 021BH in the ROM to display a message pointed to by HL and then RETurns), to continue.

522AH - ERR7 - Display "MEMORY FAULT AT X 'nnnn'" and RETurn.

522AERR7
LD HL,5269LD HL,BADRAM
LET Register Pair HL = 5269H which points to the message "MEMORY FAULT AT X 'nnnn'" + 0DH.
Original Source Code Comment: CLEAR COMMAND BAD MEM FIND MSG
522D
JUMP to 523DH (which, in turn, jumps to 021BH in the ROM to display a message pointed to by HL and then RETurns), to continue.

522FH - ERR13 - Display "LRL OF FILES DO NOT MATCH" and RETurn.

522FERR13
LD HL,5281LD HL,BADLRL
LET Register Pair HL = 5281H which points to the message "LRL OF FILES DO NOT MATCH" + 0DH.
Original Source Code Comment: LRL DOES NOT MATCH MSG
5232
JUMP to 523DH (which, in turn, jumps to 021BH in the ROM to display a message pointed to by HL and then RETurns), to continue.

5234H - ERR9 - Process a DISK DRIVE NOT ON error.

5234ERR9
LD A,02LD A,EDNS
LET Register A = 02H, which is the code for a DISK DRIVE NOT ON error.
Original Source Code Comment: DISK DRIVE NOT IN SYSTEM
5236
JUMP to 523AH to continue.

5238H - ERR4 - Process a FILE ACCESS DENIED error.

5238ERR4
LD A,19LD A,EFAD
LET Register A = 28H, which is the code for a FILE ACCESS DENIED error.
Original Source Code Comment: ACCESS DENIED
523AERRX
JUMP to the DOS ERROR routine at 6132H.

523DH - ERRY - Display the message pointed to by Register Pair HL via the ROM and RETurn.

523DERRY
JUMP to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found.
Original Source Code Comment: PRINT & RET

5240H - MES5 - Message Storage Area.

5240MES5
DEFM
"END LESS THAN START" + 0DH.
5254MES6
DEFM
"START LESS THAN 6000" + 0DH.
5269BADRAM
DEFM
"MEMORY FAULT AT X 'nnnn'" + 0DH.
5281BADLRL
DEFM
"LRL OF FILES DO NOT MATCH" + 0DH.

529BH - GETTAB - Routine to Parse the Table of Functions looking to match the requested function number (held in Register C on entry).

529BGETTAB
LD HL,52B3LD HL,TABCOM
LET Register Pair HL = 52B3H to point to the table of functions in this Overlay.
Original Source Code Comment: HL => TABLE OF COMMANDS
529EGETTA1
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the command number in the table) and put it into Register A.
Original Source Code Comment: GET THE TABLE COMPARE BYTE
529F
OR A
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A.
Original Source Code Comment: END OF TABLE?
52A0
If the command number in the table is zero, then we have run out of table entries to match against but did not have a match, so JUMP to 52B1H.
Original Source Code Comment: YES, COMMAND NOT FOUND
52A2
CP C
Compare the value held in Register A (i.e., the command number which HL is pointing to in the table of functions) against the value held in Register C (i.e., the command number passed on entry). Results: If Register A equals C, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: MATCH THE COMMAND?
52A3
If the Z FLAG (Zero) is set, then the command number requested (i.e., Register C) matches the current entry in the lookup table (pointed to by [HL]), so JUMP to 52AAH.
Original Source Code Comment: YES, GOT IT
52A6
52A5
52A7
INC HL
INC HL
INC HL
If we're here then we didn't get a match in the command table lookup, so we need to move the table pointer (i.e., Register Pair HL) 3 entries down the table.
Original Source Code Comment: HL => MSB OF ADDRESS
52A8
LOOP BACK to the top of this routine to 529EH.
Original Source Code Comment: LOOP TILL FOUND

52AAH - FOUND - Continuation of the routine to Parse the Table of Functions. If we are here, then HL is pointing to the entry in the lookup table which matches the desired routine held in Register C on entry.

52AAFOUND
INC HL
Bump the value stored in Register Pair HL by 1 so that HL now points to the LSB of the routine address for the matching routine.
Original Source Code Comment: HL => LSB OF ADDRESS
52AB
LD E,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL, which will be the LSB of the address of the matching routine, and put it into Register E.
Original Source Code Comment: GET THE ADDRESS
52AC
INC HL
Bump the value stored in Register Pair HL by 1 to point to the MSB of the routine address for the matching routine.
52AD
LD D,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL, which will be the MSB of the address of the matching routine, and put it into Register D.
52AE
EX DE,HL
EXchange the value stored in Register Pair HL (i.e., the pointer to the MSB of the routine address for the matching routine) with the value stored in Register Pair DE (i.e., the address of the matching routine).
Original Source Code Comment: HL = COMMAND ADDRESS
52AF
OR A
Set FLAGS based on the contents of Register A, which also clears the CARRY FLAG (which acts as the error flag).
Original Source Code Comment: INSURE CARRY OFF
52B0
RET
RETurn to the caller.

52B1H - NOTFND - Continuation of the routine to Parse the Table of Functions. If we are here, then we parsed the table of functions but did not fine one which matches the requested function number (held in Register C on entry).

52B1NOTFND
SCF
Set the CARRY FLAG to signify that there was an error.
Original Source Code Comment: SET CARRY, NOT FOUND
52B2
RET
RETurn to the caller.
Original Source Code Comment: DONE

52B3H - TABCOM - Table of Functions in this Overlay.

52B3TABCOM
DEFB 1APP
APPEND command number.
52B4H
DEFW 568EAPPEND
APPEND command routine address.
52B6H
DEFB 2ATT
ATTRIB command number.
52B7H
DEFW 585EATTRIB
ATTRIB command routine address.
52B9H
DEFB 3AUT
AUTO command number.
52BAH
DEFW 52EDAUTO
AUTO command routine address.
52BCH
DEFB 5BULD
BUILD command number.
52BDH
DEFW 5FC9BUILD
BUILD command routine address.
52BFH
DEFB 6CLER
CLEAR command number.
52C0H
DEFW 5EFFCLEAR
CLEAR command routine address.
52C2H
DEFB 7CLCK
CLOCK command number.
52C3H
DEFW 53E2CLOCK
CLOCK command routine address.
52C5H
DEFB 0ACRET
CREATE command number.
52C6H
DEFW 5E52CREATE
CREATE command routine address.
52C8H
DEFB 0BDTE
DATE command number.
52C9H
DEFW 5361S6DATE
DATE command routine address.
52CBH
DEFB 13DIRE
DIR command number.
52CCH
DEFW 59D9DIR
DIR command routine address.
52CEH
DEFB 0EDODO
DO command number.
52CFH
DEFW 603DDO
DO command routine address.
52D1H
DEFB 10DMP
DUMP command number.
52D2H
DEFW 5700DUMP
DUMP command routine address.
52D4H
DEFB 11RERR
ERROR command number.
52D5H
DEFW 6114EZZOR
ERROR command routine address.
52D7H
DEFB 14FREEE
FREE command number.
52D8H
DEFW 5CDCS6FREE
FREE command routine address.
52DAH
DEFB 17LIBB
LIB command number.
52DBH
DEFW 5423LIB
LIB command routine address.
52DDH
DEFB 19LOADD
LOAD command number.
52DEH
DEFW 584FLOAD
LOAD command routine address.
52E0H
DEFB 1CPAU
PAUSE command number.
52E1H
DEFW 60CFSPAUSE
PAUSE command routine address.
52E3H
DEFB 1DPROTT
PROT command number.
52E4H
DEFW 5455S6PROT
PROT command routine address.
52E6H
DEFB 32RENME
RENAME command number.
52E7H
DEFW 559FRENAME
RENAME command routine address.
52E9H
DEFB 36TTIME
TIME command number.
52EAH
DEFW 53ABS6TIME
TIME command routine address.
52ECH
DEFB 00
End of Table Delimeter.
Original Source Code Comment: END OF LIST TERMINATOR

52EDH - AUTO Library Command - Function 3

52EDAUTO
LD A,(HL)
Fetch the first character stored at memory location pointed to by Register Pair HL (i.e., the command line which was passed to this Overlay on entry) and put it into Register A.
Original Source Code Comment: GET NEXT CHARACTER FROM COMMAND LINE
52EE
CP 3AH
Prepare to test for a DRIVE NUMBER 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?
52F0
If we did not get a : the NZ FLAG (Not Zero) is set, so JUMP to 52FFH.
Original Source Code Comment: NO, CONTINUE
52F2
INC HL
Bump the value stored in Register Pair HL by 1 so as to point to the second character stored at memory location pointed to by Register Pair HL (i.e., the command line which was passed to this Overlay on entry).
Original Source Code Comment: BUMP TO NEXT CHARACTER
52F3
LD A,(HL)
Fetch the second character from the command line (i.e., the memory location pointed to by Register Pair HL) and put it into Register A.
Original Source Code Comment: GET THE DRIVE NUMBER
52F4
SUB 30H
SUBtract the value 30H from Register A. Note: Subtracting 30H from from Register A will convert an ASCII number '0'-'9' to its decimal equivalent (i.e., 6 in ASCII is 36H in Hex; so 36H-30H = 6).
Original Source Code Comment: MASK OFF ASCII
52F6
LD (5301H),ALD (AUTDRV),A
Store the value held in Register A (which should be the decimal equivalent of the specified drive number) into the memory location 5301H (which is in the middle of a LD C,nnH OPCODE).
Original Source Code Comment: SAVE IT IN PROGRAM
52F9AUTO1
INC HL
Bump the value stored in Register Pair HL by 1 to point to the next character stored at memory location pointed to by Register Pair HL (i.e., the command line which was passed to this Overlay on entry).
Original Source Code Comment: BUMP PAST DRIVE NUMBER
52FA
LD A,(HL)
Fetch the next character from the command line (i.e., the memory location pointed to by Register Pair HL) and put it into Register A.
Original Source Code Comment: GET THE NEXT CHARACTER
52FB
CP 20H
Compare the value held in Register A against 20H (ASCII: SPACE). Results: If Register A equals SPACE, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: SPACE?
52FD
If the Z FLAG (Zero) is set then we got a SPACE so LOOP back to 52F9H to check the next character.
Original Source Code Comment: YES, SKIP IT
52FFAUTO2
PUSH HL
Save Register HL (i.e., the current parsed location in the command line which was passed to this Overlay on entry) to the top of the stack.
Original Source Code Comment: SAVE COMMAND LINE POINTER
5300
LD C,nnH
LD C,AUTDRV
LET Register C = the drive number received, as has been filled in at 52F6H.
Original Source Code Comment: SET FOR DRIVE 0
5302
GOSUB to 4A93H.
NOTE: 4A93H is the SYS00/SYS routine to READ THE GAT SECTOR INTO RAM (Buffer at 4D00H).
Original Source Code Comment: GET SECTOR THAT HAS COMMAND
5305
POP HL
Restore the current parsed location in the command line which was passed to this Overlay on entry from the top of the STACK into Register Pair HL.
Original Source Code Comment: GET COMMAND LINE POINTER BACK
5306
If the NZ FLAG (Not Zero) is set then the READ THE GAT SECTOR routine returned with an error so JUMP to 6132H.
Original Source Code Comment: EXIT IF ERROR
5309
PUSH HL
Save the current parsed location in the command line which was passed to this Overlay on entry held in Register Pair HL to the top of the STACK.
Original Source Code Comment: SAVE POINTER
530A
LD B,01H
LET Register B = 01H to prepare for using B as a counter.
Original Source Code Comment: SET A COUNTER
530CAUTO3
LD A,(HL)
Fetch the next character from the command line (i.e., the memory location pointed to by Register Pair HL) and put it into Register A.
Original Source Code Comment: GET A CHAR
530D
CP 20H
Compare the value held in Register A against a 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?
530F
If the C FLAG (Carry) is set then A < SPACE, meaning we have a control character, so JUMP to 5315H.
Original Source Code Comment: YES, EXIT
5311
INC HL
Bump the value stored in Register Pair HL by 1 so as to point HL to the next character from the command line .
Original Source Code Comment: BUMP TO NEXT CHAR
5312
INC B
Bump the value stored in Register B (which is acting as a counter) by 1.
Original Source Code Comment: BUMP THE COUNT
5313
LOOP BACK to 530CH to keep parsing the command line.
Original Source Code Comment: LOOP TILL FOUND

5315H - AUTO4 - Continuation of the AUTO command; jumped here if there was a command character found in the passed command line. This routine will fill the command line to be 31 chararcters (with spaces) and put it into the appropriate location in the GAT sector.

5315AUTO4
LD A,20H
LET Register A = 20H (Decimal: 32), which is the maximum length of a valid AUTO command.
Original Source Code Comment: NUMBER OF BYTES IN AUTO FUNCTION
5317
SUB B
SUBtract the value held in Register B (i.e., the number of characters used) from Register A (i.e., the number of possible characters), thus leaving Register A holding the number of spaces left.
Original Source Code Comment: A = NUMBER OF REMAINING BYTES
5318
LD B,A
LET Register B = Register A (i.e., the number of characters left on a full command line).
Original Source Code Comment: INTO B
5319
INC HL
Bump the value stored in Register Pair HL by 1 so as to point HL to the next character from the command line.
Original Source Code Comment: BUMP PAST CONTROL CHAR
531AAUTO5
LD (HL),20H
Store a SPACE into the memory location pointed to by Register Pair HL.
Original Source Code Comment: FILL WITH SPACES
531C
INC HL
Bump the value stored in Register Pair HL by 1 so as to point HL to the next character from the command line.
Original Source Code Comment: BUMP TO NEXT SLOT
531D
LOOP back to 531AH until Register B is ZERO so that all remaining characters on the command line have been turned in to spaces.
Original Source Code Comment: LOOP FOR COUNT
531F
POP HL
Restore Register Pair HL (i.e., the pointer to the current location on the command line) from the top of the STACK.
Original Source Code Comment: GET POINTER BACK
5320
LD DE,4DE0LD DE,BUFF2 + DAUTO
LET Register Pair DE = 4DE0H, which is the memory location of the GAT SECTOR in RAM for the AUTO command.
Original Source Code Comment: POINT TO WHERE COMMAND TO GO
5323
LD BC,0020H
LET Register Pair BC = 0020H (Decimal: 32), which is the maximum length of a valid AUTO command.
Original Source Code Comment: SET FOR 32 CHARS
5326
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
5328
LD A,(5301H)LD A,(AUTDRV)
Fetch the value stored at memory location 5301H (i.e., the applicable drive number) and put it into Register A.
Original Source Code Comment: GET THE DRIVE NUMBER
532B
LD C,A
LET Register C = Register A (i.e., the applicable drive number).
Original Source Code Comment: INTO C
532C
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 THE COMMAND OUT TO DISK
532F
If the NZ FLAG (Not Zero) is set then the WRITE THE GAT SECTOR routine returned with an error so JUMP to 6132H.
Original Source Code Comment: EXIT IF ERROR
5332
LD HL,5355LD HL,AUTMSG
LET Register Pair HL = 5355H, which is a pointer to the AUTO = " message.
Original Source Code Comment: POINT TO 'AUTO =' MSG
5335
GOSUB to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found.
Original Source Code Comment: DISPLAY IT
5338
LD HL,4DE0LD HL,BUFF2 + DAUTO
LET Register Pair HL = 4DE0H, which is the memory location of the GAT SECTOR in RAM for the AUTO command.
Original Source Code Comment: POINT TO COMMAND
533B
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the first byte of the AUTO command) and put it into Register A.
Original Source Code Comment: GET THE FIRST CHAR THERE
533C
CP 20H
Compare the value held in Register A (i.e., the first byte of the AUTO command) 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?
533E
If A < SPACE, meaning the first byte of the AUTO command is a command code, the C FLAG (Carry) is will be set, so JUMP to 534FH.
Original Source Code Comment: YES, PRINT ''
5340
PUSH HL
Save Register HL (i.e., the memory location of the GAT SECTOR in RAM for the AUTO command) to the top of the STACK.
Original Source Code Comment: SAVE POINTER
5341AUTO6
LD A,(HL)
Fetch the value stored at memory location (i.e., a letter of the AUTO command) pointed to by Register Pair HL and put it into Register A.
Original Source Code Comment: GET A CHAR
5342
CP 20H
Compare the value held in Register A (i.e., the first byte of the AUTO command) 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
5344
If A < SPACE, meaning the current byte of the AUTO command is a command code, the C FLAG (Carry) is will be set, so JUMP to 5349H.
Original Source Code Comment: YES, EXIT
5346
INC HL
Bump the value stored in Register Pair HL (i.e., the pointer to a byte of the AUTO command) by 1.
Original Source Code Comment: NO, BUMP TO NEXT CHAR
5347
LOOP BACK to 5341H to keep parsing the AUTO command.
Original Source Code Comment: LOOP TILL FOUND

5349H - AUTO7 - Continuation of the AUTO command; jumped here if we reached the end of the AUTO command as stored in the GAT sector.

5349AUTO7
LD (HL),03H
Store an 03H (i.e., a standard terminator) into the memory location (i.e., the control character in the AUTO command) pointed to by Register Pair HL, because an 03H terminator is required by the ROM routine at 021BH.
Original Source Code Comment: SET TERMINATOR
534B
POP HL
Restore the memory location of the GAT SECTOR in RAM for the AUTO command from the top of the STACK into Register Pair HL.
534C
GOSUB to 021BH.
NOTE: 021BH is the routine in the Model III ROM which will display the character at (HL) until a 03H is found.
Original Source Code Comment: DISPLAY FUNCTION
534FAUTO8
LD HL,535FLD HL,AUTNUL
LET Register Pair HL = 535FH, which is the message storage area for '.
Original Source Code Comment: HL => 'CR
5352
JUMP to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found.
Original Source Code Comment: DISPLAY AND RETURN

5355H - AUTMSG - AUTO COMMAND MESSAGE STORAGE AREA.

5355AUTMSG
DEFM ...
"AUTO = '".
535FAUTNUL
DEFB ...
"'".

5361H - S6DATE - DATE Library Command - Function 11

5361S6DATE
LD C,2FH
LET Register C = 2FH (ASCII: /).
Original Source Code Comment: LOAD THE DELIMITER
5363
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the command line which was passed to this overlay) and put it into Register A.
Original Source Code Comment: GET THE NEXT CHAR ON COMMAND LINE
5364
CP 0DH
Compare the value held in Register A against 0DH (ASCII: CARRIAGE RETURN). Results: If Register A equals CARRIAGE RETURN, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: ANY PARAMETER?
5366
If the Z FLAG (Zero) is set then we are at a CARRIAGE RETURN, meaning we are at the end of the passed command line, so JUMP to 61EAH to then display the time and the date.
Original Source Code Comment: NOPE, JUST DISPLAY DATE
5369
CP 03H
Compare the value held in Register A against 03H (i.e., a standard terminator). Results: If Register A equals 03H, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: (OTHER TERMINATOR)
536B
If the Z FLAG (Zero) is set then we have a terminator in the passed command line, so JUMP to 61EAH to then display the time and the date.
Original Source Code Comment: JUST DISPLAY DATE
536E
GOSUB to 53EEH to decode the date.
Original Source Code Comment: CONVER THE PARAMETER
5371
If the prior CALL returned with NZ set, that signifies that it exited with an error. If that is the case, JUMP to 5214H.
Original Source Code Comment: SYNTAX ERROR
5374
LD A,(53EBH)LD A,(BIN)
Fetch the value stored at memory location 53EBH (i.e., the YEAR or SECOND) and put it into Register A.
Original Source Code Comment: GET THE YEAR
5377
CP 64H
Compare the value held in Register A against 64H (Decimal: 100). Results:
  • If Register A equals 100, the Z FLAG is set.
  • If A < 100, the CARRY FLAG will be set.
  • if A >= 100, the NO CARRY FLAG will be set.

Original Source Code Comment: SILLY?
5379
If A >= 100 then we have a bad YEAR (and the NC FLAG will be set), so JUMP to 5214H.
Original Source Code Comment: YES
537C
LD A,(53ECH)LD A,(BIN + 1)
Fetch the value stored at memory location 53ECH (i.e., the DAY or MINUTE) and put it into Register A.
Original Source Code Comment: GET THE DAY
537F
CP 20H
Compare the value held in Register A against 20H (Decimal: 32). Results:
  • If Register A equals 32, the Z FLAG is set.
  • If A < 32, the CARRY FLAG will be set.
  • if A >= 32, the NO CARRY FLAG will be set.

Original Source Code Comment: SILLY?
5381
If A >= 32 then we have a bad DAY (and the NC FLAG will be set), so JUMP to 5214H.
5384
OR A
Set FLAGS based on the contents of Register A.
Original Source Code Comment: 0?
5385
If the MONTH is 0, then we have a bad MONTH (and the Z FLAG will be set), so JUMP to 5214H.
5388
LD A,(53EDH)LD A,(BIN+2)
Fetch the value stored at memory location 53EDH (i.e., the MONTH or HOUR) and put it into Register A.
Original Source Code Comment: GET THE MONTH
538B
CP 0DH
Compare the value held in Register A against 0DH (Decimal: 13). Results:
  • If Register A equals 13, the Z FLAG is set.
  • If A < 13, the CARRY FLAG will be set.
  • if A >= 13, the NO CARRY FLAG will be set.

Original Source Code Comment: SILLY?
538D
If A >= 13 then we have a bad MONTH (and the NC FLAG will be set), so JUMP to 5214H.
Original Source Code Comment: YES
5390
OR A
Set FLAGS based on the contents of Register A.
Original Source Code Comment: SILLY?
5391
If the DAY is 0, then we have a bad DAY (and the Z FLAG will be set), so JUMP to 5214H.
5394
LD HL,53EBLD HL,BIN
LET Register Pair HL = 53EBH (i.e., the first byte of the 3 bytes comprising a DATE or TIME).
Original Source Code Comment: POINT TO CONVERSION
5397
LD DE,421ALD DE,YEAR
LET Register Pair DE = 421AH, which will be the destination for the 3 numbers comprising the date.
Original Source Code Comment: PLACE TO STORE DATE
539A
LD BC,0003H
LET Register Pair BC = 0003H, to signify 3 bytes to move.
Original Source Code Comment: 3 HEX CHARS
539D
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.
539F
LD HL,53EBLD HL,BIN
LET Register Pair HL = 53EBH (i.e., the first byte of the 3 bytes comprising a DATE or TIME).
Original Source Code Comment: MOVE IT TO SAVE AREA ALSO
53A2
LD DE,42B7LD DE,DTSAVE
LET Register Pair DE = 42B7H, which will be the destination for the 3 numbers comprising the date.
53A5
LD BC,0003H
LET Register Pair BC = 0003H, to signify 3 bytes to move.
53A8
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.
53AA
RET
RETurn to the caller.

53ABH - S6TIME - TIME Library Command - Function 36

53ABS6TIME
LD C,3AH
LET Register C = 3AH (ASCII: :).
Original Source Code Comment: LOAD THE DELIMITER
53AD
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the command line which was passed to this overlay) and put it into Register A.
Original Source Code Comment: GET NEXT CHAR ON COMMAND LINE
53AE
CP 0DH
Compare the value held in Register A against 0DH (ASCII: CARRIAGE RETURN). Results: If Register A equals CARRIAGE RETURN, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: ANY PARAMETER?
53B0
If the Z FLAG (Zero) is set then we are at a CARRIAGE RETURN, meaning we are at the end of the passed command line, so JUMP to 61EAH to then display the time and the date.
Original Source Code Comment: NOPE, JUST PRINT TIME
53B3
CP 03H
Compare the value held in Register A against 03H (i.e., a standard terminator). Results: If Register A equals 03H, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: (OTHER TERMINATOR)
53B5
If the Z FLAG (Zero) is set then we have a terminator in the passed command line, so JUMP to 61EAH to then display the time and the date.
Original Source Code Comment: JUST PRINT TIME
53B8
GOSUB to 53EEH to decode the time.
Original Source Code Comment: DO THE CONVERSION
53BB
If the prior CALL returned with NZ set, that signifies that it exited with an error. If that is the case, JUMP to 5214H.
Original Source Code Comment: SYNTAX ERROR
53BE
LD A,(53EBH)LD A,(BIN)
Fetch the value stored at memory location 53EBH (i.e., the YEAR or SECOND) and put it into Register A.
Original Source Code Comment: GET THE SECONDS
53C1
CP 3DH
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: SILLY?
53C3
If A >= 61 then we have a bad SECOND (and the NC FLAG will be set), so JUMP to 5214H.
Original Source Code Comment: YES
53C6
LD A,(53ECH)LD A,(BIN + 1)
Fetch the value stored at memory location 53ECH (i.e., the DAY or MINUTE) and put it into Register A.
Original Source Code Comment: GET THE MINUTES
53C9
CP 3DH
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: SILLY?
53CB
If A >= 61 then we have a bad MINUTE (and the NC FLAG will be set), so JUMP to 5214H.
Original Source Code Comment: YES
53CE
LD A,(53EDH)LD A,(BIN + 2)
Fetch the value stored at memory location 53EDH (i.e., the MONTH or HOUR) and put it into Register A.
Original Source Code Comment: GET THE HOURS
53D1
CP 18H
Compare the value held in Register A against 18H (Decimal: 24). Results:
  • If Register A equals 24, the Z FLAG is set.
  • If A < 24, the CARRY FLAG will be set.
  • if A >= 24, the NO CARRY FLAG will be set.

Original Source Code Comment: SILLY?
53D3
If A >= 24 then we have a bad HOUR (and the NC FLAG will be set), so JUMP to 5214H.
53D6
LD HL,53EBLD HL,BIN
LET Register Pair HL = 53EBH (i.e., the first byte of the 3 bytes comprising a DATE or TIME).
Original Source Code Comment: POINT TO CONVERSION
53D9
LD DE,4217LD DE,SECOND
LET Register Pair DE = 4217H, which will be the destination for the 3 numbers comprising the time.
Original Source Code Comment: PLACE TO STORE TIME
53DC
LD BC,0003H
LET Register Pair BC = 0003H, to signify 3 bytes to move.
Original Source Code Comment: 3 HEX CHARS
53DF
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.
53E1
RET
RETurn to the caller.

53E2H - CLOCK Library Command - Function 7. Exits with Z FLAG for OFF and NZ FLAG for ON.

53E2CLOCK
GOSUB to 5081H to evaluate for ON/OFF Parameters.
Original Source Code Comment: CLOCK ON OR OFF? (SYS1 CHECK)
53E5
If the Z FLAG (Zero) is set then we received an OFF parameter, so JUMP to 02A1H.
NOTE: 02A1H is the Model III ROM routine to disable the clock display by disabling Bit 0 of 4210H.
Original Source Code Comment: DO CLOCK OFF IN ROM
53E8
JUMP to 0298H.
NOTE: 02A1H is the Model III ROM routine to enable the clock display by enabling Bit 0 of 4210H.
Original Source Code Comment: DO CLOCK ON IN ROM

53EBH - BIN - BYTE STORAGE AREA FOR TIME AND DATE ROUTINES.

53EBBIN
DEFB 00H
Storage for YEAR or SECOND.
Original Source Code Comment: 3 BYTE STORE AREA
53EC
DEFB 00H
Storage for DAY or MINUTE.
53ED
DEFB 00H
Storage for MONTH or HOUR.

53EEH - CONV1 - Subroutine within the DATE COMMAND to decode the date and validate for proper delimeters.

53EECONV1
LD DE,53EDLD DE,BIN + 2
LET Register Pair DE = 53EDH (i.e., the end of the DATE storage area, since this routine is parsing the numbers backwards).
Original Source Code Comment: POINT TO LAST STORE AREA
53F1
LD B,03H
LET Register B = 03H, to signify 3 bytes.
Original Source Code Comment: SET FOR 3 CHARS
53F3L6OP1
PUSH DE
Save Register DE (i.e., the DATE storage area) to the top of the stack.
Original Source Code Comment: SAVE POINT TO SAVE AREA
53F4
GOSUB to 5403H to decode a two digit number pointed to by Register Pair HL; results in Register A.
Original Source Code Comment: CONVERT THE CHAR TO HEX
53F7
POP DE
Restore the DATE storage area from the top of the STACK into Register Pair DE .
Original Source Code Comment: RESTORE POINTER
53F8
RET NZ
If the NZ FLAG (Not Zero) is set then that CALL exited with an error, so RETurn to the caller.
Original Source Code Comment: EXIT IF SYNTAX ERROR
53F9
LD (DE),A
Store the value held in Register A (i.e., the decoded number) into the memory location pointed to by Register Pair DE.
Original Source Code Comment: STORE THE HEX CHAR
53FA
DEC DE
DECrement the value stored in Register Pair DE by 1 to point to the next entry in the DATE STORAGE AREA.
Original Source Code Comment: POINT TO NEXT SLOT
53FB
DEC B
DECrement the value stored in Register B (i.e., a counter) by 1.
Original Source Code Comment: DEC THE COUNTER
53FC
RET Z
If the Z FLAG (Zero) is set then we have processed all 3 elements of a date, so RETurn to the caller.
Original Source Code Comment: EXIT IF DONE
53FD
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the command line) and put it into Register A.
Original Source Code Comment: GET THE NEXT CHAR TO CONVERT
53FE
INC HL
Bump the value stored in Register Pair HL by 1 to point to the next character in the command line.
Original Source Code Comment: BUMP THE POINTER
53FF
CP C
Compare the value held in Register A (i.e., a character in the command line) against the value held in Register C (i.e., a / delimeter). Results: If Register A equals /, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: MATCH THE DELIMITER?
5400
If we properly had a / here, then the Z FLAG (Zero) is set, JUMP to 53F3H to keep parsing the 3 date elements.
Original Source Code Comment: CONTINUE IF SO
5402
RET
RETurn to the caller with NZ set to signify an error.
Original Source Code Comment: EXIT, SYNTAX ERROR

5403H - DECBIN - Subroutine within the DATE COMMAND to decode a two digit number pointed to by Register Pair HL; results in Register A.

5403DECBIN
GOSUB to 541AH to convert a COMMAND LINE byte pair to decimal.
Original Source Code Comment: GET CHAR AND MASK ASCII
5406
If the NC FLAG (No Carry) is set then that CALL exited with an ERROR so JUMP to 5418H.
Original Source Code Comment: RET IF NOT NUMERIC
5408
LD E,A
LET Register E = Register A (i.e., the returned value).
Original Source Code Comment: SAVE IT IN (E)
5409
RLCA
Let A = A * 2.
Original Source Code Comment: TIMES 2
540A
RLCA
Let A = A * 2 (so A is now 4 times the original value).
Original Source Code Comment: * 4
540B
ADD A,E
ADD the value held in Register E to Register A (so A is now 5 times the original value).
Original Source Code Comment: * 5
540C
RLCA
Let A = A * 2 (so A is now 10 times the original value).
Original Source Code Comment: * 10
540D
LD E,A
LET Register E = Register A (i.e., the returned value, but now in the tens place).
Original Source Code Comment: SAVE IT IN (E)
540E
GOSUB to 541AH to get the parameter digit value.
Original Source Code Comment: GET NEXT NUMBER
5411
If the NC FLAG (No Carry) is set then that CALL exited with an ERROR so JUMP to 5418H.
Original Source Code Comment: EXIT IF NOT NUMERIC
5413
ADD A,E
ADD the value held in Register E (i.e., the first number shifted to the tens place) to Register A (i.e., the second number we just processed).
Original Source Code Comment: ADD IN THE TENS DIGIT
5414
LD E,A
LET Register E = Register A (i.e., the two numbers combined).
Original Source Code Comment: SAVE IN (E)
5415
XOR A
Set Register A to ZERO and clear all Flags.
Original Source Code Comment: SHOW GOOD RETURN
5416
LD A,E
LET Register A = Register E (i.e., the two numbers combined).
Original Source Code Comment: GET THE NUMBER BACK
5417
RET
RETurn to the caller.

5418H - RET1 - Subroutine within the DATE COMMAND to exit with the error status set.

5418RET1
OR A
Set FLAGS based on the contents of Register A.
Original Source Code Comment: SET NZ, ERROR
5419
RET
RETurn to the caller.

541AH - DECCHK - Subroutine within the DATE COMMAND to convert a COMMAND LINE byte pair to decimal. Exits with NC FLAG set if there is an error.

541ADECCHK
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the parameter byte we want to decode) and put it into Register A.
Original Source Code Comment: GET THE CHAR
541B
INC HL
Bump the value stored in Register Pair HL by 1 to point to the next parameter byte.
Original Source Code Comment: POINT TO NEXT CHAR
541C
SUB 30H
SUBtract the value 30H from Register A. Note: Subtracting 30H from from Register A will convert an ASCII number '0'-'9' to its decimal equivalent (i.e., 6 in ASCII is 36H in Hex; so 36H-30H = 6).
Original Source Code Comment: MASK OFF ASCII
541E
CCF
Invert the state of the CARRY FLAG.
Original Source Code Comment: COMPLIMENT THE CARRY
541F
RET NC
If the NC FLAG (No Carry) is set, RETurn to the caller.
Original Source Code Comment: RET IF LESS THEN NUMBER
5420
CP 0AH
Compare the value held in Register A against 0AH (Decimal: 10) as a double-check. Results:
  • If Register A equals 10, the Z FLAG is set.
  • If A < 10 (which is good), the CARRY FLAG will be set.
  • if A >= 10, which is bad, the NO CARRY FLAG will be set.

Original Source Code Comment: GREATER THAN 9?
5422
RET
RETurn to the caller.

5423H - LIB Library Command - Function 23

5423LIB
LD HL,50C9LD HL,LIBCOM
LET Register Pair HL = 50C9H which is the OVERLAY 1 COMMAND TABLE.
Original Source Code Comment: POINT TO LIBRARY COMMANDS
5426L6OP4
LD C,08H
LET Register C = 08H, because there are 8 columns per row.
Original Source Code Comment: SET FOR 8 COMMANDS PER LINE
5428L6OP3
LD B,06H
LET Register B = 06H, because there are 6 characters per library command.
Original Source Code Comment: SET FOR 6 CHARS
542AL6OP2
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the OVERLAY 1 COMMAND TABLE) and put it into Register A.
Original Source Code Comment: GET A CHAR
542B
INC HL
Bump the value stored in Register Pair HL by 1 to point to the next character of that command table.
Original Source Code Comment: POINT TO NEXT CHAR
542C
GOSUB to 0033H.
NOTE: 0033H is the Model III ROM character print routine; displays the character held in Register A at the current cursor position.
Original Source Code Comment: OUTPUT IT
542F
LOOP back to 542AH until Register B is ZERO, meaning a full command has been displayed.
Original Source Code Comment: DO FOR COUNT
5431
LD A,(4020H)LD A,(CURSOR)
Fetch the value stored at memory location 4020H and put it into Register A.
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
Original Source Code Comment: GET THE CURSOR POSITION
5434
AND 3FH
MASK the value of Register A against 3FH to mask for an END OF DISPLAY LINE computation.
Original Source Code Comment: MASK FOR 1 ROW
5436
CP 38H
Compare the value held in Register A against 38H to see if we have reached the end of a line on the screen. Results: if A >= 38H, the NO CARRY FLAG will be set.
Original Source Code Comment: TOO FAR TO THE RIGHT OF SCREEN?
5438
If the NC FLAG (No Carry) is set then we are at the end of a display line, so JUMP to 5442H to skip the spacing between the library commands.
Original Source Code Comment: YES, DON'T OUTPUT SPACES
543A
LD A,20H
LET Register A = 20H (ASCII: SPACE) because we need to put two spaces between library commands.
Original Source Code Comment: OUTPUT TWO SPACES
543C
GOSUB to 0033H.
NOTE: 0033H is the Model III ROM character print routine; displays the character held in Register A at the current cursor position.
Original Source Code Comment: OUTPUT IT
543F
GOSUB to 0033H.
NOTE: 0033H is the Model III ROM character print routine; displays the character held in Register A at the current cursor position.
Original Source Code Comment: OUTPUT IT
5442-5443LL6OP2
INC HL
INC HL
Bump the value stored in Register Pair HL by 2 to point to the next entry in the OVERLAY 1 COMMAND TABLE.
Original Source Code Comment: PASS UP COMMAND ADDRESS
5444
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the next command in the OVERLAY 1 COMMAND TABLE) and put it into Register A.
Original Source Code Comment: GET A CHAR
5445
OR A
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A.
Original Source Code Comment: END OF LIST?
5446
If the Z FLAG (Zero) is set then we have hit the END of the OVERLAY 1 COMMAND TABLE so JUMP to 5450H to finish up.
Original Source Code Comment: DO A CR IF SO
5448
DEC C
DECrement the value stored in Register C by 1, since C is counting down the number of columns on a display.
Original Source Code Comment: DEC THE NUM PER LINE COUNT
5449
If the NZ FLAG (Not Zero) is set, JUMP to 5428H to process the next library command.
Original Source Code Comment: CONTINUE TILL 1 LINE PRINTED
544B
GOSUB to 5450H to move to a new line on the screen.
Original Source Code Comment: NEW LINE
544E
JUMP to 5426H to keep displaying.
Original Source Code Comment: AND CONTINUE

5450H - S6CR - Continuation of the LIBRARY COMMAND; jumped to if we have finished displaying the OVERLAY 1 COMMAND TABLE.

5450S6CR
LD A,0DH
LET Register A = 0DH (ASCII: CARRIAGE RETURN.
Original Source Code Comment: LOAD A CR
5452
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.
Original Source Code Comment: PRINT & RET

5455H - S6PROT - PROT Library Command - Function 29

5455S6PROT
LD BC,0000H
LET Register Pair BC = 0000H so that we can turn off a bunch of options.
Original Source Code Comment: CLEAR OUT OUR LOCATIONS
5458
LD (54A3H),BCLD (PW),BC
Store the value held in Register BC (i.e., 0000H) into the memory location 54A3H (which is in the middle of an LD DE,nnnnH OPCODE).
545C
LD (54C3H),BCLD (LOCK),BC
Store the value held in Register BC (i.e., 0000H) into the memory location 54C3H (which is in the middle of a LD DE,nnnnH OPCODE).
5460
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the command line which was passed to this overlay) and put it into Register A.
Original Source Code Comment: GET A CHAR FROM COMMAND LINE
5461
CP 3AH
Compare the value held in Register A against 3AH (ASCII: :) to check for a DRIVE NUMBER. Results: If Register A equals :, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: DRIVE SPECIFIER?
5463
If the character retrieved from the command line is not a :, then the NZ FLAG (Not Zero) is set, so JUMP to 546BH.
Original Source Code Comment: NOPE
5465
INC HL
If we are here, we are expecing a DRIVE NUMBER to be the next character, so bump the value stored in Register Pair HL (i.e., the command line which was passed to this overlay) by 1.
Original Source Code Comment: YES, BUMP TO NEXT LOC
5466
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL, which we hope to be a drive number, and put it into Register A.
Original Source Code Comment: GET THE DRIVE NUMBER
5467
SUB 30H
SUBtract the value 30H from Register A. Note: Subtracting 30H from from Register A will convert an ASCII number '0'-'9' to its decimal equivalent (i.e., 6 in ASCII is 36H in Hex; so 36H-30H = 6).
Original Source Code Comment: MASK OFF ASCII
5469
LD C,A
LET Register C = Register A (i.e., the decimal equivalent of a drive number from the command line).
Original Source Code Comment: PUT BINARY DRIVE NUM IN (C)
546A
INC HL
Bump the value stored in Register Pair HL (i.e., the command line which was passed to this overlay) by 1.
Original Source Code Comment: BUMP TO NEXT LOCATION
546BNODRV3
LD A,C
LET Register A = Register C (i.e., the decimal equivalent of a drive number from the command line).
Original Source Code Comment: LOAD THE DRIVE NUM INTO (A)
546C
LD (548FH),ALD (DRV3),A
Store the value held in Register A (i.e., the decimal equivalent of a drive number from the command line) into the memory location 548FH (which is in the middle of a LD C,nn OPCODE).
Original Source Code Comment: SAVE IT FOR LATER
546F
LD DE,554ELD DE,SWTCH5
LET Register Pair DE = 554EH to point to the PARAMETER TABLE.
Original Source Code Comment: POINT TO PROT MATCH TABLE
5472
GOSUB to 4454H.
NOTE: 4454H is the DOS PARAMETER STRING PARSE routine. It decodes DOS LIBRARY parameters.
Original Source Code Comment: GET PARM AND SYNTAX (SYS1)
5475
If the NZ FLAG (Not Zero) is set then the prior CALL exited with an error, so JUMP to 5214H.
Original Source Code Comment: SYNTAX ERROR
5478
LD A,(54A3H)LD A,(PW)
We need to check to see if either of the valid parameters were specified so first fetch the value stored at memory location 54A3H (which is in the middle of an LD DE,nnnnH OPCODE, but is doubling as storage as well) and put it into Register A.
547B
LD HL,54C3LD HL,LOCK
LET Register Pair HL = 54C3H (which an LD DE,nnnnH OPCODE that is doubling as storage as well.
547E
OR (HL)
OR the value stored at (HL) against Register A to see if those 2 locations match. The results are stored in Register A.
547F
If the Z FLAG (Zero) is set then we have a problem so JUMP to 5218H.
5482
LD HL,5526LD HL,OLDMAS
LET Register Pair HL = 5526H to point to the message storage area for "MASTER PASSWORD?".
Original Source Code Comment: POINT TO 'OLD' MSG
5485
GOSUB to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found.
Original Source Code Comment: PRINT IT
5488
GOSUB to 551AH to get a response from the user to that prompt and encode it; results in HL.
Original Source Code Comment: GET OLD MAST PASSWORD
548B
LD (549AH),HLLD (INPPAS),HL
Store the value held in Register HL (i.e., the hashed password) into the memory location 549AH.
Original Source Code Comment: STORE IT
548E
LD C,00LD C,DRV3
LET Register C = nnH, a value which is placed in 458FH elsewhere.
Original Source Code Comment: GET DRIVE NUMBER
5490
GOSUB to 4A93H.
NOTE: 4A93H is the SYS00/SYS routine to READ THE GAT sector into RAM (Buffer at 4D00H).
Original Source Code Comment: GET THE PASSWORD FROM DISK
5493
If the NZ FLAG (Not Zero) is set then the CALL to READ THE GAT SECTOR has resulted in an error; so JUMP to 6132H.
Original Source Code Comment: EXIT IF ERROR
5496
LD HL,(4DCEH)LD HL,(BUFF2 + DPASS)
Fetch the value stored at memory location 4DCEH (i.e., the hashed master password as stored in the GAT SECTOR) and put it into Register HL.
Original Source Code Comment: M PASS LOCATION
5499
LD DE,0000LD DE,INPPASS
LET Register Pair DE = nnnnH, a value which is placed in 549AH-549BH elsewhere.
Original Source Code Comment: GET THE OLD PASSWORD
549C
OR A
Set FLAGS based on the contents of Register A.
Original Source Code Comment: CLEAR CARRY
549D
SBC HL,DE
Subtracts the value stored in Register Pair DE (i.e., the hashed version of the master password the user just entered) and the carry flag from the value stored in Register Pair HL (i.e., the hashed master password as stored in the GAT SECTOR).
Original Source Code Comment: SEE IF A MATCH USER SUPPLIED
549F
If the NZ FLAG (Not Zero) is set then those two passwords did NOT match, so JUMP to 5238H.
Original Source Code Comment: NOPE, ERROR
54A2
LD DE,0000LD DE,PW
LET Register Pair DE = nnnnH, a value which is placed in 54A3H-54A4H elsewhere.
Original Source Code Comment: GET NEW PASSWORD
54A6
54A5
LD A,D
OR E
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.
54A7
If the Z FLAG (Zero) is set then we have NOT been asked to change the password, so JUMP to 54BFH.
Original Source Code Comment: NO, USE DEFAULT PASSWORD
54A9
LD HL,5538LD HL,NEWPAS
LET Register Pair HL = 5538H to point to the message storage area for "NEW MASTER PASSWORD?".
Original Source Code Comment: POINT TO 'NEW' MSG
54AC
GOSUB to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found.
Original Source Code Comment: PRINT IT
54AF
GOSUB to 551AH to get a response from the user to that prompt and encode it; results in HL.
Original Source Code Comment: GET ANSWER
54B2PROTOK
LD (4DCEH),HLLD (BUFF2 + DPASS),HL
Store the value held in Register HL into the memory location 4DCEH, which is the location in the GAT SECTOR in RAM for the MASTER PASSWORD.
Original Source Code Comment: SET NEW PASSWORD
54B5
LD A,(548FH)LD A,(DRV3)
Fetch the value stored at memory location 548FH (i.e., the drive spec) and put it into Register A.
Original Source Code Comment: GET THE DRIVE NUMBER
54B8
LD C,A
Since most DISK I/O routines expect the drive letter to be in Register C, LET Register C = Register A (i.e., the drive spec).
Original Source Code Comment: INTO C
54B9
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 NEW PASSWORD
54BC
If the NZ FLAG (Not Zero) is set then the routine to WRITE THE GAT SECTOR FROM RAM TO DISK returned an error, so JUMP to 6132H.
Original Source Code Comment: EXIT IF ERROR
54BFNOPW
LD HL,(4DCEH)LD HL,(BUFF2 + DPASS)
Fetch the value stored at memory location 4DCEH (i.e., the hashed master password as stored in the GAT SECTOR) and put it into Register HL.
Original Source Code Comment: GET THE PASSWORD
54C2
LD DE,0000LD DE,LOCK
LET Register Pair DE = nnnnH, a value stored in memory locations 54C3H-54C4 elsewhere in this overlay.
Original Source Code Comment: GET LOCK PASSWORD
54C6
54C5
LD A,D
OR E
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.
54C7
RET Z
If the Z FLAG (Zero) is set, then DE was zero meaning that we do not need to lock all the files on the diskette, so RETurn to the caller.
Original Source Code Comment: NO, EXIT
54C8NOLOCK
LD (54F2H),HLLD (PASSW),HL
Store the value held in Register HL (i..e, the hashed master password) into the memory location 54F2H.
Original Source Code Comment: SAVE THE USER HASH PASSWORD
54CB
LD A,(548FH)LD A,(DRV3)
Fetch the value stored at memory location 548FH (i.e., the drive number) and put it into Register A.
Original Source Code Comment: GET THE DRIVE WE'RE WORKING ON
54CE
LD C,A
Since most DISK I/O routines expect the drive letter to be in Register C, LET Register C = Register A (i.e., the drive spec).
Original Source Code Comment: INTO C
54CF
GOSUB to 4B3EH to prepare the diskette for a DIRECTORY READ.
Original Source Code Comment: GET THE DIRECTORY TRACK NUMBER THIS DISK
54D2
LD E,03LD E,DIRSEC
LET Register E = 03H to signify that we want directory sector 3.
Original Source Code Comment: E = DIRECTORY RECORDS STARTING SECTOR
54D4L6OP36
LD HL,4300LD HL,BUFF1
LET Register Pair HL = 4300H to set up for a RAM buffer.
Original Source Code Comment: PLACE TO STORE A DIR SECTOR
54D7
LD (54FDH),HLLD (BUFSAV),HL
Store the value held in Register HL (i.e., the RAM buffer pointer) into the memory location 54FDH.
Original Source Code Comment: SAVE IT FOR LATER
54DA
GOSUB to 4B0DH to READ the directory sector held in Register E from the Drive held in Register C into a memory buffer pointed to by Register Pair HL.
Original Source Code Comment: READ IN A SECTOR
54DD
If the NZ FLAG (Not Zero) is set then the CALL to READ THE DIRECTOR SECTOR returned an error; so JUMP to 6132H.
Original Source Code Comment: EXIT IF ERROR
54E0L6OP35
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., a byte of the directory sector) and put it into Register A.
54E1
OR A
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A.
Original Source Code Comment: ANY FILE HERE?
54E2
If the Z FLAG (Zero) is set, then the first byte in the directory sector is ZERO, meaning file is NOT in use. If that's the case, JUMP to 54FCH.
Original Source Code Comment: NO, BYPASS IT
54E4
AND 07AND PNOACC
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, which are the SECURITY LEVEL active.
Original Source Code Comment: MASK OFF ALL BUT PROTECTION BITS
54E6
If the NZ FLAG (Not Zero) is set then we have a SYSTEM FILE here, so JUMP to 54FCH.
Original Source Code Comment: HAS A PASSWORD. SKIP IT
54E8
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the FILE TYPE byte of the DIRECTORY SECTOR in RAM) and put it into Register A.
Original Source Code Comment: GET THE ATTRIB VALUE
54E9
OR 06OR PEXEC
OR Register A against 06H (0000 0110). This has the effect of turning on bits 2 and 1 to signify KILL access.
Original Source Code Comment: MAKE IT EXECUTE ONLY
54EB
LD (HL),A
Store the value held in Register A (i.e., the FILE TYPE byte with KILL ACCESS enabled) into the memory location (i.e., the FILE TYPE byte of the DIRECTORY SECTOR in RAM) pointed to by Register Pair HL.
Original Source Code Comment: SET THE VALUE
54ED
54EC
54EF
LD A,L
ADD A,DUPD
LD L,A
LET Register L = Register L + 10H. HL will now point to the PASSWORD in the DIRECTORY SECTOR in RAM.
Original Source Code Comment: BUMP IT TO THE UPDATE PASSWORD TRAP DOOR
54F0
PUSH DE
Save Register DE to the top of the stack.
Original Source Code Comment: SAVE THE SECTOR NUMBER IN (E)
54F1
LD DE,0000LD DE,PASSW
LET Register Pair DE = nnnnH, a value stored in memory locations 54F2H-54F3H elsewhere in this overlay.
Original Source Code Comment: GET THE USER SUPPLIED HASH

The next few instructions put the password hash stored in Register Pair DE into the UPDATE and ACCESS password slots of the DIRECTORY SECTOR in RAM.

54F4
LD (HL),E
Store the value held in Register E into the memory location pointed to by Register Pair HL.
Original Source Code Comment: AND PUT IT INTO THE UPDATE
54F5
INC HL
Bump the value stored in Register Pair HL by 1.
54F6
LD (HL),D
Store the value held in Register D into the memory location pointed to by Register Pair HL.
54F7
INC L
Bump the value stored in Register L by 1.
54F8
LD (HL),E
Store the value held in Register E into the memory location pointed to by Register Pair HL.
Original Source Code Comment: AND ALSO THE ACCESS
54F9
INC HL
Bump the value stored in Register Pair HL by 1.
54FA
LD (HL),D
Store the value held in Register D into the memory location pointed to by Register Pair HL.
54FB
POP DE
Restore Register Pair DE from the top of the STACK.
Original Source Code Comment: GET SECTOR NUMBER BACK
54FCHASPAS
LD HL,0000LD HL,BUFSAV
LET Register Pair HL = nnnnH, a value stored in memory locations 54FDH-54FEH elsewhere in this overlay, and is meant to be the buffer pointer.
Original Source Code Comment: BUFFER POINTER SAVED HERE
5500
54FF
5502
LD A,L
ADD A,SIZDIR
LD L,A
LET Register L = Register L + 30H. HL will now point to the next directory entry in the DIRECTORY SECTOR in RAM.
Original Source Code Comment: BUMP TO NEXT FILE
5503
LD (54FDH),HLLD (BUFSAV),HL
Store the value held in Register HL (i.e., the buffer pointer) into the memory location 54FDH.
Original Source Code Comment: SAVE NEW POINTER
5506
CP 0F0H
Compare the value held in Register A against 0F0H to see if we are at the end of a sector yet. Results:
  • If Register A equals 0F0H, the Z FLAG is set.
  • If A < 0F0H, the CARRY FLAG will be set.
  • if A >= 0F0H, the NO CARRY FLAG will be set.

Original Source Code Comment: END OF DIR?
5508
If the C FLAG (Carry) is set, then we are NOT at the end of the sector, so LOOP BACK to 54E0H.
Original Source Code Comment: NO, CONTINUE
550A
LD HL,4300LD HL,BUFF1
LET Register Pair HL = 4300H, which is the RAM Buffer.
Original Source Code Comment: WRITE OUT THE NEW DIR SECTOR
550D
GOSUB to 45F7H to write the RAM BUFFER pointed to by Register Pair HL to the directory sector.
Original Source Code Comment: WRITE OUT THE NEW DIR RECORD
5510
If the NZ FLAG (Not Zero) is set then the prior subroutine to write the RAM BUFFER to diskette returned an error, so JUMP to 6132H.
5513
INC E
Bump the value stored in Register E by 1 so as to point to the next sector of the directory.
Original Source Code Comment: BUMP TO NEXT SECTOR NUMBER
5514
LD A,E
LET Register A = Register E for purposes of checking that value.
5515
CP 13CP TRACK + 1
Compare the value held in Register A against 13H (Decimal: 19). Results:
  • If Register A equals 13H, the Z FLAG is set.
  • If A < 13H, the CARRY FLAG will be set.
  • if A >= 13H, the NO CARRY FLAG will be set.

Original Source Code Comment: WE DONE WITH DIRECTORY?
5517
If the C FLAG (Carry) is set then we have not yet reached the end of the directory, so LOOP BACK to 54D4H.
Original Source Code Comment: NO, CONTINUE
5519
RET
RETurn to the caller.

551AH - MASINP - SUBroutine as part of the PROT routine.

551AMASINP
LD HL,4300LD HL,BUFF1
LET Register Pair HL = 4300H to as to point to the RAM BUFFER.
Original Source Code Comment: SCRATCH PAD BUFFER
551D
LD B,08H
LET Register B = 08H, signifying 8 characters to be read.
Original Source Code Comment: MAX LEN OF A PASSWORD
551F
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 Pair DE is altered in this routine.
Original Source Code Comment: KEYBOARD INPUT THE MASTER PASSWORD
5522
GOSUB to 555FH to to encode a password into Register Pair HL.
Original Source Code Comment: CALCULATE THE TRAP DOOR CODE
5525
RET
RETurn to the caller.
Original Source Code Comment: EXIT

5526H - OLDMAS - MESSAGE STORAGE AREA for the PROT command.

5526OLDMAS
DEFM ...
"MASTER PASSWORD?".
5538NEWPAS
DEFM ...
"NEW MASTER PASSWORD?".

554EH - SWTCH5 - PARAMETER STORAGE AREA for the PROT command.

554ESWTCH5
DEFM ...
"PW ". Note: The FLAG for this is at 54A3H.
5546
DEFM ...
"LOCK ". Note: The FLAG for this is at 54CEH.
555E
DEFB 00H
Terminator.

555FH - TRAP - SUBROUTINE from the PROT library command to encode a password.

555FTRAP
EX DE,HL
EXchange the value stored in Register Pair HL (i.e., the end of the password entered by the user followed by the terminating character) with the value stored in Register Pair DE (i.e., the password entered by the user followed by the terminating character).
5560
LD H,D
LET Register H = Register D.
5561
LD A,B
LET Register A = Register B (i.e., the length of the password which was entered).
5562
ADD A,E
LET Register A = Register A + Register E.
5563
LD L,A
LET Register L = Register A.
5564
LD A,08H
LET Register A = 08H, which is the length of a full size password.
5566
SUB B
LET Register A = Register A - Register B.
5567
If the the length of the password entered is equal to the maximum length of password then the Z FLAG (Zero) is set, JUMP to 556FH.
5569
LD B,A
LET Register B = Register A (i.e., the number of blanks at the end of the password), in preparation for a DJNZ loop to fill in that number of characters with spaces.
556AFILSPC
LD (HL),20H
Store the a SPACE into the memory location pointed to by Register Pair HL.
556C
INC HL
INCrement the value stored in Register Pair HL by 1 to point to the next character in the user entered password.
556D
LOOP back to 556AH, 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.
556FNOSPC
LD HL,0FFFFH
LET Register Pair HL = 0FFFFH (Decimal: -1).
5572
LD B,08H
LET Register B = 08H, which is the length of a full size password.
5574
5575
5577
LD A,E
ADD A,07H
LD E,A
LET Register E = Register E + 07H, which means DE is now the last letter in the password.
5578
Since we only did math on E instead of Register Pair DE, there is a risk that Register E will have spilled over. If that happened, then the C FLAG will be sent and we will need to increase D. If, however, the NC FLAG (No Carry) is set, we don't need to do that, so skip that by JUMPing to 557BH.
557A
INC D
INCrement the value stored in Register D by 1 since the math on Register E produced a carry.
557BSETTD2
LD A,(DE)
Fetch the value stored at memory location pointed to by Register Pair DE (i.e., a character in the password) and put it into Register A.
557C
PUSH DE
Save Register Pair DE (i.e., the pointer to the currently processed character in the user entered password) to the top of the stack.
557D
LD D,A
LET Register D = Register A (i.e., the character pointed to by register pair (DE)).
557E
LD E,H
LET Register E = Register H (i.e., the MSB of the password).
557F
LD A,L
LET Register A = Register L (i.e., the LSB of the password).
5580
AND 07H
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.
5583
5582
5584
RRCA
RRCA
RRCA
Rotate the remaining bits (2-1-0) into bits 7-6-5 by doing three RRCA's (which rotates the contents of A right one bit position; so that, for example, the contents of bit 0 are copied bit 7).
5585
XOR L
eXclusive OR Register L against Register A, to combine with the LSB. The results are stored in Register A.
5586
LD L,A
LET Register L = Register A (i.e., the masked, rotated, XOR'd LSB of the password).
5587
LD H,00H
LET Register H = 00H, in preparation for math.
5589
SBC HL,DE
LET HL = A - DE.
558C
558B
ADD HL,HL
ADD HL,HL
LET Register Pair HL = Register Pair HL * 4.
558E
558D
XOR H
XOR D
eXclusive OR Register H and then Register D against Register. This leaves the new MSB in Register A.
558F
LD D,A
LET Register D = Register A (i.e., the MSB of the password).
5590
LD A,L
LET Register A = Register L (i.e., the LSB of the password).
5591
ADD HL,HL
LET Register Pair HL = Register Pair HL * 2.
5592
XOR H
eXclusive OR Register H against Register A to combine with the MSB.
5593
XOR E
eXclusive OR Register E against Register A to further combine with the LSB of Register Pair DE.
5594
LD E,A
LET Register E = Register A (i.e., the new LSB of DE).
5595
EX DE,HL
EXchange the value stored in Register Pair HL with the value stored in Register Pair DE (i.e., the new password).
5596
POP DE
Put the value held at the top of the STACK (i.e., the pointer to the character in the password string which was just processed) into Restore Register Pair DE, and then remove the entry from the stack.
5597
DEC DE
DECrement the value stored in Register Pair DE by 1 so as to move the pointer to the previous character in the password string.
5598
Keep processing 8 characters of the password by LOOPing back to 557BH, 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.
559B
559A
LD A,H
OR L
Since the Z-80 cannot test Register Pair HL against zero, the common trick is to set Register A to equal to Register H, and then OR A against Register L. Only if both Register H and Register L were zero can the Z FLAG be set.
559C
RET NZ
If the password is NOT blank (i.e., Register Pair HL does not equal 0), then the NZ FLAG (Not Zero) is set, and RETurn to the caller.
559D
INC L
If we are here, then HL=0, which is bad. Since we can't have a 0 there, INCrement the value stored in Register L by 1.
559E
RET
RETurn to the caller.

559FH - RENAME Library Command

559FRENAME
GOSUB to 623AH to isolate and validate the FILESPEC from the command line via an OVERLAY call to ROUTINE 4 of OVERLAY 1.
Original Source Code Comment: DO SYNTAX CHECK OF 1ST NAME
55A2
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5218H.
Original Source Code Comment: EXIT IF SYNTAX ERROR
55A5
PUSH HL
Save Register Pair HL (i.e., the command line address) to the top of the stack.
Original Source Code Comment: SAVE COMMAND LINE POINTER
55A6
PUSH DE
Save Register Pair DE (i.e., the DCB address) to the top of the stack.
Original Source Code Comment: SAVE DCB POINTER
55A7
LD HL,5666LD HL,NAME1
LET Register Pair HL = 5666H to point to the filename.
Original Source Code Comment: POINT TO 1ST NAME
55AA
LD DE,6280LD DE,S6DCB1
LET Register Pair DE = 6280H to point to the print buffer.
Original Source Code Comment: POINT TO DCB
55AD
GOSUB to 563DH to copy the contents of (DE) to (HL) until a control character is reached, at which point JUMP to 5647.
Original Source Code Comment: MOVE THE NAME TO 1ST DCB
55B0
POP DE
Put the value held at the top of the STACK (i.e., the DCB address) into Restore Register Pair DE, and then remove the entry from the stack.
Original Source Code Comment: RESTORE POINTERS
55B1
POP HL
Put the value held at the top of the STACK (i.e., the command line address) into Restore Register Pair HL, and then remove the entry from the stack.
55B2
GOSUB to 4424H which is the SYS00/SYS routine to OPEN A DISK FILE for use. This RST 28H's with a value of 92H so as to call ROUTINE 1 in OVERLAY 3.
Original Source Code Comment: OPEN THE FILE
55B5
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
Original Source Code Comment: EXIT IF ERROR
55B8
LD DE,62B2LD DE,S6DCB2
LET Register Pair DE = 62B2H to point to the second filename DCB.
Original Source Code Comment: POINT TO 2ND DCB
55BB
GOSUB to 441CH.
Original Source Code Comment: DO SYNTAX AND MOVE IT TO THE DCB
55BE
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5218H.
Original Source Code Comment: EXIT IF ERROR
55C1
LD A,(6281H)LD A,(S6DCB1 + PROT)
Fetch the value stored at memory location 6281H (i.e., the access level byte in the first file's DCB) and put it into Register A.
Original Source Code Comment: GET PROTECTION LEVEL OF 1ST FILE
55C4
AND 07H
MASK the value of Register A against 07H (0000 0111) to isolate the access level. This has the effect of turning off bits 7, 6, 5, 4, 3, leaving only bits 2, 1, 0 active.
Original Source Code Comment: MASK OFF STATUS BITS
55C6
CP 03H
Compare the value held in Register A against 03H, which would be the right to RENAME or higher. Results:
  • If Register A equals 03H, the Z FLAG is set.
  • If A < 03H, the CARRY FLAG will be set.
  • if A >= 03H, the NO CARRY FLAG will be set.

Original Source Code Comment: WRITE PRIVILEDGE?
55C8
LD A,19LD A,EFAD
LET Register A = 19H, to signify a File Access Denied Due to To Password Protection error.
Original Source Code Comment: 'FILE ACCESS DENIED' ERROR
55CA
If the access level was >= 03H, the NC FLAG (No Carry) will be set, JUMP away to 6132H.
Original Source Code Comment: NO, ERROR
55CD
LD HL,62B2LD HL,S6DCB2
LET Register Pair HL = 62B2H so as to point to the second filename.
Original Source Code Comment: POINT TO NEW NAME DCB
55D0L6OP34
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL and put it into Register A.
Original Source Code Comment: GET A CHARACTER
55D1
CP 3AH
Compare the value held in Register A against 3AH (ASCII: :) to test for a drive number. Results: If Register A equals :, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: DRIVE SPECIFIER?
55D3
If that character was a :, which is not a good thing, then the Z FLAG (Zero) is set, so JUMP to 5214H.
Original Source Code Comment: YES, NOT ALLOWED
55D6
CP 20H
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?
55D8
INC HL
INCrement the value stored in Register Pair HL by 1 so as to point to the next characeter in the second filename.
Original Source Code Comment: BUMP POINTER
55D9
If the character was a A >= SPACE, then the NC FLAG (No Carry) is set, so LOOP back to 55D0H to keep parsing the 2nd filename.
Original Source Code Comment: NO, KEEP GOING
55DB
DEC HL
DECrement the value stored in Register Pair HL by 1 so that HL will now point to the end of the filename.
Original Source Code Comment: BACK UP ONE
55DCCONTE
LD (HL),3AH
Store a 20H (ASCII: :) into the memory location pointed to by Register Pair HL (i.e., the end of the filename).
Original Source Code Comment: LOAD DRIVE SPECIFIER
55DE
INC HL
INCrement the value stored in Register Pair HL by 1 to point to the next character of the filename.
Original Source Code Comment: BUMP TO NEXT POSITION
55DF
LD A,(6286H)LD A,(S6DCB1 + DRVNUM)
Fetch the value stored at memory location 6286H (i.e., the drive number, in decimal) and put it into Register A.
Original Source Code Comment: GET THE DRIVE NUM FROM 1ST FILE
55E2
ADD A,30H
LET Register A = Register A + 30H. Note: Adding 30H to from Register A will convert decimal number 0-9 into its ASCII equivalent (i.e., 6 + 30H = 36H, which, in ASCII, is 6.
Original Source Code Comment: MAKE IT ASCII
55E4
LD (HL),A
Store the value held in Register A (i.e., the ASCII equivalent of the drive number) into the memory location pointed to by Register Pair HL (i.e, the end of the filename).
Original Source Code Comment: STORE IT INTO NAME
55E5
INC HL
INCrement the value stored in Register Pair HL by 1 to point to the next character of the filename.
Original Source Code Comment: BUMP POINTER
55E6
LD (HL),03H
Store the value held in Register 03H, which is a standard terminator, into the memory location pointed to by Register Pair HL (i.e., the end of the filename).
Original Source Code Comment: LOAD EOL CHAR
55E8
LD DE,62B2LD DE,S6DCB2
LET Register Pair DE = 62B2H to point to the SECOND filename.
Original Source Code Comment: POINT TO NEW NAME DCB
55EB
PUSH HL
Save Register Pair HL (i.e., the pointer to the last character of the first filename) to the top of the stack.
Original Source Code Comment: SAVE POINTER TO END OF LINE
55EC
PUSH DE
Save Register Pair DE (i.e., the pointer to the second filename) to the top of the stack.
Original Source Code Comment: SAVE POINTER TO DCB
55ED
LD HL,5676LD HL,NAME2
LET Register Pair HL = 5676H to point to the second filename.
Original Source Code Comment: POINT TO 2ND NAME
55F0
LD DE,62B2LD DE,S6DCB2
LET Register Pair DE = 62B2H to point to the print buffer.
Original Source Code Comment: POINT TO 2ND DCB
55F3
GOSUB to 563DH to copy the contents of (DE) to (HL) until a control character is reached, at which point JUMP to 5647.
Original Source Code Comment: MOVE THE NAME TO DCB
55F6
POP DE
Put the value held at the top of the STACK (i.e., the pointer to the second filename) into Restore Register Pair DE, and then remove the entry from the stack.
Original Source Code Comment: GET THE DCB POINTER BACK
55F7
POP HL
Put the value held at the top of the STACK (i.e., the pointer to the last character of the first filename) into Restore Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: GET THE NAME POINTER BACK
55F8
GOSUB to 4424H
NOTE: 4424H is the SYS00/SYS routine to OPEN A DISK FILE for use. This RST 28H's with a value of 92H so as to call ROUTINE 1 in OVERLAY 3.
Original Source Code Comment: OPEN THE FILE
55FB
If the Z FLAG (Zero) is set then the second filename has been found, so JUMP to 521CH.
Original Source Code Comment: EXIT IF THAT NAME EXISTS
55FE
CP 18CP EFNF
Compare the value held in Register A (which returned from 521CH) against 18H (i.e., a FILE NOT FOUND ERROR). Results: If Register A equals 18H, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: FILE NOT IN DIRECTORY?
5600
If the NZ FLAG (Not Zero) is set, then we didn't get a FILE NOT FOUND error, so JUMP to 6132H.
Original Source Code Comment: IF NOT, TRUE ERROR
5603
GOSUB to 564AH to Display a Verification Message of "filename1 ----> filename2".
Original Source Code Comment: GO DISPLAY BOTH NAMES
5606
LD BC,(6286H)LD BC,(S6DCB1 + DRVNUM)
Fetch the value stored at memory location 6286H (i.e., the drivespec) and put it into Register BC.
Original Source Code Comment: GET THE DRIVE NUMBER
560A
PUSH BC
Save Register Pair BC (i.e., the the drive number and file number) to the top of the stack.
Original Source Code Comment: SAVE IT
560B
GOSUB to 4A67H.
NOTE: 4A67H is the SYS00/SYS routine to read the directory entry into RAM (Buffer at 4300H).
Original Source Code Comment: GO GET THE DIRECTORY
560E
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
Original Source Code Comment: EXIT IF ERROR

The next 4 instructions just set DE = HL + 5, which is the the pointer to the FILENAME in the directory entry.

5611
LD D,H
LET Register D = Register H, so Register D (MSB of DE) will match H (MSB of HL).
Original Source Code Comment: MOVE THE MSB TO (D)
5612
LD A,L
LET Register A = Register L, so Register A = the LSB of HL.
Original Source Code Comment: MOVE THE LSB TO (A)
5613
ADD A,05ADD A,DNAME
LET Register A = Register A + 05H, so Register A = the LSB of HL + 5.
Original Source Code Comment: SKIP OVER ATTRIB BYTES
5615
LD E,A
LET Register E = Register A (i.e., the LSB of HL + 5). Register Pair DE is now pointing to the the FILENAME in the directory entry.
Original Source Code Comment: AND PUT IT INTO (E)
5616
LD HL,5141LD HL,NAME
LET Register Pair HL = 5141H, which is a temporary memory storage location for the filename.
Original Source Code Comment: DCB AFTER OPEN
5619
LD BC,000BH
LET Register Pair BC = 000BH (Decimal: 11) to set up for a move of 11 bytes.
Original Source Code Comment: 11 CHARS TO MOVE
561C
LDIR
Use LDIR to move the filename to 5141H. 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.
561E
POP BC
Put the value held at the top of the STACK (i.e., the drive number and file number) into Register Pair BC, and then remove the entry from the stack.
Original Source Code Comment: GET THE DRIVE NUM BACK
561F
GOSUB to 4A7BH.
NOTE: 4A7BH is the SYS00/SYS routine to to write the directory entry from the copy in RAM to the diskette.
Original Source Code Comment: WRITE OUT THE NEW NAME
5622
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
Original Source Code Comment: EXIT IF ERROR
5625
GOSUB to 4ABAH.
NOTE: 4ABAH is the SYS00/SYS routine to read the HIT sector into RAM.
Original Source Code Comment: GET THE NAME'S HASH CODE
5628
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
Original Source Code Comment: EXIT IF ERROR
562B
LD D,H
LET Register D = Register H, so Register D (MSB of DE) will match H (MSB of HL).
Original Source Code Comment: PUT THE TABLE MSB INTO (D)
562C
LD E,B
LET Register E = Register B (i.e., the file number). With this Register Pair DE now points to the HASH TABLE ENTRY for the filename.
Original Source Code Comment: PUT THE OFFSET INTO (E)
562D
PUSH BC
Save Register Pair BC (i.e., the drive number and file number) to the top of the stack.
Original Source Code Comment: SAVE DRIVE NO. (C)
562E
LD HL,5141LD HL,NAME
LET Register Pair HL = 5141H, which is a temporary memory storage location for the filename.
Original Source Code Comment: POINT TO THE NAME
5631
GOSUB to 50E7H to hash the filename pointed to by Register Pair HL; results in Register A.
Original Source Code Comment: GO HASH IT
5634
POP BC
Put the value held at the top of the STACK (i.e., the drive number and file number) into Restore Register Pair BC, and then remove the entry from the stack.
Original Source Code Comment: GET DRIVE BACK
5635
LD (DE),A
Store the value held in Register A (i.e., the hashed filename) into the memory location pointed to by Register Pair DE.
Original Source Code Comment: PUT THE NEW HASH CODE IN TABLE
5636
GOSUB to 4AC2H.
NOTE: 4AC2H is the SYS00/SYS routine to write the HIT sector from RAM to diskette.
Original Source Code Comment: WRITE HASH TABLE
5639
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
Original Source Code Comment: EXIT IF ERROR
563C
RET
RETurn to the caller.
Original Source Code Comment: DONE

563DH - MOVNAM - Copy the contents of (DE) to (HL) until a control character is reached, at which point JUMP to 5647.

563DMOVNAM
LD A,(DE)
Fetch the value stored at memory location (i.e., a character) pointed to by Register Pair DE and put it into Register A.
Original Source Code Comment: GET A CHARACTER
563E
CP 20H
Compare the value held in Register A against 20H. If Register A < 20H, the CARRY FLAG will be set.
Original Source Code Comment: END OF LINE?
5640
If Register A < 20H, then the C FLAG (Carry) is set and we have a CONTROL CHARACTER, so JUMP to 5647H to add a 03H terminator and RETURN.
Original Source Code Comment: EXIT IF SO
5642
LD (HL),A
Store the value held in Register A (i.e., a character which we now know is at least greater than 20H) into the memory location pointed to by Register Pair HL.
Original Source Code Comment: STORE THE CHAR
5643
INC HL
INCrement the value stored in Register Pair HL by 1 for the next character to test and move from (DE) to (HL).
Original Source Code Comment: BUMP POINTERS
5644
INC DE
INCrement the value stored in Register Pair DE by 1 for the next character to test and move from (DE) to (HL).
5645
LOOP back to the top of this routine at 563DH.
Original Source Code Comment: AND CONTINUE

5647H - MOVNA1 - Continuation of the 563DH routine; add a 03H Terminator and RETurn.

5647MOVNA1
LD (HL),03H
Store the value held in Register 03H into the memory location pointed to by Register Pair HL.
Original Source Code Comment: LOAD A TERMINATOR CHAR
5649
RET
RETurn to the caller.

564AH - DSPNAM - SUBROUTINE called from 5603H to Display a Verification Message of "filename1 ----> filename2".

564ADSPNAM
PUSH BC
Save Register Pair BC to the top of the stack.
Original Source Code Comment: SAVE THE REGISTERS
564B
PUSH DE
Save Register Pair DE to the top of the stack.
564C
PUSH HL
Save Register Pair HL to the top of the stack.
564D
LD HL,5666LD HL,NAME1
LET Register Pair HL = 5666H to point to FILENAME 1.
Original Source Code Comment: POINT TO 1ST NAME
5650
GOSUB to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found.
Original Source Code Comment: DISPLAY IT
5653
LD HL,5686LD HL,NAMARO
LET Register Pair HL = 5686H to point to the message "---->".
Original Source Code Comment: HL => '--->' MSG
5656
GOSUB to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found.
Original Source Code Comment: DISPLAY IT
5659
LD HL,5676LD HL,NAME2
LET Register Pair HL = 5676H to point to FILENAME 2.
Original Source Code Comment: POINT TO 2ND NAME
565C
GOSUB to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found.
Original Source Code Comment: DISPLAY IT
565F
GOSUB to 5450H to display a carriage return via a JUMP to 0033H in the Model III ROM.
Original Source Code Comment: OUTPUT A CR
5662
POP HL
Put the value held at the top of the STACK into Restore Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: RESTORE REGISTERS
5663
POP DE
Put the value held at the top of the STACK into Restore Register Pair DE, and then remove the entry from the stack.
5664
POP BC
Put the value held at the top of the STACK into Restore Register Pair BC, and then remove the entry from the stack.
5665
RET
RETurn to the caller.

5666H - NAME1 - MESSAGE STORAGE AREA for the RENAME Command.

5666NAME1
DEFM ...
PRINT BUFFER FOR FILESPEC 1 of 16 characters.
Original Source Code Comment: PLACE TO STORE OLD NAME
5676NAME2
DEFM ...
PRINT BUFFER FOR FILESPEC 2 of 16 characters.
Original Source Code Comment: PLACE TO STORE NEW NAME
5686NAMARO
DEFM ...
---->.

568EH - "APPEND" Command.

568EAPPEND
GOSUB to 623AH to isolate and validate the FILESPEC from the command line via an OVERLAY call to ROUTINE 4 of OVERLAY 1.
Original Source Code Comment: GET SYNTAX OF 1ST FILE NAME
5691
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5218H.
Original Source Code Comment: EXIT IF ERROR
5694
LD DE,62B2LD DE,S6DCB2
LET Register Pair DE = 62B2H to point to FILESPEC 2's FCB.
Original Source Code Comment: POINT TO 2ND DCB
5697
GOSUB to 441CH.
NOTE: 441CH is the SYS00/SYS routine to CHECK THE SYNTAX OF A FILESPEC before for use. This RST 28H's with a value of C1H so as to call ROUTINE 4 in OVERLAY 1.
Original Source Code Comment: CHECK SYNTAX
569A
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5218H.
Original Source Code Comment: EXIT IF ERROR
569D
LD B,00H
LET Register B = 00H to signify a 256 Byte Full Sector LRL.
Original Source Code Comment: LRL = 256
569F
LD HL,6400LD HL,S6BUF2
LET Register Pair HL = 6400H for a memory buffer.
Original Source Code Comment: POINT TO BUFFER
56A2
GOSUB to 4424H to open FILESPEC 2.
NOTE: 4424H is the SYS00/SYS routine to OPEN A DISK FILE for use. This RST 28H's with a value of 92H so as to call ROUTINE 1 in OVERLAY 3.
Original Source Code Comment: OPEN THE FILE
56A5
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
Original Source Code Comment: EXIT IF ERROR
56A8
GOSUB to 6225H to open FILESPEC 1.
Original Source Code Comment: OPEN THE 1ST FILE
56AB
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
Original Source Code Comment: EXIT IF ERROR
56AE
LD A,(6289H)LD A,(S6DCB1 + LRL)
Fetch the value stored at memory location 6289H (i.e., the LRL for FILESPEC 1) and put it into Register A.
Original Source Code Comment: GET THE LRL OF FILE 1
56B1
LD B,A
LET Register B = Register A (i.e., the LRL for FILESPEC 1).
Original Source Code Comment: INTO B
56B2
LD A,(62BBH)LD A,(S6DCB2 + LRL)
Fetch the value stored at memory location 62BBH (i.e., the LRL for FILESPEC 2) and put it into Register A.
Original Source Code Comment: GET THE LRL OF FILE 2
56B5
CP B
Compare the value held in Register A against the value held in Register B. Results: If Register A equals Register B (meaning that both files LRL's are the same), the Z FLAG is set; otherwise the NZ FLAG is set.
56B6
If the file LRL's are different, then the the NZ FLAG (Not Zero) will be set so JUMP to 522FH.
Original Source Code Comment: EXIT IF LRLS DON'T MATCH
56B9
LD DE,62B2LD DE,S6DCB2
LET Register Pair DE = 62B2H to point to the FCB for FILESPEC 2.
Original Source Code Comment: POINT TO 2ND DCB
56BC
GOSUB to 4448H.
NOTE: 4448H is the SYS00/SYS vector for 'POSEOF', which positions the disk drive to the last record of the open file.
Original Source Code Comment: POSITION TO END OF THE FILE
56BF
If that CALL routine exited with no error, the Z FLAG (Zero) will be set, so in that case JUMP to 56C6H.
Original Source Code Comment: JR IF NO ERROR
56C1
CP 1CCP EEOF
Compare the value held in Register A against 1CH (i.e., an END OF FILE error). Results: If Register A equals 1CH, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: EOF ERROR?
56C3
If the NZ FLAG (Not Zero) is set, then we do have an error, just not END OF FILE, so JUMP to 6132H.
Original Source Code Comment: EXIT, IT'S TRUE ERROR
56C6L6OP10
LD DE,6280LD DE,S6DCB1
LET Register Pair DE = 6280H to point to the FCB for FILESPEC 1.
Original Source Code Comment: POINT TO 1ST DCB
56C9
Try to read a byte from FILESPEC 1 by GOSUBing to 0013H which 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
56CC
If the Z FLAG (Zero) is set, then that CALL returned a DEVICE READY, so JUMP to 56DAH.
Original Source Code Comment: JR IF NO ERROR
56CE
LD B,A
LET Register B = Register A (i.e., the error code returned from the CALL GET).
Original Source Code Comment: SAVE THE ERROR CODE
56CF
AND 0FEH
MASK the value of Register A against 0FEH (1111 1110) to turn off bit 0.
Original Source Code Comment: MASK ERROR 29 TO 28
56D1
CP 1CCP EEOF
Compare the value held in Register A against 1CH (i.e., the END OF FILE error code). Results:
  • If Register A equals 1CH, the Z FLAG is set.
  • If A < 1CH, the CARRY FLAG will be set.
  • if A >= 1CH/ 28/, the NO CARRY FLAG will be set.

Original Source Code Comment: EOF?
56D3
LD A,B
LET Register A = Register B (i.e., the error code returned from the CALL GET).
Original Source Code Comment: GET THE ERROR CODE BACK
56D4
If the Z FLAG (Zero) is set, then while we have a problem we do not care because we are done appending, so JUMP to 56EDH to close the files and RETURN.
Original Source Code Comment: DONE IF SO
56D7
JUMP to 6132H to exit the APPEND routine with an error.
Original Source Code Comment: ELSE EXIT, ERROR

56DAH - CONT - Continuation of APPEND Command. This routine is jumped to from 56CC if we got a DEVICE READY regarding FILESPEC 1 after reading a byte.

56DACONT
LD B,A
LET Register B = Register A (i.e., the byte read from FILESPEC 1 via a ROM call to 0013H) in 56C9.
Original Source Code Comment: SAVE THE CHAR WE JUST READ
56DB
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: SEE IF USER HITTING BREAK KEY
56DE
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned a BREAK, so JUMP to 56EDH to close the files and RETURN.
Original Source Code Comment: EXIT IF SO
56E1
LD A,B
LET Register A = Register B (i.e., the byte read from FILESPEC 1).
Original Source Code Comment: GET THE CHAR BACK
56E2
LD DE,62B2LD DE,S6DCB2
LET Register Pair DE = 62B2H to point to FILESPEC 2's FCB.
Original Source Code Comment: POINT TO 2ND DCB
56E5
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: WRITE A BYTE
56E8
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
Original Source Code Comment: EXIT IF ERROR
56EB
LOOP back to 56C6H to continue processing bytes.
Original Source Code Comment: ELSE CONTINUE

56EDH - CLOZE - Close FILESPEC 1 and FILESPEC 2 and RETurn.

56EDCLOZE
LD DE,62B2H
LET Register Pair DE = 62B2H to point to FILESPEC 2's FCB.
Original Source Code Comment: POINT TO FILE 2
56F0
GOSUB to 4428H to CLOSE the file for FILESPEC 2.
Original Source Code Comment: CLOSE THE FILE
56F3
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
Original Source Code Comment: EXIT IF ERROR
56F6CLOZE1
LD DE,6280LD DE,S6DCB1
LET Register Pair DE = 6280H to point to FILESPEC 1's FCB.
Original Source Code Comment: POINT TO FILE 1
56F9CLOZE2
GOSUB to 4428H to CLOSE the file for FILESPEC 1.
Original Source Code Comment: CLOSE THE FILE
56FC
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
Original Source Code Comment: EXIT IF ERROR
56FF
RET
RETurn to the caller.

5700H - "DUMP" Command.

The DUMP command stores a program into a disk file. The command structure is:

DUMP file (START=aaaa,END=bbbb,TRA=cccc,RELO=dddd)

  • aaaa = The 4 hexadecimal digit start address of the memory block to dump.
  • bbbb = The 4 hexadecimal digit end address of the memory block to dump.
  • cccc = The 4 hexadecimal digit transfer address to use to execute the program once it has been loaded. If blank, TRSDOS RE-ENTRY is used.
  • dddd = The 4 hexadecimal digit start address for relocating or loading the program back into memory. If blank, no relocation is done
  • Note: All hexadecimal numbers which begin with a letter must start with a 0. No x'____' notation is used.
5700DUMP
LD BC,6000H
LET Register Pair BC = 6000H which will be the default START and END numbers.
Original Source Code Comment: ASSUME STARTING ADDR OF 7000
5735
GOSUB to 59CBH to test the validity of the character of the filename stored in Register A.
Original Source Code Comment: SEE IF LEGAL CHAR
5738
If the C FLAG (Carry) is set then that routine returned a result that the character of the filename stored in Register A is INVALID. JUMP to 5741 to stop reading/processing characters from the scratch area and fill the rest of the filename with spaces.
Original Source Code Comment: JR IF SO
573AFILASC
LD (DE),A
Store the value held in Register A (i.e., the validated character of the filename) into the memory location pointed to by Register Pair DE (i.e., the 8 BYTE storage area for the FILENAME).
Original Source Code Comment: PUT THE CHAR INTO THE DCB
573B
INC HL
INCrement the value stored in Register Pair HL by 1 to point to the next character in the filename held in the scratch area.
Original Source Code Comment: BUMP POINTERS
573C
INC DE
INCrement the value stored in Register Pair DE by 1 to point to the next character in the 8 BYTE storage area for the FILENAME.
573D
LOOP back to 5734H, reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
Original Source Code Comment: CONTINUE FOR COUNT
573F
JUMP to 5747H to continue the "DUMP" routine.

5741H - SPCFIL - Part of the DUMP command. Jumped here if the character of the filename stored in Register A is INVALID.

5741SPCFIL
LD A,20H
LET Register A = 20H (ASCII: SPACE).
Original Source Code Comment: FILL REMAINDER OF
5743L6OP75
LD (DE),A
Store the value held in Register A (i.e., a SPACE) into the memory location pointed to by Register Pair DE (i.e., the 8 BYTE storage area for the FILENAME).
Original Source Code Comment: DCB WITH SPACES
5744
INC DE
INCrement the value stored in Register Pair DE by 1 to point to the next byte in the 8 BYTE storage area for the FILENAME.
5745
LOOP back to 5743H, 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.
5747CONTH
LD DE,6280LD DE,S6DCB1
LET Register Pair DE = 6280H, which is where the filename is currently stored.
Original Source Code Comment: POINT TO DCB
574A
LD HL,5822LD HL,CMD
LET Register Pair HL = 5822H, which points to a /CMD message.
Original Source Code Comment: POINT TO DEFAULT EXTENSION
574D
GOSUB to 444BH to add the extension pointed to by Register Pair HL to the end of the filename pointed to by Register Pair DE.
Original Source Code Comment: ADD IT TO THE NAME
5750
LD B,00H
LET Register B = 00H to set up for creating a file with an LRL of 256.
Original Source Code Comment: SET FOR LRL = 256
5752
LD HL,6300LD HL,S6BUF1
LET Register Pair HL = 6300H to use as a buffer for the 4420H CALL.
Original Source Code Comment: POINT TO BUFFER
5755
GOSUB to 4420H.
NOTE: 4420H is the SYS00/SYS routine to INITIALIZE A DISK (i.e., CREATE or OPEN). This RST 28H's with a value of A2H so as to call ROUTINE 2 in OVERLAY 2. Register HL needs to point to a RAM BUFFER for the DCB's.
Original Source Code Comment: GO OPEN (OR INIT) THE FILE
5758
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
Original Source Code Comment: EXIT IF ERROR
575B
LD A,05H
LET Register A = 05H, which is a COMMENT BLOCK designator.
Original Source Code Comment: LOAD A REMARK LOAD FILE FORMAT
575D
GOSUB to 581CH to write the contents of Register A (i.e., a COMMENT BLOCK designator) to the file.
Original Source Code Comment: WRITE REMARK HEADER OUT
5760
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
Original Source Code Comment: EXIT IF ERROR
5763
LD A,10H
LET Register A = 10H (Decimal: 16) to set up the next CALL for a write of 16 bytes.
Original Source Code Comment: SET CHARACTER COUNT
5765
GOSUB to 581CH to write the contents of Register A (i.e., 10H) to the file.
Original Source Code Comment: WRITE OUT THE CHAR COUNT
5768
LD B,08H
LET Register B = 08H, to set up for a DJNZ loop of 8 characters, which is the length of the FILESPEC.
Original Source Code Comment: SET FOR 8 CHARS TO WRITE OUT
576A
LD HL,5846LD HL,NAMFIL
LET Register Pair HL = 5846H, which is an 8 BYTE storage area for the FILENAME.
Original Source Code Comment: POINT TO NAME
576DL6OP71
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., a current byte from the FILESPEC) and put it into Register A.
Original Source Code Comment: GET A NAME CHAR
576E
INC HL
INCrement the value stored in Register Pair HL by 1 to point to the next byte of the FILESPEC.
Original Source Code Comment: BUMP POINTER
576F
GOSUB to 581CH to write the contents of Register A (i.e., a byte of the filename) to the file.
Original Source Code Comment: WRITE OUT THE CHAR
5772
LOOP back to 576DH, 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
5774
PUSH BC
Save Register Pair BC to the top of the stack.
Original Source Code Comment: SAVE THE REGISTERS
5775
PUSH DE
Save Register Pair DE to the top of the stack.
5776
PUSH IX
Save Register Pair IX to the top of the stack.
5778
LD C,2FH
LET Register C = 2FH (ASCII: /) in preparation for writing the DATE.
Original Source Code Comment: LOAD THE DATE DELIMITER
577A
GOSUB to 61F0H to generate the date and place it into the file.
Original Source Code Comment: GET THE 'TIME'
577D
POP IX
Put the value held at the top of the STACK into Restore Register Pair IX, and then remove the entry from the stack.
Original Source Code Comment: RESTORE THE REGISTERS
577F
POP DE
Put the value held at the top of the STACK into Restore Register Pair DE, and then remove the entry from the stack.
5780
POP BC
Put the value held at the top of the STACK into Restore Register Pair BC, and then remove the entry from the stack.
5781
LD B,08H
LET Register B = 08H, to set up for a DJNZ loop of 8 characters, which is the length of the DATE.
Original Source Code Comment: SET FOR COUNT OF 8 CHARS
5783L6OP91
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL and put it into Register A.
Original Source Code Comment: GET A DATE CHAR
5784
INC HL
INCrement the value stored in Register Pair HL by 1.
Original Source Code Comment: BUMP POINTER
5785
GOSUB to 581CH to write the contents of Register A (i.e., a byte of the DATE) to the file.
Original Source Code Comment: WRITE OUT THE CHAR
5788
LOOP back to 5783H, 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
578A
LD HL,(57BBH)LD HL,(END)
Fetch the value stored at memory location 57BBH (i.e., the END address) and put it into Register HL.
Original Source Code Comment: GET THE DUMP ENDING ADDR
578D
LD BC,(57B1H)LD BC,(START)
Fetch the value stored at memory location 57B1H (i.e., the START address) and put it into Register BC.
Original Source Code Comment: GET THE DUMP BEGINNING ADDR
5791
OR A
Set FLAGS based on the contents of Register A.
Original Source Code Comment: CLEAR CARRY
5792
SBC HL,BC
Subtracts the value stored in Register Pair BC (i.e., the START address) and the carry flag from the value stored in Register Pair HL (i.e., the END address).
Original Source Code Comment: GET THE DIFFERENCE
5794
If the C FLAG (Carry) is set, then the END address in HL was > the START address in DE, which is a problem, so JUMP to 5220H.
Original Source Code Comment: IF CARRY, END LESS THAN START
5797
LD HL,5FFFH
LET Register Pair HL = 5FFFH, which is 1 byte below the lowest permitted START address.
Original Source Code Comment: SEE IF BELOW ALLOABLE ADDRESS
579A
SBC HL,BC
Subtracts the value stored in Register Pair BC (i.e., the START address) and the carry flag from the value stored in Register Pair HL (i.e., 5FFFH, which is the lowest permitted START address).
Original Source Code Comment: GET THE DIFFERENCE
579C
If the NC FLAG (No Carry) is set, then the START address is too low, so JUMP to 5225H.
Original Source Code Comment: YES, ILLEGAL ADDRESS
579F
LD HL,(57B5H)LD HL,(RELO)
Fetch the value stored at memory location 57B5H (i.e., the RELO address) and put it into Register HL.
Original Source Code Comment: GET THE RELO ADDR IF ANY
57A3
57A2
LD A,H
OR L
Since the Z-80 cannot test Register Pair HL against zero, the common trick is to set Register A to equal to Register H, and then OR A against Register L. Only if both Register H and Register L were zero can the Z FLAG be set.
57A4
If the NZ FLAG (Not Zero) is set, then we have a RELO parameter to deal with, so JUMP to 57B0H.
Original Source Code Comment: YES, GO FIGURE OFFSET
57A6
LD HL,(57B1H)LD HL,(START)
Fetch the value stored at memory location 57B1H (i.e., the START address) and put it into Register HL.
Original Source Code Comment: MAKE THE RELO SAME AS START
57A9
LD (57B5H),HLLD (RELO),HL
Store the value held in Register HL (i.e., the START address) into the memory location 57B5H (i.e., the RELO address).
57AC
LD IX,5845LD IX,DCOUNT
LET Register Pair IX = 5845H so as to point to the FILENAME.
Original Source Code Comment: IX => RESIDUAL COUNT
57B0RELO1
LD HL,0000LD HL,START
LET Register Pair HL = the value put into 57B1H, which is the START address.
Original Source Code Comment: GET THE MODIFIED START ADDR
57B3
LD IY,0000LD IY,RELO
LET Register Pair IY = the value put into 57B5H, which is the RELO address.
Original Source Code Comment: GET THE RELOCATE ADDR
57B7L6OP73
PUSH HL
Save Register Pair HL (i.e., the START address) to the top of the stack.
Original Source Code Comment: SAVE START ADDR
57B8
LD B,H
LET Register B = Register H (i.e., MSB of the the START address).
Original Source Code Comment: MIRROR TO BC
57B9
LD C,L
LET Register C = Register L (i.e., LSB of the the START address).
57BA
LD HL,0000LD HL,END
LET Register Pair HL = the value put into 57BBH, which is the END address.
Original Source Code Comment: GET THE ENDING ADDR
57BD
INC HL
INCrement the value stored in Register Pair HL (i.e., the END address) by 1.
Original Source Code Comment: BUMP IT BY ONE
57BE
OR A
Set FLAGS based on the contents of Register A, which clears the CARRY FLAG.
Original Source Code Comment: CLEAR CARRY
57BF
SBC HL,BC
Subtracts the value stored in Register Pair BC (i.e., the START address) and the carry flag from the value stored in Register Pair HL (i.e., the END address + 1). With this, HL will now contain the number of bytes to save.
Original Source Code Comment: WE AT THE END YET?
57C1
If the Z FLAG (Zero) is set, then there are no bytes to save, so JUMP to 57F4H.
Original Source Code Comment: YES, CLOSE THE FILE
57C3
LD B,0FEH
LET Register B = 0FEH for a loop of 254 bytes to write each time.
Original Source Code Comment: NO, SET CHAR COUNT
57C5
LD A,H
LET Register A = Register H (i.e., the MSB of the number of bytes to save).
Original Source Code Comment: GET THE MSG OF BYTE COUNT
57C6
OR A
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A.
Original Source Code Comment: ZERO?
57C7
If the NZ FLAG (Not Zero) is set, then there is more than just one page (meaning the number of bytes was more than what the LSB could hold) so JUMP to 57CFH.
Original Source Code Comment: NO, GO WRITE A SECTOR
57C9
LD A,L
LET Register A = Register L (i.e., the LSB of the number of bytes to save).
Original Source Code Comment: GET THE LSB OF BYTE COUNT
57CA
CP 0FFH
Compare the value held in Register A against 0FFH (Decimal: 255). Results:
  • If Register A equals 255, the Z FLAG is set.
  • If A < 255, the CARRY FLAG will be set.
  • if A >= 255, the NO CARRY FLAG will be set.

Original Source Code Comment: MORE THAN A SECTOR?
57CC
If the NC FLAG (No Carry) is set, then there are 255 or more bytes, which is still too many since we need to write 254, so JUMP to 57CFH.
Original Source Code Comment: YES, GO WRITE IT OUT
57CE
LD B,L
LET Register B = Register L (i.e., the LSB of the number of bytes to save).
Original Source Code Comment: NO, USE THE BYTE COUNT AS HEADER COUNT
57CFDUMP1
POP HL
Put the value held at the top of the STACK (i.e., the START address) into Restore Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: GET STARTING ADDRESS BACK
57D0
LD A,01H
LET Register A = 01H, which is code for a DATA BLOCK.
Original Source Code Comment: LOAD A LOAD FILE FORMAT
57D2
GOSUB to 581CH to write the contents of Register A (i.e., a DATA BLOCK designator) to the file.
Original Source Code Comment: WRITE IT OUT
57D5
LD A,B
LET Register A = Register B (i.e., the LSB of the number of bytes to save).
Original Source Code Comment: GET THE CHAR COUNT
57D6
ADD A,02H
LET Register A = Register A + 02H (i.e., the the number of bytes to save + 2).
Original Source Code Comment: ADD THE ADDR COUNT TO IT
57D8
GOSUB to 581CH to write the contents of Register A (i.e., the number of bytes about to be written) to the file.
Original Source Code Comment: WRITE OUT THE CHAR COUNT
57DB
PUSH IY
Save Register Pair IY (i.e., the RELO address) to the top of the stack.
Original Source Code Comment: PUT THE DUMMY ADDRESS ON STACK
57DD
EX (SP),HL
EXchange the value stored in Register Pair HL (i.e., the total number of bytes to save) with the value stored at the top of the STACK (i.e., the RELO address).
Original Source Code Comment: GET IT INTO HL
57DE
LD A,L
LET Register A = Register L (i.e., the LSB of the RELO address), which means we are writing out the RELO address instead of the TRANSFER address.
Original Source Code Comment: GET THE LSB OF THE DUMMY ADDR
57DF
GOSUB to 581CH to write the contents of Register A (i.e., the MSB of the RELO address) to the file.
Original Source Code Comment: WRITE IT OUT
57E2
LD A,H
LET Register A = Register H (i.e., the MSB of the RELO address), which means we are writing out the RELO address instead of the TRANSFER address.
Original Source Code Comment: GET THE MSB OF THE ADDR
57E3
EX (SP),HL
EXchange the value stored in Register Pair HL (i.e., the RELO address) with the value stored at the top of the STACK (i.e., the total number of bytes to save).
Original Source Code Comment: PUT THE ADDR BACK ON STACK
57E4
POP IY
Put the value held at the top of the STACK (i.e., the RELO address) into Restore Register Pair IY, and then remove the entry from the stack.
Original Source Code Comment: GET THE STACK CORRECT
57E6
GOSUB to 581CH to write the contents of Register A (i.e., the MSB of the RELO address) to the file.
Original Source Code Comment: WRITE OUT THE MSB
57E9L6OP72
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., a data byte) and put it into Register A.
Original Source Code Comment: GET A CHAR
57EA
INC HL
INCrement the value stored in Register Pair HL (i.e., a data byte) by 1.
Original Source Code Comment: BUMP POINTER
57EB
INC IY
INCrement the value stored in Register Pair IY (i.e., the RELO address) by 1.
Original Source Code Comment: BUMP DUMMY ADDRESS
57ED
GOSUB to 581CH to write the contents of Register A (i.e., a data byte) to the file.
Original Source Code Comment: WRITE OUT THE CHAR
57F0
LOOP back to 57E9H (which is looping L), reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
Original Source Code Comment: DO FOR COUNT
57F2
BIG LOOP back to 57B7H until all of H is also exhausted.
Original Source Code Comment: AND CONTINUE

57F4H - DOEND - Part of the "DUMP" COMMAND. Jumped here when there are no more bytes to save.

In a /CMD file, the TRANSFER address format is 02 nn xx yy, where nn is the length of the block, xx=the LSB, and yy=the MSB.

57F4DOEND
POP HL
Clear the STACK.
Original Source Code Comment: GET THE STACK CORRECT
57F5
LD A,02H
LET Register A = 02H, which is code for the EXECUTION ADDRESS.
Original Source Code Comment: LOAD A 'END' SPECIFIER
57F7
GOSUB to 581CH to write the contents of Register A (i.e., an 02H) to the file.
Original Source Code Comment: WRITE IT OUT
57FA
LD A,02H
LET Register A = 02H, which is code for the EXECUTION ADDRESS block length (i.e., 2 bytes - a LSB and a MSB).
Original Source Code Comment: LOAD CHAR COUNT OF 2
57FC
GOSUB to 581CH to write the contents of Register A (i.e., an 02H) to the file.
Original Source Code Comment: WRITE IT OUT
57FF
LD HL,0000LD HL,TRA
LET Register Pair HL = the value stored in 5800H-5801H, which was placed here by other code. It is where the TRANSFER ADDRESS has been stored.
Original Source Code Comment: GET THE TRANSFER ADDR
5802
LD A,L
LET Register A = Register L (i.e., the LSB of the TRANSFER ADDRESS).
Original Source Code Comment: LOAD THE LSB
5803
GOSUB to 581CH to write the contents of Register A (i.e., the LSB of the TRANSFER ADDRESS) to the file.
Original Source Code Comment: WRITE IT OUT
5806
LD A,H
LET Register A = Register H (i.e., the MSB of the TRANSFER ADDRESS).
Original Source Code Comment: GET THE MSB
5807
GOSUB to 581CH to write the contents of Register A (i.e., the MSB of the TRANSFER ADDRESS) to the file.
Original Source Code Comment: WRITE IT OUT
580A
LD A,(5845H)LD A,(DCOUNT)
Fetch the value stored at memory location 5845H (i.e., the number of bytes left in the sector) and put it into Register A so as to check to see if the last sector is full or not.
Original Source Code Comment: GET THE RESIDUAL COUNT
580D
OR A
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A.
Original Source Code Comment: DONE?
580E
If the Z FLAG (Zero) is set, then the last sector is full, so JUMP to 56F9H to close the file.
Original Source Code Comment: YES, CLOSE THE FILE
5811
LD B,A
LET Register B = Register A (i.e., the number of bytes left in the sector) to prepare for DJNZ loop.
Original Source Code Comment: NO, FILL REST OF SECTOR
5812TRA1
LD A,0E5H
LET Register A = 0E5H, which will be the value to fill the rest of the sector with.
Original Source Code Comment: FILL BYTE
5814
GOSUB to 001BH
NOTE: 001BH is the Model III ROM routine to output a byte (held in Register A) to a device. Register Pair DE has the DCB of the device to be output to. Z is set if the device is ready.
Original Source Code Comment: PUT IT TO DISK
5817
LOOP back to 5812H, 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
5819
JUMP to 56F9H to close the file and exit.
Original Source Code Comment: CLOSE THE FILE

581CH - PUTIT - Part of the "DUMP" command. This routine is called each time a byte needs to be written, as it also includes that that byte in the running byte count.

581CPUTIT
INC (IX+00H)
IX+00H points to the byte-in-sector counter, so this bumps that by 1.
Original Source Code Comment: BUMP THE RESIDUAL COUNT
581F
to 001BH
NOTE: 001BH is the Model III ROM routine to output a byte (held in Register A) to a device. Register Pair DE has the DCB of the device to be output to. Z is set if the device is ready.
Original Source Code Comment: WRITE THE BYTE TO DISK

5822H - CMD - MESSAGE and RAM STORAGE AREA for the DUMP COMMAND.

5822CMD
DEFM ...
"CMD".
5825SWTCH7
DEFM ...
"START ".
582D
DEFM ...
"END ".
5835
DEFM ...
"TRA ".
583D
DEFM ...
"RELO ".
5845DCOUNT
00H
END OF TABLE DESIGNATOR.
5846NAMFIL
DEFB 08H
8-Byte Storage Location for the Filename.

584FH - "LOAD" Command.

The LOAD command loads a memory image file from disk. After the load, DOS returns to TRSDOS READY.

584FLOAD
GOSUB to 5FBFH to get the filespec.
Original Source Code Comment: GET SYNTAX OF FILE NAME
5852
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5218H.
Original Source Code Comment: EXIT IF ERROR
5855
LD IY,402DLD IY,SYS1IN
LET Register Pair IY = 402DH which will be the RETURN address for RETURN TO DOS when done.
Original Source Code Comment: IX => RETURN ADDRESS
5859
PUSH IY
Save Register Pair IY (i.e., the return address) to the top of the stack.
Original Source Code Comment: PUT IT ON THE STACK
585B
JUMP to 4430H.
NOTE: 4430H is DOS PROGRAM LOADER routine and does the same as the DOS LIBRARY command of LOAD. Requires Register Pair DE to contain the applicable FCB. All Registers are modified.
Original Source Code Comment: USE SYS0 LOADER AND LOAD

585EH - "ATTRIB" Command.

ATTRIB lets you change the passwords to an existing file or makes the file invisible or non-invisible. Passwords are initially assigned when the file is created. At that time, the update and access words are set to the same value (either the password you specified or a blank password).

ATTRIB file (visibility,ACC = name,UPD = name,PROT = level)
file = file specification.
visibility must be I or N.
ACC=password. If omitted, the access password is unchanged. set to "ACC=", password is set to blanks.
UPD=password. If omitted, the update password is unchanged. set to "UPD=", password is set to blanks.
PROT=Protection level. If omitted, it remains unchanged.

  • FUL = full access, no protection.
  • KILL = Kill, rename, read, execute, and write (gives total access, i.e., the least-protected).
  • NAME = Rename, read, execute, and write.
  • WRITE = Read, execute, and write.
  • READ = Read and execute.
  • EXEC = Execute only.
585EATTRIB
GOSUB to 623AH to isolate and validate the FILESPEC from the command line via an OVERLAY call to ROUTINE 4 of OVERLAY 1.
Original Source Code Comment: GET SYNTAX OF FILE NAME
5861
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5218H.
Original Source Code Comment: EXIT IF ERROR
5864
PUSH HL
Save Register Pair HL (i.e., the parameter address) to the top of the stack.
Original Source Code Comment: SAVE POINTER TO COMMAND LINE
5865
LD B,00H
LET Register B = 00H to set a LRL = 0.
Original Source Code Comment: SET FOR LRL OF 256
5867
LD HL,6400LD HL,S6BUF2
LET Register Pair HL = 6400H as a buffer.
Original Source Code Comment: POINT TO BUFFER
586A
GOSUB to 4424H.
NOTE: 4424H is the SYS00/SYS routine to OPEN A DISK FILE for use. This RST 28H's with a value of 92H so as to call ROUTINE 1 in OVERLAY 3.
Original Source Code Comment: OPEN THE FILE
586D
POP HL
Put the value held at the top of the STACK (i.e., the parameter address) into Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: GET POINTER BACK
586E
If the NZ FLAG (Not Zero) is set, JUMP to 6132H.
Original Source Code Comment: EXIT IF ERROR
5871
LD A,(6281H)LD A,(S6DCB1 + PROT)
Fetch the value stored at memory location 6281H (i.e., the FILE ACCESS LEVEL) and put it into Register A.
Original Source Code Comment: GET THE PROTECTION LEVEL
5874
AND 07H
MASK the value of Register A against 07H (0000 0111) to isolate the protection level bits. This has the effect of turning off bits 7, 6, 5, 4, 3, leaving only bits 2, 1, 0 active.
Original Source Code Comment: MASK STATUS BITS OFF
5876
LD A,19LD A,EFAD
LET Register A = 19H to set up for a FILE ACCESS DENIED.
Original Source Code Comment: ASSUME ILLEGAL ACCESS
5878
If the NZ FLAG (Not Zero) is set, that is the error we got, so exit via a JUMP to 6132H.
Original Source Code Comment: YES, IT IS
587B
XOR A
Set Register A to ZERO and clear all Flags.
Original Source Code Comment: CLEAR A AND FLAGS
587C
LD (597BH),ALD (STAT),A
Store the value held in Register A (i.e., a 0) into the memory location 597BH (i.e., the file protection status).
Original Source Code Comment: SAVE AS STATUS
587F
LD (5983H),ALD (ISTAT),A
Store the value held in Register A (i.e., a 0) into the memory location 5983H (i.e., invisible status).
Original Source Code Comment: SAVE AS INV STATUS
5882
DEC A
DECrement the value stored in Register A by 1 (i.e., to FFH).
Original Source Code Comment: MAKE NZ
5883
LD (5985H),ALD (ISTAT1),A
Store the value held in Register A (i.e., FFH) into the memory location 5985H (i.e., non-invisible status).
5886L6OP40
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the parameter character) and put it into Register A.
Original Source Code Comment: GET A CHAR FROM COMMAND LINE
5887
CP 28H
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 PARAMETER LIST?
5889
If the Z FLAG (Zero) is set then we got the (, so JUMP to 5893H.
Original Source Code Comment: YES, GET PARAMETER
588B
CP 20H
Compare the value held in Register A against 20H SPACE). Results: If Register A equals SPACE, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: SPACE?
588D
If the NZ FLAG (Not Zero) is set, then we didn't get the SPACE that we were expecting, so JUMP to 5218H.
Original Source Code Comment: IF NOT, ERROR
5890
INC HL
INCrement the value stored in Register Pair HL by 1 to point to the next character.
Original Source Code Comment: BUMP POINTER TO NEXT CHAR
5891
LOOP back to 5886H to look for a (.
Original Source Code Comment: TRY AGAIN

5893H - NEXTA - Continuation of the "ATTRIB" Command. Jumped here if a "(" was Found.

5893NEXTA
INC HL
INCrement the value stored in Register Pair HL by 1 to point to the next character.
Original Source Code Comment: POINT TO NEXT CHAR
5894
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the next character) and put it into Register A.
Original Source Code Comment: GET IT
5895
CP 49H
Compare the value held in Register A against 49H (ASCII: I). Results: If Register A equals I, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: MAKE THIS FILE INVISIBLE?
5897
If the character was a I, then the Z FLAG (Zero) will be set. JUMP to 58FAH for the INVISIBLE ATTRIBUTE.
Original Source Code Comment: YES
5899
CP 4EH
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: MAKE AN INV FILE VISIBLE?
589B
If the character was a N, then the Z FLAG (Zero) will be set. JUMP to 590AH for the NOT INVISIBLE ATTRIBUTE.
Original Source Code Comment: YES
589D
CP 41H
Compare the value held in Register A against 41H (ASCII: A). Results: If Register A equals A, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: 'A'CCESS?
589F
If the character was a A, then the Z FLAG (Zero) will be set. JUMP to 591AH to change the ACCESS PASSWORD.
Original Source Code Comment: YES
58A2
CP 55H
Compare the value held in Register A against 55H (ASCII: U). Results: If Register A equals U, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: 'U'PDATE?
58A4
If the character was a U, then the Z FLAG (Zero) will be set. JUMP to 592FH to change the UPDATE PASSWORD.
Original Source Code Comment: YES
58A7
CP 50H
Compare the value held in Register A against 50H (ASCII: P). Results: If Register A equals P, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: 'P'ROTECTION?
58A9
If the character was a P, then the Z FLAG (Zero) will be set. JUMP to 5218H to change the PROTECTIONAL LEVEL.
Original Source Code Comment: ERROR IF NOT
58AC
GOSUB to 5944H to get the next parameter.
Original Source Code Comment: GET PROT WORD
58AF
If the Z FLAG (Zero) is set then there was an error, so JUMP to 5218H.
Original Source Code Comment: EXIT IF ERROR
58B2
PUSH HL
Save Register Pair HL (i.e., the current position on the parameter line) to the top of the stack.
Original Source Code Comment: SAVE THE COMMAND LINE POINTER
58B3
LD B,07LD B,PNOACC
LET Register B = 07H, for a loop of 7 entries.
Original Source Code Comment: SET CHAR COUNT OF HIGHEST LEVEL
58B5
LD DE,(5139H)LD DE,(PWORD)
Fetch the value stored at memory location 5139H (i.e., the parameter) and put it into Register DE.
Original Source Code Comment: POINT TO WHERE PASSWORD IS
58B9
LD HL,59AFLD HL,INDEX
LET Register Pair HL = 59AFH to point to the LEVEL TABLE.
Original Source Code Comment: POINT TO WHERE IT'S TO GO
58BCL6OP38
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., a character from the LEVEL TABLE) and put it into Register A.
Original Source Code Comment: GET A CHAR
58BD
INC HL
INCrement the value stored in Register Pair HL by 1 to point to the next character in the LEVEL TABLE.
Original Source Code Comment: BUMP TO NEXT CHAR
58BE
CP E
Compare the value held in Register A against the value held in Register E. Results: If Register A equals Register E/, the Z FLAG is set; otherwise the NZ FLAG is set.
58BF
If the Z FLAG (Zero) is set, then Register A = Register E, so GOSUB to 58C8H to check the rest of the characters.
58C2
INC HL
INCrement the value stored in Register Pair HL by 1 to point to the next character in the LEVEL TABLE.
58C3
LOOP back to 58BCH to check the rest of the table, 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.
58C5
JUMP to 5218H to exit the routine as this means there was no match found.

58C8H - CMP2 - Continuation of the "ATTRIB" Command. Jumped here during the LEVEL TABLE search when the first character of the desired level matches the first character in the level table; to check the rest for matches

58C8CMP2
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., a character from the ACCESS LEVEL TABLE) and put it into Register A.
58C9
CP D
Compare the value held in Register A against the value held in Register D. Results:
  • If Register A equals Register D, the Z FLAG is set.
  • If A < D, the CARRY FLAG will be set.
  • if A >= D, the NO CARRY FLAG will be set.
58CA
RET NZ
If the NZ FLAG (Not Zero) is set then the SECOND character did NOT match, so RETurn to the caller.
58CB
POP AF
Clear the top value held on the STACK (which was the RETurn value).
58CC
LD A,B
LET Register A = Register B (i.e., the access level).
58CD
DEC A
DECrement the value stored in Register A by 1.
58CE
CP 05CP PREAD
Compare the value held in Register A against 05H (which STILL could be either REad or REname). Results: If Register A 05H the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: READ?
58D0
If the NZ FLAG (Not Zero) is set then the second character didn't match, so JUMP to 58DDH.
58D2
LD A,(513BH)LD A,(PWORD + 2)
Fetch the value stored at memory location 513BH (i.e., the THIRD character) and put it into Register A.
58D5
CP 4EH
Compare the value held in Register A against 4EH (ASCII: N). Results:
  • If Register A equals N, the Z FLAG is set.
  • If A < N, the CARRY FLAG will be set.
  • if A >= N, the NO CARRY FLAG will be set.
58D7
LD A,05LD A,PREAD
LET Register A = 05H to restore the level.
58D9
If the NZ FLAG (Not Zero) is set then the third character didn't match as an N, so JUMP to 58DDH.
58DB
LD A,02LD A,PNAME
LET Register A = 02H (i.e., "NAME").
58DDNOTRE
LD (5981H),ALD (STAT1),A
Store the value held in Register A (i.e., the access level of 2) into the memory location 5981H (i.e., the access level).
58E0
POP HL
Put the value held at the top of the STACK (i.e., the current position on the parameter line) into Restore Register Pair HL, and then remove the entry from the stack.
58E1
LD B,01H
LET Register B = 01H for a protection level test.
58E3END2
LD A,(597BH)LD A,(STAT)
Fetch the value stored at memory location 597BH (i.e., the file UPDATE protection status) and put it into Register A.
58E6
OR B
OR Register B against Register A to turn on bit zero. The results are stored in Register A.
58E7
LD (597BH),ALD (STAT),A
Store the value held in Register A into the memory location 597BH (i.e., the file UPDATE protection status).
58EAEND3
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the next character) and put it into Register A.
58EB
CP 29H
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.
58ED
If the next character is a ), then the Z FLAG (Zero) will be set. JUMP to 596DH.
58EF
CP 2CH
Compare the value held in Register A against 2CH (ASCII: ,). Results: If Register A equals ,, the Z FLAG is set; otherwise the NZ FLAG is set.
58F1
If the next character is a ,, then the Z FLAG (Zero) will be set. JUMP to 5893H.
58F3
CP 20H
Compare the value held in Register A against 20H (ASCII: SPACE). Results:
  • If Register A equals SPACE, the Z FLAG is set.
  • If A < 20H, the CARRY FLAG will be set.
  • if A >= 20H (ASCII: SPACE), the NO CARRY FLAG will be set.

Original Source Code Comment: CONTROL CHAR?
58F5
If the next character is < SPACE, then the C FLAG (Carry) will be set. JUMP to 596DH.
Original Source Code Comment: YES, DONE
58F7
If we are here then we didn't get the character we expected, so we are going to exit with an error. JUMP to 5218H.

58FAH - INVISB - Continuation of the "ATTRIB" Command. Jumped here if a "I" was found after a "(" was found.

58FAINVISB
GOSUB to 5944H to position to the next parameter.
58FD
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5218H.
5900
LD A,(5983H)LD A,(ISTAT)
Fetch the value stored at memory location 5983H (i.e., invisible status) and put it into Register A.
5903
OR 08H
OR Register A against 08H (0000 1000). This has the effect of turning on bit 3 to set the invisible status bit.
Original Source Code Comment: INV BIT
5905
LD (5983H),ALD (ISTAT),A
Store the value held in Register A into the memory location 5983H (i.e., invisible status).
5908
JUMP back inside the loop at 58EAH.

590AH - NONINV - Continuation of the "ATTRIB" Command. Jumped here if a "N" was found after a "(" was found.

590ANONINV
GOSUB to 5944H to position to the next parameter.
590D
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5218H.
5910
LD A,(5985H)LD A,(ISTAT1)
Fetch the value stored at memory location 5985H (i.e., non-invisible status) and put it into Register A.
5913
AND 0F7H
MASK the value of Register A against 0F7H (1111 0111). This has the effect of turning off bit 3, leaving all other bits active.
5915
LD (5985H),ALD (ISTAT1),A
Store the value held in Register A into the memory location 5985H (i.e., non-invisible status).
5918
JUMP back inside the loop at 58EAH.

591AH - ACCESS - Continuation of the "ATTRIB" Command. Jumped here if a "A" was found after a "(" was found.

591AACCESS
GOSUB to 5944H to position to the next parameter.
591D
If the Z FLAG (Zero) is set then no password was provided, so JUMP to 5214H.
5920
PUSH HL
Save Register Pair HL (i.e., the character in the command line) to the top of the stack.
5921
LD DE,5139LD DE,PWORD
LET Register Pair DE = 5139H which is the PARAMETER STORAGE TABLE.
5924
GOSUB to 5107H to encode the access password.
5927
LD (514EH),HLLD (ACCTDC),HL
Store the value held in Register HL (i.e., encoded the access password) into the memory location 514EH.
NOTE: 514EH is the storage location for the ACCESS PASSWORD.
592A
POP HL
Put the value held at the top of the STACK (i.e., the character in the command line) into Restore Register Pair HL, and then remove the entry from the stack.
592B
LD B,02H
LET Register B = 02H to signify that the ACCESS PASSWORD is now active.
592D
JUMP back inside the loop at 58E3H.

592FH - UPDATE - Continuation of the "ATTRIB" Command. Jumped here if a "U" was found after a "(" was found.

592FUPDATE
GOSUB to 5944H to position to the next parameter.
5932
If the Z FLAG (Zero) is set then no password was provided, so JUMP to 5214H.
5935
PUSH HL
Save Register Pair HL (i.e., the character in the command line) to the top of the stack.
5936
LD DE,5139LD DE,PWORD
LET Register Pair DE = 5139H which is the PARAMETER STORAGE TABLE.
5939
GOSUB to 5107H to encode the UPDATE password.
593C
LD (514CH),HLLD (UPDTDC),HL
Store the value held in Register HL (i.e., encoded the UPDATE password) into the memory location 514CH.
NOTE: 514CH is the storage location for the UPDATE PASSWORD.
593F
POP HL
Put the value held at the top of the STACK (i.e., the character in the command line) into Restore Register Pair HL, and then remove the entry from the stack.
5940
LD B,04H
LET Register B = 04H to signify that the UPDATE PASSWORD is now active.
5942
JUMP back inside the loop at 58E3H.

5944H - GETEND - Continuation of the "ATTRIB" Command. Jumped here to position to the next parameter on the command line.

5944GETEND
INC HL
INCrement the value stored in Register Pair HL (i.e., the character in the command line) by 1.
Original Source Code Comment: BUMP TO NEXT CHAR
5945
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the character in the command line) and put it into Register A.
Original Source Code Comment: GET THE CHAR
5946
CP 20H
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?
5948
If the character in the command line >= SPACE the NC FLAG (No Carry) is set. JUMP to 594CH.
Original Source Code Comment: NO
594A
XOR A
Set Register A to ZERO and clear all Flags.
Original Source Code Comment: YES, SET Z
594B
RET
RETurn to the caller.

594CH - GETEN1 - Continuation of the "ATTRIB" Command. Jumped here from the "position to next parameter" subroutine if a control character was detected.

594CGETEN1
CP 29H
Compare the value held in Register A against 29H (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: END OF PARM LIST?
594E
RET Z
If we have a ) then we are done and the Z FLAG (Zero) is set. RETurn to the caller.
Original Source Code Comment: YES
594F
CP 2CH
Compare the value held in Register A against 2CH (ASCII: ,). If Register A equals ,, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: DELIMITER?
5951
RET Z
If we have a , then we are done and the Z FLAG (Zero) is set. RETurn to the caller.
Original Source Code Comment: YES
5952
CP 3DH
Compare the value held in Register A against 3DH (ASCII: =). If Register A equals =, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: SPECIFIER SEPERATOR
5954
If we did NOT get an =, the NZ FLAG is set. JUMP to 5944H to look at the next character.
Original Source Code Comment: NO, KEEP LOOKING
5956
INC HL
INCrement the value stored in Register Pair HL (i.e., the character in the command line) by 1.
Original Source Code Comment: BUMP CHAR POINTER
5957
LD DE,5139LD DE,PWORD
LET Register Pair DE = 5139H which is the PARAMETER STORAGE TABLE.
Original Source Code Comment: POINT TO WHERE CHARS TO GO
595A
LD B,08H
LET Register B = 08H for a DJNZ loop of 8 characters.
Original Source Code Comment: SET FOR 8 CHARS
595C
PUSH DE
Save Register Pair DE (i.e., the 9th character in the PARAMETER STORAGE TABLE) to the top of the stack.
Original Source Code Comment: SAVE POINTER
595D
PUSH BC
Save Register Pair BC.
595E
LD A,20H
LET Register A = 20H (ASCII: SPACE).
Original Source Code Comment: LOAD A SPACE CHAR
5960L6OP39
LD (DE),A
Store the value held in Register A (i.e., a SPACE) into the memory location pointed to by Register Pair DE (i.e., the pointer to the current byte of the PARAMETER STORAGE TABLE).
Original Source Code Comment: CLEAR OUT THE LOCATIONS
5961
INC DE
INCrement the value stored in Register Pair DE (i.e., the pointer to the current byte of the PARAMETER STORAGE TABLE) by 1.
5962
LOOP back to 5960H, 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.
5964
POP BC
Put the value held at the top of the STACK into Restore Register Pair BC, and then remove the entry from the stack.
Original Source Code Comment: GET POINTERS BACK
5965
POP DE
Put the value held at the top of the STACK (i.e., the 9th character in the PARAMETER STORAGE TABLE) into Restore Register Pair DE, and then remove the entry from the stack.
5966
GOSUB to 50CDH to get the parameter.
Original Source Code Comment: ALPHA CHECK
5969
DEC HL
DECrement the value stored in Register Pair HL (i.e., the character in the command line) by 1.
Original Source Code Comment: BACK THE POINTER UP
596A
OR 01H
OR Register A against 01H. This has the effect of turning on bit 0 to set the status.
Original Source Code Comment: Z FLAG
596C
RET
RETurn to the caller.

596DH - DONEA - Continuation of the "ATTRIB" Command. This will mask the values and set the passwords and put them in the RAM STORAGE LOCATION for the DIRECTORY ENTRY.

596DDONEA
LD BC,(6286H)LD BC,(S6DCB1 + DRVNUM)
Fetch the value stored at memory location 6286H (i.e., drive number and file number) and put it into Register BC.
Original Source Code Comment: GET THE DRIVE NUMBER
5971
GOSUB to 4A67H.
NOTE: 4A67H is the SYS00/SYS routine to read the directory entry into RAM (Buffer at 4300H).
Original Source Code Comment: GO READ THE DIRECTORY
5974
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
Original Source Code Comment: EXIT IF ERROR
5977
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the file type byte) and put it into Register A.
Original Source Code Comment: GET A CHAR
5978
AND 0F8H
MASK the value of Register A against 0F8H (1111 1000). This has the effect of turning off bits 2, 1, and 0; removing the access protection code.
Original Source Code Comment: MASK OFF ATTRIB BITS
597A
LD D,00LD D,STAT
LET Register D = the contents of memory location 597BH, as set elsewhere. This will be the protection code.
597C
BIT 0,D
Test Bit Number 0 of Register D. Z FLAG will be set if that bit is 0, and NZ FLAG will be set if that bit is 1.
597E
If the Z FLAG (Zero) is set then there was no need to protect the file. JUMP to 5982H.
5980
OR 00OR STAT1
OR Register A against the contents of memory position 5981H, as set elsewhere. This will mask in the access level.
5982SKIP
OR 00OR ISTAT
OR Register A against the contents of memory position 5983H, as set elsewhere. This will start a mask for invisibility.
5984
AND 0FFAND ISTAT1
AND Register A against the contents of memory position 5985H, as set elsewhere. This will finish a mask for invisibility.
5986
LD (HL),A
Store the value held in Register A (i.e., the masked file type byte) into the memory location pointed to by Register Pair HL.
Original Source Code Comment: STORE THE NEW ATTRIB BYTE
5987
5988
598A
LD A,L
ADD A,DUPD
LD L,A
LET Register L = Register L + 10H, so as to point HL to the passwords.
Original Source Code Comment: GET THE LSB OF DIR POINTER
598B
BIT 2,D
Test Bit Number 2 of Register D to see if the update password needs to be changed.
Original Source Code Comment: ANY UPDATE PW?
598D
If the Z FLAG (Zero) is set then it does NOT need a change, so JUMP to 5999H.
Original Source Code Comment: NO, TRY FOR ACCESS

If we are here, then we need to update the UPDATE PASSWORD.

598F
LD A,(514CH)LD A,(UPDTDC)
Fetch the value stored at memory location 514CH and put it into Register A.
NOTE: 514CH is the storage location for the UPDATE PASSWORD.
Original Source Code Comment: GET THE UPDATE HASH CODE
5992
LD (HL),A
Store the value held in Register A (i.e., part of the UPDATE PASSWORD hash) into the memory location pointed to by Register Pair HL (i.e., the first byte of the UPDATE PASSWORD in the directory entry).
Original Source Code Comment: AND LAY IT INTO THE DIR REC
5993
LD A,(514DH)LD A,(UPDTD + 1)
Fetch the value stored at memory location 514DH and put it into Register A.
NOTE: 514DH is the storage location for the 2nd byte of the UPDATE PASSWORD.
5996
INC HL
INCrement the value stored in Register Pair HL (i.e., the first byte of the UPDATE PASSWORD in the directory entry) by 1.
5997
LD (HL),A
Store the value held in Register A (i.e., the 2nd byte of the UPDATE PASSWORD) into the memory location pointed to by Register Pair HL (i.e., the second byte of the UPDATE PASSWORD in the directory entry).
5998
DEC HL
DECrement the value stored in Register Pair HL (i.e., the 2nd byte of the UPDATE PASSWORD) by 1.
5999NOUPD
INC HL
INCrement the value stored in Register Pair HL (i.e., the 1st byte of the UPDATE PASSWORD in the directory entry) by 1.
599A
INC HL
INCrement the value stored in Register Pair HL (i.e., the 2nd byte of the UPDATE PASSWORD in the directory entry) by 1. Register Pair HL will now point to the first byte of the ACCESS PASSWORD in the directory entry.
Original Source Code Comment: HL => ACCESS HASH CODE IN DIR
599B
BIT 1,D
Test Bit Number 1 of Register D to see if the ACCESS password needs to be changed.
Original Source Code Comment: USER SUPPLY ACC PW?
599D
If the Z FLAG (Zero) is set then it does NOT need a change, so JUMP to 59A8H.
Original Source Code Comment: NOPE, CONTINUE
599F
LD A,(514EH)LD A,(ACCTDC)
Fetch the value stored at memory location 514EH and put it into Register A.
NOTE: 514EH is the storage location for the 1st byte of the ACCESS PASSWORD.
Original Source Code Comment: PUT THE NEW HASH CODE IN DIR
59A2
LD (HL),A
Store the value held in Register A (i.e., part of the ACCESS PASSWORD hash) into the memory location pointed to by Register Pair HL (i.e., the first byte of the ACCESS PASSWORD in the directory entry).
59A3
LD A,(514FH)LD A,(ACCTDC + 1)
Fetch the value stored at memory location 514FH and put it into Register A.
NOTE: 514FH is the storage location for the 2nd byte of the ACCESS PASSWORD.
59A6
INC HL
INCrement the value stored in Register Pair HL by 1 so that HL will point to the second byte of the ACCESS PASSWORD in the directory entry.
59A7
LD (HL),A
Store the value held in Register A (i.e., the 2nd byte of the ACCESS PASSWORD) into the memory location pointed to by Register Pair HL (i.e., the second byte of the ACCESS PASSWORD in the directory entry).
59A8SAVE2
GOSUB to 4A7BH.
NOTE: 4A7BH is the SYS00/SYS routine to write the directory entry from the copy in RAM to the diskette.
Original Source Code Comment: WRITE OUT THE NEW DIRECTORY RECORD
59AB
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
59AE
RET
RETurn to the caller.

59AFH - INDEX - MESSAGE AND RAM STORAGE AREA for the "ATTRIB" Command.

59AFINDEX
DEFM ...
"EX".
Original Source Code Comment: EXECUTE LEVEL 6
59B1
DEFM ...
"RE".
Original Source Code Comment: READ LEVEL 5
59B3
DEFM ...
"WR".
Original Source Code Comment: WRITE LEVEL 4
59B5
DEFM ...
7E 7E.
Original Source Code Comment: (DUMMY VALUE) THERE IS NO LEVEL 3 (SPARE)
59B7
DEFM ...
"NA".
Original Source Code Comment: RENAME LEVEL 2
59B9
DEFM ...
"KI".
Original Source Code Comment: KILL LEVEL 1
59BB
DEFM ...
"FU".
Original Source Code Comment: FULL LEVEL 0

59BDH - LEGAL - Part of the "DUMP" Command. Tests the validity of a HEXIDECIMAL NUMBER stored in Register A.

59BDLEGAL
CP 30H
Compare the value held in Register A against a 0. Results:
  • If Register A equals 0, the Z FLAG is set.
  • If A < 0, the CARRY FLAG will be set.
  • if A >= 0, the NO CARRY FLAG will be set.

Original Source Code Comment: LESS THAN NUMBER?
59BF
RET C
If A < 0, then A is not numeric (on the low side) and the C FLAG (Carry) is set. RETurn to the caller with the CARRY FLAG set to indicate an error (in this case, the character as below a 0).
Original Source Code Comment: YES
59C0
CP 3AH
Compare the value held in Register A against 3AH (ASCII: 1 more than 9). Results:
  • If Register A equals 1 more than 9, the Z FLAG is set.
  • If A < 1 more than 9, the CARRY FLAG will be set.
  • if A >= 1 more than 9, the NO CARRY FLAG will be set.

Original Source Code Comment: NUMBER?
59C2
CCF
Invert the state of the CARRY FLAG.
59C3
RET NC
If A < 1 more than 9 then the NC FLAG (No Carry) is set, RETurn to the caller.
Original Source Code Comment: YES
59C4
CP 41H
Compare the value held in Register A against 41H (ASCII: A). Results:
  • If Register A equals A, the Z FLAG is set.
  • If A < A, the CARRY FLAG will be set.
  • if A >= A, the NO CARRY FLAG will be set.

Original Source Code Comment: LETTER?
59C6
RET C
If A < A then the C FLAG (Carry) is set, RETurn to the caller.
Original Source Code Comment: NO
59C7
CP 47H
Compare the value held in Register A against 47H (ASCII: 1 more than F). Results:
  • If Register A equals 1 more than F, the Z FLAG is set.
  • If A < 1 more than F, the CARRY FLAG will be set.
  • if A >= 1 more than F, the NO CARRY FLAG will be set.
59C9
CCF
Invert the state of the CARRY FLAG.
59CA
RET
RETurn to the caller with CARRY FLAG set if there is an error.

59CBH - LEAL - Part of the "DUMP" Command. Tests the validity of an ALPHA NUMERIC character stored in Register A.

59CBLEAL
CP 30H
Compare the value held in Register A against a 0. Results:
  • If Register A equals 0, the Z FLAG is set.
  • If A < 0, the CARRY FLAG will be set.
  • if A >= 0, the NO CARRY FLAG will be set.

Original Source Code Comment: NUMERIC?
59CD
RET C
If A < 0, then A is below numeric and the C FLAG (Carry) is set. RETurn to the caller with the CARRY FLAG set to indicate an error (in this case, the character as below a 0).
59CE
CP 3AH
Compare the value held in Register A against 3AH (ASCII: 1 more than 9). Results:
  • If Register A equals 1 more than 9, the Z FLAG is set.
  • If A < 1 more than 9, the CARRY FLAG will be set.
  • if A >= 1 more than 9, the NO CARRY FLAG will be set.
59D0
CCF
Invert the state of the CARRY FLAG.
59D1
RET NC
If A < 1 more than 9 then the NC FLAG (No Carry) is set, RETurn to the caller.
59D2
CP 41H
Compare the value held in Register A against 41H (ASCII: A). Results:
  • If Register A equals A, the Z FLAG is set.
  • If A < A, the CARRY FLAG will be set.
  • if A >= A, the NO CARRY FLAG will be set.

Original Source Code Comment: LETTER?
59D4
RET C
If the C FLAG (Carry) is set, RETurn to the caller.
59D5
CP 5BH
Compare the value held in Register A against 5BH (ASCII: 1 more than Z). Results:
  • If Register A equals 1 more than Z, the Z FLAG is set.
  • If A < 1 more than Z, the CARRY FLAG will be set.
  • if A >= 1 more than Z, the NO CARRY FLAG will be set.
59D7
CCF
Invert the state of the CARRY FLAG.
59D8
RET
RETurn to the caller with CARRY FLAG set if there is an error.

59D9H - "DIR" command.

59D9DIR
LD BC,0000H
LET Register Pair BC = 0000H so that we can zero out a bunch of options.
Original Source Code Comment: CLEAR BC
59DC
LD (5AA5H),BCLD (SYS),BC
Store the value held in Register BC (i.e., 0000) into the memory location 5AA5H (i.e., the byte flag for SYSTEM FILES).
Original Source Code Comment: ASSUME NO SYS FILES
59E0
LD (5AB3H),BCLD (S6INV),BC
Store the value held in Register BC (i.e., 0000) into the memory location 5AB3H (i.e., the byte flag for INVISIBLE FILES).
Original Source Code Comment: ASSUME NO INV FILES
59E4
LD (5A4DH),BCLD (LPFLAG),BC
Store the value held in Register BC (i.e., 0000) into the memory location 5A4DH (i.e., the byte flag for PRINTER).
Original Source Code Comment: ASSUME OUTPUT TO VIDEO
59E8
XOR A
Set Register A to ZERO and clear all Flags.
59E9
LD (5A69H),ALD (S6DLFN),A
Store the value held in Register A (i.e., 0) into the memory location 5A69H, which is in the middle of an OPCODE and which will be holding the Logical File Number.
Original Source Code Comment: RESET THE LFN COUNTER
59EC
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the pointer to the current position on the command line which was entered) and put it into Register A.
Original Source Code Comment: GET A CHAR FROM COMMAND LINE
59ED
CP 3AH
Compare the value held in Register A against 3AH (ASCII: :) to look for a drive number parameter. Results: If Register A equals :, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: DRIVE SPECIFIER?
59EF
If there was no : then the NZ FLAG (Not Zero) is set. With this, we can skip anything regarding a drive number parameter so JUMP to 5A06H.
Original Source Code Comment: NO, DO DRIVE 0
59F1
INC HL
INCrement the value stored in Register Pair HL (i.e., the pointer to the current position on the command line which was entered) by 1.
Original Source Code Comment: BUMP TO NEXT CHAR
59F2
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the pointer to the current position on the command line which was entered) and put it into Register A. Since we had a :, we need Register A to hold a drive number for that parameter to be valid.
Original Source Code Comment: GET THE CHAR
59F3
SUB 30H
SUBtract the value 30H from Register A. Note: Subtracting 30H from Register A will convert an ASCII number '0'-'9' to its decimal equivalent (i.e., 6 in ASCII is 36H in Hex; so 36H-30H = 6).
Original Source Code Comment: MASK OFF ASCII
59F5
If the C FLAG (Carry) is set, then taking 30H away from Register A caused a CARRY operation, meaning that the number was less than "0" so JUMP to 5234H.
59F8
CP 04CP TOPDRV
Compare the value held in Register A against 04H, which would be 1 + the highest possible drive number for TRSDOS v1.3. Results:
  • If Register A equals 1 more than 3.
  • If A < 1 more than 3, the CARRY FLAG will be set.
  • if A >= 1 more than 3, the NO CARRY FLAG will be set.

Original Source Code Comment: GREATER THAN MAX DRIVES?
59FA
If A >= 1 more than 3 the NC FLAG (No Carry) is set and then we have a bad drive number, JUMP to 5234H.
Original Source Code Comment: YES, ERROR
59FD
LD C,A
If we are still here, then we had a number between 0-3 inclusive in Register A. Save that into Register C.
Original Source Code Comment: SAVE IT IN (C)
59FE
LD A,(4413H)LD A,(MAXDRV)
Fetch the value stored at memory location 4413H and put it into Register A.
NOTE: 4413H is the storage location for the NUMBER OF DISK DRIVES in the system.
Original Source Code Comment: GET NUM OF DRIVES THIS SYSTEM
5A01
CP C
Compare the value held in Register A against the value held in Register C to see if the drive number we were given (i.e., Register C) is one of the valid drives on the system (i.e., Register A). Results:
  • If Register A equals Register C, the Z FLAG is set.
  • If A < Register C, the CARRY FLAG will be set.
  • if A >= Register C, the NO CARRY FLAG will be set.

Original Source Code Comment: HIGHER THAN AVAILABLE DRIVES?
5A02
If Register A (i.e., NUMBER OF DISK DRIVES in the system) < Register C (i.e., the drive number we were given) then the C FLAG (Carry) is set, JUMP to 5234H.
Original Source Code Comment: YES, ERROR
5A05
INC HL
INCrement the value stored in Register Pair HL (i.e., the pointer to the current position on the command line which was entered) by 1.
Original Source Code Comment: BUMP TO NEXT CHAR
5A06NODRV2
PUSH BC
Save Register Pair BC (i.e., the drive number) to the top of the stack.
Original Source Code Comment: SAVE DRV NO.
5A07
LD A,C
LET Register A = Register C (i.e., the drive number).
Original Source Code Comment: PUT DRIVE IN (A)
5A08
ADD A,30H
LET Register A = Register A + 30H. Note: Adding 30H to Register A will convert decimal number 0-9 into its ASCII equivalent (i.e., 6 + 30H = 36H, which, in ASCII, is 6.
Original Source Code Comment: MAKE IT ASCII
5A0A
LD (5C50H),ALD (DRV2),A
Store the value held in Register A into the memory location 5C50H which is the message storage location for the DIR command header text.
Original Source Code Comment: STORE IN MESSAGE
5A0D
LD DE,5CC3LD DE,SWTCH3
LET Register Pair DE = 5CC3H, which is the FCB in RAM.
Original Source Code Comment: POINT TO DIR COMMAND TABLE
5A10
GOSUB to 4454H.
NOTE: 4454H is the DOS PARAMETER STRING PARSE routine. It decodes DOS LIBRARY parameters.
Original Source Code Comment: GET THE COMMANDS DESIRED
5A13
POP BC
Put the value held at the top of the STACK (i.e., the drive number) into Restore Register Pair BC, and then remove the entry from the stack.
Original Source Code Comment: MAY HAVE TO EXIT
5A14
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5214H.
Original Source Code Comment: EXIT IF ERROR
5A17
PUSH BC
Save Register Pair BC (i.e., the drive number) to the top of the stack.
Original Source Code Comment: PUT DRIVE BACK ON STACK
5A18
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 THE DRIVE NAME AND DATE
5A1B
POP BC
Put the value held at the top of the STACK (i.e., the drive number) into Restore Register Pair BC, and then remove the entry from the stack.
Original Source Code Comment: CORRECT IN CASE
5A1C
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
Original Source Code Comment: EXIT IF ERROR
5A1F
PUSH BC
Save Register Pair BC (i.e., the drive number) to the top of the stack.
Original Source Code Comment: SAVE DRIVE NUMBER
5A20
LD HL,4DD0LD HL,BUFF2 + DID
LET Register Pair HL = 4DD0H which is the pointer to the DISKETTE NAME.
Original Source Code Comment: POINT TO DISK NAME
5A23
LD DE,5C3DLD DE,DSKN2
LET Register Pair DE = 5C3DH which the location of the DISKETTE NAME in the on the printout.
Original Source Code Comment: POINT TO SLOT IN MESSAGE
5A26
LD BC,0008H
LET Register Pair BC = 0008H since there are 8 characters in a DISK NAME.
Original Source Code Comment: SET FOR 8 CHARS
5A29
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
5A2B
LD DE,5C5CLD DE,DATE2
LET Register Pair DE = 5C5CH which the location of the DISKETTE DATE in the on the printout Note that HL is already pointing to where we would want to point HL.
Original Source Code Comment: POINT TO WHERE DATE IS TO GO
5A2E
LD BC,0008H
LET Register Pair BC = 0008H since there are 8 characters in a DISK DATE.
Original Source Code Comment: SET FOR 8 CHARS
5A31
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 THE DATE
5A33
POP BC
Put the value held at the top of the STACK into Restore Register Pair BC, and then remove the entry from the stack.
Original Source Code Comment: GET THE DRIVE BACK
5A34
PUSH BC
Save Register Pair BC (i.e., the drive number) to the top of the stack.
5A35
GOSUB to 4ABAH.
NOTE: 4ABAH is the SYS00/SYS routine to read the HIT sector into RAM.
Original Source Code Comment: GET THE HAS CODE TABLE
5A38
POP BC
Put the value held at the top of the STACK (i.e., the drive number) into Restore Register Pair BC, and then remove the entry from the stack.
Original Source Code Comment: CORRECT IN CASE
5A39
If the NZ FLAG (Not Zero) is set, JUMP to 6132H.
Original Source Code Comment: EXIT IF ERROR
5A3C
PUSH BC
Save Register Pair BC to the top of the stack.
Original Source Code Comment: SAVE DRIVE NUMBER
5A3D
LD HL,4300LD HL,BUFF1
LET Register Pair HL = 4300H which is DOS BUFFER NUMBER 1.
Original Source Code Comment: WHERE HIT IS STORED
5A40
LD DE,4D00LD DE,BUFF2
LET Register Pair DE = 4D00H which is DOS BUFFER NUMBER 2.
Original Source Code Comment: WHERE WE WANT TO MOVE IT TO
5A43
LD (5A88H),DELD (PNTBUF),DE
Store the value held in Register DE (i.e., the pointer to DOS BUFFER NUMBER 2) into the memory location 5A88H.
Original Source Code Comment: SAVE THE POINTER
5A47
LD BC,0100H
LET Register Pair BC = 0100H (Decimal: 256) to signify that we are moving 256 bytes from DOS BUFFER 1 to DOS BUFFER 2.
Original Source Code Comment: NUMBER OF BYTES
5A4A
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 THE HIT TO BUFFER 2
5A4C
LD BC,0000LD BC,LPFLAG
LET Register Pair BC = the value stored in 5A4DH which was placed here by this overlay. This is the PRINT flag.
Original Source Code Comment: GET LINE PRINTER FLAG
5A4F
GOSUB to 01C9H which is the Model III ROM ROUTINE to CLEAR THE SCREEN and RETurn.
Original Source Code Comment: CLEAR THE SCREEN
5A52CONT2
LD HL,5C32LD HL,TITL2
LET Register Pair HL = 5C32H which is the message pointer to the first DIR output title line.
Original Source Code Comment: POINT TO 1ST PART OF TITLE
5A55
GOSUB to 6147H to either display or print the message pointed to by Register Pair HL.
Original Source Code Comment: GO OUTPUT IT
5A58
LD HL,5C65HLD HL,TITL4
LET Register Pair HL = 5C65H which is the message pointer to the second DIR output title line.
Original Source Code Comment: POINT TO 2ND PART OF TITLE
5A5B
GOSUB to 6147H to either display or print the message pointed to by Register Pair HL.
Original Source Code Comment: PRINT IT
5A5E
POP BC
Put the value held at the top of the STACK (i.e., the drive number) into Restore Register Pair BC, and then remove the entry from the stack.
Original Source Code Comment: GET THE DRIVE NUM BACK
5A5F
LD A,C
LET Register A = Register C (i.e., the drive number).
Original Source Code Comment: GET THE DRIVE NUMBER
5A60
LD (5A6BH),ALD (S6DDRV),A
Store the value held in Register A (i.e., the drive number) into the memory location 5A6BH which is in the middle of a LD B,nnH opcode.
Original Source Code Comment: SAVE IT
5A63
LD A,02H
LET Register A = 02H since we have printed/displayed two lines already.
Original Source Code Comment: SCROLL PROTECT THE TOP TWO LINES
5A65
LD (4214H),ALD (SCRLCT),A
Store the value held in Register A into the memory location 4214H so as to protect those 2 lines.
5A68NXTREC
LD B,00LD B,S6DLFN
LET Register B = the value placed in 5A69H elsewhere in this overlay. This is the current file number.
Original Source Code Comment: A COUNTER
5A6A
LD C,00H
LD C,nnH - LET Register C = the value placed in 5A6BH elsewhere in this overlay. This is the drive number.
Original Source Code Comment: DRIVE NUMBER SAVED HERE
5A6C
LD A,05LD A,RECSEC
LET Register A = 05H, as the number of bytes to move to the next directory sector.
Original Source Code Comment: BUMP THE COUNTER FOR NEXT TIME
5A6E
ADD A,B
LET Register A = 05H + the current file number (held in Register B).
5A6F
CP 55CP MAXFIL + RECSEC
Compare the value held in Register A against 55H to see if we are past the end of the directory. Results:
  • If Register A equals 55H, the Z FLAG is set.
  • If A < 55H, the CARRY FLAG will be set.
  • if A >= 55H, the NO CARRY FLAG will be set.

Original Source Code Comment: DONE WITH THE DIRECTORY?
5A71
If A >= 55H then the NC FLAG (No Carry) will be set and we ARE past the end of the directory, so JUMP to 5BF5H.
Original Source Code Comment: YES, EXIT
5A74
LD (5A69H),ALD (S6DLFN),A
Store the value held in Register A (i.e., the logical file number) into the memory location 5A69H.
Original Source Code Comment: NO, SAVE FOR NEXT TIME
5A77
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 DIR INTO MEMORY
5A7A
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
Original Source Code Comment: EXIT IF ERROR
5A7D
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: CKECK IF USER HOLDING BREAK KEY DOWN
5A80
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned with a BREAK, 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, RETURN TO DOS
5A83
LD HL,4300LD HL,BUFF1
LET Register Pair HL = 4300H, which is the DIRECTORY SECTOR BUFFER in RAM.
Original Source Code Comment: POINT TO BUFFER
5A86L6OP21
PUSH HL
Save Register Pair HL (i.e., the current pointer in the DIRECTORY SECTOR BUFFER in RAM) to the top of the stack.
Original Source Code Comment: SAVE THE POINTER
5A87
LD HL,0000LD HL,PNTBUF
LET Register Pair HL = the value placed in 5A88H-5A89H elsewhere in this overlay. This would be the HASH TABLE ENTRY.
Original Source Code Comment: NEXT HASH CODE POINTER STORED HERE
5A8A
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the hash code) and put it into Register A.
Original Source Code Comment: ANY FILE HERE?
5A8B
INC HL
INCrement the value stored in Register Pair HL (i.e., the current pointer in the DIRECTORY SECTOR BUFFER in RAM) by 1.
Original Source Code Comment: BUMP TO NEXT HASH CODE
5A8C
LD (5A88H),HLLD (PNTBUF),HL
Store the value held in Register HL into the memory location 5A88H (i.e., HASH TABLE ENTRY).
Original Source Code Comment: SAVE FOR NEXT TIME
5A8F
OR A
Set FLAGS based on the contents of Register A so as to check to see if that hash table entry is active or not.
Original Source Code Comment: ANY HASH CODE HERE?
5A90
If the Z FLAG (Zero) is set then the table entry is not active, so we don't need to display it. SKIP to 5BE7H.
Original Source Code Comment: NO FILE, SKIP TO NEXT
5A93
POP HL
Put the value held at the top of the STACK (i.e., the current pointer in the DIRECTORY SECTOR BUFFER in RAM) into Restore Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: GET DIR BUFFER POINTER BACK
5A94
LD A,(HL)
Fetch the value stored at memory location (i.e., the FILE TYPE BYTE) pointed to by Register Pair HL (i.e., the current pointer in the DIRECTORY SECTOR BUFFER in RAM) and put it into Register A.
Original Source Code Comment: GET 1ST BYTE OF DIR FILE
5A95
PUSH HL
Save Register Pair HL (i.e., the current pointer in the DIRECTORY SECTOR BUFFER in RAM, currently pointing at the FILE TYPE BYTE) to the top of the stack.
Original Source Code Comment: SAVE FILE LOC
5A96
BIT 7,A
Test Bit Number 7 of Register A to see if this is an EXTENDED DIRECTORY ENTRY. 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: IS THIS AN EXTENDED FILE?
5A98
If the NZ FLAG (Not Zero) is set then this is an EXTENDED DIRECTORY ENTRY, in which case we do not want to display it. SKIP to 5BE7H.
Original Source Code Comment: YES, SKIP IT
5A9B
BIT 4,A
Test Bit Number 4 of Register A to see if this is an ACTIVE PRIMARY FILE ENTRY. 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: IS THIS FILE FREE?
5A9D
If the Z FLAG (Zero) is set then this is not an ACTIVE PRIMARY FILE ENTRY, in which case we do not want to display it. SKIP to 5BE7H.
Original Source Code Comment: YES, SKIP IT
5AA0
BIT 6,A
Test Bit Number 6 of Register A to see if this is a SYSTEM FILE. Z FLAG will be set if that bit is 0 and the file is NOT a SYSTEM FILE, and NZ FLAG will be set if that bit is 1 and the file is a SYSTEM FILE.
Original Source Code Comment: IS THIS A SYS FILE?
5AA2
If the Z FLAG (Zero) is set then this is not a SYSTEM FILE, in which case we ABSOLUTELY are ready to display this entry, so SKIP to 5AAEH.
Original Source Code Comment: NO, CHECK IT FURTHER
5AA4
LD DE,0000LD DE,SYS
LET Register Pair DE = the contents of 5AA5H which was placed here elsewhere in this overlay. This is the DISPLAY SYSTEM FILE flag.
Original Source Code Comment: GET THE USER SYS SWITCH
5AA7
5AA8
LD A,D
OR E
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: USER WANT SYS DISPLAYED?
5AA9
If the Z FLAG (Zero) is set then we were NOT asked to display SYSTEM FILES, so JUMP to 5BE7H.
Original Source Code Comment: NOPE, SKIP THIS FILE
5AAC
JUMP to 5ABAH to display the file entry, 1 space, and the extension.
Original Source Code Comment: YES, DISPLAY IT

5AAEH - NOSYS - Continuation of the "DIR" Command. Jumped here when we have passed the first filtering hurdles and the directory entry being pointed to has still not yet been disqualified from being displayed.

5AAENOSYS
BIT 3,A
Test Bit Number 3 of Register A to see if the file is INVISIBLE. 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: IS IS AN INV FIL?
5AB0
If the Z FLAG (Zero) is set then the file is visible, then we can skip the test for invisible file display and JUMP to 5ABAH.
Original Source Code Comment: NOPE, CHECK FURTHER
5AB2
LD DE,0000LD DE,S6INV
LET Register Pair DE = the memory contents of 4AB3H-4AB4H, which is the flag for whether TRSDOS was asked to display invisible files.
Original Source Code Comment: GET THE USER INVISIBLE SWITCH
5AB5
5AB6
LD A,D
OR E
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: USER WANT INV FILES DISPLAYED?
5AB7
If the Z FLAG (Zero) is set then we were NOT asked to display invisible files, so JUMP to 5BE7H.
Original Source Code Comment: NOPE, SKIP IT THEN

5ABAH - NOTINV - Continuation of the "DIR" Command. Display the filespec, 1 space, and the extension.

This section handles the display of filename and extension for directory entries that have passed all the filtering tests.

5ABANOTINV
PUSH HL
Save Register Pair HL (i.e., the current pointer in the DIRECTORY SECTOR BUFFER in RAM, currently pointing at the FILE TYPE BYTE) to the top of the stack.
Original Source Code Comment: SAVE POINTER
5ABB
INC HL
INCrement the value stored in Register Pair HL (i.e., the current pointer in the DIRECTORY SECTOR BUFFER in RAM, currently pointing at the FILE TYPE BYTE) by 1 (to point to the file CREATION MONTH).
Original Source Code Comment: HL => CREATE MONTH
5ABC
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the file CREATION MONTH) and put it into Register A.
Original Source Code Comment: GET IT
5ABD
LD (5BCCH),ALD (SAVMTH),A
Store the value held in Register A (i.e., the file CREATION MONTH) into the memory location 5BCCH which is in the middle of an OPCODE.
Original Source Code Comment: SAVE IT
5AC0
INC HL
INCrement the value stored in Register Pair HL (i.e., the current pointer in the DIRECTORY SECTOR BUFFER in RAM, currently pointing at the FILE CREATION MONTH) by 1 (to point to the file CREATION YEAR).
Original Source Code Comment: HL => CREATE YEAR
5AC1
LD A,(HL)
Fetch the value stored at memory location (i.e., the file CREATION YEAR) pointed to by Register Pair HL and put it into Register A.
Original Source Code Comment: GET IT
5AC2
LD (5BD4H),ALD (SAVYR),A
Store the value held in Register A into the memory location 5BD4H which is in the middle of an OPCODE.
Original Source Code Comment: SAVE IT
5AC5
POP HL
Put the value held at the top of the STACK (i.e., the current pointer in the DIRECTORY SECTOR BUFFER in RAM, currently pointing at the FILE TYPE BYTE) into Restore Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: GET DIR POINTER BACK
5AC6
5AC7
5AC9
LD A,L
ADD A,DNAME
LD L,A
LET Register L = Register L + 05H.
Original Source Code Comment: HL => FRONT OF FILE
5ACA
PUSH HL
Save Register Pair HL (i.e., the current pointer in the DIRECTORY SECTOR BUFFER in RAM, currently pointing at the FILENAME) to the top of the stack.
Original Source Code Comment: SAVE POINTER
5ACB
LD B,08H
LET Register B = 08H since the FILENAME has 8 characters.
Original Source Code Comment: # CHARS IN NAME
5ACDL6OP16
LD A,(HL)
Fetch the value stored (i.e., a character of the filename) at memory location pointed to by Register Pair HL and put it into Register A.
Original Source Code Comment: GET A CHARACTER
5ACE
CP 20H
Compare the value held in Register A (i.e., a character of the filename) against 20H (ASCII: SPACE). Results: If Register A equals SPACE, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: SPACE?
5AD0
If we have a SPACE then the Z FLAG (Zero) is set. We will take this as the end of the filename, so JUMP to 5AD8H.
Original Source Code Comment: YES ,EXIT LOOP
5AD2
INC HL
INCrement the value stored in Register Pair HL by 1.
Original Source Code Comment: BUMP TO NEXT CHAR
5AD3
GOSUB to 6135H to display or print the byte held in Register A (i.e., a character of the filename); routine affects Registers A and E.
Original Source Code Comment: OUTPUT THE CHAR
5AD6
LOOP back to 5ACDH, 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
5AD8YESSPC
POP HL
Put the value held at the top of the STACK into Restore Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: GET POINTER BACK
5AD9
PUSH DE
Save Register Pair DE to the top of the stack.
Original Source Code Comment: SAVE DE
5ADA
LD DE,0008H
LET Register Pair DE = 0008H to skip the 8 bytes of the filename to now point to the FILE EXTENSION.
Original Source Code Comment: NUMBER OF CHARS IN NAME
5ADD
ADD HL,DE
LET Register Pair HL = Register Pair HL + Register Pair DE (8 bytes).
Original Source Code Comment: HL => EXTENSION
5ADE
POP DE
Put the value held at the top of the STACK into Restore Register Pair DE, and then remove the entry from the stack.
Original Source Code Comment: GET DE BACK
5ADF
LD B,03H
LET Register B = 03H, which is the maximum number of characters in an extension.
Original Source Code Comment: SET FOR COUNT OF 3 CHARS
5AE1
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL and put it into Register A.
Original Source Code Comment: GET 1ST CHAR
5AE2
CP 20H
Compare the value held in Register A (i.e., a character of the EXTENSION) against 20H (ASCII: SPACE). Results: If Register A equals SPACE, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: SPACE?
5AE4
If we have a SPACE then the Z FLAG (Zero) is set. We will take this as the end of the EXTENSION, so JUMP to 5AF6H.
Original Source Code Comment: YES, CONTINUE
5AE6
LD A,2FH
LET Register A = 2FH (ASCII: /) as the extension delimiter.
Original Source Code Comment: LOAD AN EXTENSION SEPERATOR
5AE8
GOSUB to 6135H to display or print the /; routine affects Registers A and E.
Original Source Code Comment: OUTPUT IT
5AEBL6OP18
LD A,(HL)
Fetch the value stored at memory location (i.e., a character of the EXTENSION) pointed to by Register Pair HL and put it into Register A.
Original Source Code Comment: GET A CHAR OF EXTENSION
5AEC
CP 20H
Compare the value held in Register A against 20H (ASCII: SPACE). Results: If the character held in Register A equals SPACE, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: END OF EXTENSION?
5AEE
If the character held in Register A equals SPACE then the Z FLAG (Zero) is set, and we have reached the end of the EXTENSION. JUMP to 5AF6H.
Original Source Code Comment: YES
5AF0
INC HL
INCrement the value stored in Register Pair HL by 1.
Original Source Code Comment: BUMP POINT TO NEXT
5AF1
GOSUB to 6135H to display or print the character held in Register A; routine affects Registers A and E.
Original Source Code Comment: OUTPUT THE CHAR
5AF4
LOOP back to 5AEBH for all 3 characters of the extension, 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

5AF6H - ENDEXT - Continuation of the "DIR" Command. Position the Cursor to the Right Location.

5AF6ENDEXT
LD A,(4020H)LD A,(CURSOR)
Fetch the value stored at memory location 4020H (i.e., the cursor position on screen) and put it into Register A.
Original Source Code Comment: GET THE LSB OF THE CURSOR

The next set of instructions calculates how many spaces to tab over on the screen.

5AF9
AND 3FH
MASK the value of Register A against 3FH (0011 1111). This has the effect of turning off bits 7, 6, leaving only bits 5, 4, 3, 2, 1, 0, which is the column on the screen, active.
Original Source Code Comment: MASK FOR THIS ROW ONLY
5AFB
NEG
Rather than SUBTRACTING, we are going to ADD, so turn Register A negative.
Original Source Code Comment: MAKE IF NEGATIVE
5AFD
ADD A,0FH
LET Register A = Register A + 0FH.
Original Source Code Comment: DIFF TO WHERE WE NEED TO TAB TO
5AFF
LD B,A
LET Register B = Register A.
Original Source Code Comment: INTO B FOR COUNTER
5B00ENDEX1
LD A,20H
LET Register A = 20H (ASCII: SPACE).
Original Source Code Comment: A SPACE CHAR
5B02
GOSUB to 6135H to display or print the character held in Register A; routine affects Registers A and E.
Original Source Code Comment: OUTPUT IT
5B05
LOOP back to 5B00H, 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

5B07H - Continuation of the "DIR" Command. Display NON-INV, INV, or SYS FILE

5B07
DEC L
DECrement the value stored in Register L (i.e., the last character of the EXTENSION) by 1.
Original Source Code Comment: BACK UP TO THE END OF NAME
5B08
LD A,L
LET Register A = Register L (i.e., the last character of the EXTENSION).
Original Source Code Comment: GET THE LSB OF DIR POINTER
5B09
AND 0F0H
MASK the value of Register A against 0F0H (1111 0000). This has the effect of turning off bits 3, 2, 1, 0 and positions HL to the start of the directory entry.
Original Source Code Comment: FORCE IT TO BEGINNING OF FILE
5B0B
LD L,A
LET Register L = Register A.
Original Source Code Comment: POINT TO BEGIN OF FILE SPEC
5B0C
LD B,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the FILE TYPE byte of the DIRECTORY SECTOR in RAM) and put it into Register B.
Original Source Code Comment: GET THE ATTRIB BYTE
5B0D
LD A,49H
LET Register A = 49H (ASCII: I).
Original Source Code Comment: LOAD AN 'I' IN CASE INVISIBLE
5B0F
BIT 3,B
Test Bit Number 3 of Register A to see if the file is INVISIBLE. Z FLAG will be set if that bit is 0 (and the file is VISIBLE), and NZ FLAG will be set if that bit is 1 (and the file is INVISIBLE).
Original Source Code Comment: INV?
5B11
If the NZ FLAG (Not Zero) is then file is invisible, so skip over the instruction that changes the output flag to "N" (so it stays "I") and JUMP to 5B15H.
Original Source Code Comment: YES, DISPLAY THE 'I'
5B13
LD A,4EH
LET Register A = 4EH (ASCII: N).
Original Source Code Comment: WELL, HOW ABOUT NON-INV
5B15Y1
GOSUB to 6135H to display or print the character held in Register A; routine affects Registers A and E.
Original Source Code Comment: OUTPUT IT
5B18
BIT 6,B
Test Bit Number 6 of Register B to see if this is a SYSTEM FILE. Z FLAG will be set if that bit is 0 and the file is NOT a SYSTEM FILE, and NZ FLAG will be set if that bit is 1 and the file is a SYSTEM FILE.
Original Source Code Comment: IS THIS A SYS FILE?
5B1A
LD A,53H
LET Register A = 53H (ASCII: S).
Original Source Code Comment: LOAD AN 'S' IN CASE
5B1C
If the NZ FLAG (Not Zero) is set, then the file is a SYSTEM FILE, so we want to keep the "S" in Register A. JUMP to 5B20H.
Original Source Code Comment: YES, DISPLAY THE S
5B1E
LD A,2AH
LET Register A = 2AH (ASCII: *).
Original Source Code Comment: NO, PRINT STAR INSTEAD
5B20Y2
GOSUB to 6135H to display or print the character held in Register A; routine affects Registers A and E.
Original Source Code Comment: OUTPUT IT

5B23H - Continuation of the "DIR" Command. Display the PROTECTION (U)PDATE, A(CCESS), or B(OTH) UPDATE AND ACCESS

5B23
PUSH HL
Save Register Pair HL (i.e., pointer to the FILE TYPE byte of the DIRECTORY SECTOR in RAM) to the top of the stack.
Original Source Code Comment: START OF FILE POINTER
5B24
5B25
5B27
LD A,L
ADD A,DUPD
LD L,A
LET Register L = Register L + 10H.
Original Source Code Comment: PUT THE LSB INTO (A)
5B28
LD E,(HL)
Fetch the value stored at memory location (i.e., the 1st character of the UPDATE PASSWORD byte of the DIRECTORY SECTOR in RAM) pointed to by Register Pair HL and put it into Register E.
Original Source Code Comment: GET THE UPD PASSWORD
5B29
INC HL
INCrement the value stored in Register Pair HL by 1.
5B2A
LD D,(HL)
Fetch the value stored at memory location (i.e., the 2nd character of the UPDATE PASSWORD byte of the DIRECTORY SECTOR in RAM) pointed to by Register Pair HL and put it into Register D.
5B2B
PUSH HL
Save Register Pair HL (i.e., pointer to the 2nd character of the UPDATE PASSWORD of the DIRECTORY SECTOR in RAM) to the top of the stack.
Original Source Code Comment: SAVE THIS POINTER
5B2C
LD HL,5CEFLD HL,MASTPW
LET Register Pair HL = 5CEFH which would be a blank password.
Original Source Code Comment: LOAD HASH FOR 'NO' PASSWORD
5B2F
SBC HL,DE
Subtracts the value stored in Register Pair DE (i.e., the 2-Byte UPDATE PASSWORD byte of the DIRECTORY SECTOR in RAM) and the carry flag from the value stored in Register Pair HL (i.e., 5CEFH).
Original Source Code Comment: THIS FILE HAVE ANY UPD PASS?
5B31
POP HL
Put the value held at the top of the STACK (i.e., pointer to the 2nd character of the UPDATE PASSWORD of the DIRECTORY SECTOR in RAM) into Restore Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: GET POINTER BACK
5B32
LD A,55H
LET Register A = 55H (ASCII: U). If displayed, this would indicate that the file is protected by an UPDATE PASSWORD.
Original Source Code Comment: ASSUME IT DOES
5B34
If the NZ FLAG (Not Zero) is set, then the password is NOT blank, so JUMP to 5B38H.
Original Source Code Comment: YES IT DOES
5B36
LD A,58H
LET Register A = 58H (ASCII: X). If displayed, this would indicate that the file is protected by an ACCESS PASSWORD.
Original Source Code Comment: NOPE, ASSUME NO ACC EITHER
5B38ACC
INC L
INCrement the value stored in Register L by 1 so that HL will now point to the ACCESS PASSWORD.
Original Source Code Comment: BUMP POINTER TO ACC PW
5B39
LD E,(HL)
Fetch the value stored at memory location (i.e., the 1st character of the ACCESS PASSWORD byte of the DIRECTORY SECTOR in RAM) pointed to by Register Pair HL and put it into Register E.
Original Source Code Comment: GET THE ACC PASSWORD
5B3A
INC HL
INCrement the value stored in Register Pair HL by 1.
5B3B
LD D,(HL)
Fetch the value stored at memory location (i.e., the 2nd character of the ACCESS PASSWORD byte of the DIRECTORY SECTOR in RAM) pointed to by Register Pair HL and put it into Register D.
5B3C
LD HL,5CEFLD HL,MASTPW
LET Register Pair HL = 5CEFH which would be the hash for no password.
Original Source Code Comment: HASH FOR NO PASSWORD
5B3F
OR A
Set FLAGS based on the contents of Register A.
5B40
SBC HL,DE
Subtracts the value stored in Register Pair DE (i.e., the 2-Byte ACCESS PASSWORD of the DIRECTORY SECTOR in RAM) and the carry flag from the value stored in Register Pair HL (i.e., 5CEFH).
Original Source Code Comment: THERE AN ACC PW?
5B42
If the Z FLAG (Zero) is set then the ACCESS PASSWORD is blank, so JUMP to 5B4BH.
Original Source Code Comment: NOPE
5B44
CP 55H
Compare the value held in Register A against U. Results: If Register A equals U, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: IS THERE AN UPD PW ALSO?
5B46
LD A,41H
LET Register A = 41H (ASCII: A).
Original Source Code Comment: ASSUME THERE ISN'T
5B48
If the NZ FLAG (Not Zero) is set then the file is NOT update protected, so JUMP to 5B4BH.
Original Source Code Comment: THERE WASN'T
5B4A
INC A
INCrement the value stored in Register A by 1, so that A will now be a B to signify that the file is protected BOTH by an UPDATE and an ACCESS password.
Original Source Code Comment: INC THE 'A' TO A 'B' (BOTH)
5B4BCONTY
GOSUB to 6135H to display or print the character held in Register A; routine affects Registers A and E.
Original Source Code Comment: OUTPUT IT
5B4E
POP HL
Put the value held at the top of the STACK (i.e., the file pointer) into Restore Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: GET THE FILE POINTER BACK

5B4FH - Continuation of the "DIR" Command. Display the PROTECTION NUMBER OF THE PROTECTION LEVEL.

5B4F
PUSH HL
Save Register Pair HL (i.e., the file pointer) to the top of the stack.
Original Source Code Comment: SAVE FILE POINTER
5B50
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the FILE ACCESS LEVEL) and put it into Register A.
Original Source Code Comment: GET THE ATTRIB BYTE
5B51
AND 07H
MASK the value of Register A against 07H (0000 0111). This has the effect of leaving only bits 2, 1, 0 active, which are the access level bits.
Original Source Code Comment: MASK OFF STATUS BITS
5B53
ADD A,30H
LET Register A = Register A + 30H. Note: Adding 30H to Register A will convert decimal number 0-9 into its ASCII equivalent (i.e., 6 + 30H = 36H, which, in ASCII, is 6.
Original Source Code Comment: MAKE IT ASCII
5B55
GOSUB to 6135H to display or print the character held in Register A; routine affects Registers A and E.
Original Source Code Comment: OUTPUT THE NUMERIC LEVEL

5B58H - Continuation of the "DIR" Command. Get the EOF Byte.

5B58
5B59
5B5A
INC L
INC L
INC L
INCrement the value stored in Register L by 3, so that Register Pair HL now points to the EOF byte of the DIRECTORY SECTOR in RAM.
Original Source Code Comment: INC TO THE EOF BYTE
5B5B
LD A,(HL)
Fetch the value stored at memory location (i.e., the EOF byte of the DIRECTORY SECTOR in RAM) pointed to by Register Pair HL and put it into Register A.
Original Source Code Comment: GET IT
5B5C
LD (5B90H),ALD (S6EOF),A
Store the value held in Register A (i.e., the EOF byte of the DIRECTORY SECTOR in RAM) into the memory location 5B90H.
Original Source Code Comment: STORE FOR DISPLAY

5B5FH - Continuation of the "DIR" Command. Get the LRL Byte.

5B5F
INC L
INCrement the value stored in Register L by 1, so that Register Pair HL now points to the Logical Record Length byte of the DIRECTORY SECTOR in RAM.
Original Source Code Comment: INC TO THE LRL POSITION
5B60
LD L,(HL)
Fetch the value stored at memory location (i.e., the LRL byte of the DIRECTORY SECTOR in RAM) pointed to by Register Pair HL and put it into Register L.
Original Source Code Comment: GET THE LSB OF THE LRL
5B61
LD A,L
LET Register A = Register L (i.e., the LRL byte of the DIRECTORY SECTOR in RAM).
Original Source Code Comment: PUT IT INTO (A)
5B62
LD (5B89H),ALD (LRL2),A
Store the value held in Register A (i.e., the LRL byte of the DIRECTORY SECTOR in RAM) into the memory location 5B89H.
Original Source Code Comment: STORE IT FOR DISPLAY
5B65
SUB 01H
SUBtract the value 01H from Register A (i.e., the LRL byte of the DIRECTORY SECTOR in RAM) to set the flags.
Original Source Code Comment: CORRECT FOR 1'S OFFSET
5B67
LD A,00H
LET Register A = 00H to signify a 256 Byte LRL.
5B69
ADC A,00H
Add 00H to 00H to set the flags.
5B6B
LD H,A
LET Register H = Register A (i.e., 00H, to signify a 256 byte LRL).
5B6C
GOSUB to 61C1H to display the contents of Register Pair HL (i.e., the LRL for the file being processed) in decimal form.
Original Source Code Comment: GO CONVERT TO ASCII
5B6F
POP HL
Put the value held at the top of the STACK (i.e., the value that confused me in 5B4F) into Restore Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: GET THE POINTER BACK

5B70H - Continuation of the "DIR" Command. Calculate the number of records in a file.

5B70
5B71
5B73
LD A,L
ADD A,DERN
LD L,A
LET Register L = Register L + 14H, so that Register Pair HL now points to the END OF FILE SECTOR NUMBER byte of the DIRECTORY SECTOR in RAM.
Original Source Code Comment: PUT THE LSB INTO (A)
5B74
LD E,(HL)
Fetch the value stored at memory location (i.e., the LSB of the END OF FILE SECTOR NUMBER byte of the DIRECTORY SECTOR in RAM) pointed to by Register Pair HL and put it into Register E.
Original Source Code Comment: PICK IT UP
5B75
INC L
INCrement the value stored in Register L by 1, so that Register Pair HL now points to the MSB of the END OF FILE SECTOR NUMBER byte of the DIRECTORY SECTOR in RAM.
5B76
LD D,(HL)
Fetch the value stored at memory location (i.e., the MSB of the END OF FILE SECTOR NUMBER byte of the DIRECTORY SECTOR in RAM) pointed to by Register Pair HL and put it into Register D. Now DE=HL=the END OF FILE SECTOR NUMBER byte of the DIRECTORY SECTOR in RAM.
5B77
PUSH HL
Save Register Pair HL (i.e., the pointer to the MSB of the END OF FILE SECTOR NUMBER byte of the DIRECTORY SECTOR in RAM) to the top of the stack.
Original Source Code Comment: SAVE POINTER
5B78
LD A,(5B89H)LD A,(LRL2)
Fetch the value stored at memory location 5B89H (which is in the middle of an OPCODE and is currently storing the files LRL) and put it into Register A.
Original Source Code Comment: GET THE LRL
5B7B
OR A
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A.
Original Source Code Comment: LRL 256?
5B7C
If LRL is not Zero (i.e., the LRL is not 256 bytes) then the NZ FLAG (Not Zero) will be set. JUMP to 5B87H.
Original Source Code Comment: NO, CONTINUE
5B7E
LD A,(5B90H)LD A,(S6EOF)
Fetch the value stored at memory location 5B90H (which is in the middle of an OPCODE and is currently storing the files EOF) and put it into Register A.
Original Source Code Comment: GET THE EOF BYTE
5B81
OR A
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A.
Original Source Code Comment: EOF ON EVEN BOUNDARY?
5B82
If the EOF is zero, then the Z FLAG (Zero) is set. JUMP to 5B98H.
Original Source Code Comment: YES, CONTINUE
5B84
INC DE
INCrement the value stored in Register Pair DE (i.e., the END OF FILE SECTOR NUMBER) by 1.
Original Source Code Comment: BUMP FOR THE OFFSET
5B85
JUMP to 5B98H to continue with this routine.

5B87H - NLR256 - Continuation of the "DIR" Library Command. Jumped here from 5B7CH if the LRL is not zero so that we can calculate the number of LRL for records other than a 256 LRL.

5B87NLR256
EX DE,HL
EXchange the value stored in Register Pair HL (i.e., the pointer to the MSB of the END OF FILE SECTOR NUMBER byte of the DIRECTORY SECTOR in RAM) with the value stored in Register Pair DE (i.e., the END OF FILE SECTOR NUMBER byte of the DIRECTORY SECTOR in RAM).
Original Source Code Comment: ERN INTO HL
5B88
LD A,00LD A,LRL2
LET Register A = the memory contents of 5B89, which is the files LRL, as was placed in this location elsewhere in this Overlay.
Original Source Code Comment: LRL STORED HERE
5B8A
GOSUB to 4451H to divide HL by the LRL.
5B8D
LD H,A
LET Register H = Register A (i.e., the (HL / LRL) * 256 + the EOF).
5B8E
LD D,L
LET Register D = Register L (i.e., the MSB of the number of records).
5B8F
LD L,00LD L,S6EOF
LET Register L = the memory contents of 5B90, which is the files EOF, as was placed in this location elsewhere in this Overlay.
Original Source Code Comment: EOF BYTE STORED HERE
5B91
LD A,(5B89H)LD A,(LRL2)
Fetch the value stored at memory location 5B89H (i.e., the files LRL) and put it into Register A.
Original Source Code Comment: GET THE LRL
5B94
GOSUB to 4451H to divide HL by the LRL again.
5B97
LD E,L
LET Register E = Register L so that Register Pair DE holds the number of records.
Original Source Code Comment: INTO DE

Next up we need to display the number of records in the file.

5B98LRL257
EX DE,HL
EXchange the value stored in Register Pair HL with the value stored in Register Pair DE (i.e., the number of records, now held in HL).
Original Source Code Comment: NUMBER OF RECORDS TO HL
5B99
GOSUB to 61C1H to display the contents of Register Pair HL (i.e., the number of records for the file being processed) in decimal form.
Original Source Code Comment: CONVERT TO ASCII AND DISPLAY NUMBER OF RECS

Next up we need to calculate the number of GRANS and EXTENT POINTERS in the file.

5B9C
POP HL
Put the value held at the top of the STACK (i.e., the pointer to the MSB of the END OF FILE SECTOR NUMBER byte of the DIRECTORY SECTOR in RAM) into Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: GET DIRECTORY POINTER BACK
5B9D
INC L
INCrement the value stored in Register L by 1 so that Register Pair HL now points to the EXTENTS byte of the DIRECTORY SECTOR in RAM.
Original Source Code Comment: BUMP TO 1ST EXT

We are about to count up the grans by adding the gran numbers found in each valid extent. Register Pair DE will hold the number of grans and Register Pair BC will hold the number of extents.

5B9E
LD DE,0000H
LET Register Pair DE = 0000H.
Original Source Code Comment: CLEAR A COUNTER
5BA1
LD C,D
LET Register C = Register D.
Original Source Code Comment: AND ANOTHER ONE
5BA2
LD B,0DLD B,MAXEXT
LET Register B = 0DH (Decimal: 13) for a loop that will skip over the 13 extents.
Original Source Code Comment: SET A COUNTER FOR MAXIMUM EXTENTS
5BA4L6OP19
LD A,(HL)
Fetch the value stored at memory location (i.e., an extent byte) pointed to by Register Pair HL and put it into Register A.
Original Source Code Comment: GET EXT POINTER
5BA5
INC L
INCrement the value stored in Register L by 1 so that Register Pair HL now points to the GRAN byte of that valid EXTENT byte of the DIRECTORY SECTOR in RAM.
Original Source Code Comment: BUMP TO NUMBER OF GRANS THIS EXTENT
5BA6
CP 0FEH
Compare the value held in Register A against 0FEH, which would indicate if we have run out of EXTENT bytes. Results:
  • If Register A equals 0FEH, the Z FLAG is set.
  • If A < 0FEH, the CARRY FLAG will be set.
  • if A >= 0FEH, the NO CARRY FLAG will be set.

Original Source Code Comment: THIS THE END OF EXTENTS?
5BA8
If the extent byte in Register A equals 0FEH or 0FFH then the NC FLAG (No Carry) is set, and we have reached the end of the valid extent bytes. JUMP to 5BB6H.
Original Source Code Comment: YES, DISPLAY NUMBER OF EXTENTS
5BAA
INC C
If we didn't jump away, then we have a valid extent byte in Register A, so INCrement the value stored in Register C (which is counting the number of extents) by 1.
Original Source Code Comment: NO, INC THE EXT COUNTER
5BAB
LD A,(HL)
Fetch the value stored at memory location (i.e., the number of grans) pointed to by Register Pair HL and put it into Register A.
Original Source Code Comment: GET NUMBER OF GRANS AND STARTING GRAN
5BAC
INC L
INCrement the value stored in Register L by 1 so that Register Pair HL now points to the next EXTENT byte of the DIRECTORY SECTOR in RAM.
Original Source Code Comment: BUMP TO NEXT EXTENT POINTER
5BAD
AND 1FH
MASK the value of Register A (i.e., the number of grans in the extent) against 1FH (0001 1111). This has the effect of turning off bits 7, 6, 5, leaving only bits 4, 3, 2, 1, 0 active.
Original Source Code Comment: MASK ALL BUT NUMBER OF GRANS
5BAF
ADD A,E
LET Register A = Register A + Register E (i.e., the total number of grans for the file).
Original Source Code Comment: ADD IT TO THE COUNTER
5BB0
LD E,A
LET Register E = Register A (i.e., the total number of grans for the file).
Original Source Code Comment: SAVE FOR LATER
5BB1
If the NC FLAG (No Carry) is set then we did NOT have an overflow, so skip the next couple of instructions (which deal with an overflow) to 5BB4H.
Original Source Code Comment: JR IF WE DIDN'T PASS 256 GRANS
5BB3
INC D
INCrement the value stored in Register D (which is also tracking the number of grans, but on the MSB level) by 1.
Original Source Code Comment: ELSE INC THE 256 COUNTER
5BB4CONT3
LOOP back to 5BA4H, 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

5BB6H - CONT4 - Continuation of the "DIR" Command. Display the Number of GRANS in a File.

5BB6CONT4
EX DE,HL
EXchange the value stored in Register Pair HL (i.e., the pointer to the EXTENT byte of the DIRECTORY SECTOR in RAM) with the value stored in Register Pair DE (i.e., the number of grans for the file).
Original Source Code Comment: HL = NUMBER OF GRANS FOR THIS FILE
5BB7
PUSH BC
Save Register Pair BC (i.e., the number of extents for the file being processed) to the top of the stack.
Original Source Code Comment: SAVE NUMBER OF EXTENTS
5BB8
GOSUB to 61C1H to display the contents of Register Pair HL (i.e., the number of grans for the file being processed) in decimal form.
Original Source Code Comment: CONVERT TO ASCII AND DISPLAY NUMBER OF GRANS
5BBB
POP BC
Put the value held at the top of the STACK (i.e., the number of extents for the file being processed) into Restore Register Pair BC, and then remove the entry from the stack.

5BBCH - Continuation of the "DIR" Command. Display the Number of EXTENTS in a File.

5BBC
5BBD
LD H,00H
LD L,C
LET Register Pair HL = Register C (i.e., the number of extents in the file being processed).
Original Source Code Comment: GET THE NUMBER OF EXTENTS
5BBF
GOSUB to 61C1H to display the contents of Register Pair HL (i.e., the number of EXTENTS for the file being processed) in decimal form.
Original Source Code Comment: CONVERT IT AND DISPLAY

5BC2H - Continuation of the "DIR" Command. Display the EOF BYTE OFFSET of a File.

5BC2
LD A,(5B90H)LD A,(S6EOF)
Fetch the value stored at memory location 5B90H (i.e., the EOF byte of the file being processed) and put it into Register A.
Original Source Code Comment: GET THE EOF BYTE OFFSET
5BC5
5BC6
LD H,00H
LD L,A
LET Register Pair HL = Register A (i.e., the EOF BYTE of the file being processed).
Original Source Code Comment: INTO HL
5BC8
GOSUB to 61C1H to display the contents of Register Pair HL (i.e., the EOF BYTE of the file being processed) in decimal form.
Original Source Code Comment: CONVERT AND DISPLAY EOF BYTE

5BCBH - Continuation of the "DIR" Command. Display the DATE OF CREATION for a File.

5BCB
LD A,00LD A,SAVMTH
LET Register A = the memory contents of 5BCCH, which was placed here elsewhere in this Overlay. This is the file's creation month.
Original Source Code Comment: MONTH OF CREATION STORED HERE
5BCD
LD HL,5CBDLD HL,MTH
LET Register Pair HL = 5CBDH, which is the pointer to the creation month in the MESSAGE STORAGE table for the DIR command.
Original Source Code Comment: WHERE TO STORE ASCII VALUE
5BD0
GOSUB to 61B5H to convert the value.
Original Source Code Comment: CONVERT IT TO ASCII
5BD3
LD A,00LD A,SAVYR
LET Register A = the memory contents of 5BD4H, which was placed here elsewhere in this Overlay. This is the file's creation year.
Original Source Code Comment: YEAR OF CREATION STORED HERE
5BD5
LD HL,5CC0LD HL,YER
LET Register Pair HL = 5CC0H, which is the pointer to the creation year in the MESSAGE STORAGE table for the DIR command.
Original Source Code Comment: WHERE TO STORE ASCII VALUE
5BD8
GOSUB to 61B5H to convert the value.
Original Source Code Comment: CONVERT TO ASCII
5BDB
LD HL,5CBALD HL,DETA
LET Register Pair HL = 5CBAH, which is the pointer to the date in the MESSAGE STORAGE table for the DIR command.
Original Source Code Comment: HL => ASCII DATE STRING
5BDE
GOSUB to 6147H to either display or print the message pointed to by Register Pair HL.
Original Source Code Comment: OUTPUT IT

5BE1H - NO - Continuation of the "DIR" Command. Check for a User HOLD Key.

5BE1NO
GOSUB to 6167H to check the keyboard for a pause request.
5BE4
POP HL
Put the value held at the top of the STACK (I have NO idea what this might be) into Restore Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: GET DIR POINTER BACK
5BE5
RET NZ
If the NZ FLAG (Not Zero) is set then we got a BREAK so we abort out and RETurn to the caller.
Original Source Code Comment: EXIT, WASN'T CR
5BE6
PUSH HL
Save Register Pair HL to the top of the stack.
Original Source Code Comment: PUSH FOR NEXT POP

5BE7H - NXTFIL - Continuation of the "DIR" Command. Bump to the next file in the directory.

5BE7NXTFIL
POP HL
Put the value held at the top of the STACK into Restore Register Pair HL, and then remove the entry from the stack.
5BE8NXTFI1
LD DE,0030LD DE,SIZDIR
LET Register Pair DE = 0030H so that we can advance HL to point to the next directory entry. 30H is the size of one directory record.
Original Source Code Comment: DE = SIZE OF ONE DIRECTORY RECORD
5BEB
ADD HL,DE
LET Register Pair HL = Register Pair HL (i.e., the pointer to some byte in a directory entry) + Register DE (i.e., an offset from whatever that byte was to the beginning of the next directory entry).
Original Source Code Comment: HL => NEXT FILE
5BEC
LD A,L
LET Register A = Register L so that we can test to see if that was the last directory entry in the sector.
Original Source Code Comment: GET THE LSB OF THE BUFFER ADDRESS
5BED
CP 0F0H
Compare the value held in Register A against 0F0H (i.e., the LSB byte location in a sector where we have reached the end of the directory entries in that sector). Results: If Register A equals 0F0H, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: WE READING A NON-EXISTANT FILE?
5BEF
If the Z FLAG (Zero) is set then we have a new sector to deal with so JUMP to 5A68H.
Original Source Code Comment: YES, READ IN THE NEXT RECORD
5BF2
If we have not reached the end of the sector then LOOP BACK to 5A86H to keep processing directory entries.
Original Source Code Comment: NO, DISPLAY NEXT DIR RECORD

5BF5H - ENDFIL - Continuation of the "DIR" Command. All Files have been displayed. Calculate the number of FREE GRANS on the Disk.

5BF5ENDFIL
LD A,(5A6BH)LD A,(S6DDRV)
Fetch the value stored at memory location 5A6BH (i.e., the drive number) and put it into Register A.
Original Source Code Comment: GET THE DRIVE NUMBER BACK
5BF8
LD C,A
LET Register C = Register A (i.e., the drive number).
Original Source Code Comment: INTO C
5BF9
GOSUB to 4A93H.
NOTE: 4A93H is the SYS00/SYS routine to READ THE GAT sector into RAM (Buffer at 4D00H).
Original Source Code Comment: GET THE GAT BACK
5BFC
LD IX,4D00LD IX,BUFF2
LET Register Pair IX = 4D00H, which is the pointer to the GAT SECTOR now in RAM.
Original Source Code Comment: WHERE GAT IS STORED
5C00
LD HL,0000H
LET Register Pair HL = 0000H.
Original Source Code Comment: CLEAR A GAT COUNTER
5C03
5C04
LD D,H
LD E,L
LET Register DE = Register HL.
Original Source Code Comment: CLEAR DE ALSO
5C05
LD C,28LD C,MAXTRK
LET Register C = 28H (Decimal: 40) as there are 40 tracks on a TRSDOS v1.3 diskette.
Original Source Code Comment: NUMBER OF TRACKS TO CHECK
5C07L6OP23
INC (IX+FLAW)
Bump the value stored in the 60H sector of the GAT Table in RAM, which is the number of flawed tracks.
Original Source Code Comment: IS THIS TRACK FLAWED?
5C0A
If the NZ FLAG (Not Zero) is set, then the track is not flawed, so JUMP to 5C10H.
Original Source Code Comment: NO, CONTINUE
5C0C
LD (IX+00H),USDTRK
Store the value held in Register 3FH (i.e., the indicator that the GRAN is used) into the memory location IX+00H.
Original Source Code Comment: SHOW THE TRACK AS FULL
5C10L66O23
LD A,(IX+00H)
Fetch the value stored at the memory location pointed to by IX+00H (i.e., the allocation status) and put it into Register A.
Original Source Code Comment: GET A ALLOCATION BYTE
5C13
LD B,06LD B,NGRAN
LET Register B = 06H, which is the number of grans in a block.
Original Source Code Comment: NUMBER OF GRANS PER TRACK
5C15L6OP22
RRA
Rotate Register A's bits right one bit position, with Bit 0 going to the CARRY FLAG, and the old CARRY FLAG, going to Bit 7. This will allow us to check the gran by simply working with the CARRY FLAG.
5C16
CCF
Invert the state of the CARRY FLAG.
Original Source Code Comment: COMPLIMENT THE GRAN
5C17
ADC HL,DE
Add WITH CARRY Register Pair HL (i.e., a running total) and Register Pair DE.
Original Source Code Comment: HL=GRAN COUNT, DE=0, NO CARRY IF GRAN ALLOC
5C19
LOOP back to 5C15H, 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.
5C1B
INC IX
INCrement the value stored in Register Pair IX (i.e., the pointer to the current track being examined in the GAT TABLE in RAM) by 1.
Original Source Code Comment: INC TO NEXT TRACK
5C1D
DEC C
DECrement the value stored in Register C (i.e., the tracks left to be checked) by 1.
Original Source Code Comment: DEC THE TRACK COUNTER
5C1E
If the NZ FLAG (Not Zero) is set, meaning that Register C still shows we have tracks to scan, JUMP to 5C07H.
Original Source Code Comment: LOOP IF NOT DONE
5C20
PUSH HL
Save Register Pair HL (i.e., the running total of the count) to the top of the stack.
Original Source Code Comment: SAVE NUMBER OF GRANS
5C21
LD HL,5CA3LD HL,FIRST
LET Register Pair HL = 5CA3H, which is a pointer to the "* * *" message pointer.
Original Source Code Comment: HL => '***' MSG
5C24
GOSUB to 6147H to display/print the message being pointed to by Register Pair HL (i.e., "* * *").
Original Source Code Comment: PRINT IT
5C27
POP HL
Put the value held at the top of the STACK (i.e., the running total of the count) into Restore Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: GET NUMBER OF GRANS BACK
5C28
GOSUB to 61CAH (which is in the middle of the 61C1H routine to display the contents of Register Pair HL in decimal form).
Original Source Code Comment: CONVERT TRACK COUNTER TO ASCII
5C2B
LD HL,5CA7HLD HL,SECND
LET Register Pair HL = 5CA7H, which is a pointer to the "FREE GRANULES" message pointer.
Original Source Code Comment: HL => 'FREE GRAN' MSG
5C2E
GOSUB to 6147H to display/print the message being pointed to by Register Pair HL.
Original Source Code Comment: PRINT IT
5C31
RET
RETurn to the caller.

5C32H - TITL2 - MESSAGE AND STORAGE for the "DIR" Command.

5C32TITL2
DEFM ...
"DISK NAME: ".
5C3DHDSKN2
DEFM ...
" DRIVE: ".
5C50HDRV2
DEFM ...
" ".
5C56HDSIDE2
DEFM ...
" ".
5C5CHDATE2
DEFM ...
" " + 0DH
5C65TITL4
DEFM ...
"FILENAME ATTRB LRL #REC ".
5C89
DEFM ...
"#GRN EEXT EOF DATE:" + 0DH.
5CA3FIRST
DEFM ...
"***" + 03H.
5CA7SECND
DEFM ...
" FREE GRANULES ***" + 0DH.
5CBADETA
DEFM ...
" ".
5CBDHMTH
DEFM ...
"00/"
5CC0HYER
DEFM ...
"00" + 0DH.

5CC3H - SWTCH3 - "DIR" Command Parameter Table.

5CC3SWTCH3
DEFM 'SYS '
5CC9
DEFW SYS
5CCB
DEFM 'INV '
5CD1
DEFW INV
5CD3SWTCHH1
DEFM 'PRT '
5CD9
DEFW LPFLAG
5CDB
DEFB 00H

5CDCH - S6FREE - "FREE" Library Command.

5CDCS6FREE
LD BC,0000H
LET Register Pair BC = 0000H so that we can clear the PRINTER FLAG in the next instruction.
Original Source Code Comment: CLEAR BC
5CDF
LD (5A4DH),BCLD (LPFLAG),BC
Store the value held in Register BC (i.e., 0000H) into the memory location 5A4DH (i.e., the byte flag for PRINT).
Original Source Code Comment: ASSUME OUTPUT TO VIDEO
5CE3
LD A,(HL)
Fetch the first character stored at memory location pointed to by Register Pair HL (i.e., the pointer to the beginning of the command line which was passed to this Overlay on entry) and put it into Register A.
Original Source Code Comment: GET A CHAR FROM COMMAND LINE
5CE4
CP 3AH
Prepare to test for a DRIVE NUMBER 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?
5CE6
If we did not get a : the NZ FLAG (Not Zero) is set, so JUMP to 5CFDH.
Original Source Code Comment: NO, DEFAULT TO DRIVE 0
5CE8
INC HL
Bump the value stored in Register Pair HL by 1 so as to point to the next character stored at memory location pointed to by Register Pair HL (i.e., the command line which was passed to this Overlay on entry). If we had a :, then this would be a drive number.
Original Source Code Comment: BUMP TO NEXT CHAR
5CE9
LD A,(HL)
Fetch the value stored at memory location (i.e., the character following a ":" on the command line) pointed to by Register Pair HL and put it into Register A.
Original Source Code Comment: GET THE DRIVE NUMBER
5CEA
INC HL
Bump the value stored in Register Pair HL by 1 so as to point to the next character stored at memory location pointed to by Register Pair HL (i.e., the command line which was passed to this Overlay on entry).
Original Source Code Comment: BUMP TO NEXT CHAR
5CEB
SUB 30H
SUBtract the value 30H from Register A (i.e., the 2nd character on the command line if the first character was a ":"). Note: Subtracting 30H from Register A will convert an ASCII number '0'-'9' to its decimal equivalent (i.e., 6 in ASCII is 36H in Hex; so 36H-30H = 6).
Original Source Code Comment: MASK OFF ASCII
5CED
If the C FLAG (Carry) is set then the character's value was too low to be a number, so JUMP to 5234H.
Original Source Code Comment: EXIT IF LESS THAN NUMERIC
5CF0
CP 04CP TOPDRV
Compare the value held in Register A against 04H, which is 1 + the maximum number of drives permitted on a TRSDOS v1.3 system. Results:
  • If Register A equals 04H, the Z FLAG is set.
  • If A < 1 + the maximum number drives permitted, the CARRY FLAG will be set.
  • if A >= 1 + the maximum number drives permitted, the NO CARRY FLAG will be set.

Original Source Code Comment: GREATER THAN DRIVE 3?
5CF2
If the NC FLAG (No Carry) is set then the character we are testing for a drive number was >= 1 + the maximum number drives permitted, meaning it was not a proper drive number, so JUMP to 5234H.
Original Source Code Comment: YES, ERROR
5CF5
LD C,A
LET Register C = Register A (i.e., the partially validated drive number from the command line).
Original Source Code Comment: PUT THE DRIVE NUM IN (C)
5CF6
LD A,(4413H)LD A,(MAXDRV)
Fetch the value stored at memory location 4413H and put 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 THIS SYSTEM
5CF9
CP C
Compare the value held in Register A (i.e., the number of disk drives actually present on the system) against the value held in Register C (i.e., the partially validated drive number from the command line). Results: If the number of disk drives actually present on the system (Register A) >= the partially validated drive number from the command line (Register C), then the drive number requested is present on the system, and the NC FLAG will be set; if the requested drive is higher than the number of drives available, the CARRY FLAG will be set.
Original Source Code Comment: ASKING FOR NON-EXISTANT DRIVE?
5CFA
If the C FLAG (Carry) is set then the requested drive number is higher than the highest disk drive on the system so JUMP to 5234H.
Original Source Code Comment: YES, ERROR
5CFDNODRV
LD A,C
LET Register A = Register C (i.e., the fully validated drive number specified on the command line).
Original Source Code Comment: PUT THE DRIVE NUM IN A
5CFE
ADD A,30H
LET Register A = Register A + 30H. Note: Adding 30H to Register A will convert decimal number 0-9 into its ASCII equivalent (i.e., 6 + 30H = 36H, which, in ASCII, is 6.
Original Source Code Comment: MAKE IT ASCII
5D00
LD (5E0DH),ALD (DRIVE),A
Store the value held in Register A (i.e., the ASCII representation of the fully validated drive number specified on the command line) into the memory location 5E0DH, which is in the MESSAGE STORAGE AREA for the "FREE" Command.
Original Source Code Comment: STORE IN MESSAGE
5D03
PUSH BC
Save Register Pair BC (i.e., the fully validated drive number specified on the command line) to the top of the stack.
Original Source Code Comment: SAVE THE DRIVE NUMBER
5D04
LD DE,5CD3LD DE,SWTCH1
LET Register Pair DE = 5CD3H, which is the pointer to the "PRT " message.
Original Source Code Comment: POINT TO OPTION TABLE
5D07
GOSUB to 4454H.
NOTE: 4454H is the DOS PARAMETER STRING PARSE routine. It decodes DOS LIBRARY parameters.
Original Source Code Comment: WANT PRINTER OPTION?
5D0A
POP BC
Put the value held at the top of the STACK (i.e., the fully validated drive number specified on the command line) into Restore Register Pair BC, and then remove the entry from the stack.
Original Source Code Comment: RESTORE DRIVE NO.
5D0B
If the NZ FLAG (Not Zero) is set, then the CALL for the DOS PARAMETER STRING PARSE returned an error, so JUMP to 5214H.
Original Source Code Comment: EXIT IF SYNTAX ERROR
5D0E
GOSUB to 4B3EH to prepare the diskette for a DIRECTORY READ.
Original Source Code Comment: GET THE DIRECTORY TRACK NUMBER
5D11
LD A,D
LET Register A = Register D (i.e., the directory track number).
Original Source Code Comment: INTO (A)
5D12
LD (5E45H),ALD (CDIRET),A
Store the value held in Register A (i.e., the directory track number) into the memory location 5E45H (which is the DEFB storage area for the directory track number).
Original Source Code Comment: SAVE IT FOR LATER ON
5D15
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
5D18
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
Original Source Code Comment: EXIT IF ERROR
5D1B
LD HL,4DD0LD HL,BUFF2 + DID
LET Register Pair HL = 4DD0H, which is the pointer to the memory location holding the FILENAME in the GAT SECTOR we just read.
Original Source Code Comment: HL => DISK NAME
5D1E
LD DE,5DE7LD DE,DSKNAM
LET Register Pair DE = 5DE7H, which is a pointer to the MESSAGE STORAGE AREA for the FREE command.
Original Source Code Comment: PLACE TO PUT IT
5D21
LD BC,0008H
LET Register Pair BC = 0008H, which is the number of bytes in a filename (and therefore is the number of bytes to move).
Original Source Code Comment: NUMBER OF BYTES
5D24
LDIR
Copy the filename from the GAT SECTOR into the MESSAGE STORAGE AREA 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: MOVE THE NAME
5D26
LD BC,(5A4DH)LD BC,(LPFLAG)
Fetch the value stored at memory location 5A4DH (i.e., the PRINTER OUTPUT flag) and put it into Register BC.
Original Source Code Comment: OUTPUT TO LINE PRINTER?
5D2A
5D2B
LD A,B
OR C
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.
5D2C
If the NZ FLAG (Not Zero) is set, then PRINTER OUTPUT is selected, so skip the display routine which is next and JUMP to 5D31H.
Original Source Code Comment: YES, DON'T CLEAR SCREEN
5D2E
GOSUB to 01C9H which is the Model III ROM Routine to Clear the Screen.
Original Source Code Comment: CLEAR THE SCREEN
5D31CONTD
LD B,15H
LET Register B = 15H (Decimal: 21) for the 21 spaces we are about to print.
Original Source Code Comment: SET A COUNTER
5D33
LD A,20H
LET Register A = 20H (ASCII: SPACE) for the 21 spaces we are about to print.
Original Source Code Comment: LOAD A SPACE
5D35L6OP33
GOSUB to 6135H to display or print the character held in Register A; routine affects Registers A and E.
Original Source Code Comment: OUTPUT IT TO PUT THE NAME
5D38
LOOP back to 5D35H, 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: ON SCREEN, IN FROM EDGE
5D3A
LD HL,5DC2LD HL,TITLE
LET Register Pair HL = 5DC2H which is the MESSAGE STORAGE AREA for " FREE SPACE MAP ".
Original Source Code Comment: POINT TO 'FREE' MAP MSG
5D3D
GOSUB to 6147H to either display or print the message pointed to by Register Pair HL.
Original Source Code Comment: OUTPUT IT
5D40
LD HL,5DDDLD HL,TITL3
LET Register Pair HL = 5DDDH which is the MESSAGE STORAGE AREA for header text.
Original Source Code Comment: POINT TO REMAINDER OF HEADER
5D43
GOSUB to 6147H to either display or print the message pointed to by Register Pair HL.
Original Source Code Comment: OUTPUT IT
5D46
LD A,0FFH
LET Register A = 0FFH to prepare for initializing the track number.
Original Source Code Comment: SET A COUNT TO -1 (WILL BE INC'ED FIRST)
5D48
LD (5E44H),ALD (COUNT),A
Store the value held in Register A into the memory location 5E44H (i.e., the byte storage area set up to hold the track number) so that it can be fetched within the below loop.
Original Source Code Comment: SAVE IT
5D4B
LD HL,4D00LD HL,BUFF2
LET Register Pair HL = 4D00H, which is the BUFFER into which the GAT TABLE has been read.
Original Source Code Comment: POINT TO ALLOCATION TABLE
5D4EL6OP7
LD A,(5E44H)LD A,(COUNT)
Fetch the value stored at memory location 5E44H (i.e., the byte storage area set up to hold the track number) and put it into Register A.
Original Source Code Comment: GET COUNT
5D51
INC A
INCrement the value stored in Register A (i.e., the track number) by 1.
Original Source Code Comment: BUMP IT
5D52
CP 28CP MAXTRK
Compare the value held in Register A against 28H (Decimal: 40), which is the maximum number of tracks on a disk. Results: If Register A (i.e., the track number) >= 40, the NO CARRY FLAG will be set.
Original Source Code Comment: ALL TRACKS READ?
5D54
RET NC
If the NC FLAG (No Carry) is set then we are at (or beyond) the end of the disk, so RETurn to the caller.
Original Source Code Comment: EXIT IF SO
5D55
PUSH HL
Save Register Pair HL (i.e., the pointer to the GAT sector in RAM) to the top of the stack.
Original Source Code Comment: SAVE POINTER
5D56
PUSH AF
Save Register Pair AF (i.e., the track number) to the top of the stack.
Original Source Code Comment: SAVE COUNT
5D57
LD HL,5E0FLD HL,LOW
LET Register Pair HL = 5E0FH, which is the MESSAGE STORAGE AREA for the output line format.
Original Source Code Comment: POINT TO DROP IN INFO
5D5A
GOSUB to 5E46H to put the first track number in the data line for printout.
Original Source Code Comment: CONVERT TRK TO ASCII AND SAVE
5D5D
POP AF
Put the value held at the top of the STACK into Restore Register Pair AF (i.e., the track number), and then remove the entry from the stack.
Original Source Code Comment: RESTORE TRK
5D5E
ADD A,04H
LET Register A = Register A (i.e., the track number) + 04H.
Original Source Code Comment: BUMP IT BY 4
5D60
LD (5E44H),ALD (COUNT),A
Store the value held in Register A (i.e., the track number + 4) into the memory location 5E44H (i.e., the byte storage area set up to hold the track number).
Original Source Code Comment: SAVE IT
5D63
LD HL,5E12LD HL,LOW + 3
LET Register Pair HL = 5E12H which is the pointer for the fourth track number in the data line for printout.
Original Source Code Comment: POINT TO REST OF DROP IN
5D66
GOSUB to 5E46H to put the fourth track number in the data line for printout.
Original Source Code Comment: DROP IN NEW TRACK
5D69
LD DE,5E19LD DE,TABLE
LET Register Pair DE = 5E19H which is the pointer to the start of track data.
Original Source Code Comment: POINT TO 'XX:XX' TABLE
5D6C
POP HL
Put the value held at the top of the STACK (i.e., the pointer to the GAT table in RAM) into Restore Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: GET GAT POINTER
5D6D
LD B,05H
LET Register B = 05H for a loop of 5 tracks.
Original Source Code Comment: SET A COUNTER
5D6FL6OO8
PUSH HL
Save Register Pair HL (i.e., the pointer to the GAT table in RAM) to the top of the stack.
Original Source Code Comment: SAVE GAT POINTER
5D70
PUSH DE
Save Register Pair DE to the top of the stack.
Original Source Code Comment: SAVE TABLE POINTER
5D71
LD DE,0060LD DE,FLAW
LET Register Pair DE = 0060H which will be an offset to HL so that HL will point to the track existence table in the GAT sector.
Original Source Code Comment: OFFSET TO THE FLAWED TRACK INFO
5D74
ADD HL,DE
LET Register Pair HL = Register Pair HL + Register DE.
Original Source Code Comment: HL => THIS TRACK'S FLAW INFO
5D75
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the track existence table in the GAT sector) and put it into Register A.
Original Source Code Comment: GET THE FLAW TRACK INFO
5D76
POP DE
Put the value held at the top of the STACK into Restore Register Pair DE, and then remove the entry from the stack.
Original Source Code Comment: GET TABLE POINTER BACK
5D77
POP HL
Put the value held at the top of the STACK (i.e., the pointer to the GAT table in RAM) into Restore Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: GET ALLOCATION POINTER BACK
5D78
CP 0FFH
Compare the value held in Register A against 0FFH to test for a flawed track. Results: If Register A equals 0FFH, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: FLAWED TRACK?
5D7A
If the NZ FLAG (Not Zero) is set then the track is NOT flawed so skip the flawed track display routine and JUMP to 5D8EH.
Original Source Code Comment: NO, CHECK GRANS
5D7CL66P08
LD IX,5DD1LD IX,GFLAW
LET Register Pair IX = 5DD1H so as to point to "FLAWED".
Original Source Code Comment: IX => 'FLAWED' MSG
5D80L6PO8
PUSH BC
Save Register Pair BC (i.e., the count) to the top of the stack.
Original Source Code Comment: SAVE THE COUNTER
5D81
LD B,06LD B,NGRAN
LET Register B = 06H for a DJNZ loop of 6 iterations (i.e., the number of grans on a track) to move bytes from IX to DE.
Original Source Code Comment: NUMBER OF GRANS ON TRACK
5D83L6OOP8
LD A,(IX+00H)
Fetch the value stored at the memory location pointed to by IX+00H and put it into Register A.
Original Source Code Comment: GET A BYTE
5D86
LD (DE),A
Store the value held in Register A into the memory location pointed to by Register Pair DE.
Original Source Code Comment: INTO THE DISPLAY TABLE
5D87
INC IX
INCrement the value stored in Register Pair IX by 1.
Original Source Code Comment: BUMP POINTERS
5D89
INC DE
INCrement the value stored in Register Pair DE by 1.
5D8A
LOOP back to 5D83H, 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 GRAN COUNT
5D8C
JUMP to 5DACH.
Original Source Code Comment: AND CONTINUE

5D8EH - L6PO9 - Continuation of the "FREE" command. Jumped here if the track is NOT flawed (so as to skip the display of a flawed track).

5D8EL6PO9
LD A,(5E45H)LD A,(CDIRET)
Fetch the value stored at memory location 5E45H (i.e., the directory track number) and put it into Register A.
Original Source Code Comment: GET THE DIRECTORY TRACK LOCATION
5D91
CP L
Compare the value held in Register A against the value held in Register L. Results: If Register A equals Register L, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: WE AT DIRECTORY?
5D92
If the NZ FLAG (Not Zero) is set then we have not yet reached the directory track, so JUMP to 5D9AH.
Original Source Code Comment: NO, DISPLAY INFO
5D94
LD IX,5DD7LD IX,GDIR
If we are here, we have finally hit the directory sector. LET Register Pair IX = 5DD7H to point to "DIRECT".
Original Source Code Comment: IX => 'DIRECTORY' MSG
5D98
JUMP to 5D80H.
Original Source Code Comment: AND FILL THIS TRACK WITH 'D'

5D9AH - L6PO10 - Continuation of the "FREE" command. Jumped here if the track is NOT flawed (so as to skip the display of a flawed track) and we have not yet hit the directory track.

5D9AL6PO10
LD C,(HL)
Fetch the value stored at memory location (i.e., the allocation bytes) pointed to by Register Pair HL and put it into Register C.
Original Source Code Comment: GET THE ALLOCATION BYTE
5D9BL60010
PUSH BC
Save Register Pair BC (i.e., the count) to the top of the stack.
Original Source Code Comment: SAVE THE COUNTER
5D9C
LD B,06LD B,NGRAN
LET Register B = 06H for a DJNZ loop of 6 iterations to move bytes from IX to DE.
Original Source Code Comment: NUMBER OF GRANS IN THIS TRACK
5D9EL6PO11
SRL C
We need to see if the gran at issue is allocated so a SRL C is involked whereby the contents of Register C are shifted right one bit position, with bit 0 copied to the carry flag and a zero put into bit 7.
Original Source Code Comment: SHIFT ALLOCATION BIT INTO CARRY
5DA0
If the C FLAG (Carry) is set (meaning bit 0 of Register C was set), then the gran was allocated, so JUMP to 5DA6H.
Original Source Code Comment: IF CARRY, GRAN ALLOCATED
5DA2
LD A,2EH
LET Register A = 2EH (ASCII: .).
Original Source Code Comment: SHOW 'NOT' ALLOCATED
5DA4
JUMP to 5DA8H.

5DA6H - SETX - Continuation of the "FREE" command. Jumped here if the track is NOT flawed (so as to skip the display of a flawed track) and we have not yet hit the directory track AND the gran is allocated.

5DA6SETX
LD A,58H
LET Register A = 58H (ASCII: X).
Original Source Code Comment: SHOW 'IS' ALLOCATED
5DA8SETXX
LD (DE),A
Store the value held in Register A into the memory location pointed to by Register Pair DE (i.e., a location in the data line to be output).
Original Source Code Comment: SET IT INTO THE TABLE
5DA9
INC DE
INCrement the value stored in Register Pair DE (i.e., a location in the data line to be output) by 1.
Original Source Code Comment: BUMP TO NEXT BYTE IN TABLE
5DAA
LOOP back to 5D9EH, 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 ALL GRANS THIS TRACK
5DACL6PO20
POP BC
Put the value held at the top of the STACK (i.e., the counter) into Restore Register Pair BC, and then remove the entry from the stack.
Original Source Code Comment: GET THE COUNTER BACK
5DAD
PUSH HL
Save Register Pair HL (i.e., a pointer in the GAT SECTOR in RAM) to the top of the stack.
Original Source Code Comment: SAVE THE GAT POINTER
5DAE
LD HL,0003H
LET Register Pair HL = 0003H to prepare to skip over 3 spaces in the data line to be output.
Original Source Code Comment: NUMBER OF BYTES TO SKIP OVER IN TABLE
5DB1
ADD HL,DE
LET Register Pair HL = Register Pair HL (i.e. 3) + Register DE (the pointer to the the data line to be output).
Original Source Code Comment: DE => NEXT TRACK IN ASCII TABLE
5DB2
EX DE,HL
EXchange the value stored in Register Pair HL (the pointer to the the data line to be output + 3) with the value stored in Register Pair DE (the pointer to the the data line to be output).
Original Source Code Comment: PUT IT INTO DE
5DB3
POP HL
Put the value held at the top of the STACK (i.e., a pointer in the GAT SECTOR in RAM) into Restore Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: GET GAT POINTER BACK
5DB4
INC HL
INCrement the value stored in Register Pair HL (i.e., a pointer in the GAT SECTOR in RAM) by 1.
Original Source Code Comment: BUMP TO NEXT ALLOCATION BYTE
5DB5
LOOP back to 5D6FH (to loop over tracks), 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 5 TRACKS
5DB7
PUSH HL
Save Register Pair HL (i.e., a pointer in the GAT SECTOR in RAM) to the top of the stack.
Original Source Code Comment: SAVE GAT POINTER
5DB8
LD HL,5E0FLD HL,LOW
LET Register Pair HL = 5E0FH to point to the data line.
5DBB
GOSUB to 6147H to either display or print the message pointed to by Register Pair HL.
5DBE
POP HL
Put the value held at the top of the STACK into Restore Register Pair HL, and then remove the entry from the stack.
5DBF
JUMP to 5D4EH to keep looping over the entire disk.

5DC2H - TITLE - MESSAGE and BYTE STORAGE AREA for "FREE".

5DC2TITLE
DEFM 'FREE SPACE MAP" + 0DH
5DD1GFLAW
DEFM 'FLAWED'
5DD7GDIR
DEFM 'DIRECT'
5DDDTITL3
DEFM 'TRK # '
5DE7HDSKNAM
DEFM 'SIDE: ------------------ DRIVE: '
5E0DHDRIVE
DEFM ' ' + 0DH
5E0FLOW
DEFM ' - : '
5E19HTABLE
DEFM ...
"' : : : : ' + 0DH".
5E44COUNT
DEFB 0
Storage area for the Track Number.
5E45CDIRET
DEFB 0
Storage area for the Directory's Track Number.

5E46H - HEXCOV - Subroutine in the "FREE" Library Command to Generate a 2-Digit Decimal Number.

5E46HEXCOV
LD (HL),2FH
Store the value of 1 character below "0" into the memory location pointed to by Register Pair HL.
5E48HEXCO2
INC (HL)
Increase the character held in Register Pair HL by 1.
5E49
SUB 0AH
SUBtract 10 from that character value.
5E4B
If the NC FLAG (No Carry) is set, the value went negative, so JUMP to 5E48H.
5E4DHEXCO1
ADD A,3AH
LET Register A = Register A (i.e., the remainder from that subtraction) + 3AH to convert that value to ASCII.
5E4F
INC HL
INCrement the value stored in Register Pair HL by 1 to point to the byte which will hold the second digit.
5E50
LD (HL),A
Store the value held in Register A (i.e., the remainder from that subtraction + 3AH) into the memory location pointed to by Register Pair HL.
5E51
RET
RETurn to the caller.

5E52H - "CREATE" Library Command.

5E52CREATE
LD BC,0000H
LET Register Pair BC = 0000H.
Original Source Code Comment: CLEAR BC
5E55
LD (5E95H),BCLD (NRECS),BC
Store the value held in Register BC (i.e., 0000H) into the memory location 5E95H (i.e., the storage location for the NUMBER OF RECORDS).
Original Source Code Comment: ASSUME NO RECORDS
5E59
LD (5E7FH),BCLD (S6LRL),BC
Store the value held in Register BC (i.e., 0000H) into the memory location 5E7FH (i.e., the storage location for the LOGICAL RECORD LENGTH).
Original Source Code Comment: ASSUME LRL OF 256
5E5D
GOSUB to 623AH to isolate and validate the FILESPEC from the command line via an OVERLAY call to ROUTINE 4 of OVERLAY 1.
Original Source Code Comment: GET SYNTAX OF NAME
5E60
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5218H.
Original Source Code Comment: EXIT IF SYNTAX ERROR
5E63CONT10
LD DE,5EB1LD DE,SWTCH2
LET Register Pair DE = 5EB1H to point to the valid parameter table (which is either REC or LRL).
Original Source Code Comment: POINT TO CREATE COMMAND TABLE
5E66
GOSUB to 4454H.
NOTE: 4454H is the DOS PARAMETER STRING PARSE routine. It decodes DOS LIBRARY parameters.
Original Source Code Comment: GET ANY OPTIONS
5E69
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5214H.
Original Source Code Comment: EXIT IF ERROR
5E6C
LD HL,(5E95H)LD HL,(NRECS)
Fetch the value stored at memory location 5E95H (i.e., the storage location for the number of records) and put it into Register HL.
Original Source Code Comment: GET THE RECORD NUMBER
5E6F
GOSUB to 5EC2H to convert the Binary Coded Decimal Value Pointed to by Register Pair HL into Binary.
Original Source Code Comment: CONVERT IT TO DECIMAL
5E72
LD (5E95H),HLLD (NRECS),HL
Store the value held in Register HL (i.e., the converted value) into the memory location 5E95H (i.e., the storage location for the number of records).
Original Source Code Comment: SAVE IT
5E75
LD HL,(5E7FH)LD HL,(S6LRL)
Fetch the value stored at memory location 5E7FH (i.e., the storage location for the LRL) and put it into Register HL.
Original Source Code Comment: GET THE LRL
5E78
GOSUB to 5EC2H to convert the Binary Coded Decimal Value Pointed to by Register Pair HL into Binary.
Original Source Code Comment: CONVERT IT TO DECIMAL
5E7B
LD (5E7FH),HLLD (S6LRL),HL
Store the value held in Register HL into the memory location 5E7FH (i.e., the storage location for the LRL).
Original Source Code Comment: SAVE IT
5E7E
LD BC,(0000H)LD BC,(S6LRL)
LET Register Pair BC = the value stored in the memory locations 5E7F-5E80H, which represet the LRL, and which were placed here by other instructions in this overlay.
Original Source Code Comment: LOAD LRL INTO BC
5E81
LD A,B
LET Register A = Register B (i.e., the MSB of the LRL).
Original Source Code Comment: LRL .GT. 256?
5E82
CP 02H
Compare the value held in Register A (i.e., the MSB of the LRL) against 02H. Result: if A >= 02H, the NO CARRY FLAG will be set.
5E84
If the NC FLAG (No Carry) is set then the LRL is too big, so JUMP to 5214H.
Original Source Code Comment: ERROR IF SO
5E87
LD B,C
LET Register B = Register C (i.e., the LSB of the LRL).
Original Source Code Comment: PUT THE LRL INTO B
5E88
GOSUB to 622DH to set the parameters for an OVERLAY call to open a file.
Original Source Code Comment: SETUP THE DCB
5E8B
GOSUB to 4420H.
NOTE: 4420H is the SYS00/SYS routine to INITIALIZE A DISK (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: INIT THE FILE
5E8E
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
Original Source Code Comment: EXIT IF ERROR
5E91
If the NC FLAG (No Carry) is set then that CALL resulted in a "FILE ALREADY EXISTS" status, so JUMP to 521CH.
Original Source Code Comment: EXIT IF FILE EXISTS
5E94
LD BC,(0000H)LD BC,(NRECS)
LET Register Pair BC = the value stored in the memory locations 5E95H-5E96H, which represet the NUMBER OF RECORDS, and which were placed here by other instructions in this overlay.
Original Source Code Comment: GET THE NUM OF RECS
5E97-5E98L6OP12
LD A,B
OR C
Since the Z-80 cannot test Register Pair BC against zero, the common trick is to set Register A to equal to Register B, and then OR A against Register C. Only if both Register B and Register C were zero can the Z FLAG be set.
Original Source Code Comment: ANY RECS GIVEN?
5E99
If the number of records is zero (or not supplied), then the Z FLAG (Zero) is set, so JUMP to 56F6H to close and exit.
Original Source Code Comment: IF NOT, DONE
5E9C
DEC BC
If we are here, then we were given a NUMBER OF RECORDS in excess of ZERO. DECrement the value stored in Register Pair BC (i.e., the record number to position to) by 1.
Original Source Code Comment: CORRECT FOR 1'S OFFSET
5E9D
LD DE,6280LD DE,S6DCB1
LET Register Pair DE = 6280H, which will be the DCB address.
Original Source Code Comment: DE => DCB
5EA0
PUSH DE
Save Register Pair DE (i.e., the DCB address) to the top of the stack.
Original Source Code Comment: SAVE IT
5EA1
GOSUB to 4442H to position the file to the last record.
Original Source Code Comment: POSITION TO THAT SPOT
5EA4
POP DE
Put the value held at the top of the STACK (i.e., the DCB address) into Restore Register Pair DE, and then remove the entry from the stack.
5EA5
LD HL,3C00H
LET Register Pair HL = 3C00H, which is the first character location on the screen.
Original Source Code Comment: POINT TO VIDEO AS DATA
5EA8
GOSUB to 4439H to write from the video screen to a file.
Original Source Code Comment: WRITE OUT SOME DUMMY STUFF
5EAB
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
Original Source Code Comment: EXIT IF ERROR
5EAE
JUMP to 56F6H to close the file and exit.
Original Source Code Comment: CLOSE THE FILE

5EB1H - SWTCH2 - PARAMETER TABLE for the "CREATE" Command.

5EB1SWTCH2
DEFM "REC "
Text Storage
5EB7
DEFW 5E95HDEFW NRECS
Pointer to 5E95H
5EB9
DEFM "LRL "
Text Storage
5EBE
DEFW 5E7FS6LRL
Pointer to 5E7FH
5EC1
DEFB 00H
End of Table Delimeter.

5EC2H - CONVHX - SUBROUTINE in the "CREATE" Command to Convert the Binary Coded Decimal Value Pointed to by Register Pair HL into Binary.

5EC2CONVHX
LD IX,0000H
LET Register Pair IX = 0000H, which is where the results will be stored.
Original Source Code Comment: CLEAR 16 BIT ACCUMULATOR
5EC6
LD IY,5EF7LD IY,POWR10
LET Register Pair IY = 5EF7H, which is a pointer to a POWER OF TEN table.
5ECA
LD A,H
LET Register A = Register H (i.e., the MSB).
Original Source Code Comment: GET THE MSB
5ECB
GOSUB to 5ED6H to convert from Hexadecimal.
Original Source Code Comment: ADD IN THE POWER
5ECE
LD A,L
LET Register A = Register L (i.e., the LSB).
Original Source Code Comment: GET THE LSB
5ECF
GOSUB to 5ED6H to convert from Hexadecimal.
Original Source Code Comment: ADD IT IN
5ED2
5ED4
PUSH IX
POP HL
Let Register Pair HL = Register Pair IX.
Original Source Code Comment: MOVE THE VALUE TO HL
5ED5
RET
RETurn to the caller.

5ED6H - ADDHL - SUBROUTINE to the above SUBROUTINE in the "CREATE" Command. Converts the value held in A to Hexadecimal.

5ED6ADDHL
PUSH AF
Save Register Pair AF (i.e., the byte we are converting) to the top of the stack.
Original Source Code Comment: SAVE THE VALUE
5ED7
5ED9
5EDB
5EDD
SRA A
SRA A
SRA A
SRA A
Shift the contents of Register A right one bit position four times. In each iteration, the contents of bit 0 are copied to the carry flag and the previous contents of bit 7 are unchanged. This basically erases the low nybble.
Original Source Code Comment: SHIFT THE MSD OVER
5EDF
GOSUB to 5EE3H to convert Register A to a Decimal Decoded number.
Original Source Code Comment: ADD IT IN
5EE2
POP AF
Put the value held at the top of the STACK into Restore Register Pair AF (i.e., the byte we are converting), and then remove the entry from the stack.
Original Source Code Comment: GET THE VALUE BACK
5EE3ADDIX
AND 0FH
MASK the value of Register A against 0FH (0000 1111) to keep only bits 3, 2, 1, 0, which turns Register A into the low nybble of Register A.
Original Source Code Comment: MASK FOR LOW BITS ONLY
5EE5
LD B,A
LET Register B = Register A (i.e., the low nybble of the byte we are converting).
Original Source Code Comment: INTO B

The next few instructions get the appropriate power of 10 from a table.

5EE6
LD E,(IY+00H)
Fetch the value stored at memory location IY+00H and put it into Register E.
Original Source Code Comment: GET THE LSB FROM POWER TABLE
5EE9
INC IY
INCrement the value stored in Register Pair IY by 1.
5EEB
LD D,(IY+00H)
Fetch the value stored at memory location IY+00H and put it into Register D.
5EEE
INC IY
INCrement the value stored in Register Pair IY by 1.
Original Source Code Comment: BUMP FOR NEXT TIME
5EF0
INC B
INCrement the value stored in Register B by 1.
Original Source Code Comment: SEE IF B IS ZERO
5EF1ADDIX1
DEC B
DECrement the value stored in Register B by 1 so as to trigger a Z or NZ flag.
Original Source Code Comment: DEC THE COUNTER
5EF2
RET Z
If the Z FLAG (Zero) is set, then our digit is zero, so RETurn to the caller.
Original Source Code Comment: IS DONE. EXIT
5EF3
ADD IX,DE
LET Register Pair IX = Register Pair IX (i.e., returning code) + Register DE (i.e., the table value).
Original Source Code Comment: ADD IN THE POWER
5EF5
LOOP BACK 3 instructions to 5EF1H.

5EF7H - POWR10 - POWERS OF 10 TABLE for the "CREATE" Command.

5EF7POWR10
E8 03
This is hex for 1000.
5EF9
64 00
This is hex for 100.
5EFB
0A
This is hex for 10.
5EFC
00
This is hex for 0.

5EFFH - "CLEAR" Library Command.

5EFFCLEAR
LD BC,0000H
LET Register Pair BC = 0000H so we can zero out the following memory locations.
Original Source Code Comment: CLEAR OUT THE SWITCHES
5F02
LD (5F29H),BCLD (LOWRAM),BC
Store the value held in Register BC (i.e., 0000H) into the memory location 5F29H (i.e., the memory location storing the STARTING ADDRESS).
5F06
LD (5F38H),BCLD (HIGHRAM),BC
Store the value held in Register BC (i.e., 0000H) into the memory location 5F38H (i.e., the memory location storing the ENDING ADDRESS).
5F0A
LD (5F4CH),BCLD (NEWMEM),BC
Store the value held in Register BC (i.e., 0000H) into the memory location 5F4CH (i.e., the memory location storing the MEMORY PROTECT ADDRESS).
5F0E
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the pointer to the command line entered by the USER after the library command itself) and put it into Register A.
Original Source Code Comment: GET THE NEXT CHAR ON COMMAND LINE
5F0F
CP 0DH
Compare the value held in Register A against 0DH (ASCII: CARRIAGE RETURN). Results: If Register A equals CARRIAGE RETURN, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: END OF LINE?
5F11
If the NZ FLAG (Not Zero) is set, then we have parameters (i.e., we didn't just get a CARRIAGE RETURN) so JUMP to 5F1FH.
Original Source Code Comment: NO, PARSE THE COMMANDS
5F13
LD A,(4CFDH)LD A,(DOFLAG)
Fetch the value stored at memory location 4CFDH (i.e., the memory location storing whether the DO command is active or not) and put it into Register A.
Original Source Code Comment: GET THE DO FLAG
5F16
OR A
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A.
Original Source Code Comment: DO ACTIVE?
5F17
If the Z FLAG (Zero) is set, then the DO command is NOT active, so JUMP to 5F63H.
Original Source Code Comment: NO, IT'S ALLOWED
5F19
LD HL,5FAALD HL,CNTCLR
LET Register Pair HL = 5FAAH which is a pointer to an error message, since you are not permitted to CLEAR memory while DO is active.
Original Source Code Comment: HL => 'CANT CLEAR' MSG
5F1C
JUMP to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found.
Original Source Code Comment: DISPLAY AND EXIT

5F1FH - CLEARX - Subroutine in the "CLEAR" Library Command. Jumped to if we have parameters on the command line.

5F1FCLEARX
LD DE,5F91LD DE,CLRTAB
LET Register Pair DE = 5F91H to point to the PARAMETER TABLE for the CLEAR command.
Original Source Code Comment: DE => CLEAR TABLE
5F22
GOSUB to 4454H.
NOTE: 4454H is the DOS PARAMETER STRING PARSE routine. It decodes DOS LIBRARY parameters.
Original Source Code Comment: DO THE CHECK ON IT
5F25
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5214H.
Original Source Code Comment: EXIT IF ERROR
5F28
LD DE,(0000H)LD DE,(LOWRAM)
LET Register Pair DE = the value stored in 5F29H-5F30H (i.e., the memory location storing the STARTING ADDRESS), which was placed here by other instructions in this overlay.
Original Source Code Comment: LOW RAM ADDRESS STORED HERE
5F2B
5F2C
LD A,D
OR E
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: ANY SPECIFIED?
5F2D
If the Z FLAG (Zero) is set, then the START entry was ZERO, so JUMP to 5F4BH.
Original Source Code Comment: NO, CHECK MEMORY SIZE
5F2F
LD HL,6000H
LET Register Pair HL = 6000H, which is the lowest RAM location which is permitted.
Original Source Code Comment: SEE IF LEGAL ADDRESS
5F32
SBC HL,DE
Subtracts the value stored in Register Pair DE (i.e., the memory location storing the STARTING ADDRESS) and the carry flag from the value stored in Register Pair HL (i.e., 6000H, the floor of the permitted STARTING address).
5F34
If the NC FLAG (No Carry) is set, then that subtraction didn't trigger an overflow, so we were given a STARTING ADDRESS which is too low. JUMP to 5225H.
Original Source Code Comment: NO, ERROR
5F37
LD HL,(0000H)LD HL,(HIGHRAM)
LET Register Pair HL = the value stored in 5F38H-5F39H (i.e., the memory location storing the ENDING ADDRESS), which was placed here by other instructions in this overlay.
Original Source Code Comment: HIGH RAM ADDRESS STORED HERE
5F3A
SBC HL,DE
Subtracts the value stored in Register Pair DE (i.e., the memory location storing the ENDING ADDRESS) and the carry flag from the value stored in Register Pair HL (i.e., the STARTING ADDRESS).
Original Source Code Comment: GET THE DIFFERENCE
5F3C
If the C FLAG (Carry) is set then that subtraction triggered an overflow, so JUMP to 5220H to exit.
Original Source Code Comment: START GREATER THAN END
5F3F
If the Z FLAG (Zero) is set then the START and END addresses are the same, so JUMP to 5220H to exit.
Original Source Code Comment: START:=END. ERROR
5F42
5F43
LD B,H
LD C,L
Let Register Pair BC = Register Pair HL (i.e., the ENDING ADDRESS - STARTING ADDRESS).
Original Source Code Comment: PUT THE COUNT INTO BC
5F44
5F45
LD H,D
LD L,E
LET Register Pair HL = Register Pair DE (i.e., the STARTING ADDRESS).
Original Source Code Comment: MIRROR START TO HL
5F46
INC DE
INCrement the value stored in Register Pair DE (i.e., the STARTING ADDRESS) by 1.
Original Source Code Comment: DE = START+1
5F47
LD (HL),00H
Store a 00H into the memory location pointed to by Register Pair HL.
Original Source Code Comment: THE CLEAR BYTE
5F49
LDIR
Clear the entire area by using a LDIR command, 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 OUT THE RAM

5F4BH - CHKMEM - Continuation of CLEAR command

5F4BCHKMEM
LD HL,(0000H)LD HL,(NEWMEM)
LET Register Pair HL = the value stored in 5F4CH-5F4DH (i.e., the memory location storing the MEMORY PROTECT ADDRESS), which was placed here by other instructions in this overlay.
Original Source Code Comment: NEW MEMORY SIZE ADDRESS STORED HERE
5F4E
5F4F
LD A,H
OR L
Since the Z-80 cannot test Register Pair HL against zero, the common trick is to set Register A to equal to Register H, and then OR A against Register L. Only if both Register H and Register L were zero can the Z FLAG be set.
Original Source Code Comment: ANY GIVEN?
5F50
If the Z FLAG (Zero) is set, then there was either NO memory protect address given or it was zero, so JUMP to 01C9H which is the Model III ROM Routine to clear the screen (and this routine will exit after that).
Original Source Code Comment: NO, CLEAR THE SCREEN
5F53
EX DE,HL
EXchange the value stored in Register Pair HL (i.e., the memory location storing the MEMORY PROTECT ADDRESS) with the value stored in Register Pair DE. Register Pair DE will now contain the the memory location storing the MEMORY PROTECT ADDRESS.
Original Source Code Comment: PUT IT INTO DE
5F54
LD HL,5FFFH
LET Register Pair HL = 5FFFH (i.e., 1 byte lower than the lowest byte we will permit).
Original Source Code Comment: SEE IF LEGAL RAM LOCATION
5F57
SBC HL,DE
Subtracts the value stored in Register Pair DE and the carry flag from the value stored in Register Pair HL.
5F59
If the NC FLAG (No Carry) is set that means the User tried to set the MEMORY PROTECT ADDRESS to less than 6000H, which is invalid, so JUMP to 5225H.
Original Source Code Comment: NO, NOT LEGAL
5F5C
LD (4411H),DELD (MEMEND),DE
Store the value held in Register DE into the memory location 4411H.
NOTE: 4411H is the storage location for the MEMORY PROTECT address.
Original Source Code Comment: YES, SET NEW END OF MEMORY
5F60
JUMP to 01C9H which is the Model III ROM Routine to clear the screen (and this routine will exit after that).
Original Source Code Comment: AND CLEAR THE SCREEN

5F63H - CLEAR0 - Part of the "CLEAR" Library Command. Jumped here if the user didn't provide any parameters.

5F63CLEAR0
LD DE,(4415H)LD DE,(MEM2)
Fetch the value stored at memory location 4415H and put it into Register DE.
NOTE: 4415H is the storage location for the ADDRESS OF THE END OF PHYSICAL MEMORY.
Original Source Code Comment: GET THE 'REAL' END OF MEMORY
5F67
LD (4411H),DELD (MEMEND),DE
Store the value held in Register DE into the memory location 4411H.
NOTE: 4411H is the storage location for the MEMORY PROTECT address.
Original Source Code Comment: RESET THE END OF MEMORY POINTER
5F6B
LD HL,6280LD HL,S6DCB1
LET Register Pair HL = 6280H, which will be the base memory address for a memory test.
Original Source Code Comment: PLACE TO START CLEARING
5F6E
XOR A
Set Register A to ZERO and clear all Flags.
Original Source Code Comment: CLEAR A
5F6FL6OP9
LD (HL),A
Store the value held in Register A (i.e., a 00H) into the memory location pointed to by Register Pair HL.
Original Source Code Comment: PUT A 0 INTO MEMORY
5F70
CP (HL)
Compare the value held in Register A against the value held in the memory location (HL) to see if that LD command worked. Results: If Register A equals 00H, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: IS THAT WHAT MEMORY SAYS?
5F71
If the NZ FLAG (Not Zero) is set then the LD command didn't stick and we have a memory error, so JUMP to 5F7BH.
Original Source Code Comment: NO, CHECK ADDRESS
5F73
INC HL
INCrement the value stored in Register Pair HL (i.e., a location in RAM we are testing) by 1.
Original Source Code Comment: BUMP TO NEXT LOCATION
5F74
PUSH HL
Save Register Pair HL (i.e., a location in RAM we are testing) to the top of the stack.
Original Source Code Comment: SEE IF AT END OF MEMORY
5F75
OR A
Clear the CARRY flag, leave everything else alone.
5F76
SBC HL,DE
Subtracts the value stored in Register Pair DE (i.e., the END OF MEMORY) and the carry flag from the value stored in Register Pair HL (i.e., a location in RAM we are testing).
5F78
POP HL
Put the value held at the top of the STACK (i.e., a location in RAM we are testing) into Restore Register Pair HL, and then remove the entry from the stack.
5F79
If the NZ FLAG (Not Zero) is set, then we have not yet reached the end of MEMORY, so LOOP BACK to to 5F6FH to keep testing.
Original Source Code Comment: NO, CONTINUE CLEARING
5F7BCLER1
PUSH HL
Save Register Pair HL (i.e., the last location in RAM we are testing) to the top of the stack.
Original Source Code Comment: SAVE POINTER
5F7C
OR A
Clear the CARRY flag, leave everything else alone.
Original Source Code Comment: CLEAR CARRY
5F7D
SBC HL,DE
Subtracts the value stored in Register Pair DE (i.e., the END OF MEMORY) and the carry flag from the value stored in Register Pair HL (i.e., the last location in RAM we are testing).
Original Source Code Comment: SEE IF AT END OF MEMORY
5F7F
POP DE
Put the value held at the top of the STACK (i.e., the last location in RAM we are testing) into Restore Register Pair DE, and then remove the entry from the stack.
Original Source Code Comment: GET POINTER INTO DE
5F80
If the NC FLAG (No Carry) is set then we are done testing, so JUMP to 01C9Hwhich is the Model III ROM Routine to clear the screen (and this routine will exit after that).
Original Source Code Comment: YES, END OF MEM. CLS
5F83
LD HL,527BLD HL,HEXADD
LET Register Pair HL = 527BH, which is a pointer to a MESSAGE STORAGE AREA.
Original Source Code Comment: PLACE TO STORE ASCII ADDRESS
5F86
LD A,D
LET Register A = Register D (i.e., the MSB of the byte of RAM which failed).
Original Source Code Comment: GET THE MSG
5F87
GOSUB to 61A1H to insert that value into the MESSAGE.
Original Source Code Comment: CONVERT IT
5F8A
LD A,E
LET Register A = Register E (i.e., the LSB of the byte of RAM which failed).
Original Source Code Comment: GET THE LSB
5F8B
GOSUB to 61A1H to insert that value into the MESSAGE.
Original Source Code Comment: CONVERT IT
5F8E
JUMP to 522AH to display the error and exit.
Original Source Code Comment: REPORT BAD RAM LOCATION

5F91H - CLRTAB - PARAMETER TABLE for the "CLEAR" Command.

5F91CLRTAB
DEFM ...
"START ".
5F99
DEFM ...
"END ".
5FA1
DEFM ...
"MEM ".
5FA9
DEFB 00H
End of Table Delimeter.
5FAACNTCLR
DEFM ...
"CAN'T CLEAR WHILE DO IS ACTIVE" + 0DH.

5FC9H - "BUILD" Library Command.

5FC9BUILD
GOSUB to 623AH to isolate and validate the FILESPEC from the command line via an OVERLAY call to ROUTINE 4 of OVERLAY 1.
Original Source Code Comment: GET SYNTAX OF FILE NAME
5FCC
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5218H.
Original Source Code Comment: EXIT IF SYNTAX ERROR
5FCF
LD HL,60CCLD HL,EXT5
LET Register Pair HL = 60CCH to point to a default file extension.
Original Source Code Comment: POINT TO 'BLD' EXTENSION
5FD2
GOSUB to 444BH to add the extension pointed to by Register Pair HL to the end of the filename pointed to by Register Pair DE.
Original Source Code Comment: GO ADD TO FILE NAME
5FD5
GOSUB to 6234H to create a file.
Original Source Code Comment: GO INIT THE FILE
5FD8
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
Original Source Code Comment: EXIT IF ERROR
5FDB
LD HL,602BLD HL,BRKPMT
LET Register Pair HL = 602BH to point to the MESSAGE "HIT BREAK TO EXIT".
Original Source Code Comment: HL => 'HIT BREAK' MSG
5FDE
GOSUB to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found.
5FE1BUILD1
LD HL,600FLD HL,S6PRMP
LET Register Pair HL = 600FH to point to the MESSAGE "TYPE UP TO 63 CHARACTERS".
Original Source Code Comment: POINT TO PROMPT MSG
5FE4
GOSUB to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found.
Original Source Code Comment: DISPLAY IT
5FE7
LD B,3FH
LET Register B = 3FH (Decimal: 63) which is the maximum number of characters permitted.
Original Source Code Comment: SET MAX CHAR COUNT TO 63
5FE9
LD HL,6400LD HL,S6BUF2
LET Register Pair HL = 6400H, which will act as a buffer for the 63 characters being typed in.
Original Source Code Comment: USE OTHER BUFFER FOR KEYBOARD
5FEC
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 A LINE OF BUILD COMMAND
5FEF
If the C FLAG (Carry) is set then the BREAK key was hit, so JUMP to 6001H.
Original Source Code Comment: EXIT IF BREAK KEY
5FF1
INC B
INCrement the value stored in Register B (i.e., the number of characters actually typed in) by 1.
Original Source Code Comment: ADD IN THE CR AT END OF LINE
5FF2
LD HL,6400LD HL,S6BUF2
LET Register Pair HL = 6400H, which will act as a buffer for the 63 characters being typed in.
Original Source Code Comment: HL => KEYED IN DATA
5FF5BUILD2
LD A,(HL)
Fetch the value stored at memory location (i.e., one of the characters which was just typed in) pointed to by Register Pair HL (i.e., a pointer to the buffer of characters typed in by the user) and put it into Register A.
Original Source Code Comment: GET A CHARACTER
5FF6
LD DE,6280LD DE,S6DCB1
LET Register Pair DE = 6280H, which is the DCB address (which is needed for a call to 001BH).
Original Source Code Comment: DE => DISK DCB
5FF9
GOSUB to 001BH.
NOTE: 001BH is the Model III ROM routine to output a byte (held in Register A) to a device. Register Pair DE has the DCB of the device to be output to. Z is set if the device is ready.
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 IT INTO THE BUFFER
5FFC
INC HL
INCrement the value stored in Register Pair HL (i.e., a pointer to the buffer of characters typed in by the user) by 1.
Original Source Code Comment: BUMP TO NEXT CHAR
5FFD
LOOP back to 5FF5H, 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
5FFF
JUMP to 5FE1H to prompt for another line.
Original Source Code Comment: AND GET MORE

6001H - BLDEXT - Continuation of the "BUILD" Library Command; jumped to if a BREAK key was hit.

6001BLDEXT
LD A,0FFH
LET Register A = 0FFH, which is an End of File designator.
Original Source Code Comment: SET END OF FILE FLAG
6003
LD DE,6280LD DE,S6DCB1
LET Register Pair DE = 6280H, which is the DCB address (which is needed for a call to 001BH).
6006
GOSUB to 001BH.
NOTE: 001BH is the Model III ROM routine to output a byte (held in Register A) to a device. Register Pair DE has the DCB of the device to be output to. Z is set if the device is ready.
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.
6009
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.
600C
JUMP to 56F6H to close the file and exit.
Original Source Code Comment: ELSE CLOSE THE FILE

600FH - S6PRMP - MESSAGE and BYTE STORAGE AREA for "BUILD".

600FS6PRMP
DEFM ...
"TYPE UP TO 63 CHARACTERS" + 0DH.
602BBRKPMT
DEFM ...
"HIT BREAK TO EXIT" + 0DH.

603DH - "DO" Library Command.

This command modifies the keyboard DCB to force the characters otherwise expected to be input to come from the DO FILE rather than the keyboard. The routine will supply 1 character each time it is called, just like someone typing each letter. The procedure is:

  • Get the end of memory address and reserve 544 bytes for use by the DO routine.
  • Relocate the DO routine to the top 256 bytes of that space. This is what the keyboard will call.
  • Set up the next lower 256 bytes as the file buffer for the DO.
  • Set up the next lower 32 bytes as the DCB for the DO file.
603DDO
LD A,(4CFDH)LD A,(DOFLAG)
Fetch the value stored at memory location 4CFDH (i.e., the memory location storing whether the DO command is active or not) and put it into Register A.
Original Source Code Comment: SEE IF WE'RE ALREADY ACTIVE
6040
OR A
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A.
6041
If the NZ FLAG (Not Zero) is set, then the DO command is already active, so JUMP to 5214H to exit.
Original Source Code Comment: YES, BAD PARAMETER
6044
DEC A
DECrement the value stored in Register A (i.e., the memory location which stores the flag for whether a DO command is active, which is definitely holding a 1), by 1 (i.e., to zero).
Original Source Code Comment: SET DO ACTIVE
6045
LD (4CFDH),ALD (DOFLAG),A
Store the value held in Register A (i.e., 00H) into the memory location 4CFDH (i.e., the memory location which stores the flag for whether a DO command is active), to indicate that DO is active.
6048
PUSH HL
Save Register Pair HL (i.e., the pointer to the command line entered by the USER after the library command itself) to the top of the stack.
Original Source Code Comment: SAVE COMMAND LINE POINTER
6049
LD HL,(4415H)LD HL,(MEM2)
Fetch the value stored at memory location 4415H and put it into Register HL.
NOTE: 4415H is the storage location for the ADDRESS OF THE END OF PHYSICAL MEMORY.
Original Source Code Comment: GET END OF MEMORY
604C
LD (4411H),HLLD (MEMEND),HL
Store the value held in Register HL into the memory location 4411H.
NOTE: 4411H is the storage location for the MEMORY PROTECT address.
Original Source Code Comment: MAKE BOTH MEM ENDS AGREE
604F
LD HL,(4016H)LD HL,(KDCB + 1)
Fetch the value stored at memory location 4016H (i.e., the keyboard driver address) and put it into Register HL.
Original Source Code Comment: GET KEYBOARD DRIVER ADDR
6052
LD (42B1H),HLLD (GOSAVE),HL
Store the value held in Register HL into the memory location 42B1H.
Original Source Code Comment: SAVE IT
6055
LD HL,(4411H)LD HL,(MEMEND)
Fetch the value stored at memory location 4411H and put it into Register HL.
NOTE: 4411H is the storage location for the MEMORY PROTECT address.
Original Source Code Comment: GET MEMEND
6058
LD L,90H
LET Register L = 90H (Decimal: 144) so as to back up 144 bytes.
Original Source Code Comment: MAKE LSB POINT TO XX90H
605A
LD (4016H),HLLD (KDCB + 1),HL
Store the value held in Register HL (i.e., the MEMORY PROTECT address) into the memory location 4016H (i.e., the keyboard driver address).
Original Source Code Comment: SET AT KEYBOARD DRV ADDR
605D
PUSH HL
Save Register Pair HL (i.e., the keyboard driver address) to the top of the stack.
Original Source Code Comment: SAVE MEMORY POINTER
605E
LD DE,002BLD DE,GOGO4 - GOGO1 + 5
LET Register Pair DE = 002BH (Decimal: 43) as a 43 byte offset to the DCB.
Original Source Code Comment: LENGTH OF DO PROGRAM (+ BREATHING RM)
6061
ADD HL,DE
LET Register Pair HL = Register Pair HL (i.e., the keyboard driver address) + Register DE (i.e., a 43 byte offset).
Original Source Code Comment: HL => 1ST BYTE AFTER PGM
6062
LD (60A8H),HLLD (GODCB),HL
Store the value held in Register HL (i.e., the keyboard driver address + a 43 byte offset) into the memory location 60A8H, which is the middle of an OPCODE.
Original Source Code Comment: SET AS DCB POINTER
6065
LD (609BH),HLLD (TMPDCB),HL
Store the value held in Register HL (i.e., the keyboard driver address + a 43 byte offset) into the memory location 609BH, which is the middle of an OPCODE.
6068
POP HL
Put the value held at the top of the STACK (i.e., the keyboard driver address) into Restore Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: GET MEMORY POINTER BACK
6069
EX DE,HL
Prepare for a LDIR by first EXchanging the value stored in Register Pair HL (i.e., the keyboard driver address) with the value stored in Register Pair DE; so now Register Pair DE holds the the keyboard driver address.
Original Source Code Comment: PUT IT INTO DE ALSO
606A
LD HL,60A6LD HL,GOGO1
LET Register Pair HL = 60A6H, which is the "DO" Driver Routine.
Original Source Code Comment: POINT TO BEG OF 'REAL' DO PGM
606D
LD BC,0026LD BC,GOGO4 - GOGO1
LET Register Pair BC = 0026H (Decimal: 38).
Original Source Code Comment: GET LENGTH OF PGM
6070
LDIR
Transfers a byte of data from the memory location pointed to by HL to the memory location pointed to by DE. Then HL and DE are incremented and BC is decremented. If BC is not zero, this operation is repeated. Interrupts can trigger while this instruction is processing.
Original Source Code Comment: MOVE IT TO HIGH MEM
6072
POP HL
Put the value held at the top of the STACK (i.e., the pointer to the command line entered by the USER after the library command itself) into Restore Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: GET COMMAND LINE BACK
6073
LD DE,(4411H)LD DE,(MEMEND)
Fetch the value stored at memory location 4411H and put it into Register DE.
NOTE: 4411H is the storage location for the MEMORY PROTECT address.
Original Source Code Comment: GET END OF MEMORY
6077
6078
6079
DEC D
DEC D
LD E,0E0H
Let Register Pair DE = 544 bytes before the end of RAM.
Original Source Code Comment: BACK UP 256 BYTES
607B
LD (4411H),DELD (MEMEND),DE
Store the value held in Register DE into the memory location 4411H.
NOTE: 4411H is the storage location for the MEMORY PROTECT address.
Original Source Code Comment: SET AS MEM END
607F
LD (40A0H),DELD (MEM1),DE
Store the value held in Register DE into the memory location 40A0H.
NOTE: 40A0H is the storage location for the TOP OF FREE MEMORY.
Original Source Code Comment: SET AS END FOR BASIC AS WELL
6083
LD DE,(609BH)LD DE,(TMPDCB)
Fetch the value stored at memory location 609BH (i.e., the DCB address) and put it into Register DE.
Original Source Code Comment: GET OUR DCB POINTER
6087
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: GET SYNTAX OF FILE NAME
608A
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5218H.
Original Source Code Comment: EXIT IF ERROR
608D
LD HL,60CCLD HL,EXT5
LET Register Pair HL = 60CCH to point to a default file extension.
Original Source Code Comment: POINT TO 'BLD' EXTENSION
6090
GOSUB to 444BH to add the extension pointed to by Register Pair HL to the end of the filename pointed to by Register Pair DE.
Original Source Code Comment: ADD IT TO FILE NAME

The next few instructions calculate a buffer address.

6093
LD HL,(4411H)LD HL,(MEMEND)
Fetch the value stored at memory location 4411H and put it into Register HL.
NOTE: 4411H is the storage location for the MEMORY PROTECT address.
Original Source Code Comment: GET MODIFIED END OF MEMORY
6096
LD DE,0020H
LET Register Pair DE = 0020H (Decimal: 32) for 32 characters.
Original Source Code Comment: BRING IT BACK TO A 0 BOUNDARY
6099
ADD HL,DE
LET Register Pair HL = Register Pair HL + Register DE.
609A
LD DE,(0000H)LD DE,(TMPDCB)
LET Register Pair DE = the value stored in memory location 609BH, which was put there elsewhere in this overlay. This is the DCB address.
Original Source Code Comment: DCB POINTER STORED HERE
609D
LD B,00H
LET Register B = 00H so as to set the file to a LRL = 0.
Original Source Code Comment: SET FOR LRL OF 256
609F
GOSUB to 4424H.
NOTE: 4424H is the SYS00/SYS routine to OPEN A DISK FILE for use. This RST 28H's with a value of 92H so as to call ROUTINE 1 in OVERLAY 3.
Original Source Code Comment: OPEN THE FILE
60A2
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.
Original Source Code Comment: EXIT IF ERROR
60A5
RET
RETurn to the caller.

60A6H - GOGO1 - "DO" Driver Routine.

This is the new keyboard routine and is moved to high ram. This restores the normal keyboard driver upon termination of the DO file. Once DO is started, there is no way to stop it, as the keyboard is no longer active.

60A6GOGO1
PUSH DE
Save Register Pair DE (i.e., the DCB address) to the top of the stack.
Original Source Code Comment: SAVE DE
60A7
LD DE,(0000H)LD DE,(GODCB)
LET Register Pair DE = the memory contents of 60A8H-60A9H which were put there elsewhere in this overlay. This will be the new DCB address.
Original Source Code Comment: DCB POINTER STORED HERE
60AA
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 THE FILE
60AD
If the Z FLAG (Zero) is set then there was no error, so JUMP to 60B8H.
Original Source Code Comment: NO ERRORS
60AF
AND 0FEH
MASK the value of Register A against 0FEH (1111 1110). This has the effect of turning off Bit 0.
Original Source Code Comment: FORCE TO EOF
60B1
CP 1CCP EEOF
Compare the value held in Register A against 1CH to see if there is an EOF ERROR. Results: If Register A equals 1CH, the Z FLAG is set; otherwise the NZ FLAG is set.
60B3
If the NZ FLAG (Not Zero) is set, JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.
Original Source Code Comment: EXIT IF ERROR
60B6
JUMP to 60BEH to terminate the "DO" Execution.
Original Source Code Comment: END IF FILE. TERMINATE

60B8H - OKGO - Continuation of the "DO" Command. Jumped here if there was an error in getting characters.

60B8OKGO
CP 0FFH
Compare the value held in Register A against 0FFH (i.e., EOF). Results: If Register A equals 0FFH, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: END OF FILE FLAG
60BA
If the Z FLAG (Zero) is set then we have an EOF, so JUMP to 60BEH to terminate the "DO" Execution.
Original Source Code Comment: YES, TERMINATE
60BCGOGO2
POP DE
Put the value held at the top of the STACK (i.e., the DCB address) into Restore Register Pair DE, and then remove the entry from the stack.
Original Source Code Comment: RESTORE DE
60BD
RET
RETurn to the caller.
Original Source Code Comment: RET, A HAS CHAR

60BEH - GOGO3 - JUMP to 60BEH to terminate the "DO" Execution.

60BEGOGO3
LD DE,(42B1H)LD DE,(GOSAVE)
Fetch the value stored at memory location 42B1H (i.e., the saved driver address) and put it into Register DE.
Original Source Code Comment: GET THE ORIGINAL KEYBOARD DRV ADDR
60C2
LD (4016H),DELD (KDCB + 1),DE
Store the value held in Register DE (i.e., the saved driver address) into the memory location 4016H (i.e., the keyboard driver address).
Original Source Code Comment: RESTORE IT AT KEYBD DCB
60C6
XOR A
Set Register A to ZERO and clear all Flags.
Original Source Code Comment: CLEAR THE DO FLAG
60C7
LD (4CFDH),ALD (DOFLAG),A
Store the value held in Register A (i.e., 0) into the memory location 4CFDH (i.e., the flag indicating if "DO" is active).
60CA
JUMP to 60BCH to restore the DCB address and RETurn.
Original Source Code Comment: AND EXIT

60CCH - EXT5 - MESSAGE STORAGE AREA for "DO".

60CCEXT5
DEFM ...
"BLD".

60CFH - SPAUSE - "PAUSE" Library Command.

60CFSPAUSE
PUSH HL
Save Register Pair HL (i.e., the pointer to the command line entered by the USER after the library command itself) to the top of the stack.
Original Source Code Comment: SAVE POINTER
60D0
LD HL,60F8LD HL,PRESNY
LET Register Pair HL = 60F8H, which is a pointer to the message "PRESS ENTER TO CONTINUE".
Original Source Code Comment: HL => 'PRESS ANY KEY' MSG
60D3
GOSUB to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found.
Original Source Code Comment: DISPLAY IT
60D6
LD A,(4CFDH)LD A,(DOFLAG)
Fetch the value stored at memory location 4CFDH (i.e., the memory location storing whether the DO command is active or not) and put it into Register A.
Original Source Code Comment: IS THIS DO CALLING?
60D9
OR A
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A.
60DA
If the NZ FLAG (Not Zero) is set, then the "DO" command is active, so JUMP to 60EAH.
Original Source Code Comment: YES, DO KEYBOARD SCAN
60DC
PUSH BC
Save Register Pair BC to the top of the stack.
Original Source Code Comment: NO, DO KEYBOARD ROUTINE
60DDSPAUS0
LD B,01H
LET Register B = 01H, which is the number of characters we want to receive from the keyboard.
60DF
LD HL,0000H
LET Register Pair HL = 0000H to clear out the location where that character will be stored.
Original Source Code Comment: SET BUFFER TO ROM
60E2
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: WAIT FOR CR
60E5
If the C FLAG (Carry) is set then the BREAK key was hit, so LOOP BACK to 60DDH and wait for another key.
Original Source Code Comment: NOT BREAK KEY DUMMY!!
60E7
POP BC
Put the value held at the top of the STACK (i.e., whatever BC was before this; didn't matter) into Restore Register Pair BC, and then remove the entry from the stack.
Original Source Code Comment: RESTORE REGISTERS
60E8
POP HL
Put the value held at the top of the STACK (i.e., the pointer to the command line entered by the USER after the library command itself) into Restore Register Pair HL, and then remove the entry from the stack.
60E9
RET
RETurn to the caller.

60EAH - SPAUS1 - Continuation of the "PAUSE" Library Command, Jumped here if the "DO" command is active.

60EASPAUS1
GOSUB to 60EFH to wait for an ENTER key.
Original Source Code Comment: WAIT FOR THE CR
60ED
POP HL
Put the value held at the top of the STACK (i.e., the pointer to the command line entered by the USER after the library command itself) into Restore Register Pair HL, and then remove the entry from the stack.
Original Source Code Comment: GET HL BACK
60EE
RET
RETurn to the caller.

60EFH - GETCR - Continuation of the "PAUSE" Library Command. Subroutine to read the keyboard for an ENTER key.

60EFGETCR
LD A,(3840H)
Fetch the value stored at memory location 3840H (i.e., the keyboard row with the ENTER key) and put it into Register A.
Original Source Code Comment: SCAN THE KEYBOARD MATRIX
60F2
CP 01H
Compare the value held in Register A against 01H (i.e., the ENTER key). Results: If Register A equals the ENTER key, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: ENTER KEY?
60F4
If the NZ FLAG (Not Zero) is set then we didn't get the ENTER key, so LOOP BACK to the top of this routine at 60EFH and keep checking.
Original Source Code Comment: NO, KEEP SCANNING
60F6
XOR A
Set Register A to ZERO and clear all Flags.
Original Source Code Comment: SET Z
60F7
RET
RETurn to the caller.

60F8H - PRESNY - MESSAGE STORAGE AREA for "PAUSE".

60F8PRESNY
DEFM ...
"PRESS ENTER TO CONTINUE" + 0DH
6112HBUFPNT
DEFW 00H

6114H - EZZOR - "ERROR" Library Command.

6114EZZOR
GOSUB to 541AH to convert a COMMAND LINE byte pair to decimal.
Original Source Code Comment: GET THE 1ST BYTE
6117
If the NC FLAG (No Carry) is set then that routine returned with an error, so JUMP to 5214H.
Original Source Code Comment: BAD PARAMETER
611A
LD E,A
LET Register E = Register A (i.e., the requested error code).
Original Source Code Comment: SAVE THE NUMBER
611B
LD A,(HL)
Fetch the value stored at memory location (i.e., the next byte in the requested error code) pointed to by Register Pair HL (i.e., the pointer to the command line entered by the USER after the library command itself) and put it into Register A.
Original Source Code Comment: GET THE CHARACTER
611C
CP 20H
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?
611E
LD A,E
LET Register A = Register E (i.e., the requested error code).
Original Source Code Comment: GET THE LSB BACK
611F
If the C FLAG (Carry) is set then Register A < SPACE, JUMP to 6130H.
Original Source Code Comment: YES, EXIT
6121
GOSUB to 541AH to convert a COMMAND LINE byte pair to decimal.
Original Source Code Comment: GET THE NUMBER
6124
If the NC FLAG (No Carry) is set then that routine returned with an error, so JUMP to 5214H.
Original Source Code Comment: EXIT IF ERROR
6127
PUSH AF
Save Register Pair AF (i.e., the requested error code) to the top of the stack.
Original Source Code Comment: SAVE THE VALUE
6128
LD A,E
LET Register A = Register E (i.e., the first digit of the requested error code).
Original Source Code Comment: GET THE MSB BACK
6129
612A
RLCA
RLCA
Let Register A = Register A * 4.
Original Source Code Comment: TIMES 2
612B
ADD A,E
LET Register A = Register A + Register E, so Register A = original Register A * 5.
Original Source Code Comment: TIMES 5
612C
RLCA
Rotate the bits in A left, so Register A = original Register A * 10.
Original Source Code Comment: TIMES 10
612D
LD E,A
LET Register E = Register A, but moved to the TENS digit.
Original Source Code Comment: SAVE NEW VALUE
612E
POP AF
Put the value held at the top of the STACK (i.e., the requested error code) into Restore Register Pair AF, and then remove the entry from the stack.
Original Source Code Comment: GET THE LSB BACK
612F
ADD A,E
LET Register A = Register A + Register E, so now we have both digits.
Original Source Code Comment: ADD IN THE MSB
6130EZZO1
OR 0C0H
OR Register A against 0C0H (1100 0000) to set the LONG ERROR MESSAGE bits (i.e., bits 7 and 6)
Original Source Code Comment: SET DETAIL BITS ON
6132ERR
JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.

6135H - PDATA - Common Subroutine - Display or Print the Character held in Register A.

6135PDATA
PUSH BC
Save Register Pair BC to the top of the stack.
Original Source Code Comment: SAVE BC
6136
LD BC,(5A4DH)LD BC,(LPFLAG)
Fetch the value stored at memory location 5A4DH (i.e., the byte flag for PRINTER) and put it into Register BC.
Original Source Code Comment: GET LPRINT FLAG
613A
LD E,A
LET Register E = Register A (i.e., the character to output).
Original Source Code Comment: SAVE CHAR IN (E)
613B
613C
LD A,B
OR C
Since the Z-80 cannot test Register Pair BC against zero, the common trick is to set Register A to equal to Register B, and then OR A against Register C. Only if both Register B and Register C were zero can the Z FLAG be set.
Original Source Code Comment: OUTPUT TO LINE PRINTER?
613D
LD A,E
LET Register A = Register E (i.e., the character to output).
Original Source Code Comment: GET THE CHAR BACK
613E
POP BC
Put the value held at the top of the STACK into Restore Register Pair BC, and then remove the entry from the stack.
Original Source Code Comment: GET BC BACK
613F
PUSH AF
Save Register Pair AF (i.e., the character to output) to the top of the stack.
Original Source Code Comment: SAVE THE CHARACTER
6140
If the NZ FLAG (Not Zero) is set, GOSUB to 003BH which 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
6143
POP AF
Put the value held at the top of the STACK (i.e., the character to output) into Restore Register Pair AF, and then remove the entry from the stack.
6144
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.
Original Source Code Comment: IF NOT, THEN DISPLAY

6147H - PRT2 - Common Subroutine - Display or Print the message pointed to by Register Pair HL.

6147PRT2
PUSH BC
Save Register Pair BC to the top of the stack.
Original Source Code Comment: SAVE BC
6148
LD BC,(5A4DH)LD BC,(LPFLAG)
Fetch the value stored at memory location 5A4DH (i.e., the byte flag for PRINTER) and put it into Register BC.
Original Source Code Comment: GET LPRINT FLAG
614C
614D
LD A,B
OR C
Since the Z-80 cannot test Register Pair BC against zero, the common trick is to set Register A to equal to Register B, and then OR A against Register C. Only if both Register B and Register C were zero can the Z FLAG be set.
Original Source Code Comment: OUTPUT TO LINE PRINTER?
614E
POP BC
Put the value held at the top of the STACK into Restore Register Pair BC, and then remove the entry from the stack.
Original Source Code Comment: GET BC BACK
614F
PUSH HL
Save Register Pair HL (i.e., the pointer to the the messsage to be displayed or printed) to the top of the stack.
Original Source Code Comment: SAVE LINE POINTER
6150
If the NZ FLAG (Not Zero) is set, meaning that the printer flag was NZ, GOSUB to 6157H to output the message to the Printer.
Original Source Code Comment: OUTPUT TO PRINTER
6153
POP HL
Put the value held at the top of the STACK (i.e., the pointer to the the messsage to be displayed or printed) into Restore Register Pair HL, and then remove the entry from the stack.
6154
JUMP to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found.
Original Source Code Comment: NO, PRINT

6157H - LPRINT - Common Subroutine - Print a Message Pointed to by Register Pair HL, until a 03H or 0DH is reached.

6157LPRINT
PUSH HL
Save Register Pair HL (i.e., the pointer to the messsage to be displayed or printed) to the top of the stack.
Original Source Code Comment: SAVE POINTER
6158LPRIN0
LD A,(HL)
Fetch the value stored at memory location (i.e., a character in the messsage to be displayed or printed) pointed to by Register Pair HL (i.e., the pointer to the messsage to be displayed or printed) and put it into Register A.
Original Source Code Comment: GET A CHAR
6159
CP 03H
Compare the value held in Register A against 03H, which is a standard terminator. Results: If Register A equals 03H, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: EOF?
615B
If the Z FLAG (Zero) is set, meaning that we a terminator, JUMP to 6165H to restore HL from the STACK and RETurn.
Original Source Code Comment: YES, EXIT
615D
GOSUB to 003BH which 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: OUTPUT IT
6160
INC HL
INCrement the value stored in Register Pair HL (i.e., the pointer to the messsage to be displayed or printed) by 1.
Original Source Code Comment: BUMP TO NEXT CHAR
6161
CP 0DH
Compare the value held in Register A against 0DH (ASCII: CARRIAGE RETURN). Results: If Register A equals CARRIAGE RETURN, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: CR?
6163
If the NZ FLAG (Not Zero) is set, JUMP to 6158H to continue looping through (HL) and printing the character until a 03H or 0DH is reached.
Original Source Code Comment: NO, CONTINUE
6165LPRIN1
POP HL
Put the value held at the top of the STACK into Restore Register Pair HL (i.e., the pointer to the the messsage to be displayed or printed), and then remove the entry from the stack.
Original Source Code Comment: RESTORE POINTER
6166
RET
RETurn to the caller.
Original Source Code Comment: EXIT

6167H - INKEY - SUBROUTINE in the "DIR" Library Routine to Start Processing a @ (aka Pause) request.

6167INKEY
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: CALL BREAK KEY CHECK IN ROM
616A
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, 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: ABORT IF BREAK KEY
616D
GOSUB to 6188H to scan the keyboard.
Original Source Code Comment: SCAN THE KEYBOARD
6170
OR A
Set FLAGS based on the contents of Register A.
Original Source Code Comment: ANYTHING THERE?
6171
RET Z
If the Z FLAG (Zero) is set, RETurn to the caller.
Original Source Code Comment: NOPE, RETURN
6172
CP 40H
Compare the value held in Register A against 40H (ASCII: @). Results: If Register A equals (ASCII: @), the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: HOLD?
6174
If the Z FLAG (Zero) is set because we got a @, JUMP to 617CH to actually deal with being paused.
6176
PUSH BC
Save Register Pair BC to the top of the stack.
Original Source Code Comment: SAVE BC
6177
LD B,A
LET Register B = Register A (i.e., the key which was pressed).
Original Source Code Comment: PUT THE CHAR INTO B
6178
XOR A
Set Register A to ZERO and clear all Flags to clear any error status.
Original Source Code Comment: SET Z
6179
LD A,B
LET Register A = Register B (i.e., the key which was pressed).
Original Source Code Comment: GET THE CHAR BACK
617A
POP BC
Put the value held at the top of the STACK into Restore Register Pair BC, and then remove the entry from the stack.
Original Source Code Comment: GET BC BACK
617B
RET
RETurn to the caller.
Original Source Code Comment: EXIT

617CH - HLDPAT - Continuation of the SUBROUTINE in the "DIR" Library Routine to Process a @ (aka Pause) keypress.

617CHLDPAT
GOSUB to 6188H to scan the keyboard.
Original Source Code Comment: SCAN THE KEYBOARD
617F
OR A
Set FLAGS based on the contents of Register A.
6180
If the Z FLAG (Zero) is set then no key was pressed so JUMP back to 617CH and keep polling.
6182
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: CR?
6184
If the NZ FLAG (Not Zero) is set then we still do not have a ENTER, JUMP back to 617CH and keep polling.
Original Source Code Comment: NO, LOCK
6186
XOR A
Set Register A to ZERO and clear all Flags.
Original Source Code Comment: CLEAR A
6187
RET
RETurn to the caller.

6188H - GETKBD - Continuation of the SUBROUTINE in the "DIR" Library Routine to Process a @ (aka Pause) keypress. This part scans the keyboard, bypassing the DO command.

6188GETKBD
LD A,(4CFDH)LD A,(DOFLAG)
Fetch the value stored at memory location 4CFDH (i.e., to see if the "DO" command is active) and put it into Register A.
Original Source Code Comment: DO FILE IN PROGRESS?
618B
OR A
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A.
618C
If the Z FLAG (Zero) is set then the "DO" command is NOT active, JUMP 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: NO, DO NORMAL KEYBOARD ROUTINE

If we are here then we need an ACTUAL keypress, but DO is active; meaning that the keyboard is actually feeding from a disk file. With this we need to jump to a routine in ROM which reads the keyboard regardless of whether DO is active or not.

618F
PUSH BC
Save Register Pair BC to the top of the stack.
Original Source Code Comment: SAVE REGISTERS
6190
PUSH DE
Save Register Pair DE to the top of the stack.
6191
PUSH HL
Save Register Pair HL to the top of the stack.
6192
PUSH IX
Save Register Pair IX to the top of the stack.
6194
LD IX,4015LD IX,KDCB
LET Register Pair IX = 4015H, which is the real keyboard DCB, so as to ignore any DO command rerouting of the keyboard.
Original Source Code Comment: IX => KEYBOARD DCB
6198
GOSUB to 3024H which is the Model III ROM Routine Vector to a routine to get keyboard input.
Original Source Code Comment: CALL THE KEYBOARD
619B
POP IX
Put the value held at the top of the STACK into Restore Register Pair IX, and then remove the entry from the stack.
Original Source Code Comment: RESTORE REGISTERS
619D
POP HL
Put the value held at the top of the STACK into Restore Register Pair HL, and then remove the entry from the stack.
619E
POP DE
Put the value held at the top of the STACK into Restore Register Pair DE, and then remove the entry from the stack.
619F
POP BC
Put the value held at the top of the STACK into Restore Register Pair BC, and then remove the entry from the stack.
61A0
RET
RETurn to the caller.

61A1H - HEXS - Part of the "CLEAR" Library Command. Jumped here to insert a value into a message.

61A1HEXS
PUSH AF
Save Register Pair AF to the top of the stack.
Original Source Code Comment: SAVE THE VALUE
61A2
61A3
61A4
61A5
RLCA
RLCA
RLCA
RLCA
Swap the lower nybble with the higher nybble by rotating the bits in A left (with Bit 7 going into both the CARRY and Bit 0) four times. This rotates bits 3, 2, 1, 0 into bits 7, 6, 5, 4 and bits 7, 6, 5, 4 into bits 3, 2, 1, 0.
Original Source Code Comment: THE THE MSB NIBBLES
61A6
GOSUB to 61AAH which is a nice space saving trick. It GOSUB's 2 instructions down, so the routine can easily handle the lower and upper nybble without a lot of extra code.
61A9
POP AF
Put the value held at the top of the STACK into Restore Register Pair AF (restoring the original Register A), and then remove the entry from the stack.
61AAHEXS1
AND 0FH
MASK the value of Register A against 0FH (0000 1111). This has the effect of turning off bits 7, 6, 5, 4, leaving only bits 3, 2, 1, 0 active.
Original Source Code Comment: MASK OFF HI NIBBLES

Another DAA set ... Never been able to find a good source to clearly explain this. It is converting a decimal value into a binary coded decimal value.

61AC
ADD A,90H
LET Register A = Register A + 90H. Since Register A's possible value is 0-F, this changes Register A's possible values to 90H-9FH.
61AE
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.
61AF
ADC A,40H
61B1
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.
61B2
LD (HL),A
Store the value held in Register A (which is the converted character) into the memory location pointed to by Register Pair HL (i.e., the location in the message text into which to put the character).
61B3
INC HL
INCrement the value stored in Register Pair HL by 1 (i.e., the NEXT location in the message text).
61B4
RET
RETurn to the caller.

61B5H - HEXAAS - Part of the "DIR" Library Command to convert a value held in Register A (which is either FILE CREATION MONTH or FILE CREATION YEAR as extracted from a files directory entry) and place it in the middle of the message " 00/00", in the specific the location pointed to by Register Pair HL. Routine is called once with MONTH and then once with YEAR.

61B5HEXAAS
LD (HL),2FH
Store the character which precedes 0 into the memory location pointed to by Register Pair HL.
Original Source Code Comment: START WITH 0
61B7HEXAA1
INC (HL)
Top of a loop. Bump the character pointed to by HL by 1 (so on initial run, this will start at 0 being placed in the message for a leading zero (i.e., if the initial character for a month is below 10).
61B8
SUB 0AH
SUBtract the value 0AH from Register A (i.e., the byte containing either the file creation MONTH or file creation YEAR from the file's directory sector).
61BA
If the NC FLAG (No Carry) is set, meaning that the subtraction didn't fall below 0, JUMP to 61B7H. If this is the month, then it will jump on months 1-9, and not jump on months 10-12.
61BC
ADD A,3AH
LET Register A = Register A + 3AH. When 3AH is added to -9 (i.e., January) through -1 (i.e, September), it turns into the ASCII versions of "1"-"9".
61BE
INC HL
INCrement the value stored in Register Pair HL by 1 so as to point to the next character in the message to overwrite.
61BF
LD (HL),A
Store the value held in Register A into the memory location pointed to by Register Pair HL (i.e., a specific location in a message).
61C0
RET
RETurn to the caller.

61C1H - BINDEC - Part of the "DIR" Library Command to display the contents of Register Pair HL in decimal form.

61C1BINDEC
LD A,20H
LET Register A = 20H (ASCII: SPACE).
Original Source Code Comment: LOAD A BLANK
61C3
LD B,02H
LET Register B = 02H for a loop of 2 times.
Original Source Code Comment: SET COUNTER FOR 2 OF THEM
61C5L6OP30
GOSUB to 6135H to display or print the byte held in Register A (i.e., a character of the filename); routine affects Registers A and E.
Original Source Code Comment: OUTPUT IT
61C8
LOOP back to 61C5H, 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. This will have displayed and/or printed two SPACE characters.
Original Source Code Comment: LOOP FOR COUNT
61CABINDC1
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: ROM HEX/ASCII CONVERSION
61CD
XOR A
Set Register A to ZERO and clear all Flags.
61CE
GOSUB to 1034H in the Model III ROM. This routine prepares for the conversion of Register A into ASCII. Register Pair HL is modified.
61D1
OR (HL)
OR the value stored at (HL) against Register A. The results are stored in Register A.
61D2
GOSUB to 0FD9H in the Model III ROM. This routine finishes the conversion of Register A into ASCII.
61D5
LD HL,4131H
LET Register Pair HL = 4131H which is the memory location holding the converted number.
61D8L6OP25
LD A,(HL)
Fetch the value stored at memory location (i.e., the ASCII character for that number) pointed to by Register Pair HL and put it into Register A.
61D9
OR A
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A.
61DA
RET Z
If the Z FLAG (Zero) is set then we have an END OF STRING, so RETurn to the caller.
61DB
GOSUB to 6135H to output the character held in Register A.
61DE
INC HL
INCrement the value stored in Register Pair HL by 1 so as to point to the next memory location to be converted.
61DF
LOOP back to 61D8H and keep going until exited by hitting a 0.

61E1H - DPRT1 - Message Storage Area for TIME and DATE DISPLAY.

61E1DPRT1
DEFM '00'
61E3DELIM1
DEFM ':'
61E4DPRT2
DEFM '00'
61E6DELIM2
DEFM ':'
61E7DPRT3
DEFM '00' + 0DH

61EAH - MSGPRT - Display TIME$ and DATE$. This routine is called by both the DATE and TIME library commands, and Register C holds the delimter character of either / or :.

61EAMSGPRT
GOSUB to 61F0H to generate the text line of xx/xx/xx or yy:yy:yy.
61ED
JUMP to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found and then RETurn to this routines caller (since JUMP was used instead of CALL).

61F0H - MSGPR0 - Part of the "DATE" and "TIME" Library Commands. This generates the text line of xx/xx/xx or yy:yy:yy.

61F0MSGPR0
LD A,C
LET Register A = Register C (i.e., the / or :).
61F1
LD (61E3H),ALD (DELIM1),A
Store the value held in Register A into the memory location 61E3H, which is the first delimter in the 00:00:00 message stored at 61E1H.
61F4
LD (61E6H),ALD (DELIM2),A
Store the value held in Register A into the memory location 61E6H, which is the second delimter in the 00:00:00 message stored at 61E1H.
61F7
LD IX,4219LD IX,HOUR
LET Register Pair IX = 4219H, which is the memory location holding the HOUR.
61FB
CP 3AH
Compare the value held in Register A against 3AH (ASCII: :) to see if we are processing the TIME or the DATE. Results: If Register A equals 3AH :, the Z FLAG is set; otherwise the NZ FLAG is set.
61FD
If the Z FLAG (Zero) is set then we are processing the TIME, so JUMP to 6203H.
61FF
LD IX,421CLD IX,MONTH
LET Register Pair IX = 421CH, which is the memory location holding the MONTH.
6203MSGPR1
LD HL,61E1LD HL,DPRT1
LET Register Pair HL = 61E1H, which is the pointer to the message "00:00:00".
6206
LD B,03H
LET Register B = 03H for a DJNZ loop of 3 sets of numbers to copy.
6208MSGPR2
LD A,(IX+00H)
Fetch the value stored at the memory location pointed to by IX+00H (i.e., the current location of the "00:00:00" message) and put it into Register A.
620B
GOSUB to 5E46H to convert this into a two digit decimal number.
620E
620F
INC HL
INC HL
INCrement the value stored in Register Pair HL by 2 character locations.
6210
DEC IX
DECrement the value stored in Register Pair IX by 1 so as to point to the next number.
6212
LOOP back to 6208H, 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.
6214
LD HL,61E1LD HL,DPRT1
LET Register Pair HL = 61E1H, which is the pointer to the message "00:00:00".
6217
RET
RETurn to the caller.

6218H - REDIT - Routine to READ A RECORD from FILE 1.

6218REDIT
PUSH BC
Save Register Pair BC to the top of the stack.
6219
GOSUB to 622BH to set the variables for the following JUMP.
621C
GOSUB to 4436H.
NOTE: 4436H is the SYS00/SYS vector for 'READ', which reads the record that the disk drive is positioned over.
621F
POP BC
Put the value held at the top of the STACK into Restore Register Pair BC, and then remove the entry from the stack.
6220
RET Z
If the Z FLAG (Zero) is set, then there was no error returned from the read VECTOR call, so RETurn to the caller.
6221
POP HL
If we're here, there was an error so ... first, empty the stack.
Original Source Code Comment: DESTROY CALL TO READIT
6222
and then exit with a JUMP to 6132H.

6225H - OPENIT - Routine to OPEN from FILE 1.

6225OPENIT
GOSUB to 622BH to set the variables for the following JUMP.
6228
JUMP to 4424H.
NOTE: 4424H is the SYS00/SYS routine to OPEN A DISK FILE for use. This RST 28H's with a value of 92H so as to call ROUTINE 1 in OVERLAY 3.

622BH - GETDCB - Routine to Set the Variables Needed for a JUMP to 4424H.

622BGETDCB
LD B,00H
LET Register B = 00H to signify a LRL of 0.
622DGETDC1
LD DE,6280LD DE,S6DCB1
LET Register Pair DE = 6280H as the applicable DCB.
6230
LD HL,6300LD HL,S6BUF1
LET Register Pair HL = 6300H as the applicable RAM BUFFER.
6233
RET
RETurn to the caller.

6234H - INITIT - Routine to CREATE FILE 1.

6234INITIT
GOSUB to 622BH to set the variables for the following JUMP.
6237
JUMP to 4420H.
NOTE: 4420H is the SYS00/SYS routine to INITIALIZE A FILE (i.e., CREATE or OPEN). This RST 28H's with a value of A2H so as to call ROUTINE 2 in OVERLAY 2. Register HL needs to point to a RAM BUFFER for the DCB's.

623AH - GETSYN - Routine to CHECK FILE 1.

623AGETSYN
LD DE,6280LD DE,S6DCB1
LET Register Pair DE = 6280H as the applicable DCB.
623D
JUMP to 441CH.
NOTE: 441CH is the SYS00/SYS routine to CHECK THE SYNTAX OF A FILESPEC before for use. This RST 28H's with a value of C1H so as to call ROUTINE 4 in OVERLAY 1.
 
END 5200H