5200H - Command Dispatcher
SYS1/SYS's 4E90H enters here (directly, or through RST 28H code 88H when SYS6/SYS is not yet in memory) with Register C = the library command's number in SYS1/SYS's second command table (1 APPEND to 19 VERIFY) and Register Pair HL = the command line after the command name. 402DH (DOS READY) is pushed as the return address of every command, then Register A counts down to the command's routine. A number outside 1-19 shows RESERVED COMMAND.
5200
LD A,C 79
Copy the command number from Register C into Register A, the counter for the dispatch chain below (1 APPEND, 2 ATTRIB ... 19 VERIFY, the order of SYS1/SYS's table at 4EBDH).
5201
LD BC,402DH 01 2D 40
Load Register Pair BC with 402DH, the DOS READY entry (JP 4400H) in SYS0/SYS's vector area.
5204
PUSH BC C5
Save Register Pair BC (402DH) onto the stack: every command's final RET goes to DOS READY.
5205
DEC A 3D
DECrement Register A (the command number) by 1: the Z FLAG is set for command 1.
5206
If the Z FLAG is set (command 1, APPEND), JUMP to 5700H.
5209
DEC A 3D
DECrement Register A (the command number) by 1: the Z FLAG is set for command 2.
520A
If the Z FLAG is set (command 2, ATTRIB), JUMP to 5B00H.
520D
DEC A 3D
DECrement Register A (the command number) by 1: the Z FLAG is set for command 3.
520E
If the Z FLAG is set (command 3, AUTO), JUMP to 5283H.
5211
DEC A 3D
DECrement Register A (the command number) by 1: the Z FLAG is set for command 4.
5212
If the Z FLAG is set (command 4, CLOCK), JUMP to 52C5H.
5215
DEC A 3D
DECrement Register A (the command number) by 1: the Z FLAG is set for command 5.
5216
If the Z FLAG is set (command 5, COPY), JUMP to 574FH.
5219
DEC A 3D
DECrement Register A (the command number) by 1: the Z FLAG is set for command 6.
521A
If the Z FLAG is set (command 6, DATE), JUMP to 529DH.
521D
DEC A 3D
DECrement Register A (the command number) by 1: the Z FLAG is set for command 7.
521E
If the Z FLAG is set (command 7, DEVICE), JUMP to 531DH.
5221
DEC A 3D
DECrement Register A (the command number) by 1: the Z FLAG is set for command 8.
5222
If the Z FLAG is set (command 8, DIR), JUMP to 5C6FH.
5225
DEC A 3D
DECrement Register A (the command number) by 1: the Z FLAG is set for command 9.
5226
If the Z FLAG is set (command 9, DUMP), JUMP to 57D7H.
5229
DEC A 3D
DECrement Register A (the command number) by 1: the Z FLAG is set for command 10.
522A
If the Z FLAG is set (command 10, FREE), JUMP to 5EE0H.
522D
DEC A 3D
DECrement Register A (the command number) by 1: the Z FLAG is set for command 11.
522E
If the Z FLAG is set (command 11, KILL), JUMP to 5914H.
5231
DEC A 3D
DECrement Register A (the command number) by 1: the Z FLAG is set for command 12.
5232
If the Z FLAG is set (command 12, LIB), JUMP to 533AH.
5235
DEC A 3D
DECrement Register A (the command number) by 1: the Z FLAG is set for command 13.
5236
If the Z FLAG is set (command 13, LIST), JUMP to 592CH.
5239
DEC A 3D
DECrement Register A (the command number) by 1: the Z FLAG is set for command 14.
523A
If the Z FLAG is set (command 14, LOAD), JUMP to 5994H.
523D
DEC A 3D
DECrement Register A (the command number) by 1: the Z FLAG is set for command 15.
523E
If the Z FLAG is set (command 15, PRINT), JUMP to 59ACH.
5241
DEC A 3D
DECrement Register A (the command number) by 1: the Z FLAG is set for command 16.
5242
If the Z FLAG is set (command 16, PROT), JUMP to 536AH.
5245
DEC A 3D
DECrement Register A (the command number) by 1: the Z FLAG is set for command 17.
5246
If the Z FLAG is set (command 17, RENAME), JUMP to 5F9CH.
5249
DEC A 3D
DECrement Register A (the command number) by 1: the Z FLAG is set for command 18.
524A
If the Z FLAG is set (command 18, TIME), JUMP to 52B1H.
524D
DEC A 3D
DECrement Register A (the command number) by 1: the Z FLAG is set for command 19.
524E
If the Z FLAG is set (command 19, VERIFY), JUMP to 5504H.
5251
LD HL,525AH 21 5A 52
Reserved Command
Point Register Pair HL to 525AH, the message RESERVED COMMAND: Register C was 0 or above 19, which SYS1/SYS's table never passes.
5254
GOSUB to SYS0/SYS's 4467H to display the text at Register Pair HL (525AH) up to and including its 0DH.
5257
JUMP to 4030H, the exit after an error (DOS READY, or DEBUG when DEBUG is on).
525A-526A
DEFM "RESERVED COMMAND" / DEFB 0DH 52 45 53 45 52 56 45 44 20 43 4F 4D 4D 41 4E 44 0D
Message for a command number outside 1-19, ended by 0DH (ENTER); shown by 5251H-5254H.
526BH - Nothing Done
PROT jumps here (53A3H) when none of PW, LOCK and UNLOCK was given, and ATTRIB (5B34H) when no parameter list follows the filespec.
526B
LD HL,5274H 21 74 52
Point Register Pair HL to 5274H, the message -NOTHING DONE-. 53A3H and 5B34H jump here.
526E
GOSUB to SYS0/SYS's 4467H to display the text at Register Pair HL (5274H) up to and including its 0DH.
5271
JUMP to 4030H, the exit after an error (DOS READY, or DEBUG when DEBUG is on).
5274-5282
DEFM "-NOTHING DONE-" / DEFB 0DH 2D 4E 4F 54 48 49 4E 47 20 44 4F 4E 45 2D 0D
Message shown by 526BH, ended by 0DH (ENTER).
5283H - AUTO (Command 3)
Copies 32 bytes of the command line, starting after the space that ends the word AUTO, into bytes E0H-FFH of the granule allocation table of drive 0, the place where SYS0/SYS's start-up looks for a command to run. The 32 bytes are copied whatever the length of the command, so the 0DH ending a short command is followed by whatever was in the command line buffer after it; AUTO with no command stores the 0DH first, which means no automatic command.
5283
LD C,00H 0E 00
Load Register C with 00H, drive 0, the drive SYS0/SYS starts from.
5285
GOSUB to SYS0/SYS's 4AF0H to read the granule allocation table of drive Register C (0) into 4D00H-4DFFH; it returns the NZ FLAG and Register A = 14H (GAT READ ERROR) on failure.
5288
If the NZ FLAG is set (the table could not be read), JUMP to 554CH to show the error in Register A.
528B
LD D,4DH 16 4D
Load Register D with 4DH, the high byte of 4DE0H.
528D
LD E,E0H 1E E0
Load Register E with E0H: Register Pair DE = 4DE0H, byte E0H of the table, where the automatic command is kept.
528F
LD BC,0020H 01 20 00
Load Register Pair BC with 0020H, the 32 bytes of the automatic command area (E0H-FFH).
5292
LDIR ED B0
Copy the command: LDIR moves 32 bytes from (HL) (Register Pair HL = the command line after AUTO and its space, or its 0DH when nothing follows) to (DE) (Register Pair DE = 4DE0H), counting Register Pair BC down to 0000H.
5294
LD C,00H 0E 00
Load Register C with 00H, drive 0 again (LDIR left Register Pair BC = 0000H).
5296
GOSUB to SYS0/SYS's 4B03H to write 4D00H-4DFFH back as the granule allocation table of drive Register C (0); it returns the NZ FLAG and Register A = 15H (GAT WRITE ERROR) on failure.
5299
If the NZ FLAG is set (the table could not be written), JUMP to 554CH to show the error in Register A.
529C
RET C9
RETURN to 402DH, DOS READY, which 5204H pushed.
529DH - DATE (Command 6)
DATE MM/DD/YY: three two-digit decimal numbers separated by slashes, read by 52EAH into 52DEH (month), 52DDH (day) and 52DCH (year) and copied into SYS0/SYS's date bytes 4044H (year), 4045H (day) and 4046H (month). The numbers are not checked against the length of a month or year; anything after the third number is ignored.
529D
LD C,2FH 0E 2F
Load Register C with 2FH, the slash that must separate the three numbers.
529F
GOSUB to 52EAH to read three two-digit numbers separated by Register C (the slash) from the command line at Register Pair HL into 52DEH, 52DDH and 52DCH; the NZ FLAG means a bad number or separator.
52A2
If the NZ FLAG is set (the date is not in the MM/DD/YY form), JUMP to 52D3H to display BAD FORMAT.
52A5
LD HL,52DCH 21 DC 52
Point Register Pair HL to 52DCH, the three values: year (52DCH), day (52DDH), month (52DEH).
52A8
LD DE,4044H 11 44 40
Point Register Pair DE to 4044H, SYS0/SYS's date: year (4044H), day (4045H), month (4046H).
52AB
LD BC,0003H 01 03 00
Load Register Pair BC with 0003H, the three bytes to copy.
52AE
LDIR ED B0
Copy the date: LDIR moves 3 bytes from (HL) (Register Pair HL = 52DCH) to (DE) (Register Pair DE = 4044H), counting Register Pair BC down to 0000H.
52B0
RET C9
RETURN to 402DH, DOS READY, which 5204H pushed.
52B1H - TIME (Command 18)
TIME HH:MM:SS: three two-digit decimal numbers separated by colons, read by 52EAH into 52DEH (hours), 52DDH (minutes) and 52DCH (seconds) and copied into SYS0/SYS's clock bytes 4041H (seconds), 4042H (minutes) and 4043H (hours). The numbers are not checked against 24 hours or 60 minutes; anything after the third number is ignored.
52B1
LD C,3AH 0E 3A
Load Register C with 3AH, the colon that must separate the three numbers.
52B3
GOSUB to 52EAH to read three two-digit numbers separated by Register C (the colon) from the command line at Register Pair HL into 52DEH, 52DDH and 52DCH; the NZ FLAG means a bad number or separator.
52B6
If the NZ FLAG is set (the time is not in the HH:MM:SS form), JUMP to 52D3H to display BAD FORMAT.
52B9
LD HL,52DCH 21 DC 52
Point Register Pair HL to 52DCH, the three values: seconds (52DCH), minutes (52DDH), hours (52DEH).
52BC
LD DE,4041H 11 41 40
Point Register Pair DE to 4041H, SYS0/SYS's clock: seconds (4041H), minutes (4042H), hours (4043H).
52BF
LD BC,0003H 01 03 00
Load Register Pair BC with 0003H, the three bytes to copy.
52C2
LDIR ED B0
Copy the time: LDIR moves 3 bytes from (HL) (Register Pair HL = 52DCH) to (DE) (Register Pair DE = 4041H), counting Register Pair BC down to 0000H.
52C4
RET C9
RETURN to 402DH, DOS READY, which 5204H pushed.
52C5H - CLOCK (Command 4)
CLOCK or CLOCK (ON) adds SYS0/SYS's time display task (the task control block at 4CA9H, which shows the time on the top line of the screen at 3C35H-3C3CH) to timer slot 6; CLOCK (OFF) removes it. The word in parentheses is read by SYS1/SYS's 51A0H, which is still in the overlay area at 4E00H-51FFH because SYS1/SYS has just dispatched this command.
52C5
GOSUB to SYS1/SYS's 51A0H to skip spaces and read an optional (ON) or (OFF) at Register Pair HL: it returns the Z FLAG for OFF (or any word other than Y or ON) and the NZ FLAG for ON or no parentheses.
52C8
LD DE,4CA9H 11 A9 4C
Point Register Pair DE to 4CA9H, SYS0/SYS's task control block for the time display (routine 4CACH, countdown 05H).
52CB
LD A,06H 3E 06
Load Register A with 06H, timer slot 6, the slot of the time display.
52CD
If the Z FLAG is set (OFF), JUMP to SYS0/SYS's 4413H to remove the task in slot Register A (6); it returns to 402DH.
52D0
JUMP to SYS0/SYS's 4410H to put the task control block at Register Pair DE (4CA9H) into slot Register A (6); it returns to 402DH.
52D3
LD HL,52DFH 21 DF 52
Bad Format
Point Register Pair HL to 52DFH, the message BAD FORMAT. 52A2H and 52B6H jump here.
52D6
GOSUB to SYS0/SYS's 4467H to display the text at Register Pair HL (52DFH) up to and including its 0DH.
52D9
JUMP to 4030H, the exit after an error (DOS READY, or DEBUG when DEBUG is on).
52DC-52DE
DEFS 3
Not in the file: the three values of DATE or TIME, stored by 52F5H from 52DEH downward (month or hours at 52DEH, day or minutes at 52DDH, year or seconds at 52DCH) and copied out by 52AEH or 52C2H.
52DF-52E9
DEFM "BAD FORMAT" / DEFB 0DH 42 41 44 20 46 4F 52 4D 41 54 0D
Message shown by 52D3H when DATE or TIME is not followed by three two-digit numbers with the right separator, ended by 0DH (ENTER).
52EAH - Read Three Two-Digit Numbers
Register Pair HL = the command line, Register C = the separator (2FH slash for DATE, 3AH colon for TIME). Reads a two-digit decimal number, stores it at 52DEH, and repeats for 52DDH and 52DCH, with Register C required between the numbers. Returns the Z FLAG when all three were read, the NZ FLAG for a bad digit or separator. Register Pair HL ends after the third number; what follows it is not looked at.
52EA
LD DE,52DEH 11 DE 52
Point Register Pair DE to 52DEH, where the first number goes; the numbers are stored downward to 52DCH. 529FH and 52B3H call here.
52ED
LD B,03H 06 03
Load Register B with 03H, the three numbers to read.
52EF
PUSH DE D5
Number Loop
Save Register Pair DE (the store pointer) onto the stack: 52FFH uses Register E. 52FCH loops back here.
52F0
GOSUB to 52FFH to read two decimal digits from (HL) (Register Pair HL = the command line pointer); it returns the Z FLAG with Register A = the value 0-99, or the NZ FLAG.
52F3
POP DE D1
Restore Register Pair DE (the store pointer) from the stack.
52F4
RET NZ C0
If the NZ FLAG is set (not two digits), RETURN with the NZ FLAG: BAD FORMAT.
52F5
LD (DE),A 12
Store Register A (the value) at (DE) (Register Pair DE = 52DEH, 52DDH or 52DCH).
52F6
DEC DE 1B
DECrement Register Pair DE by 1, to where the next number goes.
52F7
DEC B 05
DECrement Register B (the numbers left) by 1: the Z FLAG is set after the third number.
52F8
RET Z C8
If the Z FLAG is set (all three stored), RETURN with the Z FLAG: the date or time was read.
52F9
LD A,(HL) 7E
Fetch the character after the number from (HL) (Register Pair HL = the command line pointer) into Register A.
52FA
INC HL 23
INCrement Register Pair HL (the command line pointer) by 1, past that character.
52FB
CP C B9
Compare Register A (the character after the number) against Register C (the separator, slash or colon).
52FC
Number Loop End
If the Z FLAG is set (the separator), LOOP BACK to 52EFH to read the next number.
52FE
RET C9
RETURN with the NZ FLAG from the compare at 52FBH: a wrong separator, BAD FORMAT.
52FFH - Read Two Decimal Digits
Register Pair HL = the text. Reads two characters that must both be digits 0-9 and combines them as tens and units. Returns the Z FLAG with Register A = Register E = the value 0-99, or the NZ FLAG when either character is not a digit. Register Pair HL ends past the characters read.
52FF
GOSUB to 5316H to read the tens digit from (HL) (Register Pair HL = the text): Register A = the character minus 30H, the CARRY FLAG set when it is a digit. 52F0H calls here.
5302
If the NO CARRY FLAG is set (not a digit), JUMP to 5314H to return the NZ FLAG.
5304
LD E,A 5F
Copy the tens digit from Register A into Register E.
5305
RLCA 07
Rotate Register A (the tens digit, 0-9) left: times 2.
5306
RLCA 07
Rotate Register A left again: the tens digit times 4.
5307
ADD A,E 83
ADD Register E (the tens digit) to Register A: the tens digit times 5.
5308
RLCA 07
Rotate Register A left: the tens digit times 10.
5309
LD E,A 5F
Copy the tens value from Register A into Register E.
530A
GOSUB to 5316H to read the units digit from (HL) (Register Pair HL = the text pointer) into Register A, the CARRY FLAG set when it is a digit.
530D
If the NO CARRY FLAG is set (not a digit), JUMP to 5314H to return the NZ FLAG.
530F
ADD A,E 83
ADD Register E (the tens value) to Register A (the units digit): the number 0-99.
5310
LD E,A 5F
Copy the number from Register A into Register E.
5311
XOR A AF
Set Register A to ZERO with XOR A, which sets the Z FLAG (success); Register A is loaded again next.
5312
LD A,E 7B
Copy the number from Register E back into Register A; LD does not change the Z FLAG.
5313
RET C9
RETURN to 52F3H with the Z FLAG and Register A = the number.
5314
OR A B7
Not a Digit
OR Register A (the character minus 30H, 0AH or more, or a wrapped value) with itself: it is not zero, so the NZ FLAG is set. 5302H and 530DH jump here.
5315
RET C9
RETURN to 52F3H with the NZ FLAG: the number is not two digits.
5316H - Read One Digit
Register Pair HL = the text. Returns Register A = the character minus 30H and the CARRY FLAG set when the character is a digit 0-9; Register Pair HL is moved past the character.
5316
LD A,(HL) 7E
Fetch the character from (HL) (Register Pair HL = the text pointer) into Register A. 52FFH and 530AH call here.
5317
INC HL 23
INCrement Register Pair HL (the text pointer) by 1, past the character.
5318
SUB 30H D6 30
SUBtract 30H (the digit 0) from Register A: a digit becomes 00H-09H; a character below 30H wraps to 0D0H or more.
531A
CP 0AH FE 0A
Compare Register A against 0AH: the CARRY FLAG is set only for 00H-09H, a digit.
531C
RET C9
RETURN with Register A = the value and the CARRY FLAG for a digit.
531DH - DEVICE (Command 7)
Lists the two-letter names of SYS0/SYS's device table at 43C0H (KI keyboard, DO display, PR printer), one per line. The table has four bytes per device (the name, then the driver address) and ends with 00H at 43CCH. Only the names are shown.
531D
LD HL,43C0H 21 C0 43
Point Register Pair HL to 43C0H, SYS0/SYS's device table.
5320
LD A,(HL) 7E
Device Loop
Fetch the first letter of the device name from (HL) (Register Pair HL = the entry) into Register A. 5335H loops back here.
5321
INC L 2C
INCrement Register L by 1, so Register Pair HL points to the second letter (the table does not cross a 256-byte page).
5322
OR A B7
OR Register A (the first letter) with itself: the Z FLAG is set for the 00H that ends the table.
5323
If the Z FLAG is set (end of the table), JUMP to 5337H to go to DOS READY.
5325
GOSUB to ROM routine at 0033H to display the first letter in Register A.
5328
LD A,(HL) 7E
Fetch the second letter of the device name from (HL) (Register Pair HL = the entry plus 1) into Register A.
5329
GOSUB to ROM routine at 0033H to display the second letter in Register A.
532C
LD A,0DH 3E 0D
Load Register A with 0DH, ENTER, to end the line.
532E
GOSUB to ROM routine at 0033H to display Register A (0DH): the next name goes on the next line.
5331
LD A,L 7D
Copy Register L (the low byte of the entry plus 1) into Register A.
5332
ADD A,03H C6 03
ADD 03H to Register A: past the second letter and the two bytes of the driver address, to the next entry.
5334
LD L,A 6F
Copy Register A into Register L: Register Pair HL = the next entry.
5335
Device Loop End
If the NO CARRY FLAG is set (Register L did not pass FFH, which it never does in this table), LOOP BACK to 5320H for the next entry.
5337
JUMP to 402DH, DOS READY. 5323H jumps here at the end of the table.
533AH - LIB (Command 12)
Lists the names of the nineteen library commands from SYS1/SYS's second command table at 4EBDH, which is still in the overlay area: four names to a line, each line starting with two spaces and each name followed by eight. A table entry is eight bytes, six characters of name and the address of its handler; the table ends with 00H.
533A
LD HL,4EBDH 21 BD 4E
Point Register Pair HL to 4EBDH, the first entry of SYS1/SYS's library command table (APPEND).
533D
LD C,04H 0E 04
Line Loop
Load Register C with 04H, the names to put on one line. 5360H loops back here.
533F
LD A,C2H 3E C2
Load Register A with C2H, a space compression code: the display driver shows C0H-FFH as that many spaces minus C0H, here two.
5341
GOSUB to ROM routine at 0033H to display Register A (C2H): two spaces at the start of the line.
5344
LD B,06H 06 06
Name Loop
Load Register B with 06H, the six characters of a name. 5359H loops back here.
5346
LD A,(HL) 7E
Character Loop
Fetch the next character of the name from (HL) (Register Pair HL = the table pointer) into Register A. 534BH loops back here.
5347
INC HL 23
INCrement Register Pair HL (the table pointer) by 1.
5348
GOSUB to ROM routine at 0033H to display the character in Register A.
534B
Character Loop End
DECrement Register B and LOOP BACK to 5346H until the six characters are shown.
534D
LD A,C8H 3E C8
Load Register A with C8H, the space compression code for eight spaces.
534F
GOSUB to ROM routine at 0033H to display Register A (C8H): eight spaces after the name.
5352
INC HL 23
INCrement Register Pair HL (the table pointer) by 1, past the low byte of the handler address.
5353
INC HL 23
INCrement Register Pair HL by 1, past the high byte: Register Pair HL = the next entry.
5354
LD A,(HL) 7E
Fetch the first byte of the next entry from (HL) (Register Pair HL = the next entry) into Register A.
5355
OR A B7
OR Register A with itself: the Z FLAG is set for the 00H that ends the table.
5356
If the Z FLAG is set (no more names), JUMP to 5362H to end the last line.
5358
DEC C 0D
DECrement Register C (the names left on this line) by 1.
5359
Name Loop End
If the NZ FLAG is set (room on this line), LOOP BACK to 5344H for the next name.
535B
LD A,0DH 3E 0D
Load Register A with 0DH, ENTER, to end the full line.
535D
GOSUB to ROM routine at 0033H to display Register A (0DH).
5360
Line Loop End
LOOP BACK to 533DH to start the next line of four names.
5362
LD A,0DH 3E 0D
Load Register A with 0DH, ENTER, to end the last line. 5356H jumps here.
5364
GOSUB to ROM routine at 0033H to display Register A (0DH).
5367
JUMP to 402DH, DOS READY, after the list of library command names.
536AH - PROT (Command 16)
PROT [:d] (PW,LOCK,UNLOCK) works on the master password of a diskette, kept as a hash at bytes CEH-CFH of its granule allocation table. It refuses to run while bit 5 of the system flags at 430FH is set. The person must type the current master password; PW then asks for a new one and writes it to the table, LOCK gives every user file on the diskette the master password as both its passwords, and UNLOCK gives them the blank password (the hash of eight spaces, 4296H). The first two directory entries of every directory sector, the places of the system files, and entries with bit 3 of their attributes set are left alone.
536A
LD A,(430FH) 3A 0F 43
Fetch the system flags from 430FH into Register A.
536D
BIT 5,A CB 6F
Test bit 5 of Register A (the system flags), the bit this command's message calls program chaining.
536F
If the NZ FLAG is set (bit 5 set), JUMP to 546EH to display INVALID COMMAND DURING PROGRAM CHAINING.
5372
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, the value of a parameter that was not given.
5375
LD (53D9H),BC ED 43 D9 53
Store Register Pair BC (0000H) into 53D9H, the operand of LD DE,nnnn at 53D8H and the variable of the parameter PW.
5379
LD (53F9H),BC ED 43 F9 53
Store Register Pair BC (0000H) into 53F9H, the operand of LD DE,nnnn at 53F8H and the variable of the parameter LOCK.
537D
LD (5403H),BC ED 43 03 54
Store Register Pair BC (0000H) into 5403H, the operand of LD DE,nnnn at 5402H and the variable of the parameter UNLOCK.
5381
LD C,00H 0E 00
Load Register C with 00H, drive 0, used when no drive is given.
5383
LD A,(HL) 7E
Fetch the first character after PROT from (HL) (Register Pair HL = the command line) into Register A.
5384
CP 3AH FE 3A
Compare Register A against 3AH, the colon before a drive number.
5386
If the NZ FLAG is set (no drive given), JUMP to 538EH with drive 0.
5388
INC HL 23
INCrement Register Pair HL (the command line pointer) by 1, past the colon.
5389
LD A,(HL) 7E
Fetch the drive digit from (HL) (Register Pair HL = the command line pointer) into Register A.
538A
SUB 30H D6 30
SUBtract 30H from Register A, turning the digit into a drive number; the character is not checked to be a digit 0-3.
538C
LD C,A 4F
Copy the drive number from Register A into Register C.
538D
INC HL 23
INCrement Register Pair HL (the command line pointer) by 1, past the digit.
538E
LD A,C 79
Copy the drive number from Register C into Register A. 5386H jumps here.
538F
LD (53BCH),A 32 BC 53
Store Register A (the drive) into 53BCH, the operand of LD C,nn at 53BBH, read again at 53EBH and 540FH.
5392
LD DE,54EBH 11 EB 54
Point Register Pair DE to 54EBH, the parameter table: PW, LOCK and UNLOCK with the addresses of their variables.
5395
GOSUB to SYS0/SYS's 4476H to read the parameter list at Register Pair HL against the table at Register Pair DE; a parameter named without a value stores FFFFH in its variable. The result flags are not tested.
5398
LD A,(53D9H) 3A D9 53
Fetch the low byte of the PW variable from 53D9H into Register A.
539B
LD HL,53F9H 21 F9 53
Point Register Pair HL to 53F9H, the low byte of the LOCK variable.
539E
OR (HL) B6
OR Register A with the LOCK variable's low byte at (HL) (Register Pair HL = 53F9H).
539F
LD HL,5403H 21 03 54
Point Register Pair HL to 5403H, the low byte of the UNLOCK variable.
53A2
OR (HL) B6
OR Register A with the UNLOCK variable's low byte at (HL) (Register Pair HL = 5403H): the Z FLAG is set when none of the three was given (only the low bytes are looked at).
53A3
If the Z FLAG is set (no parameter), JUMP to 526BH to display -NOTHING DONE-.
53A6
LD A,03H 3E 03
Load Register A with 03H, the end mark of a filespec.
53A8
LD DE,5551H 11 51 55
Point Register Pair DE to 5551H, the first FCB of SYS6/SYS.
53AB
LD (DE),A 12
Store Register A (03H) at (DE) (Register Pair DE = 5551H): the FCB holds an empty filespec.
53AC
GOSUB to SYS0/SYS's 4424H to open the empty filespec in the FCB at Register Pair DE (5551H). The result is not tested; what the call leaves behind is SYS2/SYS in the overlay area at 4E00H, whose password hash routine at 50D1H the password input at 5454H jumps to.
53AF
LD HL,54A0H 21 A0 54
Point Register Pair HL to 54A0H, the prompt MASTER PASSWORD ?.
53B2
GOSUB to SYS0/SYS's 4467H to display the prompt at Register Pair HL; it ends with 03H, so the cursor stays on the line.
53B5
GOSUB to 5454H to read up to eight characters from the keyboard and return their password hash in Register Pair HL.
53B8
LD (5168H),HL 22 68 51
Store Register Pair HL (the hash of the password typed) into 5168H, a word in the work area after SYS2/SYS's loaded bytes.
53BB
LD C,00H 0E 00
Load Register C with the drive stored at 53BCH by 538FH (00H in the file).
53BD
GOSUB to SYS0/SYS's 4AF0H to read the granule allocation table of drive Register C into 4D00H-4DFFH; Register A = 14H and the NZ FLAG on failure.
53C0
If the NZ FLAG is set (the table could not be read), JUMP to 554CH to show the error in Register A.
53C3
LD HL,(4DCEH) 2A CE 4D
Fetch the master password hash from 4DCEH (bytes CEH-CFH of the table) into Register Pair HL.
53C6
LD DE,(5168H) ED 5B 68 51
Fetch the hash of the password typed from 5168H into Register Pair DE.
53CA
XOR A AF
Set Register A to ZERO with XOR A, which also clears the CARRY FLAG for the subtraction.
53CB
SBC HL,DE ED 52
SUBtract Register Pair DE (the hash typed) from Register Pair HL (the master hash): the Z FLAG is set when they are equal.
53CD
If the Z FLAG is set (the right master password), JUMP to 53D8H.
53CF
LD HL,54D2H 21 D2 54
Point Register Pair HL to 54D2H, the message INVALID MASTER PASSWORD.
53D2
GOSUB to SYS0/SYS's 4467H to display the text at Register Pair HL (54D2H) up to and including its 0DH.
53D5
JUMP to 4030H, the exit after an error (DOS READY, or DEBUG when DEBUG is on).
53D8
LD DE,0000H 11 00 00
PW: A New Master Password
Load Register Pair DE with the PW variable, the operand at 53D9H (0000H in the file, cleared at 5375H, FFFFH or a value when PW was given). 53CDH jumps here.
53DB
LD A,D 7A
Copy the high byte of the PW variable from Register D into Register A.
53DC
OR E B3
OR Register A with Register E (the low byte): the Z FLAG is set when PW was not given.
53DD
If the Z FLAG is set (no PW), JUMP to 53F5H to look at LOCK and UNLOCK.
53DF
LD HL,54B9H 21 B9 54
Point Register Pair HL to 54B9H, the prompt NEW MASTER PASSWORD ?.
53E2
GOSUB to SYS0/SYS's 4467H to display the prompt at Register Pair HL; it ends with 03H, so the cursor stays on the line.
53E5
GOSUB to 5454H to read the new password and return its hash in Register Pair HL.
53E8
LD (4DCEH),HL 22 CE 4D
Store Register Pair HL (the hash of the new password) into 4DCEH, the master password hash in the table at 4D00H.
53EB
LD A,(53BCH) 3A BC 53
Fetch the drive from 53BCH (stored by 538FH) into Register A.
53EE
LD C,A 4F
Copy the drive from Register A into Register C.
53EF
GOSUB to SYS0/SYS's 4B03H to write 4D00H-4DFFH back as the granule allocation table of drive Register C; Register A = 15H and the NZ FLAG on failure.
53F2
If the NZ FLAG is set (the table could not be written), JUMP to 554CH to show the error in Register A.
53F5
LD HL,(4DCEH) 2A CE 4D
LOCK and UNLOCK
Fetch the master password hash from 4DCEH (the new one when PW was given) into Register Pair HL. 53DDH jumps here.
53F8
LD DE,0000H 11 00 00
Load Register Pair DE with the LOCK variable, the operand at 53F9H (0000H in the file, cleared at 5379H; FFFFH or a value when LOCK was given).
53FB
LD A,D 7A
Copy the high byte of the LOCK variable from Register D into Register A.
53FC
OR E B3
OR Register A with Register E (the low byte): the NZ FLAG is set when LOCK was given.
53FD
If the NZ FLAG is set (LOCK), JUMP to 540CH with Register Pair HL = the master password hash.
53FF
LD HL,4296H 21 96 42
Load Register Pair HL with 4296H, the hash of a blank password (eight spaces), for UNLOCK.
5402
LD DE,0000H 11 00 00
Load Register Pair DE with the UNLOCK variable, the operand at 5403H (0000H in the file, cleared at 537DH; FFFFH or a value when UNLOCK was given).
5405
LD A,D 7A
Copy the high byte of the UNLOCK variable from Register D into Register A.
5406
OR E B3
OR Register A with Register E (the low byte): the NZ FLAG is set when UNLOCK was given.
5407
If the NZ FLAG is set (UNLOCK), JUMP to 540CH with Register Pair HL = 4296H.
5409
JUMP to 402DH, DOS READY: only PW was given and it is done.
540C
LD (5430H),HL 22 30 54
Set the Passwords of the User Files
Store Register Pair HL (the hash to give every file: the master hash for LOCK, 4296H for UNLOCK) into 5430H, the operand of LD DE,nnnn at 542FH. 53FDH and 5407H jump here.
540F
LD A,(53BCH) 3A BC 53
Fetch the drive from 53BCH (stored by 538FH) into Register A.
5412
LD C,A 4F
Copy the drive from Register A into Register C.
5413
GOSUB to SYS0/SYS's 4B55H: Register D = the directory track of drive Register C.
5416
LD E,02H 1E 02
Load Register E with 02H, directory sector 2, the first sector of directory entries.
5418
LD HL,4200H 21 00 42
Sector Loop
Point Register Pair HL to 4200H, SYS0/SYS's system sector buffer. 544FH loops back here.
541B
GOSUB to SYS0/SYS's 4B35H to read drive Register C, track Register D, sector Register E into 4200H (a system sector with the FAH data mark); Register A = the error number and the NZ FLAG on failure.
541E
If the NZ FLAG is set (a read error), JUMP to 554CH to show the error in Register A.
5421
LD L,40H 2E 40
Load Register L with 40H: Register Pair HL = 4240H, the third entry of the sector. Entries 00H and 20H of every directory sector are the places of the system files and are not changed.
5423
LD A,(HL) 7E
Entry Loop
Fetch the attribute byte of the entry from (HL) (Register Pair HL = the entry) into Register A. 5440H loops back here.
5424
AND F8H E6 F8
AND Register A with F8H, dropping the access level in bits 0-2.
5426
CP 10H FE 10
Compare Register A against 10H: the Z FLAG is set for an entry in use (bit 4) that is not a continuation entry (bit 7), not a system file (bit 6) and not invisible (bit 3).
5428
If the NZ FLAG is set (not such an entry), JUMP to 543AH to go to the next entry.
542A
LD A,L 7D
Copy Register L (the low byte of the entry address) into Register A.
542B
ADD A,10H C6 10
ADD 10H to Register A, the offset of the entry's first password hash.
542D
LD L,A 6F
Copy Register A into Register L: Register Pair HL = the entry plus 10H.
542E
PUSH DE D5
Save Register Pair DE (Register D = track, Register E = sector) onto the stack.
542F
LD DE,0000H 11 00 00
Load Register Pair DE with the hash stored at 5430H by 540CH (0000H in the file).
5432
LD (HL),E 73
Store Register E (the low byte of the hash) at (HL) (Register Pair HL = the entry plus 10H), the owner password hash.
5433
INC L 2C
INCrement Register L by 1, to the entry plus 11H.
5434
LD (HL),D 72
Store Register D (the high byte of the hash) at (HL) (Register Pair HL = the entry plus 11H).
5435
INC L 2C
INCrement Register L by 1, to the entry plus 12H, the user password hash.
5436
LD (HL),E 73
Store Register E (the low byte of the hash) at (HL) (Register Pair HL = the entry plus 12H).
5437
INC L 2C
INCrement Register L by 1, to the entry plus 13H.
5438
LD (HL),D 72
Store Register D (the high byte of the hash) at (HL) (Register Pair HL = the entry plus 13H): both passwords of the file are now the same.
5439
POP DE D1
Restore Register Pair DE (Register D = track, Register E = sector) from the stack.
543A
LD A,L 7D
Next Entry
Copy Register L (somewhere in the entry) into Register A. 5428H jumps here.
543B
AND E0H E6 E0
AND Register A with E0H, back to the start of the 32-byte entry.
543D
ADD A,20H C6 20
ADD 20H to Register A, the next entry; the CARRY FLAG is set after the eighth entry.
543F
LD L,A 6F
Copy Register A into Register L: Register Pair HL = the next entry.
5440
Entry Loop End
If the NO CARRY FLAG is set (still in this sector), LOOP BACK to 5423H.
5442
LD HL,4200H 21 00 42
Point Register Pair HL to 4200H, the sector just changed.
5445
GOSUB to SYS0/SYS's 46EFH to write 4200H to drive Register C, track Register D, sector Register E with the FAH data mark of a directory sector; Register A = the error number and the NZ FLAG on failure.
5448
If the NZ FLAG is set (a write error), JUMP to 554CH to show the error in Register A.
544B
INC E 1C
INCrement Register E (the directory sector number) by 1, to the next sector.
544C
LD A,E 7B
Copy the sector from Register E into Register A.
544D
CP 0AH FE 0A
Compare Register A against 0AH: the CARRY FLAG is set while the sector is 9 or less.
544F
Sector Loop End
If the CARRY FLAG is set, LOOP BACK to 5418H for the next directory sector.
5451
JUMP to 402DH, DOS READY, when sectors 2-9 have all been changed.
5454H - Read a Password
Reads up to eight characters typed at the keyboard into 5600H through the ROM's line input, pads them with spaces to eight characters and jumps to SYS2/SYS's 50D1H, which returns their hash in Register Pair HL. SYS2/SYS must be in the overlay area. The padding loop counts 8 minus the characters typed: when all eight are typed the count is 0 and DJNZ writes 256 spaces, from 5608H to 5707H, over the first bytes of APPEND at 5700H. BREAK is not tested.
5454
LD B,08H 06 08
Load Register B with 08H, the most characters the ROM's line input will accept. 53B5H and 53E5H call here.
5456
LD HL,5600H 21 00 56
Point Register Pair HL to 5600H, the buffer for the characters.
5459
GOSUB to ROM routine at 0040H to read a line into the buffer at Register Pair HL, at most Register B characters; it stores 0DH after them and returns Register Pair HL = 5600H, Register B = the number of characters typed, and the CARRY FLAG for BREAK.
545C
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = 5600H, the password for 50D1H.
545D
LD H,00H 26 00
Load Register H with 00H, the high byte of the count about to go into Register Pair HL.
545F
LD L,B 68
Copy the count from Register B into Register L: Register Pair HL = the number of characters typed.
5460
ADD HL,DE 19
ADD Register Pair DE (5600H) to Register Pair HL: Register Pair HL = the first byte after the characters (where the 0DH is).
5461
LD A,08H 3E 08
Load Register A with 08H, the length of a password.
5463
SUB B 90
SUBtract Register B (the characters typed) from Register A: the spaces needed.
5464
LD B,A 47
Copy the spaces needed from Register A into Register B; 00H when eight characters were typed.
5465
LD A,20H 3E 20
Load Register A with 20H, a space, the padding character of a password.
5467
LD (HL),A 77
Pad Loop
Store Register A (a space) at (HL) (Register Pair HL = the buffer pointer). 5469H loops back here.
5468
INC HL 23
INCrement Register Pair HL (the buffer pointer) by 1.
5469
Pad Loop End
DECrement Register B and LOOP BACK to 5467H until it reaches 00H; starting from 00H, this runs 256 times.
546B
JUMP to SYS2/SYS's 50D1H to hash the eight bytes at Register Pair DE (5600H); it returns to 53B8H or 53E8H with the hash in Register Pair HL.
546E
LD HL,5477H 21 77 54
Refused While Chaining
Point Register Pair HL to 5477H, the message INVALID COMMAND DURING PROGRAM CHAINING. 536FH jumps here.
5471
GOSUB to SYS0/SYS's 4467H to display the text at Register Pair HL (5477H) up to and including its 0DH.
5474
JUMP to 4030H, the exit after an error (DOS READY, or DEBUG when DEBUG is on).
5477-549F
DEFB 0AH / DEFM "INVALID COMMAND DURING PROGRAM CHAINING" / DEFB 0DH 0A 49 4E 56 41 4C 49 44 20 43 4F 4D 4D 41 4E 44 20 44 55 52 49 4E 47 20 50 52 4F 47 52 41 4D 20 43 48 41 49 4E 49 4E 47 0D
Message shown by 546EH: a line feed, the text and 0DH (ENTER).
54A0-54B8
DEFB 0AH / DEFM "MASTER PASSWORD ? " / DEFB 03H 0A 4D 41 53 54 45 52 20 50 41 53 53 57 4F 52 44 20 3F 20 20 20 20 20 20 03
Prompt shown by 53AFH: a line feed, the text with six spaces after the question mark, and 03H, the end mark that leaves the cursor on the line.
54B9-54D1
DEFB 0AH / DEFM "NEW MASTER PASSWORD ? " / DEFB 03H 0A 4E 45 57 20 4D 41 53 54 45 52 20 50 41 53 53 57 4F 52 44 20 3F 20 20 03
Prompt shown by 53DFH for PW: a line feed, the text with two spaces after the question mark, and 03H, which leaves the cursor on the line.
54D2-54EA
DEFB 0AH / DEFM "INVALID MASTER PASSWORD" / DEFB 0DH 0A 49 4E 56 41 4C 49 44 20 4D 41 53 54 45 52 20 50 41 53 53 57 4F 52 44 0D
Message shown by 53CFH when the password typed does not hash to the table's master hash: a line feed, the text and 0DH (ENTER).
54EBH - PROT Parameter Table
Three eight-byte entries for SYS1/SYS's parameter reader (4476H): six characters of name, then the address of the two-byte variable the value goes into. The variables are the operands of the LD DE,nnnn instructions that test them. 00H ends the table.
54EB-54F2
DEFM "PW " / DEFW 53D9H 50 57 20 20 20 20 D9 53
Parameter PW (new master password): its value goes into 53D9H-53DAH, read at 53D8H.
54F3-54FA
DEFM "LOCK " / DEFW 53F9H 4C 4F 43 4B 20 20 F9 53
Parameter LOCK (give every user file the master password): its value goes into 53F9H-53FAH, read at 53F8H.
54FB-5502
DEFM "UNLOCK" / DEFW 5403H 55 4E 4C 4F 43 4B 03 54
Parameter UNLOCK (give every user file the blank password): its value goes into 5403H-5404H, read at 5402H.
5503
DEFB 00H 00
End of the PROT parameter table: SYS1/SYS's table lookup stops at an entry starting with 00H.
5504H - VERIFY (Command 19)
VERIFY or VERIFY (ON) makes every write through SYS0/SYS's 4439H read the sector back, by putting 47A8H (the write with verify, 443CH's routine) into the operand of the JP at 4439H; VERIFY (OFF) puts back 478BH, the plain write. 60CDH also sets SYS0/SYS's switch at 485EH (01H on, 00H off). The file first loads 21 8B 47 (LD HL,478BH) at 5507H; a later load record replaces those three bytes with CALL 60CDH.
5504
GOSUB to SYS1/SYS's 51A0H to skip spaces and read an optional (ON) or (OFF) at Register Pair HL: the Z FLAG with Register A = 00H for OFF (or any word other than Y or ON), the NZ FLAG for ON or no parentheses.
5507
GOSUB to 60CDH: Register Pair HL = 478BH, and 485EH = 00H for OFF or 01H for ON; the Z FLAG still tells OFF from ON. This instruction is the patch loaded by the record at 5507H-5509H.
550A
If the Z FLAG is set (OFF), JUMP to 550FH with Register Pair HL = 478BH, the plain write.
550C
LD HL,47A8H 21 A8 47
Load Register Pair HL with 47A8H, SYS0/SYS's write with verify (the routine of 443CH).
550F
LD (443AH),HL 22 3A 44
Store Register Pair HL (478BH or 47A8H) into 443AH, the operand of the JP at SYS0/SYS's 4439H (write). 550AH jumps here.
5512
JUMP to 402DH, DOS READY, with the write entry 4439H now set for VERIFY on or off.
5515H - Test for BREAK and Pause
Called between records by APPEND (57C6H), LIST (5976H), PRINT (59D1H) and DIR (5DB7H). Returns the Z FLAG to go on and the NZ FLAG when BREAK is pressed. A key that gives 60H (SHIFT with @) pauses until any key is pressed; BREAK during the pause also returns the NZ FLAG. With bit 5 of the system flags at 430FH set, it returns the Z FLAG at once without looking at the keyboard.
5515
LD A,(430FH) 3A 0F 43
Fetch the system flags from 430FH into Register A. 57C6H, 5976H, 59D1H and 5DB7H call here.
5518
AND 20H E6 20
AND Register A with 20H, keeping bit 5 (the bit PROT calls program chaining).
551A
XOR 20H EE 20
XOR Register A with 20H: Register A = 00H and the Z FLAG when bit 5 was set.
551C
RET Z C8
If the Z FLAG is set (bit 5 set), RETURN with the Z FLAG: go on without testing the keyboard.
551D
LD A,(3840H) 3A 40 38
Fetch keyboard row 6 from 3840H into Register A; bit 2 is the BREAK key.
5520
AND 04H E6 04
AND Register A with 04H, keeping the BREAK bit: the NZ FLAG is set while BREAK is held down.
5522
RET NZ C0
If the NZ FLAG is set (BREAK), RETURN with the NZ FLAG: the caller stops.
5523
GOSUB to ROM routine at 002BH to scan the keyboard once; Register A = the key pressed, or 00H for none.
5526
CP 60H FE 60
Compare Register A (the key) against 60H, the code of SHIFT with @.
5528
If the Z FLAG is set (SHIFT and @), JUMP to 552CH to pause.
552A
XOR A AF
Set Register A to ZERO with XOR A, which sets the Z FLAG: go on.
552B
RET C9
RETURN to the caller with the Z FLAG (no BREAK, no pause).
552C
LD A,(3840H) 3A 40 38
Pause Loop
Fetch keyboard row 6 from 3840H into Register A; bit 2 is the BREAK key. 5528H jumps here; 5536H loops back here.
552F
AND 04H E6 04
AND Register A with 04H, keeping the BREAK bit.
5531
RET NZ C0
If the NZ FLAG is set (BREAK), RETURN with the NZ FLAG: the caller stops.
5532
GOSUB to ROM routine at 002BH to scan the keyboard once; Register A = the key pressed, or 00H for none.
5535
OR A B7
OR Register A (the key) with itself: the Z FLAG is set when no key is pressed.
5536
Pause Loop End
If the Z FLAG is set (no key), LOOP BACK to 552CH and keep waiting.
5538
XOR A AF
Set Register A to ZERO with XOR A, which sets the Z FLAG: a key ended the pause.
5539
RET C9
RETURN to the caller with the Z FLAG: the pause is over and the caller goes on.
553AH - Error Exits
553AH shows FILE SPEC REQUIRED for a missing or bad filespec or a device name where a file is needed. 5543H shows DEVICE SPEC REQUIRED; nothing in SYS6/SYS jumps to it. 554CH shows a disk error from SYS0/SYS through the error message routine 4409H with bit 6 set, so only the text of the message is shown, without the ERRCOD line or the file and REFERENCED AT lines; SYS4/SYS then goes to 4030H.
553A
LD HL,5591H 21 91 55
Point Register Pair HL to 5591H, the message FILE SPEC REQUIRED. Every command that parses a filespec jumps here when the parse fails or (except COPY, KILL and RENAME's new name) the name starts with an asterisk.
553D
GOSUB to SYS0/SYS's 4467H to display the text at Register Pair HL (5591H) up to and including its 0DH.
5540
JUMP to 4030H, the exit after an error (DOS READY, or DEBUG when DEBUG is on).
5543
LD HL,55A5H 21 A5 55
Point Register Pair HL to 55A5H, the message DEVICE SPEC REQUIRED. No instruction in SYS6/SYS jumps to 5543H.
5546
GOSUB to SYS0/SYS's 4467H to display the text at Register Pair HL (55A5H) up to and including its 0DH.
5549
JUMP to 4030H, the exit after an error (DOS READY, or DEBUG when DEBUG is on).
554C
OR 40H F6 40
Disk Error
OR Register A (the error number from SYS0/SYS or SYS2/SYS) with 40H: bit 6 asks SYS4/SYS for the message text only. Forty places jump here.
554E
JUMP to SYS0/SYS's 4409H to show the error message for Register A; with bit 7 clear SYS4/SYS goes on to 4030H.
5551-5570
DEFS 32
Not in the file: the first FCB of SYS6/SYS (the source file, or the only file). 441CH puts the filespec text here; an open turns it into a file control block: 5552H access bits, 5557H drive, 5558H directory entry locator, 5559H end-of-file byte, 555AH record length.
5571-5590
DEFS 32
Not in the file: the second FCB (the destination of APPEND and COPY, the new name of RENAME). 5579H-557AH hold its end-of-file byte and record length, set by COPY at 579EH.
5591-55A4
DEFB 0AH / DEFM "FILE SPEC REQUIRED" / DEFB 0DH 0A 46 49 4C 45 20 53 50 45 43 20 52 45 51 55 49 52 45 44 0D
Message shown by 553AH: a line feed, the text and 0DH (ENTER).
55A5-55BA
DEFB 0AH / DEFM "DEVICE SPEC REQUIRED" / DEFB 0DH 0A 44 45 56 49 43 45 20 53 50 45 43 20 52 45 51 55 49 52 45 44 0D
Message shown by 5543H: a line feed, the text and 0DH (ENTER). Nothing jumps to 5543H, so it is never shown.
55BB-55FF
DEFS 69
Not in the file and not used by SYS6/SYS: nothing reads or writes 55BBH-55FFH.
5600-56FF
DEFS 256
Not in the file: the sector buffer of the first FCB opened by APPEND (the destination), COPY (shared by both files), DUMP, LIST and PRINT, and the keyboard buffer of PROT's password input (5454H).
5700H - APPEND (Command 1)
APPEND file1 TO file2 adds the bytes of file1 to the end of file2. Both must be files (a name starting with an asterisk is refused with FILE SPEC REQUIRED) and both must exist. file2 is opened with the buffer at 5600H and positioned at its end, file1 with the buffer at 6F00H; the copy loop at 57B6H then moves one byte at a time through the ROM's device routines until file1 ends or BREAK is pressed, and both files are closed.
5700
LD DE,5551H 11 51 55
Point Register Pair DE to 5551H, the first FCB, for file1 (the file to add).
5703
GOSUB to SYS0/SYS's 441CH to parse the filespec at Register Pair HL (the command line) into the FCB at Register Pair DE; the NZ FLAG for a bad filespec. Register Pair HL is left past it, with a noise word such as TO skipped.
5706
If the NZ FLAG is set (no valid filespec), JUMP to 553AH to display FILE SPEC REQUIRED.
5709
LD A,(DE) 1A
Fetch the first character of the parsed name from (DE) (Register Pair DE = 5551H) into Register A.
570A
CP 2AH FE 2A
Compare Register A against 2AH, the asterisk that starts a device name such as the printer's PR.
570C
If the Z FLAG is set (a device), JUMP to 553AH to display FILE SPEC REQUIRED.
570F
LD DE,5571H 11 71 55
Point Register Pair DE to 5571H, the second FCB, for file2 (the file added to).
5712
GOSUB to SYS0/SYS's 441CH to parse the next filespec at Register Pair HL into the FCB at Register Pair DE (5571H); the NZ FLAG for a bad filespec.
5715
If the NZ FLAG is set (no valid filespec), JUMP to 553AH to display FILE SPEC REQUIRED.
5718
LD A,(DE) 1A
Fetch the first character of the parsed name from (DE) (Register Pair DE = 5571H) into Register A.
5719
CP 2AH FE 2A
Compare Register A against 2AH, the asterisk of a device name.
571B
If the Z FLAG is set (a device), JUMP to 553AH to display FILE SPEC REQUIRED.
571E
LD B,00H 06 00
Load Register B with 00H, the logical record length: 00H means whole 256-byte sectors.
5720
LD HL,5600H 21 00 56
Point Register Pair HL to 5600H, the buffer for file2.
5723
GOSUB to SYS0/SYS's 4424H to open the existing file2 in the FCB at Register Pair DE (5571H) with the buffer at Register Pair HL and the record length in Register B; Register A = the error number and the NZ FLAG on failure (18H when it is not in the directory).
5726
If the NZ FLAG is set (file2 could not be opened), JUMP to 554CH to show the error in Register A.
5729
LD B,00H 06 00
Load Register B with 00H, whole sectors again.
572B
LD DE,5551H 11 51 55
Point Register Pair DE to 5551H, the FCB of file1.
572E
LD HL,6F00H 21 00 6F
Point Register Pair HL to 6F00H, the buffer for file1, the last 256 bytes below 7000H.
5731
GOSUB to SYS0/SYS's 4424H to open the existing file1 in the FCB at Register Pair DE (5551H) with the buffer at Register Pair HL (6F00H) and record length Register B.
5734
If the NZ FLAG is set (file1 could not be opened), JUMP to 554CH to show the error in Register A.
5737
LD DE,5571H 11 71 55
Point Register Pair DE to 5571H, the FCB of file2.
573A
GOSUB to SYS0/SYS's 4448H to position file2 (the FCB at Register Pair DE) at its end, so the bytes written next go after its last byte. The result is not tested.
573D
NOP 00
No Operation: the first of fifteen NOP bytes (573DH-574BH) between the positioning and the jump to the copy loop.
573E
NOP 00
No Operation: the second of the fifteen NOP bytes; they do nothing and the code runs on to 574CH.
573F
NOP 00
No Operation: the third of the fifteen NOP bytes; they do nothing and the code runs on to 574CH.
5740
NOP 00
No Operation: the fourth of the fifteen NOP bytes; they do nothing and the code runs on to 574CH.
5741
NOP 00
No Operation: the fifth of the fifteen NOP bytes; they do nothing and the code runs on to 574CH.
5742
NOP 00
No Operation: the sixth of the fifteen NOP bytes; they do nothing and the code runs on to 574CH.
5743
NOP 00
No Operation: the seventh of the fifteen NOP bytes; they do nothing and the code runs on to 574CH.
5744
NOP 00
No Operation: the eighth of the fifteen NOP bytes; they do nothing and the code runs on to 574CH.
5745
NOP 00
No Operation: the ninth of the fifteen NOP bytes; they do nothing and the code runs on to 574CH.
5746
NOP 00
No Operation: the tenth of the fifteen NOP bytes; they do nothing and the code runs on to 574CH.
5747
NOP 00
No Operation: the eleventh of the fifteen NOP bytes; they do nothing and the code runs on to 574CH.
5748
NOP 00
No Operation: the twelfth of the fifteen NOP bytes; they do nothing and the code runs on to 574CH.
5749
NOP 00
No Operation: the thirteenth of the fifteen NOP bytes; they do nothing and the code runs on to 574CH.
574A
NOP 00
No Operation: the fourteenth of the fifteen NOP bytes; they do nothing and the code runs on to 574CH.
574B
NOP 00
No Operation: the last of the fifteen NOP bytes; the code runs on to the jump at 574CH.
574C
JUMP to 57B6H, the byte copy loop of APPEND, which reads file1 and writes the bytes to the end of file2.
574FH - COPY (Command 5)
COPY file1 TO file2 copies file1 sector by sector into file2, which is opened, or created when it does not exist. Both FCBs use the same buffer at 5600H, so each sector read for file1 is written to file2 straight from the buffer. When the read reports 1DH (RECORD NUMBER OUT OF RANGE), file1's end-of-file byte and record length are copied into file2's FCB before both files are closed; when it reports 1CH (END OF FILE ENCOUNTERED) both are closed as they are. A device name is not refused here.
574F
LD DE,5551H 11 51 55
Point Register Pair DE to 5551H, the first FCB, for file1 (the source).
5752
GOSUB to SYS0/SYS's 441CH to parse the filespec at Register Pair HL (the command line) into the FCB at Register Pair DE; the NZ FLAG for a bad filespec.
5755
If the NZ FLAG is set (no valid filespec), JUMP to 553AH to display FILE SPEC REQUIRED.
5758
LD DE,5571H 11 71 55
Point Register Pair DE to 5571H, the second FCB, for file2 (the destination).
575B
GOSUB to SYS0/SYS's 441CH to parse the next filespec at Register Pair HL into the FCB at Register Pair DE (5571H), skipping a noise word such as TO.
575E
If the NZ FLAG is set (no valid filespec), JUMP to 553AH to display FILE SPEC REQUIRED.
5761
LD B,00H 06 00
Load Register B with 00H, the logical record length: whole 256-byte sectors.
5763
LD DE,5551H 11 51 55
Point Register Pair DE to 5551H, the FCB of file1.
5766
LD HL,5600H 21 00 56
Point Register Pair HL to 5600H, the buffer for file1.
5769
GOSUB to SYS0/SYS's 4424H to open the existing file1 in the FCB at Register Pair DE (5551H) with the buffer at Register Pair HL (5600H) and record length Register B; the NZ FLAG and Register A = the error number on failure.
576C
If the NZ FLAG is set (file1 could not be opened), JUMP to 554CH to show the error in Register A.
576F
LD B,00H 06 00
Load Register B with 00H, whole sectors for file2 as well.
5771
LD DE,5571H 11 71 55
Point Register Pair DE to 5571H, the FCB of file2.
5774
LD HL,5600H 21 00 56
Point Register Pair HL to 5600H, the same buffer as file1.
5777
GOSUB to SYS0/SYS's 4420H to open file2 in the FCB at Register Pair DE (5571H), creating it when it does not exist, with the buffer at Register Pair HL (5600H) and record length Register B.
577A
If the NZ FLAG is set (file2 could not be opened or created), JUMP to 554CH to show the error in Register A.
577D
LD DE,5551H 11 51 55
Sector Loop
Point Register Pair DE to 5551H, the FCB of file1. 5796H loops back here.
5780
GOSUB to SYS0/SYS's 4436H to read the next sector of file1 (the FCB at Register Pair DE) into 5600H; Register A = the error number and the NZ FLAG when there is none.
5783
If the Z FLAG is set (a sector was read), JUMP to 5790H to write it to file2.
5785
CP 1CH FE 1C
Compare Register A (the error number) against 1CH, END OF FILE ENCOUNTERED.
5787
If the Z FLAG is set (1CH), JUMP to 57A1H to close both files.
5789
CP 1DH FE 1D
Compare Register A (the error number) against 1DH, RECORD NUMBER OUT OF RANGE.
578B
If the Z FLAG is set (1DH), JUMP to 579BH to copy the end-of-file byte and record length, then close.
578D
JUMP to 554CH to show the read error in Register A (both files stay open).
5790
LD DE,5571H 11 71 55
Point Register Pair DE to 5571H, the FCB of file2. 5783H jumps here.
5793
GOSUB to SYS0/SYS's 4439H to write the buffer (5600H, the sector just read) as the next sector of file2, the FCB at Register Pair DE; the Z FLAG on success.
5796
Sector Loop End
If the Z FLAG is set (written), LOOP BACK to 577DH for the next sector.
5798
JUMP to 554CH to show the write error in Register A.
579B
LD HL,(5559H) 2A 59 55
Fetch the end-of-file byte and record length of file1 from 5559H (FCB plus 08H and 09H) into Register Pair HL. 578BH jumps here.
579E
LD (5579H),HL 22 79 55
Store Register Pair HL into 5579H, the end-of-file byte and record length of file2's FCB, which the close writes into its directory entry.
57A1
LD DE,5571H 11 71 55
Close Both Files
Point Register Pair DE to 5571H, the FCB of file2 (the file written). 5787H, 57C0H and 57C9H jump here.
57A4
GOSUB to SYS0/SYS's 4428H to close the file in the FCB at Register Pair DE (5571H); the NZ FLAG and Register A = the error number on failure.
57A7
If the NZ FLAG is set (the close failed), JUMP to 554CH to show the error in Register A.
57AA
LD DE,5551H 11 51 55
Point Register Pair DE to 5551H, the FCB of file1.
57AD
GOSUB to SYS0/SYS's 4428H to close the file in the FCB at Register Pair DE (5551H).
57B0
If the NZ FLAG is set (the close failed), JUMP to 554CH to show the error in Register A.
57B3
JUMP to 402DH, DOS READY, after APPEND or COPY has closed both files.
57B6H - APPEND: Byte Copy Loop
Reached from 574CH. Each byte of file1 is read through the ROM's input routine 0013H and written to file2 through the ROM's output routine 001BH; with an open FCB as the device control block, SYS0/SYS's 47AEH reads or writes the next byte of the file. After each byte 5515H tests for BREAK, which ends the copy and closes both files.
57B6
LD DE,5551H 11 51 55
Byte Loop
Point Register Pair DE to 5551H, the FCB of file1, as the device control block. 574CH jumps here; 57D5H loops back here.
57B9
GOSUB to ROM routine at 0013H to read one byte from the device control block at Register Pair DE (an open FCB, so SYS0/SYS's 47AEH reads the next byte of file1): Register A = the byte and the Z FLAG, or the error number and the NZ FLAG.
57BC
If the Z FLAG is set (a byte was read), JUMP to 57C5H to write it.
57BE
CP 1CH FE 1C
Compare Register A (the error number) against 1CH, END OF FILE ENCOUNTERED.
57C0
If the Z FLAG is set (the end of file1), JUMP to 57A1H to close both files.
57C2
JUMP to 554CH to show the read error in Register A (both files stay open).
57C5
LD B,A 47
Copy the byte from Register A into Register B, which 5515H does not change. 57BCH jumps here.
57C6
GOSUB to 5515H to test for BREAK and for a pause with SHIFT and @; the NZ FLAG means BREAK.
57C9
If the NZ FLAG is set (BREAK), JUMP to 57A1H to close both files with the bytes copied so far.
57CB
LD A,B 78
Copy the byte back from Register B into Register A.
57CC
LD DE,5571H 11 71 55
Point Register Pair DE to 5571H, the FCB of file2, as the device control block.
57CF
GOSUB to ROM routine at 001BH to write Register A to the device control block at Register Pair DE (file2's FCB, written through SYS0/SYS's 47AEH after its last byte); the NZ FLAG and Register A = the error number on failure.
57D2
If the NZ FLAG is set (a write error), JUMP to 554CH to show the error in Register A.
57D5
Byte Loop End
LOOP BACK to 57B6H for the next byte of file1.
57D7H - DUMP (Command 9)
DUMP filespec (START=a,END=b,TRA=c) writes memory from a to b into a disk file in the load module format SYS0/SYS's loader reads: a name record (type 05H, the first six letters and digits of the file name), load records (type 01H) of at most 254 bytes each, and a transfer record (type 02H) with c. The default extension is CIM. START and END default to 7000H and TRA to 402DH (DOS READY). START must be 7000H or more, above everything SYS6/SYS uses, and END must not be below START; both are checked only after the file has been opened or created, and the error exit leaves it open.
57D7
LD BC,7000H 01 00 70
Load Register Pair BC with 7000H, the default START and END.
57DA
LD (5868H),BC ED 43 68 58
Store Register Pair BC (7000H) into 5868H, the operand of LD HL,nnnn at 5867H and the variable of the parameter START.
57DE
LD (586EH),BC ED 43 6E 58
Store Register Pair BC (7000H) into 586EH, the operand of LD HL,nnnn at 586DH and the variable of the parameter END.
57E2
LD BC,402DH 01 2D 40
Load Register Pair BC with 402DH, the default transfer address, DOS READY.
57E5
LD (58ABH),BC ED 43 AB 58
Store Register Pair BC (402DH) into 58ABH, the operand of LD HL,nnnn at 58AAH and the variable of the parameter TRA.
57E9
LD DE,5551H 11 51 55
Point Register Pair DE to 5551H, the first FCB, for the file to write.
57EC
GOSUB to SYS0/SYS's 441CH to parse the filespec at Register Pair HL (the command line) into the FCB at Register Pair DE; the NZ FLAG for a bad filespec.
57EF
If the NZ FLAG is set (no valid filespec), JUMP to 553AH to display FILE SPEC REQUIRED.
57F2
LD A,(DE) 1A
Fetch the first character of the parsed name from (DE) (Register Pair DE = 5551H) into Register A.
57F3
CP 2AH FE 2A
Compare Register A against 2AH, the asterisk that starts a device name.
57F5
If the Z FLAG is set (a device), JUMP to 553AH to display FILE SPEC REQUIRED.
57F8
LD DE,58F5H 11 F5 58
Point Register Pair DE to 58F5H, the parameter table: START, END and TRA with the addresses of their variables.
57FB
GOSUB to SYS0/SYS's 4476H to read the parameter list at Register Pair HL against the table at Register Pair DE (58F5H); values may be decimal or X'hhhh'. The result flags are not tested.
57FE
LD DE,590EH 11 0E 59
Point Register Pair DE to 590EH, the six-byte buffer for the name record.
5801
LD HL,5551H 21 51 55
Point Register Pair HL to 5551H, the filespec text in the FCB.
5804
LD B,06H 06 06
Load Register B with 06H, the six characters of the name record.
5806
LD A,(HL) 7E
Name Loop
Fetch the next character of the filespec from (HL) (Register Pair HL = the FCB pointer) into Register A. 581AH loops back here.
5807
CP 30H FE 30
Compare Register A (the filespec character) against 30H, the digit 0.
5809
If the CARRY FLAG is set (below the digit 0: the slash, the period or the 03H end mark), JUMP to 581EH to pad with spaces.
580B
CP 3AH FE 3A
Compare Register A against 3AH, one past the digit 9.
580D
If the CARRY FLAG is set (a digit), JUMP to 5817H to keep it.
580F
CP 41H FE 41
Compare Register A against 41H, the letter A.
5811
If the CARRY FLAG is set (between 9 and A, for example the colon), JUMP to 581EH to pad with spaces.
5813
CP 5BH FE 5B
Compare Register A against 5BH, one past the letter Z.
5815
If the NO CARRY FLAG is set (above the letter Z), JUMP to 581EH to pad with spaces.
5817
LD (DE),A 12
Store Register A (a letter or digit) at (DE) (Register Pair DE = the name buffer pointer). 580DH jumps here.
5818
INC HL 23
INCrement Register Pair HL (the FCB pointer) by 1.
5819
INC DE 13
INCrement Register Pair DE (the name buffer pointer) by 1.
581A
Name Loop End
DECrement Register B and LOOP BACK to 5806H until six characters are stored.
581C
JUMP to 5824H: the name filled all six places.
581E
LD A,20H 3E 20
Pad Loop
Load Register A with 20H, a space. 5809H, 5811H and 5815H jump here; 5822H loops back here.
5820
LD (DE),A 12
Store Register A (a space) at (DE) (Register Pair DE = the name buffer pointer).
5821
INC DE 13
INCrement Register Pair DE (the name buffer pointer) by 1.
5822
Pad Loop End
DECrement Register B and LOOP BACK to 581EH until the six places are filled.
5824
LD DE,5551H 11 51 55
Point Register Pair DE to 5551H, the FCB of the file. 581CH jumps here.
5827
LD HL,58F2H 21 F2 58
Point Register Pair HL to 58F2H, the default extension CIM.
582A
GOSUB to SYS0/SYS's 4473H to add the extension at Register Pair HL (CIM) to the filespec in the FCB at Register Pair DE when it has none.
582D
LD B,00H 06 00
Load Register B with 00H, the logical record length: whole sectors, written a byte at a time.
582F
LD HL,5600H 21 00 56
Point Register Pair HL to 5600H, the buffer for the file.
5832
GOSUB to SYS0/SYS's 4420H to open the file in the FCB at Register Pair DE (5551H), creating it when it does not exist, with the buffer at Register Pair HL (5600H) and record length Register B.
5835
If the NZ FLAG is set (the file could not be opened or created), JUMP to 554CH to show the error in Register A.
5838
LD A,05H 3E 05
Load Register A with 05H, the record type of a name record.
583A
GOSUB to ROM routine at 001BH to write Register A to the device control block at Register Pair DE, the open FCB at 5551H: SYS0/SYS's 47AEH puts the byte into the file.
583D
LD A,06H 3E 06
Load Register A with 06H, the length of the name record.
583F
GOSUB to ROM routine at 001BH to write Register A (06H) to the file whose FCB is at Register Pair DE.
5842
LD B,06H 06 06
Load Register B with 06H, the six name bytes.
5844
LD HL,590EH 21 0E 59
Point Register Pair HL to 590EH, the name built at 5806H-5822H.
5847
LD A,(HL) 7E
Name Record Loop
Fetch the next name byte from (HL) (Register Pair HL = the name pointer) into Register A. 584CH loops back here.
5848
INC HL 23
INCrement Register Pair HL (the name pointer) by 1.
5849
GOSUB to ROM routine at 001BH to write Register A to the file whose FCB is at Register Pair DE.
584C
Name Record Loop End
DECrement Register B and LOOP BACK to 5847H until the six bytes are written.
584E
LD HL,(586EH) 2A 6E 58
Fetch END from 586EH (the operand of 586DH) into Register Pair HL.
5851
LD BC,(5868H) ED 4B 68 58
Fetch START from 5868H (the operand of 5867H) into Register Pair BC.
5855
XOR A AF
Set Register A to ZERO with XOR A, which clears the CARRY FLAG for the subtraction.
5856
SBC HL,BC ED 42
SUBtract Register Pair BC (START) from Register Pair HL (END): the CARRY FLAG is set when END is below START.
5858
LD HL,58C4H 21 C4 58
Point Register Pair HL to 58C4H, the message END LESS THAN START; LD does not change the flags.
585B
If the CARRY FLAG is set (END below START), JUMP to 58BEH to display the message at Register Pair HL.
585D
LD HL,6FFFH 21 FF 6F
Load Register Pair HL with 6FFFH, the last address below 7000H.
5860
SBC HL,BC ED 42
SUBtract Register Pair BC (START) from Register Pair HL (6FFFH), the CARRY FLAG being clear: the NO CARRY FLAG is set when START is 6FFFH or less.
5862
LD HL,58D9H 21 D9 58
Point Register Pair HL to 58D9H, the message START LESS THAN X'7000'; LD does not change the flags.
5865
If the NO CARRY FLAG is set (START below 7000H), JUMP to 58BEH to display the message at Register Pair HL.
5867
LD HL,0000H 21 00 00
Load Register Pair HL with START, the operand at 5868H (0000H in the file, 7000H from 57DAH or the value given).
586A
PUSH HL E5
Block Loop
Save Register Pair HL (the address of the next block) onto the stack. 589DH loops back here.
586B
LD B,H 44
Copy Register H (the high byte of the block address) into Register B.
586C
LD C,L 4D
Copy Register L into Register C: Register Pair BC = the address of the next block.
586D
LD HL,0000H 21 00 00
Load Register Pair HL with END, the operand at 586EH (0000H in the file, 7000H from 57DEH or the value given).
5870
INC HL 23
INCrement Register Pair HL (END) by 1, one past the last byte to write.
5871
XOR A AF
Set Register A to ZERO with XOR A, which clears the CARRY FLAG for the subtraction.
5872
SBC HL,BC ED 42
SUBtract Register Pair BC (the next address) from Register Pair HL (END plus 1): Register Pair HL = the bytes still to write, the Z FLAG when none are left.
5874
If the Z FLAG is set (all written), JUMP to 589FH to write the transfer record.
5876
LD B,FEH 06 FE
Load Register B with FEH, 254 bytes, the most one load record holds (with its two address bytes, 256).
5878
LD A,H 7C
Copy the high byte of the count from Register H into Register A.
5879
OR A B7
OR Register A with itself: the NZ FLAG is set when 256 or more bytes are left.
587A
If the NZ FLAG is set, JUMP to 5882H with a full block of 254 bytes.
587C
LD A,L 7D
Copy the low byte of the count from Register L into Register A.
587D
CP FFH FE FF
Compare Register A (the bytes left, below 256) against FFH.
587F
If the NO CARRY FLAG is set (exactly 255 left), JUMP to 5882H with a block of 254 bytes; one byte is left for the next block.
5881
LD B,L 45
Copy the bytes left from Register L into Register B: the last block holds them all.
5882
POP HL E1
Restore Register Pair HL (the address of the block) from the stack. 587AH and 587FH jump here.
5883
LD A,01H 3E 01
Load Register A with 01H, the record type of a load record.
5885
GOSUB to ROM routine at 001BH to write Register A (01H) to the file whose FCB is at Register Pair DE.
5888
LD A,B 78
Copy the block length from Register B into Register A.
5889
ADD A,02H C6 02
ADD 02H to Register A for the two address bytes: the record length (FEH plus 2 wraps to 00H, which the loader reads as 256).
588B
GOSUB to ROM routine at 001BH to write Register A (the record length) to the file whose FCB is at Register Pair DE.
588E
LD A,L 7D
Copy the low byte of the block address from Register L into Register A.
588F
GOSUB to ROM routine at 001BH to write Register A (the address low byte) to the file whose FCB is at Register Pair DE.
5892
LD A,H 7C
Copy the high byte of the block address from Register H into Register A.
5893
GOSUB to ROM routine at 001BH to write Register A (the address high byte) to the file whose FCB is at Register Pair DE.
5896
LD A,(HL) 7E
Data Loop
Fetch the next memory byte from (HL) (Register Pair HL = the address being dumped) into Register A. 589BH loops back here.
5897
INC HL 23
INCrement Register Pair HL (the address being dumped) by 1.
5898
GOSUB to ROM routine at 001BH to write Register A (the memory byte) to the file whose FCB is at Register Pair DE.
589B
Data Loop End
DECrement Register B and LOOP BACK to 5896H until the block is written.
589D
Block Loop End
LOOP BACK to 586AH with Register Pair HL = the address of the next block.
589F
POP HL E1
Transfer Record
Restore Register Pair HL from the stack, dropping the address pushed at 586AH. 5874H jumps here.
58A0
LD A,02H 3E 02
Load Register A with 02H, the record type of a transfer record.
58A2
GOSUB to ROM routine at 001BH to write Register A (02H) to the file whose FCB is at Register Pair DE.
58A5
LD A,02H 3E 02
Load Register A with 02H, the length of the transfer record.
58A7
GOSUB to ROM routine at 001BH to write Register A (02H) to the file whose FCB is at Register Pair DE.
58AA
LD HL,0000H 21 00 00
Load Register Pair HL with TRA, the operand at 58ABH (0000H in the file, 402DH from 57E5H or the value given).
58AD
LD A,L 7D
Copy the low byte of the transfer address from Register L into Register A.
58AE
GOSUB to ROM routine at 001BH to write Register A (the transfer address low byte) to the file whose FCB is at Register Pair DE.
58B1
LD A,H 7C
Copy the high byte of the transfer address from Register H into Register A.
58B2
GOSUB to ROM routine at 001BH to write Register A (the transfer address high byte) to the file whose FCB is at Register Pair DE.
58B5
GOSUB to SYS0/SYS's 4428H to close the file in the FCB at Register Pair DE (5551H), writing its last sector.
58B8
If the NZ FLAG is set (the close failed), JUMP to 554CH to show the error in Register A.
58BB
JUMP to 402DH, DOS READY, with the file written and closed.
58BE
DUMP Error
GOSUB to SYS0/SYS's 4467H to display the message at Register Pair HL (58C4H or 58D9H). 585BH and 5865H jump here.
58C1
JUMP to 4030H, the exit after an error; the file opened at 5832H is not closed.
58C4-58D8
DEFB 0AH / DEFM "END LESS THAN START" / DEFB 0DH 0A 45 4E 44 20 4C 45 53 53 20 54 48 41 4E 20 53 54 41 52 54 0D
Message shown by 585BH: a line feed, the text and 0DH (ENTER).
58D9-58F1
DEFB 0AH / DEFM "START LESS THAN X'7000'" / DEFB 0DH 0A 53 54 41 52 54 20 4C 45 53 53 20 54 48 41 4E 20 58 27 37 30 30 30 27 0D
Message shown by 5865H: a line feed, the text and 0DH (ENTER).
58F2-58F4
DEFM "CIM" 43 49 4D
Default extension of a DUMP file, added by 582AH when the filespec has none.
58F5H - DUMP Parameter Table
Three eight-byte entries for SYS1/SYS's parameter reader (4476H): six characters of name, then the address of the two-byte variable the value goes into, the operand of an LD HL,nnnn. 00H ends the table.
58F5-58FC
DEFM "START " / DEFW 5868H 53 54 41 52 54 20 68 58
Parameter START, the first address to write: its value goes into 5868H-5869H, read at 5851H and 5867H.
58FD-5904
DEFM "END " / DEFW 586EH 45 4E 44 20 20 20 6E 58
Parameter END, the last address to write: its value goes into 586EH-586FH, read at 584EH and 586DH.
5905-590C
DEFM "TRA " / DEFW 58ABH 54 52 41 20 20 20 AB 58
Parameter TRA, the transfer address of the file: its value goes into 58ABH-58ACH, read at 58AAH.
590D
DEFB 00H 00
End of the DUMP parameter table: SYS1/SYS's table lookup stops at an entry starting with 00H.
590E-5913
DEFS 6
Not in the file: the name of the name record, built from the filespec by 5806H-5822H and written by 5847H-584CH.
5914H - KILL (Command 11)
KILL filespec opens the file, to find its directory entry and check its password, and deletes it through SYS0/SYS's 442CH. A device name is not refused here.
5914
LD DE,5551H 11 51 55
Point Register Pair DE to 5551H, the first FCB, for the file to delete.
5917
GOSUB to SYS0/SYS's 441CH to parse the filespec at Register Pair HL (the command line) into the FCB at Register Pair DE; the NZ FLAG for a bad filespec.
591A
If the NZ FLAG is set (no valid filespec), JUMP to 553AH to display FILE SPEC REQUIRED.
591D
GOSUB to SYS0/SYS's 4424H to open the file in the FCB at Register Pair DE (5551H). Register Pair HL (the command line pointer 441CH left) and Register B go in as the buffer address and record length, which the kill does not use.
5920
If the NZ FLAG is set (the file could not be opened), JUMP to 554CH to show the error in Register A.
5923
GOSUB to SYS0/SYS's 442CH to kill the open file in the FCB at Register Pair DE (5551H): SYS3/SYS frees its granules and its directory entry.
5926
If the NZ FLAG is set (the kill failed, for example 25H for a file protected against it), JUMP to 554CH to show the error in Register A.
5929
JUMP to 402DH, DOS READY, with the file deleted.
592CH - LIST (Command 13)
LIST filespec (LINE=n) shows a text file on the display, one byte at a time, testing for BREAK and the SHIFT and @ pause at the end of every line. The parameter table address is put in Register Pair BC at 5942H, but SYS0/SYS's 4476H takes the table in Register Pair DE, which still holds 5551H: the parameter names are compared with the filespec text in the FCB instead of the LINE entry at 598BH. The skip loop for LINE counts lines in Register Pair BC with DEC C and DEC B, which is only right when Register C is 00H, and it does not stop at the end of the file. The file is not closed.
592C
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, no lines to skip.
592F
LD (5954H),BC ED 43 54 59
Store Register Pair BC (0000H) into 5954H, the operand of LD BC,nnnn at 5953H and the variable of the parameter LINE.
5933
LD DE,5551H 11 51 55
Point Register Pair DE to 5551H, the first FCB, for the file to show.
5936
GOSUB to SYS0/SYS's 441CH to parse the filespec at Register Pair HL (the command line) into the FCB at Register Pair DE; the NZ FLAG for a bad filespec.
5939
If the NZ FLAG is set (no valid filespec), JUMP to 553AH to display FILE SPEC REQUIRED.
593C
LD A,(DE) 1A
Fetch the first character of the parsed name from (DE) (Register Pair DE = 5551H) into Register A.
593D
CP 2AH FE 2A
Compare Register A against 2AH, the asterisk that starts a device name.
593F
If the Z FLAG is set (a device), JUMP to 553AH to display FILE SPEC REQUIRED.
5942
LD BC,598BH 01 8B 59
Load Register Pair BC with 598BH, the LINE parameter table. 4476H does not read Register Pair BC; its table is Register Pair DE, still 5551H.
5945
GOSUB to SYS0/SYS's 4476H to read the parameter list at Register Pair HL against the table at Register Pair DE (5551H, the FCB holding the filespec text). The result flags are not tested.
5948
LD B,00H 06 00
Load Register B with 00H, the logical record length: whole sectors, read a byte at a time.
594A
LD HL,5600H 21 00 56
Point Register Pair HL to 5600H, the buffer for the file.
594D
GOSUB to SYS0/SYS's 4424H to open the file in the FCB at Register Pair DE (5551H) with the buffer at Register Pair HL (5600H) and record length Register B.
5950
If the NZ FLAG is set (the file could not be opened), JUMP to 554CH to show the error in Register A.
5953
LD BC,0000H 01 00 00
Load Register Pair BC with LINE, the operand at 5954H (0000H in the file and from 592FH; changed only if the parameter list matched, see 5942H).
5956
LD A,B 78
Copy Register B (the high byte of LINE) into Register A.
5957
OR C B1
OR Register A with Register C (the low byte): the Z FLAG is set when there are no lines to skip.
5958
If the Z FLAG is set, JUMP to 5967H to start showing the file.
595A
Skip Loop
GOSUB to ROM routine at 0013H to read one byte from the device control block at Register Pair DE (the open FCB at 5551H) into Register A. A read error is not tested. 595FH, 5962H and 5965H loop back here.
595D
CP 0DH FE 0D
Compare Register A (the byte) against 0DH, the ENTER that ends a line.
595F
If the NZ FLAG is set (not the end of a line), LOOP BACK to 595AH.
5961
DEC C 0D
DECrement Register C (the low byte of the lines to skip) by 1.
5962
If the NZ FLAG is set, LOOP BACK to 595AH to skip another line.
5964
DEC B 05
DECrement Register B (the high byte of the lines to skip) by 1; when it was 00H it becomes FFH.
5965
Skip Loop End
If the NZ FLAG is set, LOOP BACK to 595AH for 256 more lines.
5967
LD DE,5551H 11 51 55
Show Loop
Point Register Pair DE to 5551H, the FCB of the file (the ROM's 0033H leaves Register Pair DE = 401DH). 5958H jumps here; 5974H and 597CH loop back here.
596A
GOSUB to ROM routine at 0013H to read the next byte of the file from the device control block at Register Pair DE (5551H): Register A = the byte and the Z FLAG, or the error number and the NZ FLAG.
596D
If the NZ FLAG is set (end of file or an error), JUMP to 597EH.
596F
GOSUB to ROM routine at 0033H to display the byte in Register A; Register A is kept.
5972
CP 0DH FE 0D
Compare Register A (the byte shown) against 0DH, the end of a line.
5974
If the NZ FLAG is set (not the end of a line), LOOP BACK to 5967H for the next byte.
5976
GOSUB to 5515H to test for BREAK and for a pause with SHIFT and @ at the end of the line; the NZ FLAG means BREAK.
5979
If the NZ FLAG is set (BREAK), JUMP to 4030H, the exit after an error (DOS READY, or DEBUG when DEBUG is on).
597C
Show Loop End
LOOP BACK to 5967H for the next line.
597E
CP 1CH FE 1C
Compare Register A (the error number) against 1CH, END OF FILE ENCOUNTERED. 596DH jumps here.
5980
If the Z FLAG is set (the end of the file), JUMP to 402DH, DOS READY.
5983
CP 1DH FE 1D
Compare Register A (the error number) against 1DH, RECORD NUMBER OUT OF RANGE.
5985
If the Z FLAG is set (past the end), JUMP to 402DH, DOS READY.
5988
JUMP to 554CH to show the read error in Register A.
598B-5992
DEFM "LINE " / DEFW 5954H 4C 49 4E 45 20 20 54 59
The LINE parameter of LIST: the number of lines to skip goes into 5954H-5955H, read at 5953H. 5942H puts this address in Register Pair BC, where 4476H does not look for it.
5993
DEFB 00H 00
End of the LIST parameter table: SYS1/SYS's table lookup stops at an entry starting with 00H.
5994H - LOAD (Command 14)
LOAD filespec loads a program file into memory through SYS0/SYS's 4430H without running it, and goes back to DOS READY.
5994
LD DE,5551H 11 51 55
Point Register Pair DE to 5551H, the first FCB, for the program file.
5997
GOSUB to SYS0/SYS's 441CH to parse the filespec at Register Pair HL (the command line) into the FCB at Register Pair DE; the NZ FLAG for a bad filespec.
599A
If the NZ FLAG is set (no valid filespec), JUMP to 553AH to display FILE SPEC REQUIRED.
599D
LD A,(DE) 1A
Fetch the first character of the parsed name from (DE) (Register Pair DE = 5551H) into Register A.
599E
CP 2AH FE 2A
Compare Register A against 2AH, the asterisk that starts a device name.
59A0
If the Z FLAG is set (a device), JUMP to 553AH to display FILE SPEC REQUIRED.
59A3
GOSUB to SYS0/SYS's 4430H to load the program file in the FCB at Register Pair DE (5551H) into memory; the Z FLAG on success, else the NZ FLAG and Register A = the error number.
59A6
If the Z FLAG is set (loaded), JUMP to 402DH, DOS READY, without running the program.
59A9
JUMP to 554CH to show the load error in Register A.
59ACH - PRINT (Command 15)
PRINT filespec sends a file to the printer one byte at a time through the ROM's 003BH, testing for BREAK and the SHIFT and @ pause after every byte. At the end, or on an error, one more 0DH goes to the printer. The file is not closed.
59AC
LD DE,5551H 11 51 55
Point Register Pair DE to 5551H, the first FCB, for the file to print.
59AF
GOSUB to SYS0/SYS's 441CH to parse the filespec at Register Pair HL (the command line) into the FCB at Register Pair DE; the NZ FLAG for a bad filespec.
59B2
If the NZ FLAG is set (no valid filespec), JUMP to 553AH to display FILE SPEC REQUIRED.
59B5
LD A,(DE) 1A
Fetch the first character of the parsed name from (DE) (Register Pair DE = 5551H) into Register A.
59B6
CP 2AH FE 2A
Compare Register A against 2AH, the asterisk that starts a device name.
59B8
If the Z FLAG is set (a device), JUMP to 553AH to display FILE SPEC REQUIRED.
59BB
LD B,00H 06 00
Load Register B with 00H, the logical record length: whole sectors, read a byte at a time.
59BD
LD HL,5600H 21 00 56
Point Register Pair HL to 5600H, the buffer for the file.
59C0
GOSUB to SYS0/SYS's 4424H to open the file in the FCB at Register Pair DE (5551H) with the buffer at Register Pair HL (5600H) and record length Register B.
59C3
If the NZ FLAG is set (the file could not be opened), JUMP to 554CH to show the error in Register A.
59C6
LD DE,5551H 11 51 55
Print Loop
Point Register Pair DE to 5551H, the FCB of the file (the ROM's 003BH leaves Register Pair DE = 4025H, the printer's control block). 59D7H loops back here.
59C9
GOSUB to ROM routine at 0013H to read the next byte of the file from the device control block at Register Pair DE (5551H): Register A = the byte and the Z FLAG, or the error number and the NZ FLAG.
59CC
If the NZ FLAG is set (end of file or an error), JUMP to 59DAH.
59CE
GOSUB to ROM routine at 003BH to send the byte in Register A to the printer.
59D1
GOSUB to 5515H to test for BREAK and for a pause with SHIFT and @; the NZ FLAG means BREAK.
59D4
If the NZ FLAG is set (BREAK), JUMP to 4030H, the exit after an error (DOS READY, or DEBUG when DEBUG is on).
59D7
Print Loop End
JUMP to 59C6H for the next byte of the file.
59DA
PUSH AF F5
Save Register Pair AF (Register A = the error number from the read) onto the stack. 59CCH jumps here.
59DB
LD A,0DH 3E 0D
Load Register A with 0DH, ENTER, to end the printer's last line.
59DD
GOSUB to ROM routine at 003BH to send Register A (0DH) to the printer.
59E0
POP AF F1
Restore Register Pair AF (Register A = the error number) from the stack.
59E1
CP 1CH FE 1C
Compare Register A (the error number) against 1CH, END OF FILE ENCOUNTERED.
59E3
If the Z FLAG is set (the end of the file), JUMP to 402DH, DOS READY.
59E6
CP 1DH FE 1D
Compare Register A (the error number) against 1DH, RECORD NUMBER OUT OF RANGE.
59E8
If the Z FLAG is set (past the end), JUMP to 402DH, DOS READY.
59EB
JUMP to 554CH to show the read error in Register A.
59EE-5AFF
DEFS 274
Not in the file and not used by SYS6/SYS: nothing reads or writes 59EEH-5AFFH.
5B00H - ATTRIB (Command 2)
ATTRIB filespec (INV,ACC=password,UPD=password,PROT=level) changes a file's directory entry. The file must open at access level 0, with its owner password, or the command stops with error 37H, which SYS4/SYS shows as UNKNOWN ERROR CODE. Only the first letter of each option is looked at (I, A, U or P). INV sets bit 3 of the attribute byte; nothing here clears it. ACC puts the hash of its password at entry plus 12H (the user password), UPD at entry plus 10H (the owner password). PROT takes the first two letters of its level word, looks them up in the table at 5C61H (EX, RE, WR, NA, KI, FU, with REN for RENAME) and puts the level 6, 5, 4, 2, 1 or 0 into bits 0-2. The attribute byte's bits 0-2 are cleared on every ATTRIB, so a command without PROT leaves the file at level 0. Password values are copied by SYS2/SYS's field routine, which takes only letters and digits starting with a letter.
5B00
LD DE,5551H 11 51 55
Point Register Pair DE to 5551H, the first FCB, for the file.
5B03
GOSUB to SYS0/SYS's 441CH to parse the filespec at Register Pair HL (the command line) into the FCB at Register Pair DE; the NZ FLAG for a bad filespec.
5B06
If the NZ FLAG is set (no valid filespec), JUMP to 553AH to display FILE SPEC REQUIRED.
5B09
LD A,(DE) 1A
Fetch the first character of the parsed name from (DE) (Register Pair DE = 5551H) into Register A.
5B0A
CP 2AH FE 2A
Compare Register A against 2AH, the asterisk that starts a device name.
5B0C
If the Z FLAG is set (a device), JUMP to 553AH to display FILE SPEC REQUIRED.
5B0F
PUSH HL E5
Save Register Pair HL (the command line after the filespec) onto the stack.
5B10
LD B,00H 06 00
Load Register B with 00H, the logical record length (the file is not read).
5B12
LD HL,4D00H 21 00 4D
Point Register Pair HL to 4D00H, SYS0/SYS's sector buffer, as the file's buffer.
5B15
GOSUB to SYS0/SYS's 4424H to open the file in the FCB at Register Pair DE (5551H). This also loads SYS2/SYS, whose 5081H and 50D1H the options use. The file routines give back Register Pairs BC, DE and HL as they were, so Register B is still 00H afterwards.
5B18
If the NZ FLAG is set (the file could not be opened), JUMP to 554CH to show the error in Register A.
5B1B
POP HL E1
Restore Register Pair HL (the command line after the filespec) from the stack.
5B1C
LD A,(5552H) 3A 52 55
Fetch the FCB's access byte from 5552H (FCB plus 01H) into Register A; bits 0-2 are the access level the password allowed.
5B1F
AND 07H E6 07
AND Register A with 07H, keeping the access level: the Z FLAG for level 0 (opened with the owner password).
5B21
LD A,37H 3E 37
Load Register A with 37H, the error number used here; LD does not change the flags. SYS4/SYS has no message for 37H and shows UNKNOWN ERROR CODE.
5B23
If the NZ FLAG is set (not level 0), JUMP to 554CH to show error 37H.
5B26
XOR A AF
Set Register A to ZERO with XOR A, the starting value of the two option variables.
5B27
LD (5C05H),A 32 05 5C
Store Register A (00H) into 5C05H, the operand of LD D,nn at 5C04H: the options given (bit 0 PROT, bit 1 ACC, bit 2 UPD).
5B2A
LD (5C0DH),A 32 0D 5C
Store Register A (00H) into 5C0DH, the operand of OR nn at 5C0CH: 08H once INV is given.
5B2D
LD A,(HL) 7E
Find the Parenthesis
Fetch the next character from (HL) (Register Pair HL = the command line pointer) into Register A. 5B38H loops back here.
5B2E
CP 28H FE 28
Compare Register A against 28H, the opening parenthesis of the option list.
5B30
If the Z FLAG is set, JUMP to 5B3AH to read the first option.
5B32
CP 20H FE 20
Compare Register A against 20H, a space before the list.
5B34
If the NZ FLAG is set (no option list, ENTER included), JUMP to 526BH to display -NOTHING DONE-.
5B37
INC HL 23
INCrement Register Pair HL (the command line pointer) by 1, past the space.
5B38
LOOP BACK to 5B2DH to look at the next character of the command line.
5B3A
INC HL 23
Next Option
INCrement Register Pair HL (the command line pointer) by 1, past the parenthesis or comma. 5B30H and 5B92H jump here.
5B3B
LD A,(HL) 7E
Fetch the first letter of the option from (HL) (Register Pair HL = the command line pointer) into Register A.
5B3C
CP 49H FE 49
Compare Register A against 49H, the letter I (INV).
5B3E
If the Z FLAG is set (an option starting with I), JUMP to 5B97H for INV.
5B40
CP 41H FE 41
Compare Register A against 41H, the letter A (ACC).
5B42
If the Z FLAG is set (an option starting with A), JUMP to 5BA7H for ACC.
5B44
CP 55H FE 55
Compare Register A against 55H, the letter U (UPD).
5B46
If the Z FLAG is set (an option starting with U), JUMP to 5BBCH for UPD.
5B48
CP 50H FE 50
Compare Register A against 50H, the letter P (PROT).
5B4A
If the NZ FLAG is set (none of the four), JUMP to 5C39H to display ATTRIBUTE SPECIFICATION ERROR.
5B4D
PROT
GOSUB to 5BD1H to find the equals sign and copy the value into 5155H-515CH; the Z FLAG when there is no value.
5B50
If the Z FLAG is set (PROT without a level), JUMP to 5C39H to display ATTRIBUTE SPECIFICATION ERROR.
5B53
PUSH HL E5
Save Register Pair HL (the command line pointer, at the character after the value) onto the stack.
5B54
LD B,07H 06 07
Load Register B with 07H, the seven entries of the level table at 5C61H.
5B56
LD DE,(5155H) ED 5B 55 51
Fetch the first two letters of the value from 5155H into Register Pair DE: Register E = the first, Register D = the second.
5B5A
LD HL,5C61H 21 61 5C
Point Register Pair HL to 5C61H, the level table: two letters per level, from EX (6) down to FU (0).
5B5D
LD A,(HL) 7E
Level Loop
Fetch the first letter of a table entry from (HL) (Register Pair HL = the table pointer) into Register A. 5B64H loops back here.
5B5E
INC HL 23
INCrement Register Pair HL (the table pointer) by 1, to the entry's second letter.
5B5F
CP E BB
Compare Register A (the entry's first letter) against Register E (the value's first letter).
5B60
If the Z FLAG is set (the first letters match), GOSUB to 5B69H to compare the second letters; on a match it does not come back here.
5B63
INC HL 23
INCrement Register Pair HL (the table pointer) by 1, to the next entry.
5B64
Level Loop End
DECrement Register B and LOOP BACK to 5B5DH until all seven entries have been tried.
5B66
JUMP to 5C39H to display ATTRIBUTE SPECIFICATION ERROR: the level is not in the table.
5B69
LD A,(HL) 7E
Second Letter
Fetch the entry's second letter from (HL) (Register Pair HL = the table pointer) into Register A. 5B60H calls here.
5B6A
CP D BA
Compare Register A against Register D (the value's second letter).
5B6B
RET NZ C0
If the NZ FLAG is set (different), RETURN to 5B63H to try the next entry.
5B6C
POP AF F1
Restore Register Pair AF from the stack, dropping the return address 5B63H: the level is found.
5B6D
LD A,B 78
Copy the entries left from Register B (7 for EX down to 1 for FU) into Register A.
5B6E
DEC A 3D
DECrement Register A by 1: the access level, 6 for EX down to 0 for FU.
5B6F
CP 05H FE 05
Compare Register A (the level) against 05H, the level of RE.
5B71
If the NZ FLAG is set (not RE), JUMP to 5B7EH to store the level.
5B73
LD A,(5157H) 3A 57 51
Fetch the third letter of the value from 5157H into Register A.
5B76
CP 4EH FE 4E
Compare Register A against 4EH, the letter N of REN (RENAME).
5B78
LD A,05H 3E 05
Load Register A with 05H, the level for READ; LD does not change the flags.
5B7A
If the NZ FLAG is set (RE but not REN), JUMP to 5B7EH with level 5.
5B7C
LD A,02H 3E 02
Load Register A with 02H, the level for RENAME, the same as NA.
5B7E
LD (5C0BH),A 32 0B 5C
Store Register A (the level) into 5C0BH, the operand of OR nn at 5C0AH. 5B71H and 5B7AH jump here.
5B81
POP HL E1
Restore Register Pair HL (the command line pointer) from the stack.
5B82
LD B,01H 06 01
Load Register B with 01H, the option bit of PROT.
5B84
LD A,(5C05H) 3A 05 5C
Record the Option
Fetch the options given from 5C05H into Register A. 5BA5H, 5BBAH and 5BCFH jump here with the option's bit in Register B.
5B87
OR B B0
OR Register A with Register B (the option's bit).
5B88
LD (5C05H),A 32 05 5C
Store Register A (the options given) back into 5C05H, the operand of LD D,nn at 5C04H.
5B8B
LD A,(HL) 7E
Fetch the character after the option from (HL) (Register Pair HL = the command line pointer) into Register A.
5B8C
CP 29H FE 29
Compare Register A against 29H, the closing parenthesis.
5B8E
If the Z FLAG is set (end of the list), JUMP to 5BF7H to change the directory entry.
5B90
CP 2CH FE 2C
Compare Register A against 2CH, the comma before another option.
5B92
If the Z FLAG is set, JUMP to 5B3AH for the next option.
5B94
JUMP to 5C39H to display ATTRIBUTE SPECIFICATION ERROR: something else follows the option.
5B97
INV
GOSUB to 5BD1H to look for an equals sign; the Z FLAG when there is none. 5B3EH jumps here.
5B9A
If the NZ FLAG is set (INV given a value), JUMP to 5C39H to display ATTRIBUTE SPECIFICATION ERROR.
5B9D
LD A,(5C0DH) 3A 0D 5C
Fetch the INV variable from 5C0DH into Register A.
5BA0
OR 08H F6 08
OR Register A with 08H, bit 3 of the attribute byte, the invisible bit.
5BA2
LD (5C0DH),A 32 0D 5C
Store Register A into 5C0DH, the operand of OR nn at 5C0CH.
5BA5
JUMP to 5B84H with Register B still holding 00H (from 5B10H) or the bit of the option before, which records nothing new.
5BA7
ACC
GOSUB to 5BD1H to find the equals sign and copy the password into 5155H-515CH; the Z FLAG when there is no value. 5B42H jumps here.
5BAA
If the Z FLAG is set (ACC without a password), JUMP to 5C39H to display ATTRIBUTE SPECIFICATION ERROR.
5BAD
PUSH HL E5
Save Register Pair HL (the command line pointer) onto the stack.
5BAE
LD DE,5155H 11 55 51
Point Register Pair DE to 5155H, the eight-byte password padded with spaces.
5BB1
GOSUB to SYS2/SYS's 50D1H to hash the eight bytes at Register Pair DE; Register Pair HL returns the hash.
5BB4
LD (516AH),HL 22 6A 51
Store Register Pair HL (the hash) into 516AH, for the user password at entry plus 12H.
5BB7
POP HL E1
Restore Register Pair HL (the command line pointer) from the stack.
5BB8
LD B,02H 06 02
Load Register B with 02H, the option bit of ACC.
5BBA
JUMP to 5B84H to record the option bit in Register B (02H, ACC).
5BBC
UPD
GOSUB to 5BD1H to find the equals sign and copy the password into 5155H-515CH; the Z FLAG when there is no value. 5B46H jumps here.
5BBF
If the Z FLAG is set (UPD without a password), JUMP to 5C39H to display ATTRIBUTE SPECIFICATION ERROR.
5BC2
PUSH HL E5
Save Register Pair HL (the command line pointer) onto the stack.
5BC3
LD DE,5155H 11 55 51
Point Register Pair DE to 5155H, the eight-byte password padded with spaces.
5BC6
GOSUB to SYS2/SYS's 50D1H to hash the eight bytes at Register Pair DE; Register Pair HL returns the hash.
5BC9
LD (5168H),HL 22 68 51
Store Register Pair HL (the hash) into 5168H, for the owner password at entry plus 10H.
5BCC
POP HL E1
Restore Register Pair HL (the command line pointer) from the stack.
5BCD
LD B,04H 06 04
Load Register B with 04H, the option bit of UPD.
5BCF
JUMP to 5B84H to record the option bit in Register B (04H, UPD).
5BD1H - Read an Option's Value
Register Pair HL = the first letter of the option. Moves along the option's name to an equals sign. When ENTER, a closing parenthesis or a comma comes first it returns the Z FLAG with Register Pair HL on that character. Otherwise it fills 5155H-515CH with spaces, copies up to eight letters and digits of the value there through SYS2/SYS's 5081H (the first must be a letter) and returns the NZ FLAG with Register Pair HL on the character that ended the value.
5BD1
INC HL 23
Name Loop
INCrement Register Pair HL (the command line pointer) by 1. 5B4DH, 5B97H, 5BA7H and 5BBCH call here; 5BDEH loops back here.
5BD2
LD A,(HL) 7E
Fetch the character from (HL) (Register Pair HL = the command line pointer) into Register A.
5BD3
CP 0DH FE 0D
Compare Register A (the command line character) against 0DH, ENTER.
5BD5
RET Z C8
If the Z FLAG is set (end of the line), RETURN with the Z FLAG: no value.
5BD6
CP 29H FE 29
Compare Register A against 29H, the closing parenthesis.
5BD8
RET Z C8
If the Z FLAG is set, RETURN with the Z FLAG: no value.
5BD9
CP 2CH FE 2C
Compare Register A against 2CH, a comma before the next option.
5BDB
RET Z C8
If the Z FLAG is set, RETURN with the Z FLAG: no value.
5BDC
CP 3DH FE 3D
Compare Register A against 3DH, the equals sign.
5BDE
Name Loop End
If the NZ FLAG is set (still in the name), LOOP BACK to 5BD1H.
5BE0
INC HL 23
INCrement Register Pair HL (the command line pointer) by 1, past the equals sign.
5BE1
LD DE,5155H 11 55 51
Point Register Pair DE to 5155H, the value buffer: eight bytes in the work area after SYS2/SYS's loaded bytes, where SYS2/SYS keeps a password.
5BE4
LD B,08H 06 08
Load Register B with 08H, the eight bytes of the buffer.
5BE6
PUSH DE D5
Save Register Pair DE (5155H) onto the stack.
5BE7
PUSH BC C5
Save Register Pair BC (Register B = 8) onto the stack.
5BE8
LD A,20H 3E 20
Load Register A with 20H, a space, to clear the value buffer.
5BEA
LD (DE),A 12
Clear Loop
Store Register A (a space) at (DE) (Register Pair DE = the buffer pointer). 5BECH loops back here.
5BEB
INC DE 13
INCrement Register Pair DE (the buffer pointer) by 1.
5BEC
Clear Loop End
DECrement Register B and LOOP BACK to 5BEAH until the eight bytes are spaces.
5BEE
POP BC C1
Restore Register Pair BC (Register B = 8) from the stack.
5BEF
POP DE D1
Restore Register Pair DE (5155H) from the stack.
5BF0
GOSUB to SYS2/SYS's 5081H to copy the value at Register Pair HL into the buffer at Register Pair DE, at most Register B (8) characters: a letter first, then letters and digits. It returns Register A = the character that ended the value and Register Pair HL past it.
5BF3
DEC HL 2B
DECrement Register Pair HL by 1, back to the character that ended the value.
5BF4
OR 01H F6 01
OR Register A with 01H: the result is not zero, so the NZ FLAG is set (a value was looked for).
5BF6
RET C9
RETURN with the NZ FLAG and Register Pair HL on the character after the value.
5BF7H - Change the Directory Entry
Reached from 5B8EH at the closing parenthesis. Reads the directory sector holding the file's entry (drive and locator from the open FCB), rebuilds the attribute byte from the options, puts in the password hashes asked for, and writes the sector back.
5BF7
LD BC,(5557H) ED 4B 57 55
Fetch the drive and the directory entry locator from 5557H (FCB plus 06H and 07H) into Register Pair BC: Register C = the drive, Register B = the locator.
5BFB
GOSUB to SYS0/SYS's 4AC1H to read the directory sector of locator Register B on drive Register C into 4200H; Register Pair HL returns the entry's address, the NZ FLAG and Register A = 11H on failure.
5BFE
If the NZ FLAG is set (the sector could not be read), JUMP to 554CH to show the error in Register A.
5C01
LD A,(HL) 7E
Fetch the attribute byte of the entry from (HL) (Register Pair HL = the entry) into Register A.
5C02
AND F8H E6 F8
AND Register A with F8H, clearing the access level in bits 0-2 and keeping bits 3-7 (bit 3, invisible, stays as it was).
5C04
LD D,00H 16 00
Load Register D with the options given, the operand at 5C05H written by 5B27H and 5B88H (00H in the file): bit 0 PROT, bit 1 ACC, bit 2 UPD.
5C06
BIT 0,D CB 42
Test bit 0 of Register D (the options given): set when PROT was given.
5C08
If the Z FLAG is set (no PROT), JUMP to 5C0CH: the access level stays 0.
5C0A
OR 00H F6 00
OR Register A with the level stored at 5C0BH by 5B7EH (00H in the file).
5C0C
OR 00H F6 00
OR Register A with the INV bit stored at 5C0DH by 5B2AH and 5BA2H (00H in the file, 08H with INV). 5C08H jumps here.
5C0E
LD (HL),A 77
Store Register A (the new attribute byte) at (HL) (Register Pair HL = the entry).
5C0F
LD A,L 7D
Copy Register L (the low byte of the entry address) into Register A.
5C10
ADD A,10H C6 10
ADD 10H to Register A, the offset of the owner password hash.
5C12
LD L,A 6F
Copy Register A into Register L: Register Pair HL = the entry plus 10H.
5C13
BIT 2,D CB 52
Test bit 2 of Register D (the options given): set when UPD was given.
5C15
If the Z FLAG is set (no UPD), JUMP to 5C21H.
5C17
LD A,(5168H) 3A 68 51
Fetch the low byte of the UPD hash from 5168H into Register A.
5C1A
LD (HL),A 77
Store Register A at (HL) (Register Pair HL = the entry plus 10H).
5C1B
LD A,(5169H) 3A 69 51
Fetch the high byte of the UPD hash from 5169H into Register A.
5C1E
INC HL 23
INCrement Register Pair HL by 1, to the entry plus 11H.
5C1F
LD (HL),A 77
Store Register A at (HL) (Register Pair HL = the entry plus 11H): the new owner password.
5C20
DEC HL 2B
DECrement Register Pair HL by 1, back to the entry plus 10H.
5C21
INC HL 23
INCrement Register Pair HL by 1, to the entry plus 11H. 5C15H jumps here.
5C22
INC HL 23
INCrement Register Pair HL by 1, to the entry plus 12H, the user password hash.
5C23
BIT 1,D CB 4A
Test bit 1 of Register D (the options given): set when ACC was given.
5C25
If the Z FLAG is set (no ACC), JUMP to 5C30H.
5C27
LD A,(516AH) 3A 6A 51
Fetch the low byte of the ACC hash from 516AH into Register A.
5C2A
LD (HL),A 77
Store Register A at (HL) (Register Pair HL = the entry plus 12H).
5C2B
LD A,(516BH) 3A 6B 51
Fetch the high byte of the ACC hash from 516BH into Register A.
5C2E
INC HL 23
INCrement Register Pair HL by 1, to the entry plus 13H.
5C2F
LD (HL),A 77
Store Register A at (HL) (Register Pair HL = the entry plus 13H): the new user password.
5C30
GOSUB to SYS0/SYS's 4AD6H to write 4200H back as the directory sector of locator Register B on drive Register C; the NZ FLAG and Register A = 12H on failure. 5C25H jumps here.
5C33
If the NZ FLAG is set (the sector could not be written), JUMP to 554CH to show the error in Register A.
5C36
JUMP to 402DH, DOS READY, with the entry changed; the file is left open.
5C39
LD HL,5C42H 21 42 5C
Bad Option
Point Register Pair HL to 5C42H, the message ATTRIBUTE SPECIFICATION ERROR.
5C3C
GOSUB to SYS0/SYS's 4467H to display the text at Register Pair HL (5C42H) up to and including its 0DH.
5C3F
JUMP to 4030H, the exit after an error (DOS READY, or DEBUG when DEBUG is on).
5C42-5C60
DEFB 0AH / DEFM "ATTRIBUTE SPECIFICATION ERROR" / DEFB 0DH 0A 41 54 54 52 49 42 55 54 45 20 53 50 45 43 49 46 49 43 41 54 49 4F 4E 20 45 52 52 4F 52 0D
Message shown by 5C39H: a line feed, the text and 0DH (ENTER).
5C61H - Access Level Table
Seven two-letter entries read by 5B5DH. The entry found gives the level 6 for the first entry down to 0 for the last. The fourth entry, two tilde characters, stands for level 3; the value is copied by SYS2/SYS's 5081H, which takes only letters and digits, so it can never match.
5C61-5C62
DEFM "EX" 45 58
Level 6. SYS0/SYS's file routines allow neither reading nor writing above level 5.
5C63-5C64
DEFM "RE" 52 45
Level 5, at which SYS0/SYS's file routines allow reading but not writing; with N as the third letter (REN, RENAME) 5B73H-5B7CH give level 2 instead.
5C65-5C66
DEFM "WR" 57 52
Level 4, the highest level at which the file routines still allow writing.
5C67-5C68
DEFM "~~" 7E 7E
Level 3: two tilde characters (7EH), which no value copied by 5081H can hold.
5C69-5C6A
DEFM "NA" 4E 41
Level 2, the same as REN, and the highest level at which RENAME works (5FBFH accepts levels 0-2).
5C6B-5C6C
DEFM "KI" 4B 49
Level 1, the entry for the first two letters KI; RENAME accepts it.
5C6D-5C6E
DEFM "FU" 46 55
Level 0, the level a file opened with its owner password has; ATTRIB and RENAME accept it.
5C6FH - DIR (Command 8)
DIR [:d] (A,I,S) clears the screen and shows the diskette's name and date from its granule allocation table, then copies directory sectors 2-9 to 6100H-68FFH and lists the files three to a line: name/extension, then S for a system file, I for an invisible file and P for a file with a password. The list goes through the copy in the order entry 0 of every sector, then entry 1 of every sector, and so on. Unused entries and continuation entries are skipped; system files are shown only with S and invisible files only with I. With A each file gets its own line with its record length, its record count and the granules it uses. Every 12 lines DIR waits for a key; BREAK ends the list. The copy is cleared to zeros before DIR leaves.
5C6F
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, the value of an option that was not given.
5C72
LD (5D9BH),BC ED 43 9B 5D
Store Register Pair BC (0000H) into 5D9BH, the operand of LD DE,nnnn at 5D9AH and the variable of the option A.
5C76
LD (5D0BH),BC ED 43 0B 5D
Store Register Pair BC (0000H) into 5D0BH, the operand of LD DE,nnnn at 5D0AH and the variable of the option I.
5C7A
LD (5CFDH),BC ED 43 FD 5C
Store Register Pair BC (0000H) into 5CFDH, the operand of LD DE,nnnn at 5CFCH and the variable of the option S.
5C7E
LD C,00H 0E 00
Load Register C with 00H, drive 0, used when no drive is given.
5C80
LD A,(HL) 7E
Fetch the first character after DIR from (HL) (Register Pair HL = the command line) into Register A.
5C81
CP 3AH FE 3A
Compare Register A against 3AH, the colon before a drive number.
5C83
If the NZ FLAG is set (no drive given), JUMP to 5C8BH with drive 0.
5C85
INC HL 23
INCrement Register Pair HL (the command line pointer) by 1, past the colon.
5C86
LD A,(HL) 7E
Fetch the drive digit from (HL) (Register Pair HL = the command line pointer) into Register A.
5C87
INC HL 23
INCrement Register Pair HL (the command line pointer) by 1, past the digit.
5C88
SUB 30H D6 30
SUBtract 30H from Register A, turning the digit into a drive number; the character is not checked to be a digit 0-3.
5C8A
LD C,A 4F
Copy the drive number from Register A into Register C.
5C8B
PUSH BC C5
Save Register Pair BC (Register C = the drive) onto the stack. 5C83H jumps here.
5C8C
LD A,C 79
Copy the drive number from Register C into Register A.
5C8D
ADD A,30H C6 30
ADD 30H to Register A, turning the drive number into its digit.
5C8F
LD (5E9EH),A 32 9E 5E
Store Register A (the drive digit) into 5E9EH, the X of DRIVE X in the heading.
5C92
LD DE,5E6AH 11 6A 5E
Point Register Pair DE to 5E6AH, the option table: A, I and S with the addresses of their variables.
5C95
GOSUB to SYS0/SYS's 4476H to read the option list at Register Pair HL against the table at Register Pair DE (5E6AH). The result flags are not tested.
5C98
LD HL,5E83H 21 83 5E
Point Register Pair HL to 5E83H, the heading: clear the screen, FILE DIRECTORY --- DRIVE d.
5C9B
GOSUB to SYS0/SYS's 4467H to display the heading at Register Pair HL; it ends with 03H, so the diskette's name follows on the same line.
5C9E
POP BC C1
Restore Register Pair BC (Register C = the drive) from the stack.
5C9F
PUSH BC C5
Save Register Pair BC (Register C = the drive) onto the stack again.
5CA0
GOSUB to SYS0/SYS's 4B55H: Register D = the directory track of drive Register C.
5CA3
LD E,00H 1E 00
Load Register E with 00H, directory sector 0, the granule allocation table.
5CA5
LD HL,4200H 21 00 42
Point Register Pair HL to 4200H, SYS0/SYS's system sector buffer.
5CA8
GOSUB to SYS0/SYS's 4B35H to read drive Register C, track Register D, sector Register E (0) into 4200H; the NZ FLAG and Register A = the error number on failure.
5CAB
If the NZ FLAG is set (a read error), JUMP to 554CH to show the error in Register A.
5CAE
LD HL,42D0H 21 D0 42
Point Register Pair HL to 42D0H, bytes D0H-D7H of the table, the diskette's name.
5CB1
LD DE,5EA1H 11 A1 5E
Point Register Pair DE to 5EA1H, the name field of the second heading line.
5CB4
LD BC,0008H 01 08 00
Load Register Pair BC with 0008H, the eight characters of the name.
5CB7
LDIR ED B0
Copy the name: LDIR moves 8 bytes from (HL) (Register Pair HL = 42D0H) to (DE) (Register Pair DE = 5EA1H), counting Register Pair BC down; Register Pair HL ends at 42D8H.
5CB9
LD DE,5EADH 11 AD 5E
Point Register Pair DE to 5EADH, the date field of the second heading line.
5CBC
LD BC,0008H 01 08 00
Load Register Pair BC with 0008H, the eight characters of the date (MM/DD/YY).
5CBF
LDIR ED B0
Copy the date: LDIR moves 8 bytes from (HL) (Register Pair HL = 42D8H, bytes D8H-DFH of the table) to (DE) (Register Pair DE = 5EADH), counting Register Pair BC down.
5CC1
LD HL,5EA1H 21 A1 5E
Point Register Pair HL to 5EA1H, the name, two dashes and the date.
5CC4
GOSUB to SYS0/SYS's 4467H to display the text at Register Pair HL; it ends with a line feed and 0DH.
5CC7
POP BC C1
Restore Register Pair BC (Register C = the drive) from the stack.
5CC8
LD B,00H 06 00
Load Register B with 00H, the locator of the first entry of directory sector 2.
5CCA
LD DE,6100H 11 00 61
Point Register Pair DE to 6100H, where the eight directory sectors are copied.
5CCD
Copy Loop
GOSUB to SYS0/SYS's 4AC1H to read the directory sector of locator Register B (sector Register B plus 2) on drive Register C into 4200H; the NZ FLAG and Register A = 11H on failure. Register Pair DE is kept. 5CE0H loops back here.
5CD0
If the NZ FLAG is set (the sector could not be read), JUMP to 554CH to show the error in Register A.
5CD3
LD L,00H 2E 00
Load Register L with 00H: Register Pair HL = 4200H, the start of the sector.
5CD5
PUSH BC C5
Save Register Pair BC (Register B = locator, Register C = drive) onto the stack.
5CD6
LD BC,0100H 01 00 01
Load Register Pair BC with 0100H, the 256 bytes of a sector.
5CD9
LDIR ED B0
Copy the sector: LDIR moves 256 bytes from (HL) (Register Pair HL = 4200H) to (DE) (Register Pair DE = 6100H plus 100H for each sector already copied), counting Register Pair BC down.
5CDB
POP BC C1
Restore Register Pair BC (Register B = locator, Register C = drive) from the stack.
5CDC
INC B 04
INCrement Register B (the locator) by 1, to the next directory sector.
5CDD
LD A,B 78
Copy the locator from Register B into Register A.
5CDE
CP 08H FE 08
Compare Register A against 08H: the Z FLAG is set after sector 9 (locator 7).
5CE0
Copy Loop End
If the NZ FLAG is set, LOOP BACK to 5CCDH for the next sector.
5CE2
LD HL,6100H 21 00 61
Point Register Pair HL to 6100H, entry 0 of the copy of sector 2.
5CE5
LD A,0CH 3E 0C
Load Register A with 0CH, twelve lines to a screen.
5CE7
LD (5DABH),A 32 AB 5D
Store Register A (12) into 5DABH, the operand of LD A,nn at 5DAAH: the lines left before DIR waits for a key.
5CEA
LD B,03H 06 03
Load Register B with 03H, three files to a line.
5CEC
LD A,(HL) 7E
Entry Loop
Fetch the attribute byte of the entry from (HL) (Register Pair HL = the entry in the copy) into Register A. 5DC4H and 5DCDH jump here.
5CED
PUSH HL E5
Save Register Pair HL (the entry) onto the stack.
5CEE
BIT 4,A CB 67
Test bit 4 of Register A (the attribute byte), set for an entry in use.
5CF0
If the Z FLAG is set (an unused entry), JUMP to 5DBFH to go to the next one.
5CF3
BIT 7,A CB 7F
Test bit 7 of Register A (the attribute byte), set for a continuation entry.
5CF5
If the NZ FLAG is set (a continuation entry), JUMP to 5DBFH to go to the next one.
5CF8
BIT 6,A CB 77
Test bit 6 of Register A (the attribute byte), set for a system file.
5CFA
If the Z FLAG is set (not a system file), JUMP to 5D06H to test the invisible bit.
5CFC
LD DE,0000H 11 00 00
Load Register Pair DE with the S option's variable, the operand at 5CFDH (0000H in the file and from 5C7AH, FFFFH when S was given).
5CFF
LD A,D 7A
Copy the high byte of the S variable from Register D into Register A.
5D00
OR E B3
OR Register A with Register E (the low byte): the Z FLAG is set when S was not given.
5D01
If the Z FLAG is set (no S), JUMP to 5DBFH: the system file is not shown.
5D04
JUMP to 5D12H to show the system file, whatever its invisible bit.
5D06
BIT 3,A CB 5F
Test bit 3 of Register A (the attribute byte), set for an invisible file. 5CFAH jumps here.
5D08
If the Z FLAG is set (visible), JUMP to 5D12H to show it.
5D0A
LD DE,0000H 11 00 00
Load Register Pair DE with the I option's variable, the operand at 5D0BH (0000H in the file and from 5C76H, FFFFH when I was given).
5D0D
LD A,D 7A
Copy the high byte of the I variable from Register D into Register A.
5D0E
OR E B3
OR Register A with Register E (the low byte): the Z FLAG is set when I was not given.
5D0F
If the Z FLAG is set (no I), JUMP to 5DBFH: the invisible file is not shown.
5D12
PUSH BC C5
Show the Entry
Save Register Pair BC (Register B = the places left on the line) onto the stack. 5D04H and 5D08H jump here.
5D13
LD A,L 7D
Copy Register L (the low byte of the entry address) into Register A.
5D14
ADD A,05H C6 05
ADD 05H to Register A, the offset of the name in the entry.
5D16
LD L,A 6F
Copy Register A into Register L: Register Pair HL = the entry plus 05H, the name.
5D17
LD C,11H 0E 11
Load Register C with 11H, the 17 columns counted for the name, extension and space.
5D19
LD B,08H 06 08
Load Register B with 08H, the eight characters of the name.
5D1B
LD A,(HL) 7E
Name Loop
Fetch the next character of the name from (HL) (Register Pair HL = the name pointer) into Register A. 5D25H loops back here.
5D1C
INC HL 23
INCrement Register Pair HL (the name pointer) by 1.
5D1D
CP 20H FE 20
Compare Register A against 20H, the space that pads a short name.
5D1F
If the Z FLAG is set (the end of the name), JUMP to 5D29H to move to the extension.
5D21
GOSUB to ROM routine at 0033H to display the character of the name in Register A.
5D24
DEC C 0D
DECrement Register C (the columns left) by 1.
5D25
Name Loop End
DECrement Register B and LOOP BACK to 5D1BH until the eight characters are shown.
5D27
JUMP to 5D2DH: Register Pair HL is already at the extension (the entry plus 0DH).
5D29
LD A,L 7D
Copy Register L (one past the space) into Register A. 5D1FH jumps here.
5D2A
ADD A,B 80
ADD Register B (the name characters not yet looked at, the space included) to Register A.
5D2B
DEC A 3D
DECrement Register A by 1: the low byte of the entry plus 0DH, the extension.
5D2C
LD L,A 6F
Copy Register A into Register L: Register Pair HL = the extension.
5D2D
LD A,(HL) 7E
Fetch the first character of the extension from (HL) (Register Pair HL = the entry plus 0DH) into Register A. 5D27H jumps here.
5D2E
CP 20H FE 20
Compare Register A against 20H, a space: the file has no extension.
5D30
If the Z FLAG is set (no extension), JUMP to 5D46H.
5D32
LD A,2FH 3E 2F
Load Register A with 2FH, the slash between the name and the extension.
5D34
GOSUB to ROM routine at 0033H to display Register A (the slash).
5D37
DEC C 0D
DECrement Register C (the columns left) by 1.
5D38
LD B,03H 06 03
Load Register B with 03H, the three characters of the extension.
5D3A
LD A,(HL) 7E
Extension Loop
Fetch the next character of the extension from (HL) (Register Pair HL = the extension pointer) into Register A. 5D44H loops back here.
5D3B
INC HL 23
INCrement Register Pair HL (the extension pointer) by 1.
5D3C
CP 20H FE 20
Compare Register A against 20H, the space that pads a short extension.
5D3E
If the Z FLAG is set (the end of the extension), JUMP to 5D46H.
5D40
GOSUB to ROM routine at 0033H to display the character of the extension in Register A.
5D43
DEC C 0D
DECrement Register C (the columns left) by 1.
5D44
Extension Loop End
DECrement Register B and LOOP BACK to 5D3AH until the three characters are shown.
5D46
LD A,20H 3E 20
Load Register A with 20H, a space after the name. 5D30H and 5D3EH jump here.
5D48
GOSUB to ROM routine at 0033H to display Register A (the space).
5D4B
DEC C 0D
DECrement Register C (the columns left) by 1.
5D4C
LD A,L 7D
Copy Register L (somewhere in the entry) into Register A.
5D4D
AND E0H E6 E0
AND Register A with E0H, back to the start of the 32-byte entry.
5D4F
LD L,A 6F
Copy Register A into Register L: Register Pair HL = the entry.
5D50
LD B,(HL) 46
Fetch the attribute byte from (HL) (Register Pair HL = the entry) into Register B.
5D51
LD A,53H 3E 53
Load Register A with 53H, the letter S shown for a system file.
5D53
BIT 6,B CB 70
Test bit 6 of Register B (the attribute byte), set for a system file.
5D55
If the NZ FLAG is set (a system file), JUMP to 5D59H to show the S.
5D57
LD A,20H 3E 20
Load Register A with 20H, a space in place of the S.
5D59
GOSUB to ROM routine at 0033H to display Register A (S or a space). 5D55H jumps here.
5D5C
LD A,49H 3E 49
Load Register A with 49H, the letter I shown for an invisible file.
5D5E
BIT 3,B CB 58
Test bit 3 of Register B (the attribute byte), set for an invisible file.
5D60
If the NZ FLAG is set (invisible), JUMP to 5D64H to show the I.
5D62
LD A,20H 3E 20
Load Register A with 20H, a space in place of the I.
5D64
GOSUB to ROM routine at 0033H to display Register A (I or a space). 5D60H jumps here.
5D67
PUSH HL E5
Save Register Pair HL (the entry) onto the stack.
5D68
LD A,L 7D
Copy Register L (the low byte of the entry address) into Register A.
5D69
ADD A,10H C6 10
ADD 10H to Register A, the offset of the owner password hash.
5D6B
LD L,A 6F
Copy Register A into Register L: Register Pair HL = the entry plus 10H.
5D6C
LD E,(HL) 5E
Fetch the low byte of the owner password hash from (HL) (Register Pair HL = the entry plus 10H) into Register E.
5D6D
INC L 2C
INCrement Register L by 1, to the entry plus 11H.
5D6E
LD D,(HL) 56
Fetch the high byte of the owner password hash from (HL) (Register Pair HL = the entry plus 11H) into Register D.
5D6F
PUSH HL E5
Save Register Pair HL (the entry plus 11H) onto the stack.
5D70
LD HL,4296H 21 96 42
Load Register Pair HL with 4296H, the hash of a blank password (eight spaces).
5D73
SBC HL,DE ED 52
SUBtract Register Pair DE (the owner hash) from Register Pair HL (4296H); the CARRY FLAG is clear from the ADD at 5D69H. The Z FLAG is set when the owner password is blank.
5D75
POP HL E1
Restore Register Pair HL (the entry plus 11H) from the stack.
5D76
If the Z FLAG is set (no owner password), JUMP to 5D8CH to show a space.
5D78
LD A,B 78
Copy the attribute byte from Register B into Register A.
5D79
AND 07H E6 07
AND Register A with 07H, the access level; this also clears the CARRY FLAG.
5D7B
LD A,50H 3E 50
Load Register A with 50H, the letter P; LD does not change the flags.
5D7D
If the NZ FLAG is set (an owner password and a level above 0), JUMP to 5D8EH to show the P.
5D7F
INC L 2C
INCrement Register L by 1, to the entry plus 12H, the user password hash.
5D80
LD E,(HL) 5E
Fetch the low byte of the user password hash from (HL) (Register Pair HL = the entry plus 12H) into Register E.
5D81
INC L 2C
INCrement Register L by 1, to the entry plus 13H.
5D82
LD D,(HL) 56
Fetch the high byte of the user password hash from (HL) (Register Pair HL = the entry plus 13H) into Register D.
5D83
LD HL,4296H 21 96 42
Load Register Pair HL with 4296H, the hash of a blank password.
5D86
SBC HL,DE ED 52
SUBtract Register Pair DE (the user hash) from Register Pair HL (4296H), the CARRY FLAG clear from 5D79H: the NZ FLAG is set when the user password is not blank.
5D88
LD A,50H 3E 50
Load Register A with 50H, the letter P; LD does not change the flags.
5D8A
If the NZ FLAG is set (a user password), JUMP to 5D8EH to show the P.
5D8C
LD A,20H 3E 20
Load Register A with 20H, a space in place of the P. 5D76H jumps here.
5D8E
GOSUB to ROM routine at 0033H to display Register A (P or a space). 5D7DH and 5D8AH jump here.
5D91
POP HL E1
Restore Register Pair HL (the entry) from the stack.
5D92
LD A,20H 3E 20
Pad Loop
Load Register A with 20H, a space. 5D98H loops back here.
5D94
GOSUB to ROM routine at 0033H to display Register A (a space).
5D97
DEC C 0D
DECrement Register C (the columns left of the 17) by 1.
5D98
Pad Loop End
If the NZ FLAG is set, LOOP BACK to 5D92H: each file takes 20 columns (17 counted plus the S, I and P).
5D9A
LD DE,0000H 11 00 00
Load Register Pair DE with the A option's variable, the operand at 5D9BH (0000H in the file and from 5C72H, FFFFH when A was given).
5D9D
LD A,D 7A
Copy the high byte of the A variable from Register D into Register A.
5D9E
OR E B3
OR Register A with Register E (the low byte): the NZ FLAG is set when A was given.
5D9F
POP BC C1
Restore Register Pair BC (Register B = the places left on the line) from the stack; POP does not change the flags.
5DA0
If the NZ FLAG is set (A given), GOSUB to 5DF1H to show the record length, record count and granules of the entry at Register Pair HL; it returns Register B = 01H, so the line ends here.
5DA3
DECrement Register B (the places left on the line) and, while it is not zero, JUMP to 5DBFH for the next entry on the same line.
5DA5
LD A,0DH 3E 0D
Load Register A with 0DH, ENTER, to end the line.
5DA7
GOSUB to ROM routine at 0033H to display Register A (0DH).
5DAA
LD A,00H 3E 00
Load Register A with the lines left, the operand at 5DABH stored by 5CE7H and 5DB4H (00H in the file).
5DAC
DEC A 3D
DECrement Register A (the lines left on the screen) by 1: the Z FLAG when the screen is full.
5DAD
If the NZ FLAG is set (the screen is not full), JUMP to 5DB4H to store the count.
5DAF
GOSUB to ROM routine at 0049H to wait for a key: twelve lines have been shown.
5DB2
LD A,0CH 3E 0C
Load Register A with 0CH, twelve lines for the next screen.
5DB4
LD (5DABH),A 32 AB 5D
Store Register A (the lines left) into 5DABH, the operand of LD A,nn at 5DAAH. 5DADH jumps here.
5DB7
GOSUB to 5515H to test for BREAK and for a pause with SHIFT and @; the NZ FLAG means BREAK.
5DBA
If the NZ FLAG is set (BREAK), JUMP to 5DDBH to clear the copy and leave.
5DBD
LD B,03H 06 03
Load Register B with 03H, three files on the next line.
5DBF
POP HL E1
Next Entry
Restore Register Pair HL (the entry) from the stack, pushed at 5CEDH. 5CF0H, 5CF5H, 5D01H, 5D0FH and 5DA3H jump here.
5DC0
INC H 24
INCrement Register H by 1: the entry at the same place in the next sector's copy.
5DC1
LD A,H 7C
Copy Register H (the page of the sector copy) into Register A.
5DC2
CP 69H FE 69
Compare Register A against 69H, one page past the copy of sector 9.
5DC4
If the NZ FLAG is set (still in the copy), JUMP to 5CECH for that entry.
5DC7
LD H,61H 26 61
Load Register H with 61H, back to the copy of sector 2.
5DC9
LD A,L 7D
Copy Register L (the entry's offset) into Register A.
5DCA
ADD A,20H C6 20
ADD 20H to Register A, the next entry offset; the CARRY FLAG is set after offset E0H.
5DCC
LD L,A 6F
Copy Register A into Register L: Register Pair HL = the next entry of the copy of sector 2.
5DCD
If the NO CARRY FLAG is set (more entries), JUMP to 5CECH.
5DD0
GOSUB to 5DE1H to clear the copy of the directory at 6100H-68FFH to zeros.
5DD3
LD A,0DH 3E 0D
Load Register A with 0DH, ENTER, to end the last line.
5DD5
GOSUB to ROM routine at 0033H to display Register A (0DH).
5DD8
JUMP to 402DH, DOS READY, after the whole directory.
5DDB
BREAK
GOSUB to 5DE1H to clear the copy of the directory at 6100H-68FFH to zeros. 5DBAH jumps here.
5DDE
JUMP to 4030H, the exit after an error (DOS READY, or DEBUG when DEBUG is on).
5DE1H - Clear the Directory Copy
Fills 6100H-68FFH, the copy of directory sectors 2-9, with zeros.
5DE1
LD HL,6100H 21 00 61
Point Register Pair HL to 6100H, the start of the copy. 5DD0H and 5DDBH call here.
5DE4
LD B,00H 06 00
Load Register B with 00H, the byte stored all through the copy.
5DE6
LD (HL),B 70
Clear Loop
Store Register B (00H) at (HL) (Register Pair HL = the copy pointer). 5DE8H and 5DEEH loop back here.
5DE7
INC L 2C
INCrement Register L by 1: the Z FLAG is set when it wraps to 00H at the end of a page.
5DE8
If the NZ FLAG is set (still in the page), LOOP BACK to 5DE6H.
5DEA
INC H 24
INCrement Register H by 1, to the next 256-byte page of the copy.
5DEB
LD A,H 7C
Copy Register H (the page being cleared) into Register A.
5DEC
CP 69H FE 69
Compare Register A against 69H, one page past the copy.
5DEE
Clear Loop End
If the NZ FLAG is set, LOOP BACK to 5DE6H for the next page.
5DF0
RET C9
RETURN to 5DD3H or 5DDEH with 6100H-68FFH cleared.
5DF1H - DIR (A): Size of a File
Register Pair HL = the entry in the copy. Shows LRL= the record length (256 for 00H), EOF= the three bytes ending record number high, low and end-of-file byte (ERN times 256 plus the end-of-file byte) divided by the record length, and SIZE= the granules of all the file's extents. The division at 60A7H loses the top bit of its remainder when the record length is above 128, so EOF= can be wrong for record lengths 129-255. Returns Register B = 01H.
5DF1
PUSH HL E5
Save Register Pair HL (the entry) onto the stack. 5DA0H calls here.
5DF2
INC L 2C
INCrement Register L by 1, to the entry plus 01H.
5DF3
INC L 2C
INCrement Register L by 1, to the entry plus 02H.
5DF4
INC L 2C
INCrement Register L by 1, to the entry plus 03H, the end-of-file byte.
5DF5
LD A,(HL) 7E
Fetch the end-of-file byte from (HL) (Register Pair HL = the entry plus 03H) into Register A.
5DF6
LD (5E69H),A 32 69 5E
Store Register A (the end-of-file byte) into 5E69H, the low byte of the three-byte value.
5DF9
INC L 2C
INCrement Register L by 1, to the entry plus 04H, the record length.
5DFA
PUSH HL E5
Save Register Pair HL (the entry plus 04H) onto the stack.
5DFB
LD L,(HL) 6E
Fetch the record length from (HL) (Register Pair HL = the entry plus 04H) into Register L.
5DFC
LD A,L 7D
Copy the record length from Register L into Register A.
5DFD
LD (5E1FH),A 32 1F 5E
Store Register A (the record length) into 5E1FH, the operand of LD C,nn at 5E1EH: the divisor.
5E00
SUB 01H D6 01
SUBtract 01H from Register A: the CARRY FLAG is set only for a record length of 00H (256).
5E02
LD A,00H 3E 00
Load Register A with 00H; LD does not change the CARRY FLAG.
5E04
ADC A,00H CE 00
ADD WITH CARRY 00H to Register A: 01H for a record length of 00H, else 00H.
5E06
LD H,A 67
Copy Register A into Register H: Register Pair HL = 0100H (256) for 00H, else the record length.
5E07
LD DE,5EBBH 11 BB 5E
Point Register Pair DE to 5EBBH, the five digits after LRL=.
5E0A
GOSUB to 606CH to write Register Pair HL (the record length) as five decimal digits at Register Pair DE, leading zeros as spaces.
5E0D
POP HL E1
Restore Register Pair HL (the entry plus 04H) from the stack.
5E0E
LD A,L 7D
Copy Register L (the low byte of the entry plus 04H) into Register A.
5E0F
ADD A,10H C6 10
ADD 10H to Register A: the entry plus 14H, the ending record number.
5E11
LD L,A 6F
Copy Register A into Register L: Register Pair HL = the entry plus 14H.
5E12
LD A,(HL) 7E
Fetch the low byte of the ending record number from (HL) (Register Pair HL = the entry plus 14H) into Register A.
5E13
LD (5E68H),A 32 68 5E
Store Register A into 5E68H, the middle byte of the three-byte value.
5E16
INC L 2C
INCrement Register L by 1, to the entry plus 15H.
5E17
LD A,(HL) 7E
Fetch the high byte of the ending record number from (HL) (Register Pair HL = the entry plus 15H) into Register A.
5E18
LD (5E67H),A 32 67 5E
Store Register A into 5E67H, the high byte of the three-byte value.
5E1B
LD HL,5E67H 21 67 5E
Point Register Pair HL to 5E67H, the three-byte value, high byte first.
5E1E
LD C,00H 0E 00
Load Register C with the record length stored at 5E1FH by 5DFDH (00H in the file), the divisor.
5E20
GOSUB to 60A7H to divide the three bytes at Register Pair HL by Register C; Register Pair DE returns the quotient (the high and middle bytes when Register C is 00H).
5E23
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the record count.
5E24
LD DE,5EC7H 11 C7 5E
Point Register Pair DE to 5EC7H, the five digits after EOF=.
5E27
GOSUB to 606CH to write Register Pair HL (the record count) as five decimal digits at Register Pair DE.
5E2A
POP HL E1
Restore Register Pair HL (the entry) from the stack, pushed at 5DF1H.
5E2B
GOSUB to 5E3EH to count the granules of the entry at Register Pair HL and its continuation entries; Register Pair DE returns the count.
5E2E
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the granule count.
5E2F
LD DE,5ED4H 11 D4 5E
Point Register Pair DE to 5ED4H, the five digits after SIZE=.
5E32
GOSUB to 606CH to write Register Pair HL (the granules) as five decimal digits at Register Pair DE.
5E35
LD HL,5EB7H 21 B7 5E
Point Register Pair HL to 5EB7H, the text LRL=nnnnn / EOF=nnnnn / SIZE=nnnnn GRANS.
5E38
GOSUB to SYS0/SYS's 4467H to display the text at Register Pair HL; it ends with 03H, and 5DA5H ends the line.
5E3B
LD B,01H 06 01
Load Register B with 01H, so the DJNZ at 5DA3H ends the line after this file.
5E3D
RET C9
RETURN to 5DA3H with Register B = 01H and the size line shown.
5E3EH - Count a File's Granules
Register Pair HL = an entry in the copy at 6100H-68FFH. Adds up the granules of the extents at entry plus 16H: each extent is a track byte and a granule byte whose bits 0-4 are the granules minus 1. A track byte of FFH ends the list; FEH continues it in the entry whose locator is the next byte, found in the copy. Returns Register Pair DE = the granules.
5E3E
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the granule count. 5E2BH calls here.
5E41
LD A,L 7D
Copy Register L (the low byte of the entry address) into Register A.
5E42
ADD A,16H C6 16
ADD 16H to Register A, the offset of the first extent.
5E44
LD L,A 6F
Copy Register A into Register L: Register Pair HL = the first extent.
5E45
LD A,(HL) 7E
Extent Loop
Fetch the track byte of the extent from (HL) (Register Pair HL = the extent) into Register A. 5E52H, 5E55H and 5E65H loop back here.
5E46
INC L 2C
INCrement Register L by 1, to the extent's granule byte.
5E47
CP FEH FE FE
Compare Register A (the track byte) against FEH: the NO CARRY FLAG is set for FEH (continued) and FFH (end).
5E49
If the NO CARRY FLAG is set (FEH or FFH), JUMP to 5E57H.
5E4B
LD A,(HL) 7E
Fetch the granule byte from (HL) (Register Pair HL = the extent plus 1) into Register A.
5E4C
INC L 2C
INCrement Register L by 1, to the next extent.
5E4D
AND 1FH E6 1F
AND Register A with 1FH, keeping bits 0-4, the granules in the extent minus 1.
5E4F
INC A 3C
INCrement Register A by 1: the granules in the extent.
5E50
ADD A,E 83
ADD Register E (the low byte of the count) to Register A.
5E51
LD E,A 5F
Copy Register A (the new low byte of the count) into Register E.
5E52
If the NO CARRY FLAG is set (no carry out of the low byte), LOOP BACK to 5E45H.
5E54
INC D 14
INCrement Register D (the high byte of the count) by 1 for the carry.
5E55
Extent Loop End
LOOP BACK to 5E45H for the next extent.
5E57
RET NZ C0
If the NZ FLAG is set (FFH, the end of the extents), RETURN with Register Pair DE = the granules. 5E49H jumps here.
5E58
LD B,(HL) 46
Fetch the locator of the continuation entry from (HL) (Register Pair HL = the byte after FEH) into Register B.
5E59
LD A,B 78
Copy the locator from Register B into Register A.
5E5A
AND 07H E6 07
AND Register A with 07H, the directory sector minus 2.
5E5C
ADD A,61H C6 61
ADD 61H to Register A: the page of that sector's copy (6100H for sector 2).
5E5E
LD H,A 67
Copy Register A (the page of the sector copy) into Register H.
5E5F
LD A,B 78
Copy the locator from Register B into Register A.
5E60
AND E0H E6 E0
AND Register A with E0H, the entry's offset in the sector.
5E62
ADD A,16H C6 16
ADD 16H to Register A, the offset of the first extent.
5E64
LD L,A 6F
Copy Register A into Register L: Register Pair HL = the first extent of the continuation entry.
5E65
JUMP to 5E45H to go on counting in the continuation entry.
5E67-5E69
DEFS 3
Not in the file: the value divided by 5E20H, high byte first: ending record number high (5E67H), low (5E68H) and the end-of-file byte (5E69H).
5E6AH - DIR Option Table and Display Texts
The option table for 4476H (A, I and S with the addresses of their variables), the heading lines, and the size line of DIR (A). The fields that DIR fills in start rows of their own.
5E6A-5E71
DEFM "A " / DEFW 5D9BH 41 20 20 20 20 20 9B 5D
Option A (show each file's size on its own line): its value goes into 5D9BH-5D9CH, read at 5D9AH.
5E72-5E79
DEFM "I " / DEFW 5D0BH 49 20 20 20 20 20 0B 5D
Option I (show invisible files too): its value goes into 5D0BH-5D0CH, read at 5D0AH.
5E7A-5E81
DEFM "S " / DEFW 5CFDH 53 20 20 20 20 20 FD 5C
Option S (show system files too): its value goes into 5CFDH-5CFEH, read at 5CFCH.
5E82
DEFB 00H 00
End of the DIR option table: SYS1/SYS's table lookup stops at an entry starting with 00H.
5E83-5E9D
DEFB 1CH, 1FH / DEFM "FILE DIRECTORY --- DRIVE " 1C 1F 46 49 4C 45 20 44 49 52 45 43 54 4F 52 59 20 2D 2D 2D 20 44 52 49 56 45 20
The heading shown by 5C9BH: 1CH (cursor to the top left) and 1FH (erase to the end of the screen) clear the screen, then the text.
5E9E
DEFM "X" 58
The drive digit of the heading, replaced by 5C8FH.
5E9F-5EA0
DEFB C5H, 03H C5 03
Five spaces (space compression code C5H), then 03H, which ends the heading without a new line.
5EA1-5EA8
DEFM "NNNNNNNN" 4E 4E 4E 4E 4E 4E 4E 4E
The diskette's name, copied from bytes D0H-D7H of the allocation table by 5CB7H.
5EA9-5EAC
DEFM " -- " 20 2D 2D 20
Two dashes with a space on each side, between the diskette's name and its date in the second heading line.
5EAD-5EB4
DEFM "MM/DD/YY" 4D 4D 2F 44 44 2F 59 59
The diskette's date, copied from bytes D8H-DFH of the allocation table by 5CBFH.
5EB5-5EB6
DEFB 0AH, 0DH 0A 0D
A line feed and 0DH (ENTER), which ends the text of 5CC4H.
5EB7-5EBA
DEFM "LRL=" 4C 52 4C 3D
Start of the size line of DIR (A), shown by 5E38H.
5EBB-5EBF
DEFM " " 20 20 20 20 20
The record length, written as five decimal digits by 5E0AH.
5EC0-5EC6
DEFB 20H / DEFM "/ EOF=" 20 2F 20 45 4F 46 3D
The separator between the record length and the record count of the size line.
5EC7-5ECB
DEFM " " 20 20 20 20 20
The record count (ending record number times 256 plus the end-of-file byte, divided by the record length), written by 5E27H.
5ECC-5ED3
DEFB 20H / DEFM "/ SIZE=" 20 2F 20 53 49 5A 45 3D
The separator between the record count and the granule count of the size line.
5ED4-5ED8
DEFM " " 20 20 20 20 20
The granules the file uses, written by 5E32H.
5ED9-5EDF
DEFM " GRANS" / DEFB 03H 20 47 52 41 4E 53 03
End of the size line; 03H ends it without a new line, and 5DA5H ends the line.
5EE0H - FREE (Command 10)
For each drive 0-3 that has a diskette turning, FREE shows the drive number, the diskette's name and date, the free directory entries (FILES) and the free granules (GRANS). The free granules are the 0 bits of the 35 track bytes of the granule allocation table; the free entries are the 00H bytes of the hash index table at the locators of entries 2-7 of each directory sector (entries 0 and 1 are the places of the system files). An empty filespec is opened first, so that SYS2/SYS, with its drive test at 50FDH and its hash index table read at 512EH, is in the overlay area.
5EE0
LD C,00H 0E 00
Load Register C with 00H, drive 0, the first drive.
5EE2
LD A,03H 3E 03
Load Register A with 03H, the end mark of a filespec.
5EE4
LD DE,5551H 11 51 55
Point Register Pair DE to 5551H, the first FCB.
5EE7
LD (DE),A 12
Store Register A (03H) at (DE) (Register Pair DE = 5551H): the FCB holds an empty filespec.
5EE8
GOSUB to SYS0/SYS's 4424H to open the empty filespec in the FCB at Register Pair DE. The result is not tested; the call leaves SYS2/SYS in the overlay area for 50FDH and 512EH.
5EEB
PUSH BC C5
Drive Loop
Save Register Pair BC (Register C = the drive) onto the stack. 5F5DH loops back here.
5EEC
GOSUB to SYS2/SYS's 50FDH to select drive Register C and wait for its index pulse; the NZ FLAG when no diskette is turning.
5EEF
If the NZ FLAG is set (the drive is not ready), JUMP to 5F58H to go to the next drive.
5EF1
LD A,C 79
Copy the drive number from Register C into Register A.
5EF2
ADD A,30H C6 30
ADD 30H to Register A, turning the drive number into its digit.
5EF4
LD (5F68H),A 32 68 5F
Store Register A (the drive digit) into 5F68H, the X of DRIVE X in the line.
5EF7
GOSUB to SYS0/SYS's 4AF0H to read the granule allocation table of drive Register C into 4D00H-4DFFH; the NZ FLAG and Register A = 14H on failure.
5EFA
If the NZ FLAG is set (the table could not be read), JUMP to 554CH to show the error in Register A; FREE stops there.
5EFD
LD HL,4DD0H 21 D0 4D
Point Register Pair HL to 4DD0H, bytes D0H-D7H of the table, the diskette's name.
5F00
LD DE,5F6EH 11 6E 5F
Point Register Pair DE to 5F6EH, the name field of the line.
5F03
LD BC,0008H 01 08 00
Load Register Pair BC with 0008H, the eight characters of the name.
5F06
LDIR ED B0
Copy the name: LDIR moves 8 bytes from (HL) (Register Pair HL = 4DD0H) to (DE) (Register Pair DE = 5F6EH), counting Register Pair BC down; Register Pair HL ends at 4DD8H.
5F08
LD DE,5F79H 11 79 5F
Point Register Pair DE to 5F79H, the date field of the line.
5F0B
LD BC,0008H 01 08 00
Load Register Pair BC with 0008H, the eight characters of the date.
5F0E
LDIR ED B0
Copy the date: LDIR moves 8 bytes from (HL) (Register Pair HL = 4DD8H) to (DE) (Register Pair DE = 5F79H), counting Register Pair BC down.
5F10
LD HL,4D00H 21 00 4D
Point Register Pair HL to 4D00H, the byte for track 0.
5F13
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the free granule count.
5F16
LD B,23H 06 23
Load Register B with 23H, the 35 tracks (00H-22H).
5F18
LD A,(HL) 7E
Track Loop
Fetch the allocation byte of the track from (HL) (Register Pair HL = the table pointer) into Register A. 5F23H loops back here.
5F19
SCF 37
Bit Loop
Set the CARRY FLAG, the bit to shift in at the top. 5F20H loops back here.
5F1A
RRA 1F
Rotate Register A right through the CARRY FLAG: bit 0 goes into the CARRY FLAG and a 1 comes in at bit 7.
5F1B
If the CARRY FLAG is set (the bit was 1, an allocated granule), JUMP to 5F1EH.
5F1D
INC DE 13
INCrement Register Pair DE (the free granule count) by 1 for the 0 bit.
5F1E
CP FFH FE FF
Compare Register A against FFH: the Z FLAG is set once every 0 bit has been shifted out. 5F1BH jumps here.
5F20
Bit Loop End
If the NZ FLAG is set, LOOP BACK to 5F19H to look at the next bit.
5F22
INC L 2C
INCrement Register L by 1, to the next track's byte.
5F23
Track Loop End
DECrement Register B and LOOP BACK to 5F18H until the 35 tracks are counted.
5F25
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the free granules.
5F26
LD DE,5F90H 11 90 5F
Point Register Pair DE to 5F90H, the five digits before GRANS.
5F29
GOSUB to 606CH to write Register Pair HL (the free granules) as five decimal digits at Register Pair DE.
5F2C
POP BC C1
Restore Register Pair BC (Register C = the drive) from the stack.
5F2D
PUSH BC C5
Save Register Pair BC (Register C = the drive) onto the stack again.
5F2E
GOSUB to SYS2/SYS's 512EH to read the hash index table of drive Register C into 4D00H-4DFFH; the NZ FLAG and Register A = 16H on failure.
5F31
If the NZ FLAG is set (the table could not be read), JUMP to 554CH to show the error in Register A.
5F34
LD HL,4D40H 21 40 4D
Point Register Pair HL to 4D40H, the byte for locator 40H, entry 2 of directory sector 2.
5F37
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the free entry count.
5F3A
LD A,(HL) 7E
Slot Loop
Fetch the hash byte from (HL) (Register Pair HL = the table pointer, at a locator) into Register A. 5F44H and 5F49H loop back here.
5F3B
OR A B7
OR Register A with itself: the Z FLAG is set for 00H, a free entry.
5F3C
If the NZ FLAG is set (an entry in use), JUMP to 5F3FH.
5F3E
INC DE 13
INCrement Register Pair DE (the free entry count) by 1.
5F3F
INC L 2C
INCrement Register L by 1, to the next locator. 5F3CH jumps here.
5F40
LD A,L 7D
Copy Register L (the locator) into Register A.
5F41
AND E7H E6 E7
AND Register A with E7H, clearing bits 3 and 4, which a locator never has.
5F43
CP L BD
Compare Register A against Register L: the Z FLAG is set when bits 3 and 4 of Register L are clear, a valid locator.
5F44
If the Z FLAG is set, LOOP BACK to 5F3AH to look at it.
5F46
ADD A,20H C6 20
ADD 20H to Register A (the locator with bits 3 and 4 cleared): sector index 0 of the next entry offset; it wraps to 00H after offset E0H.
5F48
LD L,A 6F
Copy Register A into Register L: the next locator to look at.
5F49
Slot Loop End
If the NZ FLAG is set (not wrapped to 00H), LOOP BACK to 5F3AH.
5F4B
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the free entries.
5F4C
LD DE,5F83H 11 83 5F
Point Register Pair DE to 5F83H, the five digits before FILES.
5F4F
GOSUB to 606CH to write Register Pair HL (the free entries) as five decimal digits at Register Pair DE.
5F52
LD HL,5F62H 21 62 5F
Point Register Pair HL to 5F62H, the line DRIVE d -- name date nnnnn FILES, nnnnn GRANS.
5F55
GOSUB to SYS0/SYS's 4467H to display the line at Register Pair HL up to and including its 0DH.
5F58
POP BC C1
Next Drive
Restore Register Pair BC (Register C = the drive) from the stack. 5EEFH jumps here.
5F59
INC C 0C
INCrement Register C (the drive) by 1, to the next of the four drives.
5F5A
LD A,C 79
Copy the drive from Register C into Register A.
5F5B
CP 04H FE 04
Compare Register A against 04H: the Z FLAG is set after drive 3.
5F5D
Drive Loop End
If the NZ FLAG is set, LOOP BACK to 5EEBH for the next drive.
5F5F
JUMP to 402DH, DOS READY, after drive 3 has been looked at.
5F62-5F67
DEFM "DRIVE " 44 52 49 56 45 20
Start of the line FREE shows for each drive, displayed by 5F55H.
5F68
DEFM "X" 58
The drive digit of the FREE line, replaced by 5EF4H with the drive being shown.
5F69-5F6D
DEFM " -- " 20 2D 2D 20 20
A space, two dashes and two spaces between the drive digit and the diskette's name.
5F6E-5F75
DEFM "NNNNNNNN" 4E 4E 4E 4E 4E 4E 4E 4E
The diskette's name, copied from bytes D0H-D7H of the allocation table by 5F06H.
5F76-5F78
DEFM " " 20 20 20
Three spaces between the diskette's name and its date in the FREE line.
5F79-5F80
DEFM "MM/DD/YY" 4D 4D 2F 44 44 2F 59 59
The diskette's date, copied from bytes D8H-DFH of the allocation table by 5F0EH.
5F81-5F82
DEFM " " 20 20
Two spaces between the diskette's date and the count of free directory entries.
5F83-5F87
DEFM " " 20 20 20 20 20
The free directory entries, written as five decimal digits by 5F4FH.
5F88-5F8F
DEFM " FILES, " 20 46 49 4C 45 53 2C 20
The word FILES after the count of free directory entries, a comma and a space.
5F90-5F94
DEFM " " 20 20 20 20 20
The free granules, written as five decimal digits by 5F29H.
5F95-5F9B
DEFM " GRANS" / DEFB 0DH 20 47 52 41 4E 53 0D
The word GRANS after the count of free granules, and 0DH (ENTER), which ends the line.
5F9CH - RENAME (Command 17)
RENAME oldname TO newname changes the name and extension in oldname's directory entry and its byte in the hash index table. oldname must open at access level 0-2 (else error 25H). newname may not name a drive (DRIVE SPECIFICATION ILLEGAL); RENAME adds oldname's drive to it and opens it to make sure no such file exists there (DUPLICATE FILE NAME). That open leaves newname's eleven-character name, parsed by SYS2/SYS, at 515DH, from where it is copied into the entry and hashed.
5F9C
LD DE,5551H 11 51 55
Point Register Pair DE to 5551H, the first FCB, for oldname.
5F9F
GOSUB to SYS0/SYS's 441CH to parse the filespec at Register Pair HL (the command line) into the FCB at Register Pair DE; the NZ FLAG for a bad filespec.
5FA2
If the NZ FLAG is set (no valid filespec), JUMP to 553AH to display FILE SPEC REQUIRED.
5FA5
LD A,(DE) 1A
Fetch the first character of the parsed name from (DE) (Register Pair DE = 5551H) into Register A.
5FA6
CP 2AH FE 2A
Compare Register A against 2AH, the asterisk that starts a device name.
5FA8
If the Z FLAG is set (a device), JUMP to 553AH to display FILE SPEC REQUIRED.
5FAB
GOSUB to SYS0/SYS's 4424H to open oldname in the FCB at Register Pair DE (5551H); Register Pair HL (the command line pointer) and Register B go in as buffer and record length and come back unchanged.
5FAE
If the NZ FLAG is set (oldname could not be opened), JUMP to 554CH to show the error in Register A.
5FB1
LD DE,5571H 11 71 55
Point Register Pair DE to 5571H, the second FCB, for newname.
5FB4
GOSUB to SYS0/SYS's 441CH to parse the next filespec at Register Pair HL into the FCB at Register Pair DE (5571H), skipping a noise word such as TO.
5FB7
If the NZ FLAG is set (no valid filespec), JUMP to 553AH to display FILE SPEC REQUIRED.
5FBA
LD A,(5552H) 3A 52 55
Fetch oldname's access byte from 5552H (FCB plus 01H) into Register A; bits 0-2 are the access level the password allowed.
5FBD
AND 07H E6 07
AND Register A with 07H, keeping the access level.
5FBF
CP 03H FE 03
Compare Register A (the access level) against 03H: the NO CARRY FLAG is set for levels 3-7.
5FC1
LD A,25H 3E 25
Load Register A with 25H, ILLEGAL ACCESS ATTEMPTED TO PROTECTED FILE; LD does not change the flags.
5FC3
If the NO CARRY FLAG is set (level 3 or above), JUMP to 554CH to show error 25H.
5FC6
LD HL,5571H 21 71 55
Point Register Pair HL to 5571H, newname's filespec text.
5FC9
LD A,(HL) 7E
Scan Loop
Fetch the next character of newname from (HL) (Register Pair HL = the text pointer) into Register A. 5FD3H loops back here.
5FCA
CP 3AH FE 3A
Compare Register A against 3AH, the colon before a drive number.
5FCC
If the Z FLAG is set (newname names a drive), JUMP to 6028H to display DRIVE SPECIFICATION ILLEGAL.
5FCE
CP 20H FE 20
Compare Register A against 20H: the CARRY FLAG is set for a control character, the 03H that ends the text.
5FD0
If the CARRY FLAG is set (the end of newname), JUMP to 5FD5H to add the drive.
5FD2
INC HL 23
INCrement Register Pair HL (the text pointer) by 1.
5FD3
Scan Loop End
LOOP BACK to 5FC9H for the next character.
5FD5
LD (HL),3AH 36 3A
Store 3AH, a colon, at (HL) (Register Pair HL = the end of newname's text, over its 03H). 5FD0H jumps here.
5FD7
INC HL 23
INCrement Register Pair HL (the text pointer) by 1.
5FD8
LD A,(5557H) 3A 57 55
Fetch oldname's drive from 5557H (FCB plus 06H, set by the open) into Register A.
5FDB
ADD A,30H C6 30
ADD 30H to Register A, turning the drive into its digit.
5FDD
LD (HL),A 77
Store Register A (the drive digit) at (HL) (Register Pair HL = the text pointer).
5FDE
INC HL 23
INCrement Register Pair HL (the text pointer) by 1.
5FDF
LD (HL),03H 36 03
Store 03H, the end mark of a filespec, at (HL) (Register Pair HL = the text pointer): newname now ends :d on oldname's drive.
5FE1
LD DE,5571H 11 71 55
Point Register Pair DE to 5571H, newname's FCB.
5FE4
GOSUB to SYS0/SYS's 4424H to open newname on oldname's drive (the FCB at Register Pair DE; Register Pair HL and Register B as they are). Its parse leaves newname's name and extension at 515DH.
5FE7
If the Z FLAG is set (a file of that name exists), JUMP to 604EH to display DUPLICATE FILE NAME.
5FEA
CP 18H FE 18
Compare Register A (the error number) against 18H, FILE NOT IN DIRECTORY, the result wanted.
5FEC
If the NZ FLAG is set (another error), JUMP to 554CH to show the error in Register A.
5FEF
LD BC,(5557H) ED 4B 57 55
Fetch oldname's drive and directory entry locator from 5557H (FCB plus 06H and 07H) into Register Pair BC: Register C = the drive, Register B = the locator.
5FF3
PUSH BC C5
Save Register Pair BC (drive and locator) onto the stack.
5FF4
GOSUB to SYS0/SYS's 4AC1H to read the directory sector of locator Register B on drive Register C into 4200H; Register Pair HL returns oldname's entry, the NZ FLAG and Register A = 11H on failure.
5FF7
If the NZ FLAG is set (the sector could not be read), JUMP to 554CH to show the error in Register A.
5FFA
LD D,H 54
Copy Register H (the high byte of the entry address, 42H) into Register D.
5FFB
LD A,L 7D
Copy Register L (the low byte of the entry address) into Register A.
5FFC
ADD A,05H C6 05
ADD 05H to Register A, the offset of the name in the entry.
5FFE
LD E,A 5F
Copy Register A into Register E: Register Pair DE = the entry plus 05H, the name and extension.
5FFF
LD HL,515DH 21 5D 51
Point Register Pair HL to 515DH, newname's eleven characters as SYS2/SYS's parse left them.
6002
LD BC,000BH 01 0B 00
Load Register Pair BC with 000BH, the eight characters of the name and three of the extension.
6005
LDIR ED B0
Copy the new name: LDIR moves 11 bytes from (HL) (Register Pair HL = 515DH) to (DE) (Register Pair DE = the entry plus 05H), counting Register Pair BC down.
6007
POP BC C1
Restore Register Pair BC (Register C = the drive, Register B = the locator) from the stack.
6008
GOSUB to SYS0/SYS's 4AD6H to write 4200H back as the directory sector of locator Register B on drive Register C; the NZ FLAG and Register A = 12H on failure.
600B
If the NZ FLAG is set (the sector could not be written), JUMP to 554CH to show the error in Register A.
600E
GOSUB to SYS2/SYS's 512EH to read the hash index table of drive Register C into 4D00H-4DFFH; the NZ FLAG and Register A = 16H on failure.
6011
If the NZ FLAG is set (the table could not be read), JUMP to 554CH to show the error in Register A.
6014
LD D,H 54
Copy Register H (4DH, from the read into 4D00H) into Register D.
6015
LD E,B 58
Copy the locator from Register B into Register E: Register Pair DE = 4D00H plus the locator, the entry's byte in the hash index table.
6016
PUSH BC C5
Save Register Pair BC (drive and locator) onto the stack.
6017
LD HL,515DH 21 5D 51
Point Register Pair HL to 515DH, newname's eleven characters.
601A
GOSUB to SYS2/SYS's 509BH to hash the eleven bytes at Register Pair HL; Register A returns the hash (never 00H). It uses Register Pair BC.
601D
POP BC C1
Restore Register Pair BC (Register C = the drive, Register B = the locator) from the stack.
601E
LD (DE),A 12
Store Register A (the new hash) at (DE) (Register Pair DE = the entry's byte in the hash index table).
601F
GOSUB to SYS2/SYS's 5141H to write 4D00H-4DFFH back as the hash index table of drive Register C; the NZ FLAG and Register A = 17H on failure.
6022
If the NZ FLAG is set (the table could not be written), JUMP to 554CH to show the error in Register A.
6025
JUMP to 402DH, DOS READY, with the file renamed; the FCBs are not closed.
6028
LD HL,6031H 21 31 60
Drive in the New Name
Point Register Pair HL to 6031H, the message DRIVE SPECIFICATION ILLEGAL. 5FCCH jumps here.
602B
GOSUB to SYS0/SYS's 4467H to display the text at Register Pair HL (6031H) up to and including its 0DH.
602E
JUMP to 4030H, the exit after an error (DOS READY, or DEBUG when DEBUG is on).
6031-604D
DEFB 0AH / DEFM "DRIVE SPECIFICATION ILLEGAL" / DEFB 0DH 0A 44 52 49 56 45 20 53 50 45 43 49 46 49 43 41 54 49 4F 4E 20 49 4C 4C 45 47 41 4C 0D
Message shown by 6028H when newname contains a colon: a line feed, the text and 0DH (ENTER).
604E
LD HL,6057H 21 57 60
Name Already Used
Point Register Pair HL to 6057H, the message DUPLICATE FILE NAME. 5FE7H jumps here.
6051
GOSUB to SYS0/SYS's 4467H to display the text at Register Pair HL (6057H) up to and including its 0DH.
6054
JUMP to 4030H, the exit after an error (DOS READY, or DEBUG when DEBUG is on).
6057-606B
DEFB 0AH / DEFM "DUPLICATE FILE NAME" / DEFB 0DH 0A 44 55 50 4C 49 43 41 54 45 20 46 49 4C 45 20 4E 41 4D 45 0D
Message shown by 604EH when a file called newname already exists on the drive: a line feed, the text and 0DH (ENTER).
606CH - Five Decimal Digits
Register Pair HL = the value, Register Pair DE = where the digits go. Writes HL as five characters: the ten-thousands, thousands, hundreds and tens through 608CH, with spaces in place of leading zeros, then the units digit. Register Pair DE ends past the fifth character. Used by DIR (A) and FREE.
606C
LD A,20H 3E 20
Load Register A with 20H, a space, the character written for a leading zero. 5E0AH, 5E27H, 5E32H, 5F29H and 5F4FH call here.
606E
LD BC,2710H 01 10 27
Load Register Pair BC with 2710H, 10000, the power of ten of the first digit.
6071
GOSUB to 608CH to write the ten-thousands digit of Register Pair HL at (DE); Register A returns the fill character for the next digit.
6074
LD BC,03E8H 01 E8 03
Load Register Pair BC with 03E8H, 1000, the power of ten of the second digit.
6077
GOSUB to 608CH to write the thousands digit of Register Pair HL at (DE).
607A
LD BC,0064H 01 64 00
Load Register Pair BC with 0064H, 100, the power of ten of the third digit.
607D
GOSUB to 608CH to write the hundreds digit of Register Pair HL at (DE).
6080
LD BC,000AH 01 0A 00
Load Register Pair BC with 000AH, 10, the power of ten of the fourth digit.
6083
GOSUB to 608CH to write the tens digit of Register Pair HL at (DE); Register Pair HL is left with the units, 0-9.
6086
LD A,L 7D
Copy the units from Register L into Register A.
6087
ADD A,30H C6 30
ADD 30H to Register A: the units digit, always written, so a value of 0 shows as 0.
6089
LD (DE),A 12
Store Register A (the units digit) at (DE) (Register Pair DE = the fifth character).
608A
INC DE 13
INCrement Register Pair DE by 1, past the five characters.
608B
RET C9
RETURN to the caller with the five characters written.
608CH - One Decimal Digit
Register Pair HL = the value, Register Pair BC = the power of ten, Register A = the character for a zero digit (a space until the first non-zero digit, then the digit 0). Subtracts Register Pair BC from Register Pair HL as many times as it can, writes the digit at (DE), and returns Register Pair HL = the remainder, Register A = the fill character for the next digit and Register Pair DE moved on by one.
608C
PUSH DE D5
Save Register Pair DE (where the digit goes) onto the stack. 6071H, 6077H, 607DH and 6083H call here.
608D
LD E,A 5F
Copy the fill character from Register A into Register E.
608E
LD D,FFH 16 FF
Load Register D with FFH, the digit count minus 1; the first INC makes it 00H.
6090
XOR A AF
Set Register A to ZERO with XOR A, which clears the CARRY FLAG for the first SBC.
6091
INC D 14
Subtract Loop
INCrement Register D (the digit) by 1. 6094H loops back here.
6092
SBC HL,BC ED 42
SUBtract Register Pair BC (the power of ten) from Register Pair HL (the value): the CARRY FLAG is set when it goes below zero.
6094
Subtract Loop End
If the NO CARRY FLAG is set, LOOP BACK to 6091H to subtract again.
6096
ADD HL,BC 09
ADD Register Pair BC back to Register Pair HL, undoing the subtraction that went below zero: Register Pair HL = the remainder.
6097
LD A,E 7B
Copy the fill character from Register E into Register A.
6098
LD B,D 42
Copy the digit from Register D into Register B.
6099
POP DE D1
Restore Register Pair DE (where the digit goes) from the stack.
609A
LD (DE),A 12
Store Register A (the fill character) at (DE) (Register Pair DE = the digit position); it stays for a leading zero.
609B
INC B 04
INCrement Register B (the digit) by 1, to set up the zero test of the next instruction.
609C
DEC B 05
DECrement Register B by 1 again: the Z FLAG is set when the digit is 0.
609D
If the Z FLAG is set (a zero digit), JUMP to 60A5H, leaving the fill character in place.
609F
LD A,B 78
Copy the digit from Register B into Register A.
60A0
ADD A,30H C6 30
ADD 30H to Register A, turning the digit into its character.
60A2
LD (DE),A 12
Store Register A (the digit character) at (DE) (Register Pair DE = the digit position), over the fill character.
60A3
LD A,30H 3E 30
Load Register A with 30H, the digit 0: zeros after the first non-zero digit are shown.
60A5
INC DE 13
INCrement Register Pair DE by 1, to the next digit position. 609DH jumps here.
60A6
RET C9
RETURN with Register A = the fill character for the next digit.
60A7H - Divide Three Bytes by One
Register Pair HL = a three-byte value, high byte first; Register C = the divisor. Returns Register Pair DE = the quotient (only its low 16 bits are kept) and Register A = the remainder. A divisor of 00H stands for 256: the quotient is then the first two bytes. The remainder is shifted left with RLA, which loses its top bit into the CARRY FLAG before the compare with Register C; for a divisor above 80H a remainder of 80H or more is therefore compared too small, and the quotient can be wrong. DIR (A) calls it with the record length.
60A7
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the quotient. 5E20H calls here.
60AA
LD A,C 79
Copy the divisor from Register C into Register A.
60AB
OR A B7
OR Register A with itself: the Z FLAG is set for a divisor of 00H (256).
60AC
If the Z FLAG is set, JUMP to 60C9H to take the first two bytes as the quotient.
60AE
XOR A AF
Set Register A to ZERO with XOR A: the remainder starts at 00H.
60AF
LD B,03H 06 03
Load Register B with 03H, the three bytes of the value.
60B1
PUSH BC C5
Byte Loop
Save Register Pair BC (Register B = bytes left, Register C = the divisor) onto the stack. 60C6H loops back here.
60B2
PUSH HL E5
Save Register Pair HL (the byte pointer) onto the stack.
60B3
LD H,(HL) 66
Fetch the next byte of the value from (HL) (Register Pair HL = the byte pointer) into Register H.
60B4
LD B,08H 06 08
Load Register B with 08H, the eight bits of the byte.
60B6
EX DE,HL EB
Bit Loop
Exchange Register Pairs DE and HL, so the quotient is in Register Pair HL. 60C1H loops back here.
60B7
ADD HL,HL 29
ADD Register Pair HL (the quotient) to itself: the quotient moves one bit left.
60B8
EX DE,HL EB
Exchange Register Pairs DE and HL again: Register Pair DE = the quotient, Register H = the byte.
60B9
RLC H CB 04
Rotate Register H (the byte) left, circularly: its top bit goes into the CARRY FLAG.
60BB
RLA 17
Rotate Register A (the remainder) left through the CARRY FLAG: the byte's bit comes in at bit 0, and the remainder's top bit goes out into the CARRY FLAG and is lost.
60BC
CP C B9
Compare Register A (the remainder) against Register C (the divisor): the CARRY FLAG is set when it is smaller.
60BD
If the CARRY FLAG is set (smaller than the divisor), JUMP to 60C1H: this quotient bit is 0.
60BF
SUB C 91
SUBtract Register C (the divisor) from Register A (the remainder).
60C0
INC DE 13
INCrement Register Pair DE (the quotient) by 1: this quotient bit is 1.
60C1
Bit Loop End
DECrement Register B and LOOP BACK to 60B6H until the eight bits are done. 60BDH jumps here.
60C3
POP HL E1
Restore Register Pair HL (the byte pointer) from the stack.
60C4
INC HL 23
INCrement Register Pair HL (the byte pointer) by 1, to the next byte.
60C5
POP BC C1
Restore Register Pair BC (Register B = bytes left, Register C = the divisor) from the stack.
60C6
Byte Loop End
DECrement Register B and LOOP BACK to 60B1H until the three bytes are done.
60C8
RET C9
RETURN with Register Pair DE = the quotient and Register A = the remainder.
60C9
LD D,(HL) 56
Divide by 256
Fetch the first (high) byte from (HL) (Register Pair HL = the value) into Register D. 60ACH jumps here.
60CA
INC HL 23
INCrement Register Pair HL (the value pointer) by 1, to the middle byte.
60CB
LD E,(HL) 5E
Fetch the middle byte from (HL) (Register Pair HL = the value plus 1) into Register E: Register Pair DE = the value divided by 256.
60CC
RET C9
RETURN with Register Pair DE = the quotient; the third byte is the remainder and is not returned.
60CDH - VERIFY: Set the Switch
Loaded by the last load record of the file; the record just before it puts CALL 60CDH at 5507H. Entered with the Z FLAG and Register A = 00H for OFF, the NZ FLAG for ON. Stores 00H or 01H into SYS0/SYS's 485EH, the verify switch that 485DH reads, and returns Register Pair HL = 478BH with the Z FLAG for OFF and the NZ FLAG for ON. 478EH also stores the switch on every call of 4439H and 443CH, so the value stored here matters for writes that reach 485DH another way.
60CD
LD HL,478BH 21 8B 47
Load Register Pair HL with 478BH, SYS0/SYS's plain write, the value 550FH stores for OFF. 5507H calls here.
60D0
If the Z FLAG is set (OFF, Register A = 00H), JUMP to 60D5H to store 00H.
60D2
XOR A AF
Set Register A to ZERO with XOR A, before making it 01H for ON.
60D3
INC A 3C
INCrement Register A by 1, to 01H, the switch value for ON; INC clears the Z FLAG.
60D4
OR A B7
OR Register A (01H) with itself, leaving the NZ FLAG set for 550AH.
60D5
LD (485EH),A 32 5E 48
Store Register A (00H or 01H) into 485EH, the operand of SYS0/SYS's LD A,nn at 485DH, the verify switch. 60D0H jumps here.
60D8
RET C9
RETURN to 550AH with Register Pair HL = 478BH and the Z FLAG for OFF or the NZ FLAG for ON.