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

General:

SYS6 handles the following DOS Commands: APPEND, ATTRIB, AUTO, BUILD, CLEAR, CLOCK, CREATE, DATE, DIR, DO, DUMP, ERROR, FREE, LIB, LOAD, PAUSE, PROT, RENAME, and TIME

On Entry, Register C must hold the order number of the command and Register Pair HL the Buffer Input Line.


Disassembly:

 
ORG 5200H
“BEGIN”
5200
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.
5201
XOR A
Set Register A to ZERO and clear all Flags.
5202
LD (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.
5205
LD (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.
5208
DEC A
DECrement the value stored in Register A by 1 so that A will be FFH.
5209
LD (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.
520C
CALL GETTAB
     [529BH]
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.
520F
JR C,BEGIN1
     [5213H]
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.
5211
EX (SP),HL
EXchange the value stored in Register Pair HL with the value stored in Register Pair (SP).
5212
RET
RETurn to the caller.

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

“BEGIN1”
5213
POP HL
Restore the passed input line from the top of the stack into Register Pair HL.
“ERR2”
5214
LD A,ERICP
LET Register A = 0BH, which is the code for an ILLEGAL PARAMETER error.
5216
JR ERRX
   [523AH]
JUMP to 523AH to continue.

5218H – Process a PARAMETER NOT FOUND error.

“ERR3”
5218
LD A,ERCPM
LET Register A = 0AH, which is the code for an PARAMETER NOT FOUND error.
521A
JR ERRX
   [523AH]
JUMP to 523AH to continue.

521CH – Process a FILE ALREADY EXISTS error.

“ERR1”
521C
LD A,EFAT
LET Register A = 28H, which is the code for an FILE ALREADY EXISTS error.
521E
JR ERRX
   [523AH]
JUMP to 523AH to continue.

5220H – Display “END LESS THAN START” and RETurn.

“ERR5”
5220
LD HL,MES5
LET Register Pair HL = 5240H which points to the message “END LESS THAN START” + 0DH.
5223
JR ERRY
   [523DH]
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 – Display “START LESS THAN 6000” and RETurn.

“ERR6”
5225
LD HL,MES6
LET Register Pair HL = 5254H which points to the message “START LESS THAN 6000” + 0DH.
5228
JR ERRY
   [523DH]
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 – Display “MEMORY FAULT AT X ‘nnnn'” and RETurn.

“ERR7”
522A
LD HL,BADRAM
LET Register Pair HL = 5269H which points to the message “MEMORY FAULT AT X ‘nnnn’” + 0DH.
522D
JR ERRY
   [523DH]
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 – Display “LRL OF FILES DO NOT MATCH” and RETurn.

“ERR13”
522F
LD HL,BADLRL
LET Register Pair HL = 5281H which points to the message “LRL OF FILES DO NOT MATCH” + 0DH.
5232
JR ERRY
   [523DH]
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 – Process a DISK DRIVE NOT ON error.

“ERR9”
5234
LD A,EDNS
LET Register A = 02H, which is the code for a DISK DRIVE NOT ON error.
5236
JR ERR
   [523AH]
JUMP to 523AH to continue.

5238H – Process a FILE ACCESS DENIED error.

5238
LD A,EFAD
“ERR4”
LET Register A = 28H, which is the code for a FILE ACCESS DENIED error.
“ERRX”
523A
JP ERR
   [6132H]
JUMP to the DOS ERROR routine at 6132H.

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

“ERRY”
523D
JP PRINT
   [021BH]
JUMP to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found.

5240H – Message Storage Area.

“MESS5”
5240
DEFM
END LESS THAN START” + 0DH.
“MESS6”
5254
DEFM
START LESS THAN 6000” + 0DH.
“BADRAM”
5269
DEFM
MEMORY FAULT AT X ‘nnnn’” + 0DH.
“BADLRL”
5281
DEFM
LRL OF FILES DO NOT MATCH” + 0DH.

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

“GETTAB”
529B
LD HL,TABCOM
LET Register Pair HL = 52B3H to point to the table of functions in this Overlay.
“GETTA1”
529E
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.
529F
OR A
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A.
52A0
JR Z,NOTFND
     [52B1H]
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.
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.
52A3
JR Z,FOUND
     [52AAH]
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.
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.
52A8
JR GETTA1
   [529EH]
LOOP BACK to the top of this routine to 529EH.

52AAH – 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.

“FOUND”
52AA
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.
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.
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).
52AF
OR A
Set FLAGS based on the contents of Register A, which also clears the CARRY FLAG (which acts as the error flag).
52B0
RET
RETurn to the caller.

52B1H – 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).

“NOTFND”
52B1
SCF
Set the CARRY FLAG to signify that there was an error.
52B2
RET
RETurn to the caller.

52B3H – Table of Functions in this Overlay.

“TABCOM”
52B3H
1
APPEND command number.
52B4H
568EH
APPEND command routine address.
52B6H
2
ATTRIB command number.
52B7H
585EH
ATTRIB command routine address.
52B9H
3
AUTO command number.
52BAH
52EDH
AUTO command routine address.
52BCH
5
BUILD command number.
52BDH
5FC9H
BUILD command routine address.
52BFH
6
CLEAR command number.
52C0H
5EFFH
CLEAR command routine address.
52C2H
7
CLOCK command number.
52C3H
53E2H
CLOCK command routine address.
52C5H
0A
CREATE command number.
52C6H
5E52H
CREATE command routine address.
52C8H
0B
DATE command number.
52C9H
5361H
DATE command routine address.
52CBH
13
DIR command number.
52CCH
59D9H
DIR command routine address.
52CEH
0E
DO command number.
52CFH
603DH
DO command routine address.
52D1H
10
DUMP command number.
52D2H
5700H
DUMP command routine address.
52D4H
11
ERROR command number.
52D5H
6114H
ERROR command routine address.
52D7H
14
FREE command number.
52D8H
5CDCH
FREE command routine address.
52DAH
17
LIB command number.
52DBH
5423H
LIB command routine address.
52DDH
19
LOAD command number.
52DEH
584FH
LOAD command routine address.
52E0H
1C
PAUSE command number.
52E1H
60CFH
PAUSE command routine address.
52E3H
1D
PROT command number.
52E4H
5455H
PROT command routine address.
52E6H
32
RENAME command number.
52E7H
559FH
RENAME command routine address.
52E9H
36
TIME command number.
52EAH
53ABH
TIME command routine address.
52ECH
00
End of Table Delimeter.

52EDH – AUTO Library Command – Function 3

“AUTO”
52ED
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.
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.
52F0
JR NZ,AUTO2
      [52FFH]
If we did not get a : the NZ FLAG (Not Zero) is set, so JUMP to 52FFH.
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).
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.
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).
52F6
LD (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).
“AUTO1”
52F9
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).
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.
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.
52FD
JR Z,AUTO1
     [52F9H]
If the Z FLAG (Zero) is set then we got a SPACE so LOOP back to 52F9H to check the next character.
“AUTO2”
52FF
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.
5300
LD C,nnH
LD C,AUTDRV
LET Register C = the drive number received, as has been filled in at 52F6H.
5302
CALL RDGAT
     [4A93H]
GOSUB to 4A93H.
NOTE: 4A93H is the SYS00/SYS routine to READ THE GAT SECTOR INTO RAM (Buffer at 4D00H).
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.
5306
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set then the READ THE GAT SECTOR routine returned with an error so JUMP to 6132H.
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.
530A
LD B,01H
LET Register B = 01H to prepare for using B as a counter.
“AUTO3”
530C
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.
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.
530F
JR C,AUTO4
     [5315H]
If the C FLAG (Carry) is set then A < SPACE, meaning we have a control character, so JUMP to 5315H.
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 .
5312
INC B
Bump the value stored in Register B (which is acting as a counter) by 1.
5313
JR AUTO3
   [530CH]
LOOP BACK to 530CH to keep parsing the command line.

5315H – 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.

“AUTO4”
5315
LD A,20H
LET Register A = 20H (Decimal: 32), which is the maximum length of a valid AUTO command.
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.
5318
LD B,A
LET Register B = Register A (i.e., the number of characters left on a full command line).
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.
“AUTO5”
531A
LD (HL),20H
Store a SPACE into the memory location pointed to by Register Pair HL.
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.
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.
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.
5320
LD DE,BUFF2 + DAUTO
LET Register Pair DE = 4DE0H, which is the memory location of the GAT SECTOR in RAM for the AUTO command.
5323
LD BC,0020H
LET Register Pair BC = 0020H (Decimal: 32), which is the maximum length of a valid AUTO command.
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.
5328
LD A,(AUTDRV)
Fetch the value stored at memory location 5301H (i.e., the applicable drive number) and put it into Register A.
532B
LD C,A
LET Register C = Register A (i.e., the applicable drive number).
532C
CALL WRGAT
     [4A9BH]
GOSUB to 4A9BH.
NOTE: 4A9BH is the SYS00/SYS routine to to write the GAT sector from RAM to diskette.
532F
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set then the WRITE THE GAT SECTOR routine returned with an error so JUMP to 6132H.
5332
LD HL,AUTMSG
LET Register Pair HL = 5355H, which is a pointer to the AUTO = ” message.
5335
CALL PRINT
     [021BH]
GOSUB to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found.
5338
LD HL,BUFF2 + DAUTO
LET Register Pair HL = 4DE0H, which is the memory location of the GAT SECTOR in RAM for the AUTO 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.
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.
533E
JR C,AUTO8
     [534FH]
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.
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.
“AUTO6”
5341
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.
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.
5344
JR C,AUTO7
     [5349H]
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.
5346
INC HL
Bump the value stored in Register Pair HL (i.e., the pointer to a byte of the AUTO command) by 1.
5347
JR AUTO6
   [5341H]
LOOP BACK to 5341H to keep parsing the AUTO command.

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

“AUTO7”
5349
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.
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
CALL PRINT
     [021BH]
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.
“AUTO8”
534F
LD HL,AUTNUL
LET Register Pair HL = 535FH, which is the message storage area for .
5352
JP PRINT
   [021BH]
JUMP to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found.

5355H – AUTO COMMAND MESSAGE STORAGE AREA.

“AUTMSG”
5355
DEFM …
AUTO = ‘”.
“AUTNUL”
535F
DEFB …
‘”.

5361H – DATE Library Command – Function 11

“S6DATE”
5361
LD C,2FH
LET Register C = 2FH (ASCII: /).
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.
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.
5366
JP Z,MSGPRT
     [61EAH]
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.
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.
536B
JP Z,MSGPRT
     [61EAH]
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.
536E
CALL CONV1
     [53EEH]
GOSUB to 53EEH to decode the date.
5371
JP NZ,ERR2
      [5214H]
If the prior CALL returned with NZ set, that signifies that it exited with an error. If that is the case, JUMP to 5214H.
5374
LD A,(BIN)
Fetch the value stored at memory location 53EBH (i.e., the YEAR or SECOND) and put it into Register A.
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.
5379
JP NC,ERR2
      [5214H]
If A >= 100 then we have a bad YEAR (and the NC FLAG will be set), so JUMP to 5214H.
537C
LD A,(BIN + 1)
Fetch the value stored at memory location 53ECH (i.e., the DAY or MINUTE) and put it into Register A.
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.
5381
JP NC,ERR2
      [5214H]
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.
5385
JP Z,ERR2
     [5214H]
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,(BIN+2)
Fetch the value stored at memory location 53EDH (i.e., the MONTH or HOUR) and put it into Register A.
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.
538D
JP NC,ERR2
      [5214H]
If A >= 13 then we have a bad MONTH (and the NC FLAG will be set), so JUMP to 5214H.
5390
OR A
Set FLAGS based on the contents of Register A.
5391
JP Z,ERR2
     [5214H]
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,BIN
LET Register Pair HL = 53EBH (i.e., the first byte of the 3 bytes comprising a DATE or TIME).
5397
LD DE,YEAR
LET Register Pair DE = 421AH, which will be the destination for the 3 numbers comprising the date.
539A
LD BC,0003H
LET Register Pair BC = 0003H, to signify 3 bytes to move.
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,BIN
LET Register Pair HL = 53EBH (i.e., the first byte of the 3 bytes comprising a DATE or TIME).
53A2
LD 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 – TIME Library Command – Function 36

“S6TIME”
53AB
LD C,3AH
LET Register C = 3AH (ASCII: :).
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.
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.
53B0
JP Z,MSGPRT
     [61EAH]
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.
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.
53B5
JP Z,MSGPRT
     [61EAH]
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.
53B8
CALL CONV1
     [53EEH]
GOSUB to 53EEH to decode the time.
53BB
JP NZ,ERR2
      [5214H]
If the prior CALL returned with NZ set, that signifies that it exited with an error. If that is the case, JUMP to 5214H.
53BE
LD A,(BIN)
Fetch the value stored at memory location 53EBH (i.e., the YEAR or SECOND) and put it into Register A.
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.
53C3
JP NC,ERR2
      [5214H]
If A >= 61 then we have a bad SECOND (and the NC FLAG will be set), so JUMP to 5214H.
53C6
LD A,(BIN + 1)
Fetch the value stored at memory location 53ECH (i.e., the DAY or MINUTE) and put it into Register A.
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.
53CB
JP NC,ERR2
      [5214H]
If A >= 61 then we have a bad MINUTE (and the NC FLAG will be set), so JUMP to 5214H.
53CE
LD A,(BIN + 2)
Fetch the value stored at memory location 53EDH (i.e., the MONTH or HOUR) and put it into Register A.
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.
53D3
JP NC,ERR2
      [5214H]
If A >= 24 then we have a bad HOUR (and the NC FLAG will be set), so JUMP to 5214H.
53D6
LD HL,BIN
LET Register Pair HL = 53EBH (i.e., the first byte of the 3 bytes comprising a DATE or TIME).
53D9
LD DE,SECOND
LET Register Pair DE = 4217H, which will be the destination for the 3 numbers comprising the time.
53DC
LD BC,0003H
LET Register Pair BC = 0003H, to signify 3 bytes to move.
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.

“CLOCK”
53E2
CALL CHKFLG
     [5081H]
GOSUB to 5081H to evaluate for ON/OFF Parameters.
53E5
JP Z,CLOCKF
     [02A1H]
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.
53E8
JP CLOCKN
   [0298H]
JUMP to 0298H.
NOTE: 02A1H is the Model III ROM routine to enable the clock display by enabling Bit 0 of 4210H.

53EBH – BYTE STORAGE AREA FOR TIME AND DATE ROUTINES.

“BIN”
53EB
00H
Storage for YEAR or SECOND.
53EC
00H
Storage for DAY or MINUTE.
53ED
00H
Storage for MONTH or HOUR.

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

“CONV1”
53EE
LD 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).
53F1
LD B,03H
LET Register B = 03H, to signify 3 bytes.
“L6OP1”
53F3
PUSH DE
Save Register DE (i.e., the DATE storage area) to the top of the stack.
53F4
CALL DECBIN
     [5403H]
GOSUB to 5403H to decode a two digit number pointed to by Register Pair HL; results in Register A.
53F7
POP DE
Restore the DATE storage area from the top of the STACK into Register Pair DE .
53F8
RET NZ
If the NZ FLAG (Not Zero) is set then that CALL exited with an error, so RETurn to the caller.
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.
53FA
DEC DE
DECrement the value stored in Register Pair DE by 1 to point to the next entry in the DATE STORAGE AREA.
53FB
DEC B
DECrement the value stored in Register B (i.e., a counter) by 1.
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.
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.
53FE
INC HL
Bump the value stored in Register Pair HL by 1 to point to the next character in the command line.
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.
5400
JR Z,L6OP1
     [53F3H]
If we properly had a / here, then the Z FLAG (Zero) is set, JUMP to 53F3H to keep parsing the 3 date elements.
5402
RET
RETurn to the caller with NZ set to signify an error.

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

“DECBIN”
5403
CALL 541AH
     [541AH]
GOSUB to 541AH to convert a COMMAND LINE byte pair to decimal.
5406
JR NC,RET1
      [5418H]
If the NC FLAG (No Carry) is set then that CALL exited with an ERROR so JUMP to 5418H.
5408
LD E,A
LET Register E = Register A (i.e., the returned value).
5409
RLCA
Let A = A * 2.
540A
RLCA
Let A = A * 2 (so A is now 4 times the original value).
540B
ADD A,E
ADD the value held in Register E to Register A (so A is now 5 times the original value).
540C
RLCA
Let A = A * 2 (so A is now 10 times the original value).
540D
LD E,A
LET Register E = Register A (i.e., the returned value, but now in the tens place).
540E
CALL DECCHK
     [541AH]
GOSUB to 541AH to get the parameter digit value.
5411
JR NC,RET1
      [5418H]
If the NC FLAG (No Carry) is set then that CALL exited with an ERROR so JUMP to 5418H.
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).
5414
LD E,A
LET Register E = Register A (i.e., the two numbers combined).
5415
XOR A
Set Register A to ZERO and clear all Flags.
5416
LD A,E
LET Register A = Register E (i.e., the two numbers combined).
5417
RET
RETurn to the caller.

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

“RET1”
5418
OR A
Set FLAGS based on the contents of Register A.
5419
RET
RETurn to the caller.

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

“DECCHK”
541A
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.
541B
INC HL
Bump the value stored in Register Pair HL by 1 to point to the next parameter byte.
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).
541E
CCF
Invert the state of the CARRY FLAG.
541F
RET NC
If the NC FLAG (No Carry) is set, RETurn to the caller.
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.
5422
RET
RETurn to the caller.

5423H – LIB Library Command – Function 23

“LIB”
5423
LD HL,LIBCOM
LET Register Pair HL = 50C9H which is the OVERLAY 1 COMMAND TABLE.
“L6OP4”
5426
LD C,08H
LET Register C = 08H, because there are 8 columns per row.
“L6OP3”
5428
LD B,06H
LET Register B = 06H, because there are 6 characters per library command.
“L6OP2”
542A
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.
542B
INC HL
Bump the value stored in Register Pair HL by 1 to point to the next character of that command table.
542C
CALL DSP
     [0033H]
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.
542F
LOOP back to 542AH until Register B is ZERO, meaning a full command has been displayed.
5431
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.
5434
AND 3FH
MASK the value of Register A against 3FH to mask for an END OF DISPLAY LINE computation.
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.
5438
JR NC,LL6OP2
      [5442H]
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.
543A
LD A,20H
LET Register A = 20H (ASCII: SPACE) because we need to put two spaces between library commands.
543C
CALL DSP
     [0033H]
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.
543F
CALL DSP
     [0033H]
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.
“LL6OP2”
5442
5443
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.
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.
5445
OR A
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A.
5446
JR Z,S6CR
     [5450H]
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.
5448
DEC C
DECrement the value stored in Register C by 1, since C is counting down the number of columns on a display.
5449
JR NZ,L6OP3
      [5428H]
If the NZ FLAG (Not Zero) is set, JUMP to 5428H to process the next library command.
544B
CALL S6CR
     [5450H]
GOSUB to 5450H to move to a new line on the screen.
544E
JR L6OP4
   [5426H]
JUMP to 5426H to keep displaying.

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

“S6CR”
5450
LD A,0DH
LET Register A = 0DH (ASCII: CARRIAGE RETURN.
5452
JP DSP
   [0033H]
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.

5455H – PROT Library Command – Function 29

“S6PROT”
5455
LD BC,0000H
LET Register Pair BC = 0000H so that we can turn off a bunch of options.
5458
LD (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 (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.
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.
5463
JR NZ,NODRV3
      [546BH]
If the character retrieved from the command line is not a :, then the NZ FLAG (Not Zero) is set, so JUMP to 546BH.
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.
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.
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).
5469
LD C,A
LET Register C = Register A (i.e., the decimal equivalent of a drive number from the command line).
546A
INC HL
Bump the value stored in Register Pair HL (i.e., the command line which was passed to this overlay) by 1.
“NODRV3”
546B
LD A,C
LET Register A = Register C (i.e., the decimal equivalent of a drive number from the command line).
546C
LD (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).
546F
LD DE,SWITCH5
LET Register Pair DE = 554EH to point to the PARAMETER TABLE.
5472
CALL SWITCH
     [4454H]
GOSUB to 4454H.
NOTE: 4454H is the DOS PARAMETER STRING PARSE routine. It decodes DOS LIBRARY parameters.
5475
JP NZ,ERR2
      [5214H]
If the NZ FLAG (Not Zero) is set then the prior CALL exited with an error, so JUMP to 5214H.
5478
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,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
JP Z,ERR3
     [5218H]
If the Z FLAG (Zero) is set then we have a problem so JUMP to 5218H.
5482
LD HL,OLDMAS
LET Register Pair HL = 5526H to point to the message storage area for “MASTER PASSWORD?“.
5485
CALL PRINT
     [021BH]
GOSUB to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found.
5488
CALL MASINP
     [551AH]
GOSUB to 551AH to get a response from the user to that prompt and encode it; results in HL.
548B
LD (INPPAS),HL
Store the value held in Register HL (i.e., the hashed password) into the memory location 549AH.
548E
LD C,DRV3
LET Register C = nnH, a value which is placed in 458FH elsewhere.
5490
CALL RDGAT
     [4A93H]
GOSUB to 4A93H.
NOTE: 4A93H is the SYS00/SYS routine to READ THE GAT sector into RAM (Buffer at 4D00H).
5493
JP NZ,ERR
      [6132H]
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.
5496
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.
5499
LD DE,INPPASS
LET Register Pair DE = nnnnH, a value which is placed in 549AH-549BH elsewhere.
549C
OR A
Set FLAGS based on the contents of Register A.
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).
549F
JP NZ,ERR4
      [5238H]
If the NZ FLAG (Not Zero) is set then those two passwords did NOT match, so JUMP to 5238H.
54A2
LD DE,PW
LET Register Pair DE = nnnnH, a value which is placed in 54A3H-54A4H elsewhere.
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
JR Z,NOPW
     [54BFH]
If the Z FLAG (Zero) is set then we have NOT been asked to change the password, so JUMP to 54BFH.
54A9
LD HL,NEWPAS
LET Register Pair HL = 5538H to point to the message storage area for “NEW MASTER PASSWORD?“.
54AC
CALL PRINT
     [021BH]
GOSUB to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found.
54AF
CALL MASINP
     [551AH]
GOSUB to 551AH to get a response from the user to that prompt and encode it; results in HL.
“PROTOK”
54B2
LD (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.
54B5
LD A,(DRV3)
Fetch the value stored at memory location 548FH (i.e., the drive spec) and put it into Register A.
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).
54B9
CALL WRGAT
     [4A9BH]
GOSUB to 4A9BH.
NOTE: 4A9BH is the SYS00/SYS routine to to write the GAT sector from RAM to diskette.
54BC
JP NZ,ERR
      [6132H]
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.
“NOPW”
54BF
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.
54C2
LD DE,LOCK
LET Register Pair DE = nnnnH, a value stored in memory locations 54C3H-54C4 elsewhere in this overlay.
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.
“NOLOCK”
54C8
LD (PASSW),HL
Store the value held in Register HL (i..e, the hashed master password) into the memory location 54F2H.
54CB
LD A,(DRV3)
Fetch the value stored at memory location 548FH (i.e., the drive number) and put it into Register A.
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).
54CF
CALL TRKGET
     [4B3EH]
GOSUB to 4B3EH to prepare the diskette for a DIRECTORY READ.
54D2
LD E,DIRSEC
LET Register E = 03H to signify that we want directory sector 3.
“L6OP36”
54D4
LD HL,BUFF1
LET Register Pair HL = 4300H to set up for a RAM buffer.
54D7
LD (BUFSAV),HL
Store the value held in Register HL (i.e., the RAM buffer pointer) into the memory location 54FDH.
54DA
CALL SREAD
     [4B0DH]
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.
54DD
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set then the CALL to READ THE DIRECTOR SECTOR returned an error; so JUMP to 6132H.
“L6OP35”
54E0
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.
54E2
JR Z,HASPAS
     [54FCH]
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.
54E4
AND 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.
54E6
JR NZ,HASPAS
      [54FCH]
If the NZ FLAG (Not Zero) is set then we have a SYSTEM FILE here, so JUMP to 54FCH.
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.
54E9
OR PEXEC
OR Register A against 06H (0000 0110). This has the effect of turning on bits 2 and 1 to signify KILL access.
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.
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.
54F0
PUSH DE
Save Register DE to the top of the stack.
54F1
LD DE,PASSW
LET Register Pair DE = nnnnH, a value stored in memory locations 54F2H-54F3H elsewhere in this overlay.

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.
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.
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.
“HASPASS”
54FC
LD 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.
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.
5503
LD (BUFSAV),HL
Store the value held in Register HL (i.e., the buffer pointer) into the memory location 54FDH.
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.
5508
JR C,L6OP35
     [54E0H]
If the C FLAG (Carry) is set, then we are NOT at the end of the sector, so LOOP BACK to 54E0H.
550A
LD HL,BUFF1
LET Register Pair HL = 4300H, which is the RAM Buffer.
550D
CALL XWRITE
     [45F7H]
GOSUB to 45F7H to write the RAM BUFFER pointed to by Register Pair HL to the directory sector.
5510
JP NZ,ERR
      [6132H]
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.
5514
LD A,E
LET Register A = Register E for purposes of checking that value.
5515
CP 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.
5517
JR C,L6OP36
     [54D4H]
If the C FLAG (Carry) is set then we have not yet reached the end of the directory, so LOOP BACK to 54D4H.
5519
RET
RETurn to the caller.

551AH – SUBroutine as part of the PROT routine.

“MASINP”
551A
LD HL,BUFF1
LET Register Pair HL = 4300H to as to point to the RAM BUFFER.
551D
LD B,08H
LET Register B = 08H, signifying 8 characters to be read.
551F
CALL KEYN
     [0040H]
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.
5522
CALL TRAP
     [555FH]
GOSUB to 555FH to to encode a password into Register Pair HL.
5525
RET
RETurn to the caller.

5526H – MESSAGE STORAGE AREA for the PROT command.

“OLDMAS”
5526
DEFM …
MASTER PASSWORD?“.
“NEWPAS”
5538
DEFM …
NEW MASTER PASSWORD?“.

554EH – PARAMETER STORAGE AREA for the PROT command.

“SWTCH5”
554E
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 – SUBROUTINE from the PROT library command to encode a password.

“TRAP”
555F
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
JR Z,NOSPC
     [556FH]
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.
“FILSPC”
556A
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
DJNZ FILSPC
     [556AH]
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.
“NOSPC”
556F
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
JR NC,SETTD2
      [557BH]
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.
“SETTD2”
557B
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
DJNZ SETTD2
     [557BH]
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

“RENAME”
559F
CALL GETSYN
     [623AH]
GOSUB to 623AH to isolate and validate the FILESPEC from the command line via an OVERLAY call to ROUTINE 4 of OVERLAY 1.
55A2
JP NZ,ERR3
      [5218H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5218H.
55A5
PUSH HL
Save Register Pair HL (i.e., the command line address) to the top of the stack.
55A6
PUSH DE
Save Register Pair DE (i.e., the DCB address) to the top of the stack.
55A7
LD HL,NAME1
LET Register Pair HL = 5666H to point to the filename.
55AA
LD DE,S6DCB1
LET Register Pair DE = 6280H to point to the print buffer.
55AD
CALL MOVNAM
     [563DH]
GOSUB to 563DH to copy the contents of (DE) to (HL) until a control character is reached, at which point JUMP to 5647.
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.
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
CALL OPEN
     [4424H]
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.
55B5
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
55B8
LD DE,S6DCB2
LET Register Pair DE = 62B2H to point to the second filename DCB.
55BB
CALL SYNTAX
     [441CH]
GOSUB to 441CH.
55BE
JP NZ,ERR3
      [5218H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5218H.
55C1
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.
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.
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.
55C8
LD A,EFAD
LET Register A = 19H, to signify a File Access Denied Due to To Password Protection error.
55CA
JP NC,ERR
      [6132H]
If the access level was >= 03H, the NC FLAG (No Carry) will be set, JUMP away to 6132H.
55CD
LD HL,S6DCB2
LET Register Pair HL = 62B2H so as to point to the second filename.
“L6OP34”
55D0
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL and put it into Register A.
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.
55D3
JP Z,ERR2
     [5214H]
If that character was a :, which is not a good thing, then the Z FLAG (Zero) is set, so JUMP to 5214H.
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.
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.
55D9
JR NC,L6OP34
      [55D0H]
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.
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.
“CONTE”
55DC
LD (HL),3AH
Store a 20H (ASCII: :) into the memory location pointed to by Register Pair HL (i.e., the end of the filename).
55DE
INC HL
INCrement the value stored in Register Pair HL by 1 to point to the next character of the filename.
55DF
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.
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.
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).
55E5
INC HL
INCrement the value stored in Register Pair HL by 1 to point to the next character of the filename.
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).
55E8
LD DE,S6DCB2
LET Register Pair DE = 62B2H to point to the SECOND filename.
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.
55EC
PUSH DE
Save Register Pair DE (i.e., the pointer to the second filename) to the top of the stack.
55ED
LD HL,NAME2
LET Register Pair HL = 5676H to point to the second filename.
55F0
LD DE,S6DCB2
LET Register Pair DE = 62B2H to point to the print buffer.
55F3
CALL MOVNAM
     [563DH]
GOSUB to 563DH to copy the contents of (DE) to (HL) until a control character is reached, at which point JUMP to 5647.
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.
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.
55F8
CALL OPEN
     [4424H]
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.
55FB
JP Z,ERR1
     [521CH]
If the Z FLAG (Zero) is set then the second filename has been found, so JUMP to 521CH.
55FE
CP 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.
5600
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set, then we didn’t get a FILE NOT FOUND error, so JUMP to 6132H.
5603
CALL DSPNAM
     [564AH]
GOSUB to 564AH to Display a Verification Message of “filename1 —-> filename2”.
5606
LD BC,(S6DCB1 + DRVNUM)
Fetch the value stored at memory location 6286H (i.e., the drivespec) and put it into Register BC.
560A
PUSH BC
Save Register Pair BC (i.e., the the drive number and file number) to the top of the stack.
560B
CALL RDDIR
     [4A67H]
GOSUB to 4A67H.
NOTE: 4A67H is the SYS00/SYS routine to read the directory entry into RAM (Buffer at 4300H).
560E
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.

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).
5612
LD A,L
LET Register A = Register L, so Register A = the LSB of HL.
5613
ADD A,DNAME
LET Register A = Register A + 05H, so Register A = the LSB of HL + 5.
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.
5616
LD HL,NAME
LET Register Pair HL = 5141H, which is a temporary memory storage location for the filename.
5619
LD BC,000BH
LET Register Pair BC = 000BH (Decimal: 11) to set up for a move of 11 bytes.
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.
561F
CALL WRDIR
     [4A7BH]
GOSUB to 4A7BH.
NOTE: 4A7BH is the SYS00/SYS routine to to write the directory entry from the copy in RAM to the diskette.
5622
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
5625
CALL RHDIT
     [4ABAH]
GOSUB to 4ABAH.
NOTE: 4ABAH is the SYS00/SYS routine to read the HIT sector into RAM.
5628
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
562B
LD D,H
LET Register D = Register H, so Register D (MSB of DE) will match H (MSB of HL).
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.
562D
PUSH BC
Save Register Pair BC (i.e., the drive number and file number) to the top of the stack.
562E
LD HL,NAME
LET Register Pair HL = 5141H, which is a temporary memory storage location for the filename.
5631
CALL HASH
     [50E7H]
GOSUB to 50E7H to hash the filename pointed to by Register Pair HL; results in Register A.
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.
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.
5636
CALL WRHIT
     [4AC2H]
GOSUB to 4AC2H.
NOTE: 4AC2H is the SYS00/SYS routine to write the HIT sector from RAM to diskette.
5639
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
563C
RET
RETurn to the caller.

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

“MOVNAM”
563D
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.
563E
CP 20H
Compare the value held in Register A against 20H. If Register A < 20H, the CARRY FLAG will be set.
5640
JR C,MOVNA1
     [5647H]
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.
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.
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).
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
JR MOVNAM
   [563DH]
LOOP back to the top of this routine at 563DH.

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

“MOVNA1”
5647
LD (HL),03H
Store the value held in Register 03H into the memory location pointed to by Register Pair HL.
5649
RET
RETurn to the caller.

564AH – SUBROUTINE called from 5603H to Display a Verification Message of “filename1 —-> filename2”.

“DSPNAM”
564A
PUSH BC
Save Register Pair BC to the top of the stack.
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,NAME1
LET Register Pair HL = 5666H to point to FILENAME 1.
5650
CALL PRINT
     [021BH]
GOSUB to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found.
5653
LD HL,NAMARO
LET Register Pair HL = 5686H to point to the message “—->“.
5656
CALL PRINT
     [021BH]
GOSUB to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found.
5659
LD HL,NAME2
LET Register Pair HL = 5676H to point to FILENAME 2.
565C
CALL PRINT
     [021BH]
GOSUB to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found.
565F
CALL S6CR
     [5450H]
GOSUB to 5450H to display a carriage return via a JUMP to 0033H in the Model III ROM.
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.
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.

MESSAGE STORAGE AREA for the RENAME Command.

“NAME1”
5666
DEFM …
PRINT BUFFER FOR FILESPEC 1 of 16 characters.
“NAME2”
5676
DEFM …
PRINT BUFFER FOR FILESPEC 2 of 16 characters.
“NAMARO”
5686
DEFM …
—->.

568EH – “APPEND” Command.

“APPEND”
568E
CALL GETSYN
     [623AH]
GOSUB to 623AH to isolate and validate the FILESPEC from the command line via an OVERLAY call to ROUTINE 4 of OVERLAY 1.
5691
JP NZ,ERR3
      [5218H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5218H.
5694
LD DE,S6DCB2
LET Register Pair DE = 62B2H to point to FILESPEC 2’s FCB.
5697
CALL SYNTAX
     [441CH]
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.
569A
JP NZ,ERR3
      [5218H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5218H.
569D
LD B,00H
LET Register B = 00H to signify a 256 Byte Full Sector LRL.
569F
LD HL,S6BUF2
LET Register Pair HL = 6400H for a memory buffer.
56A2
CALL OPEN
     [4424H]
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.
56A5
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
56A8
CALL OPENIT
     [6225H]
GOSUB to 6225H to open FILESPEC 1.
56AB
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
56AE
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.
56B1
LD B,A
LET Register B = Register A (i.e., the LRL for FILESPEC 1).
56B2
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.
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
JP NZ,ERR13
      [522FH]
If the file LRL’s are different, then the the NZ FLAG (Not Zero) will be set so JUMP to 522FH.
56B9
LD DE,S6DCB2
LET Register Pair DE = 62B2H to point to the FCB for FILESPEC 2.
56BC
CALL POSEOF
     [4448H]
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.
56BF
JR Z,L6OP10
     [56C6H]
If that CALL routine exited with no error, the Z FLAG (Zero) will be set, so in that case JUMP to 56C6H.
56C1
CP 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.
56C3
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set, then we do have an error, just not END OF FILE, so JUMP to 6132H.
“L6OP10”
56C6
LD DE,S6DCB1
LET Register Pair DE = 6280H to point to the FCB for FILESPEC 1.
56C9
CALL GET
     [0013H]
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.
56CC
JR Z,CONT
     [56DAH]
If the Z FLAG (Zero) is set, then that CALL returned a DEVICE READY, so JUMP to 56DAH.
56CE
LD B,A
LET Register B = Register A (i.e., the error code returned from the CALL GET).
56CF
AND 0FEH
MASK the value of Register A against 0FEH (1111 1110) to turn off bit 0.
56D1
CP 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.
56D3
LD A,B
LET Register A = Register B (i.e., the error code returned from the CALL GET).
56D4
JP Z,CLOZE
     [56EDH]
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.
56D7
JP ERR
   [6132H]
JUMP to 6132H to exit the APPEND routine with an error.

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

“CONT”
56DA
LD B,A
LET Register B = Register A (i.e., the byte read from FILESPEC 1 via a ROM call to 0013H) in 56C9.
56DB
CALL BRKCHK
     [028DH]
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.
56DE
JP NZ,CLOZE
      [56EDH]
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.
56E1
LD A,B
LET Register A = Register B (i.e., the byte read from FILESPEC 1).
56E2
LD DE,S6DCB2
LET Register Pair DE = 62B2H to point to FILESPEC 2’s FCB.
56E5
CALL PUT
     [001BH]
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.
56E8
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
56EB
JR L6OP10
   [56C6H]
LOOP back to 56C6H to continue processing bytes.

56EDH – Close FILESPEC 1 and FILESPEC 2 and RETurn.

“CLOZE”
56ED
LD DE,62B2H
LET Register Pair DE = 62B2H to point to FILESPEC 2’s FCB.
56F0
CALL CLOSE
     [4428H]
GOSUB to 4428H to CLOSE the file for FILESPEC 2.
56F3
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
“CLOZE1”
56F6
LD DE,S6DCB1
LET Register Pair DE = 6280H to point to FILESPEC 1’s FCB.
“CLOZE2”
56F9
CALL CLOSE
     [4428H]
GOSUB to 4428H to CLOSE the file for FILESPEC 1.
56FC
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
56FF
RET
RETurn to the caller.

5700H – “DUMP” Command.

The DUMP command storeas 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.

“DUMP”
5700
LD BC,6000H
LET Register Pair BC = 6000H which will be the default START and END numbers.
5703
LD (START),BC
Store the value held in Register BC (i.e., 6000H) into the memory location 57B1H (which is the memory location for the START address).
5707
LD (END),BC
Store the value held in Register BC (i.e., 6000H) into the memory location 57BBH (which is the memory location for the END address).
570B
XOR A
Set Register A to ZERO and clear all Flags.
570C
LD (DCOUNT),A
Store the value held in Register A into the memory location 5845H (which is the memory location for the DUMP PARAMETER TABLE).
570F
LD BC,0000H
LET Register Pair BC = 0000H which will be the default RELO number.
5712
LD (RELO),BC
Store the value held in Register BC into the memory location 57B5H (which is the memory location for the RELO address).
5716
LD BC,402DH
LET Register Pair BC = 402DH which will be the default TRA number.
5719
LD (TRA),BC
Store the value held in Register BC into the memory location 5800H (which is the memory location for the TRA address which is ALSO in the middle of a LD HL,nnnnH OPCODE).
571D
CALL GETSYN
     [623AH]
GOSUB to 623AH to isolate and validate the FILESPEC from the command line via an OVERLAY call to ROUTINE 4 of OVERLAY 1.
5720
JP NZ,ERR3
      [5218H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5218H.
5723
LD DE,SWTCH7
LET Register Pair DE = 5825H to point to the DUMP PARAMETER TABLE.
5726
CALL SWITCH
     [4454H]
GOSUB to 4454H.
NOTE: 4454H is the DOS PARAMETER STRING PARSE routine. It decodes DOS LIBRARY parameters.
5729
JP NZ,ERR2
      [5214H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5214H.
“DUMP10”
572C
LD DE,NAMFIL
LET Register Pair DE = 5846H, which is an 8 BYTE storage area for the FILENAME.
572F
LD HL,S6DCB1
LET Register Pair HL = 6280H, which is where the filename is currently stored.
5732
LD B,08H
LET Register B = 08H to signify an 8 character DJNZ loop.
“L6OP70”
5734
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the scratch location where the filename is current stored) and put it into Register A.
5735
CALL LEAL
     [59CBH]
GOSUB to 59CBH to test the validity of the character of the filename stored in Register A.
5738
JR C,SPCFIL
     [5741H]
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.
“FILASC”
573A
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).
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.
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
DJNZ L6OP70
     [5734H]
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.
573F
JR CONTH
   [5747H]
JUMP to 5747H to continue the “DUMP” routine.

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

“SPCFIL”
5741
LD A,20H
LET Register A = 20H (ASCII: SPACE).
“L6OP75”
5743
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).
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
DJNZ L6OP75
     [5743H]
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.
“CONTH”
5747
LD DE,S6DCB1
LET Register Pair DE = 6280H, which is where the filename is currently stored.
574A
LD HL,CMD
LET Register Pair HL = 5822H, which points to a /CMD message.
574D
CALL PUTEXT
     [444BH]
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.
5750
LD B,00H
LET Register B = 00H to set up for creating a file with an LRL of 256.
5752
LD HL,S6BUF1
LET Register Pair HL = 6300H to use as a buffer for the 4420H CALL.
5755
CALL INIT
     [4420H]
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.
5758
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
575B
LD A,05H
LET Register A = 05H, which is a COMMENT BLOCK designator.
575D
CALL PUTIT
     [581CH]
GOSUB to 581CH to write the contents of Register A (i.e., a COMMENT BLOCK designator) to the file.
5760
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
5763
LD A,10H
LET Register A = 10H (Decimal: 16) to set up the next CALL for a write of 16 bytes.
5765
CALL PUTIT
     [581CH]
GOSUB to 581CH to write the contents of Register A (i.e., 10H) to the file.
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.
576A
LD HL,NAMFIL
LET Register Pair HL = 5846H, which is an 8 BYTE storage area for the FILENAME.
“L6OP71”
576D
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.
576E
INC HL
INCrement the value stored in Register Pair HL by 1 to point to the next byte of the FILESPEC.
576F
CALL PUTIT
     [581CH]
GOSUB to 581CH to write the contents of Register A (i.e., a byte of the filename) to the file.
5772
DJNZ L6OP71
     [576DH]
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.
5774
PUSH BC
Save Register Pair BC to the top of the stack.
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.
577A
CALL MSGPR0
     [61F0H]
GOSUB to 61F0H to generate the date and place it into the file.
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.
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.
“L6OP91”
5783
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL and put it into Register A.
5784
INC HL
INCrement the value stored in Register Pair HL by 1.
5785
CALL PUTIT
     [581CH]
GOSUB to 581CH to write the contents of Register A (i.e., a byte of the DATE) to the file.
5788
DJNZ L6OP91
     [5783H]
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.
578A
LD HL,(END)
Fetch the value stored at memory location 57BBH (i.e., the END address) and put it into Register HL.
578D
LD BC,(START)
Fetch the value stored at memory location 57B1H (i.e., the START address) and put it into Register BC.
5791
OR A
Set FLAGS based on the contents of Register A.
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).
5794
JP C,ERR5
     [5220H]
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.
5797
LD HL,5FFFH
LET Register Pair HL = 5FFFH, which is 1 byte below the lowest permitted START 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).
579C
JP NC,ERR6
      [5225H]
If the NC FLAG (No Carry) is set, then the START address is too low, so JUMP to 5225H.
579F
LD HL,(RELO)
Fetch the value stored at memory location 57B5H (i.e., the RELO address) and put it into Register HL.
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
JR NZ,RELO1
      [57B0H]
If the NZ FLAG (Not Zero) is set, then we have a RELO parameter to deal with, so JUMP to 57B0H.
57A6
LD HL,(START)
Fetch the value stored at memory location 57B1H (i.e., the START address) and put it into Register HL.
57A9
LD (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,DCOUNT
LET Register Pair IX = 5845H so as to point to the FILENAME.
“RELO1”
57B0
LD HL,START
LET Register Pair HL = the value put into 57B1H, which is the START address.
57B3
LD IY,RELO
LET Register Pair IY = the value put into 57B5H, which is the RELO address.
“L6OP73”
57B7
PUSH HL
Save Register Pair HL (i.e., the START address) to the top of the stack.
57B8
LD B,H
LET Register B = Register H (i.e., MSB of the the START address).
57B9
LD C,L
LET Register C = Register L (i.e., LSB of the the START address).
57BA
LD HL,END
LET Register Pair HL = the value put into 57BBH, which is the END address.
57BD
INC HL
INCrement the value stored in Register Pair HL (i.e., the END address) by 1.
57BE
OR A
Set FLAGS based on the contents of Register A, which clears the CARRY FLAG.
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.
57C1
JR Z,DOEND
     [57F4H]
If the Z FLAG (Zero) is set, then there are no bytes to save, so JUMP to 57F4H.
57C3
LD B,0FEH
LET Register B = 0FEH for a loop of 254 bytes to write each time.
57C5
LD A,H
LET Register A = Register H (i.e., the MSB of the number of bytes to save).
57C6
OR A
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A.
57C7
JR NZ,DUMP1
      [57CFH]
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.
57C9
LD A,L
LET Register A = Register L (i.e., the LSB of the number of bytes to save).
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.
57CC
JR NC,DUMP1
      [57CFH]
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.
57CE
LD B,L
LET Register B = Register L (i.e., the LSB of the number of bytes to save).
“DUMP1”
57CF
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.
57D0
LD A,01H
LET Register A = 01H, which is code for a DATA BLOCK.
57D2
CALL PUTIT
     [581CH]
GOSUB to 581CH to write the contents of Register A (i.e., a DATA BLOCK designator) to the file.
57D5
LD A,B
LET Register A = Register B (i.e., the LSB of the number of bytes to save).
57D6
ADD A,02H
LET Register A = Register A + 02H (i.e., the the number of bytes to save + 2).
57D8
CALL PUTIT
     [581CH]
GOSUB to 581CH to write the contents of Register A (i.e., the number of bytes about to be written) to the file.
57DB
PUSH IY
Save Register Pair IY (i.e., the RELO address) to the top of the 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).
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.
57DF
CALL PUTIT
     [581CH]
GOSUB to 581CH to write the contents of Register A (i.e., the MSB of the RELO address) to the file.
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.
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).
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.
57E6
CALL PUTIT
     [581CH]
GOSUB to 581CH to write the contents of Register A (i.e., the MSB of the RELO address) to the file.
“L6OP72”
57E9
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.
57EA
INC HL
INCrement the value stored in Register Pair HL (i.e., a data byte) by 1.
57EB
INC IY
INCrement the value stored in Register Pair IY (i.e., the RELO address) by 1.
57ED
CALL PUTIT
     [581CH]
GOSUB to 581CH to write the contents of Register A (i.e., a data byte) to the file.
57F0
DJNZ L6OP72
     [57E9H]
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.
57F2
JR L6OP73
   [57B7H]
BIG LOOP back to 57B7H until all of H is also exhausted.

57F4H – Part of the “DUMP” COMMAND. Jumped here when there are no more bytes to save.

“DOEND”
57F4
POP HL
Clear the STACK.

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.

57F5
LD A,02H
LET Register A = 02H, which is code for the EXECUTION ADDRESS.
57F7
CALL PUTIT
     [581CH]
GOSUB to 581CH to write the contents of Register A (i.e., an 02H) to the file.
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).
57FC
CALL PUTIT
     [581CH]
GOSUB to 581CH to write the contents of Register A (i.e., an 02H) to the file.
57FF
LD 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.
5802
LD A,L
LET Register A = Register L (i.e., the LSB of the TRANSFER ADDRESS).
5803
CALL PUTIT
     [581CH]
GOSUB to 581CH to write the contents of Register A (i.e., the LSB of the TRANSFER ADDRESS) to the file.
5806
LD A,H
LET Register A = Register H (i.e., the MSB of the TRANSFER ADDRESS).
5807
CALL PUTIT
     [581CH]
GOSUB to 581CH to write the contents of Register A (i.e., the MSB of the TRANSFER ADDRESS) to the file.
580A
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.
580D
OR A
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A.
580E
JP Z,CLOZE2
     [56F9H]
If the Z FLAG (Zero) is set, then the last sector is full, so JUMP to 56F9H to 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.
“TRA1”
5812
LD A,0E5H
LET Register A = 0E5H, which will be the value to fill the rest of the sector with.
5814
CALL PUT
     [001BH]
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.
5817
DJNZ TRA1
     [5812H]
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.
5819
JP CLOZE2
   [56F9H]
JUMP to 56F9H to close the file and exit.

581CH – 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.

“PUTIT”
581C
INC (IX+00H)
IX+00H points to the byte-in-sector counter, so this bumps that by 1.
581F
JP PUT
   [001BH]
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.

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

“CMD”
5822
DEFM …
CMD“.
“SWITCH7”
5825
DEFM …
START “.
582D
DEFM …
END “.
5835
DEFM …
TRA “.
583D
DEFM …
RELO “.
“DCOUNT”
5845
00H
END OF TABLE DESIGNATOR.
“NAMFIL”
5846
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.

“LOAD”
584F
CALL GETSYN
     [5FBFH]
GOSUB to 5FBFH to get the filespec.
5852
JP NZ,ERR3
      [5218H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5218H.
5855
LD IY,SYS1IN
LET Register Pair IY = 402DH which will be the RETURN address for RETURN TO DOS when done.
5859
PUSH IY
Save Register Pair IY (i.e., the return address) to the top of the stack.
585B
JP LDPGM
   [4430H]
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.

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.
“ATTRIB”
585E
CALL GETSYN
     [623AH]
GOSUB to 623AH to isolate and validate the FILESPEC from the command line via an OVERLAY call to ROUTINE 4 of OVERLAY 1.
5861
JP NZ,ERR3
      [5218H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5218H.
5864
PUSH HL
Save Register Pair HL (i.e., the parameter address) to the top of the stack.
5865
LD B,00H
LET Register B = 00H to set a LRL = 0.
5867
LD HL,S6BUF2
LET Register Pair HL = 6400H as a buffer.
586A
CALL OPEN
     [4424H]
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.
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.
586E
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set, JUMP to 6132H.
5871
LD A,(S6DCB1 + PROT)
Fetch the value stored at memory location 6281H (i.e., the FILE ACCESS LEVEL) and put it into Register A.
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.
5876
LD A,EFAD
LET Register A = 19H to set up for a FILE ACCESS DENIED.
5878
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set, that is the error we got, so exit via a JUMP to 6132H.
587B
XOR A
Set Register A to ZERO and clear all Flags.
587C
LD (STAT),A
Store the value held in Register A (i.e., a 0) into the memory location 597BH (i.e., the file protection status).
587F
LD (ISTAT),A
Store the value held in Register A (i.e., a 0) into the memory location 5983H (i.e., invisible status).
5882
DEC A
DECrement the value stored in Register A by 1 (i.e., to FFH).
5883
LD (ISTAT1),A
Store the value held in Register A (i.e., FFH) into the memory location 5985H (i.e., non-invisible status).
“L6OP40”
5886
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.
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.
5889
JR Z,NEXTA
     [5893H]
If the Z FLAG (Zero) is set then we got the (, so JUMP to 5893H.
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.
588D
JP NZ,ERR3
      [5218H]
If the NZ FLAG (Not Zero) is set, then we didn’t get the SPACE that we were expecting, so JUMP to 5218H.
5890
INC HL
INCrement the value stored in Register Pair HL by 1 to point to the next character.
5891
JR L6OP40
   [5886H]
LOOP back to 5886H to look for a (.

5893H – Continuation of the “ATTRIB” Command. Jumped here if a “(” was Found.

“NEXTA”
5893
INC HL
INCrement the value stored in Register Pair HL by 1 to point to the next character.
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.
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.
5897
JR Z,INVISB
     [58FAH]
If the character was a I, then the Z FLAG (Zero) will be set. JUMP to 58FAH for the INVISIBLE ATTRIBUTE.
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.
589B
JR Z,NONINV
     [590AH]
If the character was a N, then the Z FLAG (Zero) will be set. JUMP to 590AH for the NOT INVISIBLE ATTRIBUTE.
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.
589F
JP Z,ACCESS
     [591AH]
If the character was a A, then the Z FLAG (Zero) will be set. JUMP to 591AH to change the ACCESS PASSWORD.
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.
58A4
JP Z,UPDATE
     [592FH]
If the character was a U, then the Z FLAG (Zero) will be set. JUMP to 592FH to change the UPDATE PASSWORD.
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.
58A9
JP NZ,ERR3
      [5218H]
If the character was a P, then the Z FLAG (Zero) will be set. JUMP to 5218H to change the PROTECTIONAL LEVEL.
58AC
CALL GETEND
     [5944H]
GOSUB to 5944H to get the next parameter.
58AF
JP Z,ERR3
     [5218H]
If the Z FLAG (Zero) is set then there was an error, so JUMP to 5218H.
58B2
PUSH HL
Save Register Pair HL (i.e., the current position on the parameter line) to the top of the stack.
58B3
LD B,PNOACC
LET Register B = 07H, for a loop of 7 entries.
58B5
LD DE,(PWORD)
Fetch the value stored at memory location 5139H (i.e., the parameter) and put it into Register DE.
58B9
LD HL,INDEX
LET Register Pair HL = 59AFH to point to the LEVEL TABLE.
“L6OP38”
58BC
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.
58BD
INC HL
INCrement the value stored in Register Pair HL by 1 to point to the next character in the LEVEL TABLE.
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
CALL Z,CMP2
       [58C8H]
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
DJNZ L6OP38
     [58BCH]
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
JP ERR3
   [5218H]
JUMP to 5218H to exit the routine as this means there was no match found.

58C8H – 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

“CMP2”
58C8
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., a character from the ACCESSS 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/ 22959/, 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 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.
58D0
JR NZ,NOTRE
      [58DDH]
If the NZ FLAG (Not Zero) is set then the second character didn’t match, so JUMP to 58DDH.
58D2
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,PREAD
LET Register A = 05H to restore the level.
58D9
JR NZ,NOTRE
      [58DDH]
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,PNAME
LET Register A = 02H (i.e., “NAME”).
“NOTRE”
58DD
LD (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.
“END2”
58E3
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 (STAT),A
Store the value held in Register A into the memory location 597BH (i.e., the file UPDATE protection status).
“END3”
58EA
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
JR Z,DONEA
     [596DH]
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
JR Z,NEXTA
     [5893H]
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/ 32/(ASCII: SPACE), the NO CARRY FLAG will be set.
58F5
JR C,DONEA
     [596DH]
If the next character is < SPACE, then the C FLAG (Zero) will be set. JUMP to 596DH.
58F7
JP ERR3
   [5218H]
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 – Continuation of the “ATTRIB” Command. Jumped here if a “I” was found after a “(” was found.

“INVISB”
58FA
CALL GETEND
     [5944H]
GOSUB to 5944H to position to the next parameter.
58FD
JP NZ,ERR3
      [5218H]
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,(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.
5905
LD (ISTAT),A
Store the value held in Register A into the memory location 5983H (i.e., invisible status).
5908
JR END3
   [58EAH]
JUMP back inside the loop at 58EAH.

590AH – Continuation of the “ATTRIB” Command. Jumped here if a “N” was found after a “(” was found.

“NONINV”
590A
CALL GETEND
     [5944H]
GOSUB to 5944H to position to the next parameter.
590D
JP NZ,ERR3
      [5218H]
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,(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 (ISTAT1),A
Store the value held in Register A into the memory location 5985H (i.e., non-invisible status).
5918
JR END3
   [58EAH]
JUMP back inside the loop at 58EAH.

591AH – Continuation of the “ATTRIB” Command. Jumped here if a “A” was found after a “(” was found.

“ACCESS”
591A
CALL GETEND
     [5944H]
GOSUB to 5944H to position to the next parameter.
591D
JP Z,ERR2
     [5214H]
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,PWORD
LET Register Pair DE = 5139H which is the PARAMETER STORAGE TABLE.
5924
CALL SETTDC
     [5107H]
GOSUB to 5107H to encode the access password.
5927
LD (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
JR END2
   [58E3H]
JUMP back inside the loop at 58E3H.

592FH – Continuation of the “ATTRIB” Command. Jumped here if a “U” was found after a “(” was found.

“UPDATE”
592F
CALL GETEND
     [5944H]
GOSUB to 5944H to position to the next parameter.
5932
JP Z,ERR2
     [5214H]
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,PWORD
LET Register Pair DE = 5139H which is the PARAMETER STORAGE TABLE.
5939
CALL SETTDC
     [5107H]
GOSUB to 5107H to encode the UPDATE password.
593C
LD (UPDTDC),HL
Store the value held in Register HL (i.e., encoded the ACCESS 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
JR END2
   [58E3H]
JUMP back inside the loop at 58E3H.

5944H – Continuation of the “ATTRIB” Command. Jumped here to position to the next parameter on the command line.

“GETEND”
5944
INC HL
INCrement the value stored in Register Pair HL (i.e., the character in the command line) by 1.
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.
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.
5948
JR NC,GETEN1
      [594CH]
If the character in the command line >= SPACE the NC FLAG (No Carry) is set. JUMP to 594CH.
594A
XOR A
Set Register A to ZERO and clear all Flags.
594B
RET
RETurn to the caller.

594CH – Continuation of the “ATTRIB” Command. Jumped here from the “position to next parameter” subroutine if a control character was detected.

“GETEN1”
594C
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.
594E
RET Z
If we have a ) then we are done and the Z FLAG (Zero) is set. RETurn to the caller.
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.
5951
RET Z
If we have a , then we are done and the Z FLAG (Zero) is set. RETurn to the caller.
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.
5954
JR NZ,GETEND
      [5944H]
If we did NOT get an =, the NZ FLAG is set. JUMP to 5944H to look at the next character.
5956
INC HL
INCrement the value stored in Register Pair HL (i.e., the character in the command line) by 1.
5957
LD DE,PWORD
LET Register Pair DE = 5139H which is the PARAMETER STORAGE TABLE.
595A
LD B,08H
LET Register B = 08H for a DJNZ loop of 8 characters.
595C
PUSH DE
Save Register Pair DE (i.e., the 9th character in the PARAMETER STORAGE TABLE) to the top of the stack.
595D
PUSH BC
Save Register Pair BC.
595E
LD A,20H
LET Register A = 20H (ASCII: SPACE).
“L6OP39”
5960
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).
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
DJNZ L6OP39
     [5960H]
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.
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
CALL GETFLD
     [50CDH]
GOSUB to 50CDH to get the parameter.
5969
DEC HL
DECrement the value stored in Register Pair HL (i.e., the character in the command line) by 1.
596A
OR 01H
OR Register A against 01H. This has the effect of turning on bit 0 to set the status.
596C
RET
RETurn to the caller.

596DH – 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.

“DONEA”
596D
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.
5971
CALL RDDIR
     [4A67H]
GOSUB to 4A67H.
NOTE: 4A67H is the SYS00/SYS routine to read the directory entry into RAM (Buffer at 4300H).
5974
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
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.
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.
597A
LD 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
JR Z,SKIP
     [5982H]
If the Z FLAG (Zero) is set then there was no need to protect the file. JUMP to 5982H.
5980
OR STAT1
OR Register A against the contents of memory position 5981H, as set elsewhere. This will mask in the access level.
“SKIP”
5982
OR ISTAT
OR Register A against the contents of memory position 5983H, as set elsewhere. This will start a mask for invisibility.
5984
AND 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.
5988
5987
598A
LD A,L
ADD A,DUPD
LD L,A
LET Register L = Register L + 10H, so as to point HL to the passwords.
598B
BIT 2,D
Test Bit Number 2 of Register D to see if the update password needs to be changed.
598D
JR Z,NOUPD
     [5999H]
If the Z FLAG (Zero) is set then it does NOT need a change, so JUMP to 5999H.

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

598F
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.
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).
5993
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.
“NOUPD”
5999
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.
599B
BIT 1,D
Test Bit Number 1 of Register D to see if the ACCESS password needs to be changed.
599D
JR Z,SAVE2
     [59A8H]
If the Z FLAG (Zero) is set then it does NOT need a change, so JUMP to 59A8H.
599F
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.
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,(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).
“SAVE2”
59A8
CALL WRDIR
     [4A7BH]
GOSUB to 4A7BH.
NOTE: 4A7BH is the SYS00/SYS routine to to write the directory entry from the copy in RAM to the diskette.
59AB
JP NZ,ERR
      [6132H]
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 – MESSAGE AND RAM STORAGE AREA for the “ATTRIB” Command.

“INDEX”
59AF
DEFM …
EX“.
59B1
DEFM …
RE“.
59B3
DEFM …
WR“.
59B5
DEFM …
7E 7E.
59B7
DEFM …
NA“.
59B9
DEFM …
KI“.
59BB
DEFM …
FU“.

59BDH – Part of the “DUMP” Command. Tests the validity of a HEXIDECIMAL NUMBER stored in Register A.

“LEGAL”
59BF
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.
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).
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.
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.
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.
59C6
RET C
If A < A then the the C FLAG (Carry) is set, RETurn to the caller.
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 – Part of the “DUMP” Command. Tests the validity of an ALPHA NUMERIC character stored in Register A.

“LEAL”
59CB
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.
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.
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.

“DIR”
59D9
LD BC,0000H
LET Register Pair BC = 0000H so that we can zero out a bunch of options.
59DC
LD (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).
59E0
LD (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).
59E4
LD (LPFLAG),BC
Store the value held in Register BC (i.e., 0000) into the memory location 5A4DH (i.e., the byte flag for PRINTER).
59E8
XOR A
Set Register A to ZERO and clear all Flags.
59E9
LD (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.
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.
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.
59EF
JR NZ,NODRV2
      [5A06H]
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.
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.
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. .
59F3
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).
59F5
JP C,ERR9
     [5234H]
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 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.
59FA
JP NC,ERR9
      [5234H]
If A >= 1 more than 3 the NC FLAG (No Carry) is set and then we have a bad drive number, JUMP to 5234H.
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.
59FE
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.
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.
5A02
JP C,ERR9
     [5234H]
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.
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.
“NODRV2”
5A06
PUSH BC
Save Register Pair BC (i.e., the drive number) to the top of the stack.
5A07
LD A,C
LET Register A = Register C (i.e., the drive number).
5A08
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.
5A0A
LD (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.
5A0D
LD DE,SWTCH3
LET Register Pair DE = 5CC3H, which is the FCB in RAM.
5A10
CALL SWITCH
     [4454H]
GOSUB to 4454H.
NOTE: 4454H is the DOS PARAMETER STRING PARSE routine. It decodes DOS LIBRARY parameters.
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.
5A14
JP NZ,ERR2
      [5214H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5214H.
5A17
PUSH BC
Save Register Pair BC (i.e., the drive number) to the top of the stack.
5A18
CALL RDGAT
     [4A93H]
GOSUB to 4A93H.
NOTE: 4A93H is the SYS00/SYS routine to READ THE GAT sector into RAM (Buffer at 4D00H).
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.
5A1C
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
5A1F
PUSH BC
Save Register Pair BC (i.e., the drive number) to the top of the stack.
5A20
LD HL,BUFF2 + DID
LET Register Pair HL = 4DD0H which is the pointer to the DISKETTE NAME.
5A23
LD DE,DSKN2
LET Register Pair DE = 5C3DH which the location of the DISKETTE NAME in the on the printout.
5A26
LD BC,0008H
LET Register Pair BC = 0008H since there are 8 characters in a DISK NAME.
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.
5A2B
LD 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.
5A2E
LD BC,0008H
LET Register Pair BC = 0008H since there are 8 characters in a DISK DATE.
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.
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.
5A34
PUSH BC
Save Register Pair BC (i.e., the drive number) to the top of the stack.
5A35
CALL RDHIT
     [4ABAH]
GOSUB to 4ABAH.
NOTE: 4ABAH is the SYS00/SYS routine to read the HIT sector into RAM.
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.
5A39
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set, JUMP to 6132H.
5A3C
PUSH BC
Save Register Pair BC to the top of the stack.
5A3D
LD HL,BUFF1
LET Register Pair HL = 4300H which is DOS BUFFER NUMBER 1.
5A40
LD DE,BUFF2
LET Register Pair DE = 4D00H which is DOS BUFFER NUMBER 2.
5A43
LD (PNTBUF),DE
Store the value held in Register DE (i.e., the pointer to DOS BUFFER NUMBER 2) into the memory location 5A88H.
5A47
LD BC,0100H
LET Register Pair BC = 0100H (Decimal: 256) to signif that we are moving 256 bytes from DOS BUFFER 1 to DOS BUFFER 2.
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.
5A4C
LD BC,LPFLAG
LET Register Pair BC = the value stored in 5A4DH which was placed here by this overlay. This is the PRINT flag.
5A4F
CALL CLS
     [01C9H]
GOSUB to 01C9H which is the Model III ROM ROUTINE to CLEAR THE SCREEN and RETurn.
“CONT2”
5A52
LD HL,TITL4
LET Register Pair HL = 5C32H which is the message pointer to the first DIR output title line.
5A55
CALL PRT2
     [6147H]
GOSUB to 6147H to either display or print the message pointed to by Register Pair HL.
5A58
LD HL,5C65H
LET Register Pair HL = 5C65H which is the message pointer to the second DIR output title line.
5A5B
CALL PRT2
     [6147H]
GOSUB to 6147H to either display or print the message pointed to by Register Pair HL.
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.
5A5F
LD A,C
LET Register A = Register C (i.e., the drive number).
5A60
LD (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.
5A63
LD A,02H
LET Register A = 02H since we have printed/displayed two lines already.
5A65
LD (SCRLCT),A
Store the value held in Register A into the memory location 4214H so as to protect those 2 lines.
“NXTREC”
5A68
LD B,S6DLFN
LET Register B = the value placed in 5A69H elsewhere in this overlay. This is the current file number.
5A6A
LD C,00H
LD C,nnH
LET Register C = the value placed in 5A6BH elsewhere in this overlay. This is the drive number.
5A6C
LD A,RECSEC
LET Register A = 05H, as the number of bytes to move to the next directory sector.
5A6E
ADD A,B
LET Register A = 05H + the current file number (held in Register B).
5A6F
CP 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.
5A71
JP NC,ENDIFL
      [5BF5H]
If A >= 55H then the the NC FLAG (No Carry) will be set and we ARE past the end of the directory, so JUMP to 5BF5H.
5A74
LD (S6DLFN),A
Store the value held in Register A (i.e., the logical file number) into the memory location 5A69H.
5A77
CALL RDDIR
     [4A67H]
GOSUB to 4A67H.
NOTE: 4A67H is the SYS00/SYS routine to read the directory entry into RAM (Buffer at 4300H).
5A7A
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
5A7D
CALL BRKCHK
     [028DH]
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.
5A80
JP NZ,ABORT
      [4030H]
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.
5A83
LD HL,BUFF1
LET Register Pair HL = 4300H, which is the DIRECTORY SECTOR BUFFER in RAM.
“L6OP21”
5A86
PUSH HL
Save Register Pair HL (i.e., the current pointer in the DIRECTORY SECTOR BUFFER in RAM) to the top of the stack.
5A87
LD HL,PNTBUF
LET Register Pair HL = the value placed in 5A88H-5A89H elsewhere in this overlay. This would be the HASH TABLE ENTRY.
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.
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.
5A8C
LD (PNTBUF),HL
Store the value held in Register HL into the memory location 5A88H (i.e., HASH TABLE ENTRY).
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.
5A90
JP Z,NXTFIL
     [5BE7H]
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.
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.
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.
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.
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.
5A98
JP NZ,NXTFIL
      [5BE7H]
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.
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.
5A9D
JP Z,NXTFIL
     [5BE7H]
If the Z FLAG (Zero) is set then this is an ACTIVE PRIMARY FILE ENTRY, in which case we do not want to display it. SKIP to 5BE7H.
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.
5AA2
JR Z,NOSYS
     [5AAEH]
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.
5AA4
LD 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.
5AA8
5AA7
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.
5AA9
JP Z,NXTFIL
     [5BE7H]
If the Z FLAG (Zero) is set then were NOT asked to display SYSTEM FIELS, so JUMP to 5BE7H.
5AAC
JR NOTINV
   [5ABAH]
JUMP to 5ABAH to display the file entry, 1 space, and the extension.

5AAEH – 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.

NOSYS
5AAE
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.
5AB0
JR Z,NOTINV
     [5ABAH]
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.
5AB2
LD 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.
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.
5AB7
JP Z,NXTFIL
     [5BE7H]
If the Z FLAG (Zero) is set then we were NOT asked to display invisible files, so JUMP to 5BE7H.

5ABAH – Continuation of the “DIR” Command. Display the filespec, 1 space, and the extension.

“NOTINV”
5ABA
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.
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).
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.
5ABD
LD (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.
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 MONTH).
5AC1
LD A,(HL)
Fetch the value stored at memory location (i.e., the file CREATION MONTH) pointed to by Register Pair HL (i.e., the current pointer in the DIRECTORY SECTOR BUFFER in RAM, currently pointing at the FILE CREATION MONTH) and put it into Register A.
5AC2
LD (SAVYR),A
Store the value held in Register A into the memory location 5BD4H which is in the middle of an OPCODE.
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.
5AC7
5AC6
5AC9
LD A,L
ADD A,DNAME
LD L,A
LET Register L = Register L + 05H.
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.
5ACB
LD B,08H
LET Register B = 08H since the FILENAME has 8 characters.
“L6OP16”
5ACD
LD A,(HL)
Fetch the value stored (i.e., a character of the filename) at memory location pointed to by Register Pair HL (i.e., the current pointer in the DIRECTORY SECTOR BUFFER in RAM, currently pointing at the FILENAME) and put it into Register A.
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.
5AD0
JR Z,YESSPC
     [5AD8H]
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.
5AD2
INC HL
INCrement the value stored in Register Pair HL (i.e., the current pointer in the DIRECTORY SECTOR BUFFER in RAM, currently pointing a character in the FILENAME) by 1.
5AD3
CALL PDATA
     [6135H]
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.
5AD6
DJNZ L6OP16
     [5ACDH]
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.
“YESSPC”
5AD8
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 FILENAME) into Restore Register Pair HL, and then remove the entry from the stack.
5AD9
PUSH DE
Save Register Pair DE to the top of the stack.
5ADA
LD DE,0008H
LET Register Pair DE = 0008H to skip the 8 bytes of the filename to now point to the FILE EXTENSION.
5ADD
ADD HL,DE
LET Register Pair HL = Register Pair HL (i.e., the current pointer in the DIRECTORY SECTOR BUFFER in RAM, currently pointing at the FILENAME) + Register Pair DE (8 bytes).
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.
5ADF
LD B,03H
LET Register B = 03H, which is the maximum number of characters in an extension.
5AE1
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the current pointer in the DIRECTORY SECTOR BUFFER in RAM, currently pointing at the EXTENSION) and put it into Register A.
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.
5AE4
JR Z,ENDEXT
     [5AF6H]
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.
5AE6
LD A,2FH
LET Register A = 2FH (ASCII: /) as the extension delimiter.
5AE8
CALL PDATA
     [6135H]
GOSUB to 6135H to display or print the /; routine affects Registers A and E.
“L6OP18”
5AEB
LD A,(HL)
Fetch the value stored at memory location (i.e., a character of the EXTENSION) pointed to by Register Pair HL (i.e., the current pointer in the DIRECTORY SECTOR BUFFER in RAM, currently pointing at the EXTENSION) and put it into Register A.
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.
5AEE
JR Z,ENDEXT
     [5AF6H]
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.
5AF0
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 EXTENSION) by 1.
5AF1
CALL PDATA
     [6135H]
GOSUB to 6135H to display or print the character held in Register A; routine affects Registers A and E.
5AF4
DJNZ L6OP18
     [5AEBH]
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.

5AF6H – Continuation of the “DIR” Command. Position the Cursor to the Right Location.

“ENDEXT”
5AF6
LD A,(CURSOR)
Fetch the value stored at memory location 4020H (i.e., the cursor position on screen) and put it into Register A.

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.
5AFB
NEG
Rather than SUBTRACTING, we are going to ADD, so turn Register A negative.
5AFD
ADD A,0FH
LET Register A = Register A + 0FH.
5AFF
LD B,A
LET Register B = Register A.
“ENDEX1”
5B00
LD A,20H
LET Register A = 20H (ASCII: SPACE).
5B02
CALL PDATA
     [6135H]
GOSUB to 6135H to display or print the character held in Register A; routine affects Registers A and E.
5B05
DJNZ ENDEX1
     [5B00H]
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.

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.
5B08
LD A,L
LET Register A = Register L (i.e., the last character of the EXTENSION).
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.
5B0B
LD L,A
LET Register L = Register A.
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.
5B0D
LD A,49H
LET Register A = 49H (ASCII: I).
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).
5B11
JR NZ,Y1
      [5B15H]
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.
5B13
LD A,4EH
LET Register A = 4EH (ASCII: N).
“Y1”
5B15
CALL PDATA
     [6135H]
GOSUB to 6135H to display or print the character held in Register A; routine affects Registers A and E.
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.
5B1A
LD A,53H
LET Register A = 53H (ASCII: S).
5B1C
JR NZ,Y2
      [5B20H]
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.
5B1E
LD A,2AH
LET Register A = 2AH (ASCII: *).
“Y2”
5B20
CALL PDATA
     [6135H]
GOSUB to 6135H to display or print the character held in Register A; routine affects Registers A and E.

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.
5B25
5B24
5B27
LD A,L
ADD A,DUPD
LD L,A
LET Register L = Register L + 10H.
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 (i.e., the pointer to the 1st character of the UPDATE PASSWORD byte of the DIRECTORY SECTOR in RAM) and put it into Register E.
5B29
INC HL
INCrement the value stored in Register Pair HL (i.e., the pointer to the 2nd character of the UPDATE PASSWORD byte of the DIRECTORY SECTOR in RAM) 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 (i.e., pointer to the 2nd character of the UPDATE PASSWORD of the DIRECTORY SECTOR in RAM) 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.
5B2C
LD HL,MASTPW
LET Register Pair HL = 5CEFH which would be a blank 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).
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.
5B32
LD A,55H
LET Register A = 55H (ASCII: U). If displayed, this would indicatate that the file is protected by an UPDATE PASSWORD.
5B34
JR NZ,ACC
      [5B38H]
If the NZ FLAG (Not Zero) is set, then the password is NOT blank, so JUMP to 5B38H.
5B36
LD A,58H
LET Register A = 58H (ASCII: X). If displayed, this would indicatate that the file is protected by an ACCESS PASSWORD.
“ACC”
5B38
INC L
INCrement the value stored in Register L (i.e., LSB of the pointer to the 2nd character of the UPDATE PASSWORD of the DIRECTORY SECTOR in RAM) by 1 so that HL will now point to the ACCESS PASSWORD.
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 (i.e., the pointer to the 1st character of the ACCESS PASSWORD byte of the DIRECTORY SECTOR in RAM) and put it into Register E.
5B3A
INC HL
INCrement the value stored in Register Pair HL (i.e., the pointer to the 1st character of the ACCESS PASSWORD byte of the DIRECTORY SECTOR in RAM) 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 (i.e., pointer to the 2nd character of the ACCESS PASSWORD of the DIRECTORY SECTOR in RAM) and put it into Register D.
5B3C
LD HL,MASTPW
LET Register Pair HL = 5CEFH which would be the 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).
5B42
JR Z,CONTY
     [5B4BH]
If the Z FLAG (Zero) is set then the ACCESS PASSWORD is blank, so JUMP to 5B4BH.
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.
5B46
LD A,41H
LET Register A = 41H (ASCII: A).
5B48
JR NZ,CONTY
      [5B4BH]
If the NZ FLAG (Not Zero) is set then the file is NOT update protected, so JUMP to 5B4BH.
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.
“CONTY”
5B4B
CALL PDATA
     [6135H]
GOSUB to 6135H to display or print the character held in Register A; routine affects Registers A and E.
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.

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.
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.
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.
5B53
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.
5B55
CALL PDATA
     [6135H]
GOSUB to 6135H to display or print the character held in Register A; routine affects Registers A and E.

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.
5B5B
LD A,(HL)
Fetch the value stored at memory location (i.e., the the EOF byte of the DIRECTORY SECTOR in RAM) pointed to by Register Pair HL and put it into Register A.
5B5C
LD (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.

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.
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.
5B61
LD A,L
LET Register A = Register L (i.e., the LRL byte of the DIRECTORY SECTOR in RAM).
5B62
LD (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.
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.
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
CALL BINDEC
     [61C1H]
GOSUB to 61C1H to display the contents of Register Pair HL (i.e., the LRL for the file being processed) in decimal form.
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.

5B70H – Continuation of the “DIR” Command. Calculate the number of records in a file.

5B71
5B70
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.
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.
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.
5B78
LD A,(LRL2)
Fetch the value stored at memory location 5B89H (which is in the middle of an OPCODE and is curently storing the files LRL) and put it into Register A.
5B7B
OR A
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A.
5B7C
JR NZ,NLR256
      [5B87H]
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.
5B7E
LD A,(S6EOF)
Fetch the value stored at memory location 5B90H (which is in the middle of an OPCODE and is curently storing the files EOF) and put it into Register A.
5B81
OR A
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A.
5B82
JR Z,LRL257
     [5B98H]
If the EOF is zero, then the Z FLAG (Zero) is set. JUMP to 5B98H.
5B84
INC DE
INCrement the value stored in Register Pair DE (i.e., the END OF FILE SECTOR NUMBER) by 1.
5B85
JR LRL257
   [5B98H]
JUMP to 5B98H to continue with this routine.

5B87H – 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.

“NLR256”
5B87
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).
5B88
LD A,LRL2
LET Register A = the memory contents opf 5B89, which is the files LRL, as was placed in this location elsewhere in this Overlay.
5B8A
CALL DIV
     [4451H]
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,S6EOF
LET Register L = the memory contents of 5B90, which is the files EOF, as was placed in this location elsewhere in this Overlay.
5B91
LD A,(LRL2)
Fetch the value stored at memory location 5B89H (i.e., the files LRL) and put it into Register A.
5B94
CALL DIV
     [4451H]
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.

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

“LRL257”
5B98
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).
5B99
CALL BINDEC
     [61C1H]
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.

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.
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.

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.
5BA1
LD C,D
LET Register C = Register D.
5BA2
LD B,MAXEXT
LET Register B = 0DH (Decimal: 13) for a loop that will skip over the 13 extents.
“L6OP19”
5BA4
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.
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.
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.
5BA8
JR NC,CONT4
      [5BB6H]
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.
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.
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.
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.
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.
5BAF
ADD A,E
LET Register A = Register A + Register E (i.e., the total number of grans for the file).
5BB0
LD E,A
LET Register E = Register A (i.e., the total number of grans for the file).
5BB1
JR NC,CONT3
      [5BB4H]
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.
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.
“CONT3”
5BB4
DJNZ L6OP19
     [5BA4H]
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.

5BB6H – Continuation of the “DIR” Command. Display the Number of GRANS in a File.

“CONT4”
5BB6
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).
5BB7
PUSH BC
Save Register Pair BC (i.e., the number of extents for the file being processed) to the top of the stack.
5BB8
CALL BINDEC
     [61C1H]
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.
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.

5BBD
5BBC
LD L,C
LD H,00H
LET Register Pair HL = Register C (i.e., the number of extents in the file being processed).
5BBF
CALL BINDEC
     [61C1H]
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.

5BC2H – Continuation of the “DIR” Command. Display the EOF BYTE OFFSET of a File.

5BC2
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.
5BC6
5BC5
LD L,A
LET Register Pair HL = Register A (i.e., the EOF BYTE of the file being processed).
5BC8
CALL BINDEC
     [61C1H]
GOSUB to 61C1H to display the contents of Register Pair HL (i.e., the EOF BYTE of the file being processed) in decimal form.

5BCBH – Continuation of the “DIR” Command. Display the DATE OF CREATION for a File.

5BCB
LD 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.
5BCD
LD HL,MTH
LET Register Pair HL = 5CBDH, which is the pointer to the creation month in the MESSAGE STORAGE table for the DIR command.
5BD0
CALL HEXAAS
     [61B5H]
GOSUB to 61B5H to convert the value.
5BD3
LD 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.
5BD5
LD HL,YER
LET Register Pair HL = 5CC0H, which is the pointer to the creation year in the MESSAGE STORAGE table for the DIR command.
5BD8
CALL HECXAAS
     [61B5H]
GOSUB to 61B5H to convert the value.
5BDB
LD HL,DETA
LET Register Pair HL = 5CBAH, which is the pointer to the date in the MESSAGE STORAGE table for the DIR command.
5BDE
CALL PRT2
     [6147H]
GOSUB to 6147H to either display or print the message pointed to by Register Pair HL.

5BE1H – Continuation of the “DIR” Command. Check for a User HOLD Key.

“NO”
5BE1
CALL INKEY
     [6167H]
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.
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.
5BE6
PUSH HL
Save Register Pair HL to the top of the stack.

5BE6H – Continuation of the “DIR” Command. Bump to the next file in the directory.

“NXTFIL”
5BE7
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.
“NXTFI1”
5BE8
LD 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.
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).
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.
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.
5BEF
JP Z,NXTREC
     [5A68H]
If the Z FLAG (Zero) is set then we have a new sector to deal with so JUMP to 5A68H.
5BF2
JP L6OP21
   [5A86H]
If we have not reached the end of the sector then LOOP BACK to 5A86H to keep processing directory entries.

5BF5H – Continuation of the “DIR” Command. All Files have been displayed. Calculate the number of FREE GRANS on the Dis.

“ENFILE”
5BF5
LD A,(S6DDRV)
Fetch the value stored at memory location 5A6BH (i.e., the drive number) and put it into Register A.
5BF8
LD C,A
LET Register C = Register A (i.e., the drive number).
5BF9
CALL RDGAT
     [4A93H]
GOSUB to 4A93H.
NOTE: 4A93H is the SYS00/SYS routine to READ THE GAT sector into RAM (Buffer at 4D00H).
5BFC
LD IX,BUFF2
LET Register Pair IX = 4D00H, which is the pointer to the GAT SECTOR now in RAM.
5C00
LD HL,0000H
LET Register Pair HL = 0000H.
5C04
5C03
LD D,H
LD E,L
LET Register DE = Register HL.
5C05
LD C,MAXTRK
LET Register C = 28H (Decimal: 40) as there are 40 tracks on a TRSDOS v1.3 diskette.
“L6OP23”
5C07
INC (IX+FLAW)
Bump the value stored in the 60H sector of the GAT Table in RAM, which is the number of flawed tracks.
5C0A
JR NZ,L66O23
      [5C10H]
If the NZ FLAG (Not Zero) is set, then the track is not flawed, so JUMP to 5C10H.
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.
“L66O23”
5C10
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.
5C13
LD B,NGRAN
LET Register B = 06H, which is the number of grans in a block.
“L6OP22”
5C15
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.
5C17
ADC HL,DE
Add WITH CARRY Register Pair HL (i.e., a running total) and Register Pair DE.
5C19
DJNZ L6OP22
     [5C15H]
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.
5C1D
DEC C
DECrement the value stored in Register C (i.e., the tracks left to be checked) by 1.
5C1E
JR NZ,L6OP23
      [5C07H]
If the NZ FLAG (Not Zero) is set, meaning that Register C still shows we have tracks to scan, JUMP to 5C07H.
5C20
PUSH HL
Save Register Pair HL (i.e., the running total of the count) to the top of the stack.
5C21
LD HL,FIRST
LET Register Pair HL = 5CA3H, which is a pointer to the “* * *” message pointer.
5C24
CALL PRT2
     [6147H]
GOSUB to 6147H to display/print the message being poted to by Register Pair HL (i.e., “* * *“).
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.
5C28
CALL BINDC1
     [61CAH]
GOSUB to 61CAH (which is in the middle of the 61C1H routine to display the contents of Register Pair HL in decimal form).
5C2B
LD HL,5CA7H
LET Register Pair HL = 5CA7H, which is a pointer to the “FREE GRANULES” message pointer.
5C2E
CALL PRT2
     [6147H]
GOSUB to 6147H to display/print the message being poted to by Register Pair HL (i.e., “* * *“).
5C31
RET
RETurn to the caller.

5C32H – MESSAGE AND STORAGE for the “DIR” Command.

“TITL2”
5C32
DEFM …
DISK NAME: “.
“DSKN2”
DEFM …
DRIVE:
“DRV2”
DEFM …
“DSIDE2”
DEFM …
“DATE2”
DEFM …
” + 0DH
“TITL4”
5C65
DEFM …
FILENAME ATTRB LRL #REC “.
5C89
DEFM …
#GRN EEXT EOF DATE:” + 0DH.
“FIRST”
5CA3
DEFM …
***” + 03H.
“SECND”
5CA7
DEFM …
FREE GRANULES ***” + 0DH.
DETA”
5CBA
DEFM …
“.
“MTH”
DEFM …
00/
“YER”
DEFM …
00” + 0DH.

5CC3H – “DIR” Command Parameter Table.

“SWTCH3”
5CC3
DEFM ‘SYS ‘
 
 
DEFW SYS
 
 
DEFM ‘INV ‘
 
 
DEFW INV
 
“PRT”
5CD3
DEFM ‘PRT ‘
 
 
DEFW LPFLAG
 
 
DEFB 00H
 

5CDCH – “FREE” Library Command.

“S6FREE”
5CDC
LD BC,0000H
LET Register Pair BC = 0000H so that we can clear the PRINTER FLAG in the next instruction.
5CDF
LD (LPFLAG),BC
Store the value held in Register BC (i.e., 0000H) into the memory location 5A4DH (i.e., the byte flag for PRINT).
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.
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.
5CE6
JR NZ,NODRV
      [52FFH]
If we did not get a : the NZ FLAG (Not Zero) is set, so JUMP to 5CFDH.
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.
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.
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).
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 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).
5CED
JP C,ERR9
     [5234H]
If the C FLAG (Carry) is set then the character’s value was too low to be a number, so JUMP to 5234H.
5CF0
CP 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.
5CF2
JP NC,ERR9
      [5234H]
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.
5CF5
LD C,A
LET Register C = Register A (i.e., the partially valided drive number from the command line).
5CF6
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.
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 valided drive number from the command line). Results: If the number of disk drives actually present on the system (Register A) >= the partially valided 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 drivee is higher than the number of drives available, the CARRY FLAG will be set.
5CFA
JP C,ERR9
     [5234H]
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.
“NODRV”
5CFD
LD A,C
LET Register A = Register C (i.e., the fully validated drive number specified on the command line).
5CFE
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.
5D00
LD (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.
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.
5D04
LD DE,SWTCH1
LET Register Pair DE = 5CD3H, which is the pointer to the “PRT ” message.
5D07
CALL SWITCH
     [4454H]
GOSUB to 4454H.
NOTE: 4454H is the DOS PARAMETER STRING PARSE routine. It decodes DOS LIBRARY parameters.
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.
5D0B
JP NZ,ERR2
      [5214H]
If the NZ FLAG (Not Zero) is set, then the CALL for the DOS PARAMETER STRING PARSE returned an error, so JUMP to 5214H.
5D0E
CALL TRKGET
     [4B3EH]
GOSUB to 4B3EH to prepare the diskette for a DIRECTORY READ.
5D11
LD A,D
LET Register A = Register D (i.e., the directory track number).
5D12
LD (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).
5D15
CALL RDGAT
     [4A93H]
GOSUB to 4A93H.
NOTE: 4A93H is the SYS00/SYS routine to READ THE GAT sector into RAM (Buffer at 4D00H).
5D18
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
5D1B
LD HLBUFF2 + DID
LET Register Pair HL = 4DD0H, which is the pointer to the memory location holding the FILENAME in the GAT SECTOR we just read.
5D1E
LD DE,DSKNAM
LET Register Pair DE = 5DE7H, which is a pointer to the MESSAGE STORAGE AREA for the FREE commad.
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).
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.
5D26
LD BC,(LPFLAG)
Fetch the value stored at memory location 5A4DH (i.e., the PRINTER OUTPUT flag) and put it into Register BC.
5D2B
5D2A
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
JR NZ,CONTD
      [5D31H]
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.
5D2E
CALL CLS
     [01C9H]
GOSUB to 01C9H which is the Model III ROM Routine to Clear the Screen.
“CONTD”
5D31
LD B,15H
LET Register B = 15H (Decimal: 21) for the 21 spaces we are about to print.
5D33
LD A,20H
LET Register A = 20H (ASCII: SPACE) for the 21 spaces we are about to print.
“L6OP33”
5D35
CALL PDATA
     [6135H]
GOSUB to 6135H to display or print the character held in Register A; routine affects Registers A and E.
5D38
DJNZ L6OP33
     [5D35H]
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.
5D3A
LD HL,TITLE
LET Register Pair HL = 5DC2H which is the MESSAGE STORAGE AREA for “ FREE SPACE MAP “.
5D3D
CALL PRT2
     [6147H]
GOSUB to 6147H to either display or print the message pointed to by Register Pair HL.
5D40
LD HL,TITL3
LET Register Pair HL = 5DDDH which is the MESSAGE STORAGE AREA for “?????“.
5D43
CALL PRT2
     [6147H]
GOSUB to 6147H to either display or print the message pointed to by Register Pair HL.
5D46
LD A,0FFH
LET Register A = 0FFH to prepare for initializing the track number.
5D48
LD (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.
5D4B
LD HL,BUFF2
LET Register Pair HL = 4D00H, which is the BUFFER into which the GAT TABLE has been read.
“L6OP7”
5D4E
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.
5D51
INC A
INCrement the value stored in Register A (i.e., the track number) by 1.
5D52
CP 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.
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.
5D55
PUSH HL
Save Register Pair HL (i.e., the pointer to the GAT sector in RAM) to the top of the stack.
5D56
PUSH AF
Save Register Pair AF (i.e., the track number) to the top of the stack.
5D57
LD HL,LOW
LET Register Pair HL = 5E0FH, which is the MESSAGE STORAGE AREA for “nn-nn: XXXXXXX : XXXXXX : XXXXXX : XXXXXX : XXXXXX“.
5D5A
CALL HEXCOV
     [5E46H]
GOSUB to 5E46H to put the first track number in the data line for printout.
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.
5D5E
ADD A,04H
LET Register A = Register A (i.e., the track number) + 04H.
5D60
LD (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).
5D63
LD HL,LOW + 3
LET Register Pair HL = 5E12H which is the pointer for the fourth track number in the data line for prinout.
5D66
CALL HEXCOV
     [5E46H]
GOSUB to 5E46H to put the fourth track number in the data line for printout.
5D69
LD DE,TABLE
LET Register Pair DE = 5E19H which is the pointer to the start of track data.
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.
5D6D
LD B,05H
LET Register B = 05H for a loop of 5 tracks.
“L6OO8”
5D6F
PUSH HL
Save Register Pair HL (i.e., the pointer to the GAT table in RAM) to the top of the stack.
5D70
PUSH DE
Save Register Pair DE to the top of the stack.
5D71
LD 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.
5D74
ADD HL,DE
LET Register Pair HL = Register Pair HL + Register DE.
5D75
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the the track existence table in the GAT sector) and put it into Register A.
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.
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.
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.
5D7A
JR NZ,L6PO9
      [5D8EH]
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.
“L66P08”
5D7C
LD IX,GFLAW
LET Register Pair IX = 5DD1H so as to point to “FLAWED”.
“L6PO8”
5D80
PUSH BC
Save Register Pair BC (i.e., the count) to the top of the stack.
5D81
LD 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.
“L6OOP8”
5D83
LD A,(IX+00H)
Fetch the value stored at the memory location pointed to by IX+00H and put it into Register A.
5D86
LD (DE),A
Store the value held in Register A into the memory location pointed to by Register Pair DE.
5D87
INC IX
INCrement the value stored in Register Pair IX by 1.
5D89
INC DE
INCrement the value stored in Register Pair DE by 1.
5D8A
DJNZ L6OO8
     [5D83H]
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.
5D8C
JR L6PO20
   [5DACH]
JUMP to 5DACH.

5D8EH – Continuation of the “FREE” command. Jumped here if the track is NOT flawed (so as to skip the display of a flawed track).

“L6PO9”
5D8E
LD A,(CDIRET)
Fetch the value stored at memory location 5E45H (i.e., the directory track number) and put it into Register A.
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.
5D92
JR NZ,L6PO10
      [5D9AH]
If the NZ FLAG (Not Zero) is set then we have not yet reached the directory track, so JUMP to 5D9AH.
5D94
LD IX,GDIR
If we are here, we have finally hit the directory sector. LET Register Pair IX = 5DD7H to point to “DIRECT”.
5D98
JR L6PO8
   [5D80H]
JUMP to 5D80H.

5D9AH – 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.

“L6PO10”
5D9A
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.
“L60010”
5D9B
PUSH BC
Save Register Pair BC (i.e., the count) to the top of the stack.
5D9C
LD B,NGRAN
LET Register B = 06H for a DJNZ loop of 6 iterations to move bytes from IX to DE.
“L6PO11”
5D9E
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.
5DA0
JR C,SETX
     [5DA6H]
If the C FLAG (Carry) is set (meaning bit 0 of Register C was set), then the gran was allocated, so JUMP to 5DA6H.
5DA2
LD A,2EH
LET Register A = 2EH (ASCII: .).
5DA4
JR SETXX
   [5DA8H]
JUMP to 5DA8H.

5DA6H – 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.

“SETX”
5DA6
LD A,58H
LET Register A = 58H (ASCII: X).
“SETXX”
5DA8
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).
5DA9
INC DE
INCrement the value stored in Register Pair DE (i.e., a location in the data line to be output) by 1.
5DAA
DJNZ L6PO11
     [5D9EH]
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.
“L6PO20”
5DAC
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.
5DAD
PUSH HL
Save Register Pair HL (i.e., a pointer in the GAT SECTOR in RAM) to the top of the stack.
5DAE
LD HL,0003H
LET Register Pair HL = 0003H to prepare to skip over 3 spaces in the data line to be output.
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).
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).
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.
5DB4
INC HL
INCrement the value stored in Register Pair HL (i.e., a pointer in the GAT SECTOR in RAM) by 1.
5DB5
DJNZ L6OO8
     [5D6FH]
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.
5DB7
PUSH HL
Save Register Pair HL (i.e., a pointer in the GAT SECTOR in RAM) to the top of the stack.
5DB8
LD HL,LOW
LET Register Pair HL = 5E0FH to point to the data line.
5DBB
CALL PRT2
     [6147H]
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
JP L6OP7
   [5D4EH]
JUMP to 5D4EH to keep looping over the entire disk.

5DC2H – MESSAGE and BYTE STORAGE AREA for “FREE”.

“TITLE”
5DC2
DEFM ‘FREE SPACE MAP” + 0DH
 
“GFLAW”
5DD1
DEFM ‘FLAWED’
 
“GDIR”
5DD7
DEFM ‘DIRECT’
 
“TITL3”
5DDD
DEFM ‘TRK # ‘
 
“DSKNAM”
DEFM ‘SIDE: —————— DRIVE: ‘
 
“DRIVE”
DEFM ‘ ‘ + 0DH
 
“LOW”
5E0F
DEFM ‘ – : ‘
 
“TABLE”
DEFM …
‘ : : : : ‘ + 0DH“.
“COUNT”
5E44
DEFB 0
Storage area for the Track Number.
“CDIRET”
5E45
DEFB 0
Storage area for the Directory’s Track Number.

5E46H – Subroutine in the “FREE” Library Command to Generate a 2-Digit Decimal Number.

“HEXCOV”
5E46
LD (HL),2FH
Store the value of 1 character below “0” into the memory location pointed to by Register Pair HL.
“HEXCO2”
5E48
INC (HL)
Increase the character held in Register Pair HL by 1.
5E49
SUB 0AH
SUBtract 10 from that character value.
5E4B
JR NC,HEXCO2
      [5E48H]
If the NC FLAG (No Carry) is set, the value went negative, so JUMP to 5E48H.
“HEXCO1”
5E4D
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.

“CREATE”
5E52
LD BC,0000H
LET Register Pair BC = 0000H.
5E55
LD (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).
5E59
LD (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).
5E5D
CALL GETSYN
     [623AH]
GOSUB to 623AH to isolate and validate the FILESPEC from the command line via an OVERLAY call to ROUTINE 4 of OVERLAY 1.
5E60
JP NZ,ERR3
      [5218H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5218H.
“CONT10”
5E63
LD DESWTCH2
LET Register Pair DE = 5EB1H to point to the valid parameter table (which is either REC or LRL).
5E66
CALL SWITCH
     [4454H]
GOSUB to 4454H.
NOTE: 4454H is the DOS PARAMETER STRING PARSE routine. It decodes DOS LIBRARY parameters.
5E69
JP NZ,ERR2
      [5214H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5214H.
5E6C
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.
5E6F
CALL CONVHX
     [5EC2H]
GOSUB to 5EC2H to convert the Binary Coded Decimal Value Pointed to by Register Pair HL into Binary.
5E72
LD (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).
5E75
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.
5E78
CALL CONVHX
     [5EC2H]
GOSUB to 5EC2H to convert the Binary Coded Decimal Value Pointed to by Register Pair HL into Binary.
5E7B
LD (S6LRL),HL
Store the value held in Register HL into the memory location 5E7FH (i.e., the storage location for the LRL).
5E7E
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.
5E81
LD A,B
LET Register A = Register B (i.e., the MSB of the LRL).
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
JP NC,ERR2
      [5214H]
If the NC FLAG (No Carry) is set then the LRL is too big, so JUMP to 5214H.
5E87
LD B,C
LET Register B = Register C (i.e., the LSB of the LRL).
5E88
CALL GETDC1
     [622DH]
GOSUB to 622DH to set the parameters for an OVERLAY call to open a file.
5E8B
CALL INIT
     [4420H]
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.
5E8E
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
5E91
JP NC,ERR1
      [521CH]
If the NC FLAG (No Carry) is set then that CALL resulted in a “FILE ALREADY EXISTS” status, so JUMP to 521CH.
5E94
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.
“L6OP12”
5E97
5E98
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.
5E99
JP Z,CLOZE1
     [56F6H]
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.
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.
5E9D
LD DE,S6DCB1
LET Register Pair DE = 6280H, which will be the DCB address.
5EA0
PUSH DE
Save Register Pair DE (i.e., the DCB address) to the top of the stack.
5EA1
CALL POSN
     [4442H]
GOSUB to 4442H to position the file to the last record.
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.
5EA8
CALL WRITE
     [4439H]
GOSUB to 4439H to write from the video screen to a file.
5EAB
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
5EAE
JP CLOZE1
   [56F6H]
JUMP to 56F6H to close the file and exit.

5EB1H – PARAMETER TABLE for the “CREATE” Command.

“SWTCH2”
5EB1
DEFM …
REC “.
5E91
DEFM …
LRL “.
 
DEFW S6LRL
 
5EC1
DEFB 00H
End of Table Delimeter.

5EC2H – SUBROUTINE in the “CREATE” Command to Convert the Binary Coded Decimal Value Pointed to by Register Pair HL into Binary.

“CONVHX”
5EC2
LD IX,0000H
LET Register Pair IX = 0000H, which is where the results will be stored.
5EC6
LD 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).
5ECB
CALL ADDHL
     [5ED6H]
GOSUB to 5ED6H to convert from Hexadecimal.
5ECE
LD A,L
LET Register A = Register L (i.e., the LSB).
5ECF
CALL ADDHL
     [5ED6H]
GOSUB to 5ED6H to convert from Hexadecimal.
5ED4
5ED2
PUSH IX
POP HL
Let Register Pair HL = Register Pair IX.
5ED5
RET
RETurn to the caller.

5ED6H – SUBROUTINE to the above SUBROUTINE in the “CREATE” Command. Converts the value held in A to Hexadecimal.

“ADDHL”
5ED6
PUSH AF
Save Register Pair AF (i.e., the byte we are converting) to the top of the stack.
5ED9
5ED7
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.
5EDF
CALL ADDIX
     [5EE3H]
GOSUB to 5EE3H to convert Register A to a Decimal Decoded number.
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.
“ADDIX”
5EE3
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.
5EE5
LD B,A
LET Register B = Register A (i.e., the low nybble of the byte we are converting).

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.
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.
5EF0
INC B
INCrement the value stored in Register B by 1.
“ADDIX1”
5EF1
DEC B
DECrement the value stored in Register B by 1 so as to trigger a Z or NZ flag.
5EF2
RET Z
If the Z FLAG (Zero) is set, then our digit is zero, so RETurn to the caller.
5EF3
ADD IX,DE
LET Register Pair IX = Register Pair IX (i.e., returning code) + Register DE (i.e., the table value).
5EF5
JR ADDIX1
   [5EF1H]
LOOP BACK 3 instructions to 5EF1H.

5EF7H – POWERS OF 10 TABLE for the “CREATE” Command.

“POWR10”
5EF7
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.

“CLEAR”
5EFF
LD BC,0000H
LET Register Pair BC = 0000H so we can zero out the following memory locations.
5F02
LD (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 (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 (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.
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.
5F11
JR NZ,CLEARX
      [5F1FH]
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.
5F13
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.
5F16
OR A
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A.
5F17
JR Z,CLEAR0
     [5F63H]
If the Z FLAG (Zero) is set, then the DO command is NOT active, so JUMP to 5F63H.
5F19
LD 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.
5F1C
JP PRINT
   [021BH]
JUMP to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found.

5F1FH – Subroutine in the “CLEAR” Library Command. Jumped to if we have parameters on the command line.

“CLEARX”
5F1F
LD DE,CLRTAB
LET Register Pair DE = 5F91H to point to the PARAMETER TABLE for the CLEAR command.
5F22
CALL SWITCH
     [4454H]
GOSUB to 4454H.
NOTE: 4454H is the DOS PARAMETER STRING PARSE routine. It decodes DOS LIBRARY parameters.
5F25
JP NZ,ERR2
      [5214H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5214H.
5F28
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.
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.
5F2D
JR Z,CHKMEM
     [5F4BH]
If the Z FLAG (Zero) is set, then the START entry was ZERO, so JUMP to 5F4BH.
5F2F
LD HL,6000H
LET Register Pair HL = 6000H, which is the lowest RAM location which is permitted.
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
JP NC,ERR6
      [5225H]
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.
5F37
LD HL,HIGHRAM
LET Register Pair DE = the value stored in 5F29H-5F30H (i.e., the memory location storing the ENDING ADDRESS), which was placed here by other instructions in this overlay.
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).
5F3C
JP C,ERR5
     [5220H]
If the C FLAG (Carry) is set then that subtraction triggered an overflow, so JUMP to 5220H to exit.
5F3F
JP Z,ERR5
     [5220H]
If the Z FLAG (Zero) is set then the START and END addresses are the same, so JUMP to 5220H to exit.
5F42
5F43
LD B,H
LD C,L
Let Register Pair BC = Register Pair HL (i.e., the ENDING ADDRESS – STARTING ADDRESS).
5F44
5F45
LD H,D
LD L,E
LET Register Pair HL = Register Pair DE (i.e., the STARTING ADDRESS).
5F46
INC DE
INCrement the value stored in Register Pair DE (i.e., the STARTING ADDRESS) by 1.
5F47
LD (HL),00H
Store a 00H into the memory location pointed to by Register Pair HL.
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.
“CHKMEM”
5F4B
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.
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.
5F50
JP Z,CLS
     [01C9H]
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).
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.
5F54
LD HL,5FFFH
LET Register Pair HL = 5FFFH (i.e., 1 byte lower than the lowest byte we will permit).
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
JP NC,ERR6
      [5225H]
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.
5F5C
LD (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.
5F60
JP CLS
   [01C9H]
JUMP to 01C9H which is the Model III ROM Routine to clear the screen (and this routine will exit after that).

5F63H – Part of the “CREATE” Library Command. Jumped here if the user didn’t provide any parameters.

“CLEAR0”
5F63
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.
5F67
LD (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.
5F6B
LD HL,S6DCB1
LET Register Pair HL = 6280H, which will be the base memory address for a memory test.
5F6E
XOR A
Set Register A to ZERO and clear all Flags.
“L6OP9”
5F6F
LD (HL),A
Store the value held in Register A (i.e., a 00H) into the memory location pointed to by Register Pair HL.
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.
5F71
JR NZ,CLER1
      [5F7BH]
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.
5F73
INC HL
INCrement the value stored in Register Pair HL (i.e., a location in RAM we are testing) by 1.
5F74
PUSH HL
Save Register Pair HL (i.e., a location in RAM we are testing) to the top of the stack.
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
JR NZ,L6OP9
      [5F6FH]
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.
“CLER1”
5F7B
PUSH HL
Save Register Pair HL (i.e., the last location in RAM we are testing) to the top of the stack.
5F7C
OR A
Clear the CARRY flag, leave everything else alone.
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).
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.
5F80
JP NC,CLS
      [01C9H]
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).
5F83
LD HL,HEXADD
LET Register Pair HL = 527BH, which is a pointer to a MESSAGE STORAGE AREA.
5F86
LD A,D
LET Register A = Register D (i.e., the MSB of the byte of RAM which failed).
5F87
CALL HEXS
     [61A1H]
GOSUB to 61A1H to insert that value into the MESSAGE.
5F8A
LD A,E
LET Register A = Register E (i.e., the LSB of the byte of RAM which failed).
5F8B
CALL HEXS
     [61A1H]
GOSUB to 61A1H to insert that value into the MESSAGE.
5F8E
JP ERR7
   [522AH]
JUMP to 522AH to display the error and exit.

5F91H – PARAMETER TABLE for the “CLEAR” Command.

“CLRTAB”
5F91H
DEFM …
START “.
5F99H
DEFM …
END “.
5FA1H
DEFM …
MEM “.
5FA9H
DEFB 00H
End of Table Delimeter.
5FAAH
DEFM …
CAN’T CLEAR WHILE DO IS ACTIVE” + 0DH.

5FC9H – “BUILD” Library Command..

“BUILD”
5FC9
CALL GETSYN
     [623AH]
GOSUB to 623AH to isolate and validate the FILESPEC from the command line via an OVERLAY call to ROUTINE 4 of OVERLAY 1.
5FCC
JP NZ,ERR3
      [5218H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5218H.
5FCF
LD HL,EXT5
LET Register Pair HL = 60CCH to point to a default file extension.
5FD2
CALL PUTEXT
     [444BH]
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.
5FD5
CALL INITIT
     [6234H]
GOSUB to 6234H to create a file.
5FD8
JP NZ,ERR
      [6132H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
5FDB
LD HL,BRKPMT
LET Register Pair HL = 602BH to point to the MESSAGE “HIT BREAK TO EXIT“.
5FDE
CALL PRINT
     [021BH]
GOSUB to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found.
“BUILD1”
5FE1
LD HL,S6PRMP
LET Register Pair HL = 600FH to point to the MESSAGE “TYPE UP TO 63 CHARACTERS“.
5FE4
CALL PRINT
     [021BH]
GOSUB to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found.
5FE7
LD B,3FH
LET Register B = 3FH (Decimal: 63) which is the maximum number of characters permitted.
5FE9
LD HL,S6BUF2
LET Register Pair HL = 6400H, which will act as a buffer for the 63 characters being typed in.
5FEC
CALL KEYN
     [0040H]
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.
5FEF
JR C,BLDEXT
     [6001H]
If the C FLAG (Carry) is set then the BREAK key was hit, so JUMP to 6001H.
5FF1
INC B
INCrement the value stored in Register B (i.e., the number of characters actually typed in) by 1.
5FF2
LD HLS6BUF2
LET Register Pair HL = 6400H, which will act as a buffer for the 63 characters being typed in.
“BUILD2”
5FF5
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.
5FF6
LD DE,S6DCB1
LET Register Pair DE = 6280H, which is the DCB address (which is needed for a call to 001BH).
5FF9
CALL PUT
     [001BH]
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.
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.
5FFD
DJNZ BUILD2
     [5FF5H]
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.
5FFF
JR BUILD1
   [5FE1H]
JUMP to 5FE1H to prompt for another line.

6001H – Contination of the “BUILD” Library Command; jumped to if a BREAK key was hit..

“BLDEXT”
6001
LD A,0FFH
LET Register A = 0FFH, which is an End of File designator.
6003
LD DE,S6DCB1
LET Register Pair DE = 6280H, which is the DCB address (which is needed for a call to 001BH).
6006
CALL PUT
     [001BH]
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
JP NZ,ERROR
      [4409H]
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
JP CLOZE1
   [56F6H]
JUMP to 56F6H to close the file and exit.

600FH – MESSAGE and BYTE STORAGE AREA for “BUILD”.

“BRKPMT”
600F
DEFM …
HIT BREAK TO EXIT” + 0DH.
“S6PRMP”
602B
DEFM …
TYPE UP TO 63 CHARACTERS” + 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 itis 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 bntes as the DCB for the DO file.

“DO”
603D
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.
6040
OR A
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A.
6041
JP NZ,ERR2
      [5214H]
If the NZ FLAG (Not Zero) is set, then the DO command is already active, so JUMP to 5214H to exit.
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).
6045
LD (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.
6049
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.
604C
LD (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.
604F
LD HL,(KDCB + 1)
Fetch the value stored at memory location 4016H (i.e., the keyboard driver address) and put it into Register HL.
6052
LD (GOSAVE),HL
Store the value held in Register HL into the memory location 42B1H.
6055
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.
6058
LD L,90H
LET Register L = 90H (Decimal: 144) so as to back up 144 bytes.
605A
LD (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).
605D
PUSH HL
Save Register Pair HL (i.e., the keyboard driver address) to the top of the stack.
605E
LD DE,GOGO4 – GOGO1 + 5
LET Register Pair DE = 002BH (Decimal: 43) as a 43 byte offset to the DCB.
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).
6062
LD (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.
6065
LD (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.
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.
606A
LD HL,GOGO1
LET Register Pair HL = 60A6H, which is the “DO” Driver Routine.
606D
LD BC,GOGO4 – GOGO1
LET Register Pair BC = 0026H (Decimal: 38).
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.
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.
6073
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.
6077
6078
6079
DEC D
DEC D
LD E,0E0H
Let Register Pair DE = 544 bytes before the end of RAM.
607B
LD (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.
607F
LD (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.
6083
LD DE,(TMPDCB)
Fetch the value stored at memory location 609BH (i.e., the DCB address) and put it into Register DE.
6087
CALL SYNTAX
     [441CH]
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.
608A
JP NZ,ERR3
      [5218H]
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 5218H.
608D
LD HL,EXT5
LET Register Pair HL = 60CCH to point to a default file extension.
6090
CALL PUTEXT
     [444BH]
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.

The next few instructions calculate a buffer address.

6093
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.
6096
LD DE,0020H
LET Register Pair DE = 0020H (Decimal: 32) for 32 characters.
6099
ADD HL,DE
LET Register Pair HL = Register Pair HL + Register DE.
609A
LD DE,TMPDBC
LET Register Pair DE = the value stored in memory location 609BH, which was put there elsewhere in this overlay. This is the DCB address.
609D
LD B,00H
LET Register B = 00H so as to set the file to a LRL = 0.
609F
CALL OPEN
     [4424H]
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.
60A2
JP NZ,ERROR
      [4409H]
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.
60A5
RET
RETurn to the caller.

60A6H – “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.

“GOGO1”
60A6
PUSH DE
Save Register Pair DE (i.e., the DCB address) to the top of the stack.
60A7
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.
60AA
CALL GET
     [0013H]
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.
60AD
JR Z,OKGO
     [60B8H]
If the Z FLAG (Zero) is set then there was no error, so JUMP to 60B8H.
60AF
AND 0FEH
MASK the value of Register A against 0FEH (1111 1110). This has the effect of turning off Bit 0.
60B1
CP 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
JP NZ,ERROR
      [4409H]
If the NZ FLAG (Not Zero) is set, JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.
60B6
JR GOGO3
   [60BEH]
JUMP to 60BEH to terminate the “DO” Execution.

60B8H – Continuation of the “DO” Command. Jumped here if there was an error in getting characters.

“OKGO”
60B8
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.
60BA
JR Z,GOGO3
     [60BEH]
If the Z FLAG (Zero) is set then we have an EOF, so JUMP to 60BEH to terminate the “DO” Execution.
“GOGO2”
60BC
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.
60BD
RET
RETurn to the caller.

60BEH – JUMP to 60BEH to terminate the “DO” Execution.

“GOGO3”
60BE
LD DE,(GOSAVE)
Fetch the value stored at memory location 42B1H (i.e., the saved driver address) and put it into Register DE.
60C2
LD (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).
60C6
XOR A
Set Register A to ZERO and clear all Flags.
60C7
LD (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
JR GOGO2
   [60BCH]
JUMP to 60BCH to restore the DCB address and RETurn.

60CCH – MESSAGE STORAGE AREA for “DO”.

60CCH
“EXT5”
DEFM …
BLD“.

60CFH – “PAUSE” Library Command.

SPAUSE
60CF
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.
60D0
LD HL,PRESNY
LET Register Pair HL = 60F8H, which is a pointer to the message “PRESS <ENTER> TO CONTINUE“.
60D3
CALL PRINT
     [021BH]
GOSUB to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found.
60D6
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.
60D9
OR A
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A.
60DA
JR NZ,SPAUS1
      [60EAH]
If the NZ FLAG (Not Zero) is set, then the “DO” command is active, so JUMP to 60EAH.
60DC
PUSH BC
Save Register Pair BC to the top of the stack.
“SPAUS0”
60DD
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.
60E2
CALL KEYN
     [0040H]
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.
60E5
JR C,SPAUS0
     [60DDH]
If the C FLAG (Carry) is set then the BREAK key was hit, so LOOP BACK to 60DDH and wait for another key.
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.
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 – Continuation of the “PAUSE” Library Command, Jumped here if the “DO” command is active.

“SPAUS1”
60EA
CALL GETCR
     [60EFH]
GOSUB to 60EFH to wait for an ENTER key.
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.
60EE
RET
RETurn to the caller.

60EFH – Continuation of the “PAUSE” Library Command. Subroutine to read the keyboard for an ENTER key.

“GETCR”
60EF
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.
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.
60F4
JR NZ,GETCR
      [60EFH]
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.
60F6
XOR A
Set Register A to ZERO and clear all Flags.
60F7
RET
RETurn to the caller.

60F8H – MESSAGE STORAGE AREA for “DO”.

“PRESNY”
60F8
DEFM …
PRESS <ENTER> TO CONTINUE” + 0DH
“BUFPNT”
DEFW 00H
 

6114H – “ERROR” Library Command.

“EZZOR”
6114
CALL DECCHK
     [541AH]
GOSUB to 541AH to convert a COMMAND LINE byte pair to decimal.
6117
JP NC,ERR2
      [5214H]
If the NC FLAG (No Carry) is set then that routine returned with an error, so JUMP to 5214H.
611A
LD E,A
LET Register E = Register A (i.e., the requested error code).
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.
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.
611E
LD A,E
LET Register A = Register E (i.e., the requested error code).
611F
JR C,EZZO1
     [6130H]
If the C FLAG (Carry) is set then Register A < SPACE, JUMP to 6130H.
6121
CALL DECCHK
     [541AH]
>GOSUB to 541AH to convert a COMMAND LINE byte pair to decimal.
6124
JP NC,ERR2
      [5214H]
If the NC FLAG (No Carry) is set then that routine returned with an error, so JUMP to 5214H.
6127
PUSH AF
Save Register Pair AF (i.e., the requested error code) to the top of the stack.
6128
LD A,E
LET Register A = Register E (i.e., the first digit of the requested error code).
6129
RLCA
RLCA
Let Register A = Register A * 4.
612B
ADD A,E
LET Register A = Register A + Register E, so Register A = original Register A * 5.
612C
RLCA
Rotate the bits in A left, so Register A = original Register A * 10.
612D
LD E,A
LET Register E = Register A, but moved to the TENS digit.
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.
612F
ADD A,E
LET Register A = Register A + Register E, so now we have both digits.
“EZZO1”
6130
OR 0C0H
OR Register A against 0C0H (1100 0000) to set the LONG ERROR MESSAGE bits (i.e., bits 7 and 6)
“ERRZ”
6132
JP ERROR
   [4409H]
JUMP to 4409H.
NOTE: 4409H is the SYS00/SYS routine to process DOS errors.

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

“PDATA”
6135
PUSH BC
Save Register Pair BC to the top of the stack.
6136
LD BC,(LPFLAG)
Fetch the value stored at memory location 5A4DH (i.e., the byte flag for PRINTER) and put it into Register BC.
613A
LD E,A
LET Register E = Register A (i.e., the character to output).
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.
613D
LD A,E
LET Register A = Register E (i.e., the character to output).
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.
613F
PUSH AF
Save Register Pair AF (i.e., the character to output) to the top of the stack.
6140
CALL NZ,PRT
        [003BH]
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.
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
JP DSP
   [0033H]
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.

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

“PRT2”
6147
PUSH BC
Save Register Pair BC to the top of the stack.
6148
LD BC,(LPFLAG)
Fetch the value stored at memory location 5A4DH (i.e., the byte flag for PRINTER) and put it into Register BC.
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.
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.
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.
6150
CALL NZ,LPRINT
        [6157H]
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.
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
JP PRINT
   [021BH]
JUMP to 021BH.
NOTE: 021BH will display the character at (HL) until a 03H is found.

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

“LPRINT”
6157
PUSH HL
Save Register Pair HL (i.e., the pointer to the messsage to be displayed or printed) to the top of the stack.
“LPRIN0”
6158
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.
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.
615B
JR Z,LPRIN1
     [6165H]
If the Z FLAG (Zero) is set, meaning that we a terminator, JUMP to 6165H to restore HL from the STACK and RETurn.
615D
CALL PRT
     [003BH]
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.
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.
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.
6163
JR NZ,LPRIN0
      [6158H]
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.
“LPRIN1”
6165
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.
6166
RET
RETurn to the caller.

6167H – SUBROUTINE in the “DIR” Library Routine to Start Processing a @ (aka Pause) request.

"INKEY"
6167
CALL BRKCHK
     [028DH]
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.
616A
JP NZ,ABORT
      [4030H]
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.
616D
CALL GETKBD
     [6188H]
GOSUB to 6188H to scan the keyboard.
6170
OR A
Set FLAGS based on the contents of Register A.
6171
RET Z
If the Z FLAG (Zero) is set, RETurn to the caller.
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.
6174
JR Z,HLDPAT
     [617CH]
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.
6177
LD B,A
LET Register B = Register A (i.e., the key which was pressed).
6178
XOR A
Set Register A to ZERO and clear all Flags to clear any error status.
6179
LD A,B
LET Register A = Register B (i.e., the key which was pressed).
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.
617B
RET
RETurn to the caller.

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

"HDLPAT"
617C
CALL KETKBD
     [6188H]
GOSUB to 6188H to scan the keyboard.
617F
OR A
Set FLAGS based on the contents of Register A.
6180
JR Z,HLDPAT
     [617CH]
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.
6184
JR NZ,HLDPAT
      [617CH]
If the NZ FLAG (Not Zero) is set then we still do not have a ENTER, JUMP back to 617CH and keep polling.
6186
XOR A
Set Register A to ZERO and clear all Flags.
6187
RET
RETurn to the caller.

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

"GETKBD"
6188
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.
618B
OR A
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A.
618C
JP Z,KBD
     [002BH]
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.

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.
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,KDCB
LET Register Pair IX = 4015H, which is the real keyboard DCB, so as to ignore any DO command rerouting of the keyboard.
6198
CALL KEYBDZ
     [3024H]
GOSUB to 3024H which is the Model III ROM Routine Vector to a routine to get keyboard input.
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.
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 - Part of the "CREATE" Library Command. Jumped here to insert a value into a message.

HEXS
61A1
PUSH AF
Save Register Pair AF to the top of the stack.
61A2
61A3
61A4
61A5
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.
61A6
CALL HEXS1
     [61AAH]
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.
"HEXS1"
61AA
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.

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 - 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.


"HEXAAS"
61B5
LD (HL),2FH
Store the character which precedes 0 into the memory location pointed to by Register Pair HL.

"HEXAA1"
61B7
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
JR NC,HEXAA1
      [61B7H]
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 - Part of the "DIR" Library Command to display the contents of Register Pair HL in decimal form.

"BINDEC"
61C1
LD A,20H
LET Register A = 20H (ASCII: SPACE).
61C3
LD B,02H
LET Register B = 02H for a loop of 2 times.
"L6OP30"
61C5
CALL PDATA
     [6135H]
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.
61C8
DJNZ L6OP30
     [61C5H]
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.
"BINDC1"
61CA
CALL 0A9AH
     [0A9AH]
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.
61CD
XOR A
Set Register A to ZERO and clear all Flags.
61CE
CALL 1034H
     [1034H]
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
CALL 0FD9H
     [0FD9H]
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.
"L6OP25"
61D8
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
CALL PDATA
     [6135H]
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
JR L6OP25
   [61D8H]
LOOP back to 61D8H and keep going until exited by hitting a 0.

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

"DPRT1"
61E1
DEFM '00'
 
"DELIM1"
61E3
DEFM ':'
 
"DPRT2"
61E4
DEFM '00'
 
"DELIM2"
61E6
DEFM ':'
 
"DPRT3"
61E7
DEFM '00' + 0DH
 

61EAH - 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 :.

"MSGPRT"
61EA
CALL MSGPR0
     [61F0H]
GOSUB to 61F0H to generate the text line of xx/xx/xx or yy:yy:yy.
61ED
JP PRINT
   [021BH]
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 - Part of the "DATE" and "TIME" Library Commands. This generates the text line of xx/xx/xx or yy:yy:yy.

"MSGPR0"
61F0
LD A,C
LET Register A = Register C (i.e., the / or :).
61F1
LD (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 (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,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
JR Z,MSGPR1
     [6203H]
If the Z FLAG (Zero) is set then we are processing the TIME, so JUMP to 6203H.
61FF
LD IX,MONTH
LET Register Pair IX = 421CH, which is the memory location holding the MONTH.
"MSGPR1"
6203
LD 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.
"MSGPR2"
6208
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
CALL HEXCOV
     [5E46H]
GOSUB to 5E46H to convert this into a two digit decimal number.
620F
620E
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
DJNZ MSGPR2
     [6208H]
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,DPRT1
LET Register Pair HL = 61E1H, which is the pointer to the message "00:00:00".
6217
RET
RETurn to the caller.

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

"REDIT"
6218
PUSH BC
Save Register Pair BC to the top of the stack.
6219
CALL GETDCB
     [622BH]
GOSUB to 622BH to set the variables for the following JUMP.
621C
CALL READ
     [4436H]
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.
6222
JP 6132H
   [6132H]
and then exit with a JUMP to 6132H.

6225H - Routine to OPEN from FILE 1.

"OPENIT"
6225
CALL GETDCB
     [622BH]
GOSUB to 622BH to set the variables for the following JUMP.
6228
JP OPEN
   [4424H]
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 - Routine to Set the Variables Needed for a JUMP to 4424H.

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

6234H - Routine to CREATE FILE 1.

"INITIT"
6234
CALL GETDCB
     [622BH]
GOSUB to 622BH to set the variables for the following JUMP.
6237
JP INIT
   [4420H]
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 - Routine to CHECK FILE 1.

"GETSYN"
623A
LD DE,S6DCB1
LET Register Pair DE = 6280H as the applicable DCB.
623D
JP SYNTAX
   [441CH]
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