5200H - Run a Library Command
The transfer address of SYS6/SYS, overlay 8 (directory record 20H), loaded at 5200H by the overlay dispatcher of SYS0/SYS for request code 88H, which SYS1/SYS gives at 4EA0H for a library command; when SYS6/SYS is still in memory (bit 4 of 430FH) SYS1/SYS jumps to 5200H directly (4E95H). Register C is the number of the command in SYS1/SYS's table at 4EBDH (1 APPEND to 19 VERIFY) and Register Pair HL the rest of the command line. The address 402DH is pushed first, so that each command ends at DOS READY by its RET; a chain of DEC A picks the routine.
5200
LD A,C 79
Copy Register C, the number of the library command (1-19) found by SYS1/SYS in its table at 4EBDH, into Register A for the chain of tests.
5201
LD BC,402DH 01 2D 40
Load Register Pair BC with 402DH, the vector of DOS READY (JP 4400H), the address each command returns to.
5204
PUSH BC C5
Save Register Pair BC (402DH) on the stack at the Stack Pointer: the RET at the end of a command goes to DOS READY.
5205
DEC A 3D
Decrement Register A, the command number; the Z FLAG is set when it was 1.
5206
If the Z FLAG is set (command 1, APPEND), jump to 5700H, which appends one file to the end of another.
5209
DEC A 3D
Decrement Register A, the command number; the Z FLAG is set when it was 2.
520A
If the Z FLAG is set (command 2, ATTRIB), jump to 5B00H, which sets the attributes and passwords of a file.
520D
DEC A 3D
Decrement Register A, the command number; the Z FLAG is set when it was 3.
520E
If the Z FLAG is set (command 3, AUTO), jump to 5283H, which stores the command to run at start-up in the GAT.
5211
DEC A 3D
Decrement Register A, the command number; the Z FLAG is set when it was 4.
5212
If the Z FLAG is set (command 4, CLOCK), jump to 52C5H, which turns the display of the time on or off.
5215
DEC A 3D
Decrement Register A, the command number; the Z FLAG is set when it was 5.
5216
If the Z FLAG is set (command 5, copy in small letters), jump to 5251H, which shows RESERVED COMMAND; SYS1/SYS never passes number 5.
5219
DEC A 3D
Decrement Register A, the command number; the Z FLAG is set when it was 6.
521A
If the Z FLAG is set (command 6, DATE), jump to 529DH, which sets the date at 4044H-4046H.
521D
DEC A 3D
Decrement Register A, the command number; the Z FLAG is set when it was 7.
521E
If the Z FLAG is set (command 7, double in small letters), jump to 531DH, which only returns; SYS1/SYS never passes number 7.
5221
DEC A 3D
Decrement Register A, the command number; the Z FLAG is set when it was 8.
5222
If the Z FLAG is set (command 8, DIR), jump to 5C6FH, which shows the directory of a drive.
5225
DEC A 3D
Decrement Register A, the command number; the Z FLAG is set when it was 9.
5226
If the Z FLAG is set (command 9, DUMP), jump to 57D7H, which writes an area of memory to a disk file as a program.
5229
DEC A 3D
Decrement Register A, the command number; the Z FLAG is set when it was 10.
522A
If the Z FLAG is set (command 10, FREE), jump to 5EE0H, which shows the free directory places and granules of each drive.
522D
DEC A 3D
Decrement Register A, the command number; the Z FLAG is set when it was 11.
522E
If the Z FLAG is set (command 11, KILL), jump to 5914H, which removes a file from its diskette.
5231
DEC A 3D
Decrement Register A, the command number; the Z FLAG is set when it was 12.
5232
If the Z FLAG is set (command 12, LIB), jump to 533AH, which shows the names of the library commands.
5235
DEC A 3D
Decrement Register A, the command number; the Z FLAG is set when it was 13.
5236
If the Z FLAG is set (command 13, LIST), jump to 592CH, which shows a file on the screen.
5239
DEC A 3D
Decrement Register A, the command number; the Z FLAG is set when it was 14.
523A
If the Z FLAG is set (command 14, LOAD), jump to 5994H, which loads a program file without running it.
523D
DEC A 3D
Decrement Register A, the command number; the Z FLAG is set when it was 15.
523E
If the Z FLAG is set (command 15, PRINT), jump to 59ACH, which sends a file to the printer.
5241
DEC A 3D
Decrement Register A, the command number; the Z FLAG is set when it was 16.
5242
If the Z FLAG is set (command 16, PROT), jump to 536AH, which changes the master password and locks or unlocks the files of a diskette.
5245
DEC A 3D
Decrement Register A, the command number; the Z FLAG is set when it was 17.
5246
If the Z FLAG is set (command 17, RENAME), jump to 5F9CH, which gives a file a new name.
5249
DEC A 3D
Decrement Register A, the command number; the Z FLAG is set when it was 18.
524A
If the Z FLAG is set (command 18, TIME), jump to 52B1H, which sets the time at 4041H-4043H.
524D
DEC A 3D
Decrement Register A, the command number; the Z FLAG is set when it was 19.
524E
If the Z FLAG is set (command 19, VERIFY), jump to 5504H, which turns the reading back of written sectors on or off. Any other number falls into 5251H.
5251H - Reserved Command
Command 5 (copy) and any number above 19 come here. The table of SYS1/SYS spells copy in small letters, which its lookup never matches, so that COPY runs COPY/CMD; this entry is never reached from SYS1/SYS.
5251
LD HL,525AH 21 5A 52
Load Register Pair HL with 525AH, the text RESERVED COMMAND and a carriage return.
5254
Call 4467H to show the text at Register Pair HL on the screen up to its carriage return.
5257
Jump to 4030H, the abnormal exit of a command, which returns to DOS READY (or enters DEBUG while 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
The text at 525AH shown by 5251H for the reserved command 5: RESERVED COMMAND and a carriage return that ends the text and the line.
526BH - Nothing Done
PROT comes here when no parameter was given and ATTRIB when no list in parentheses follows the file specification.
526B
LD HL,5274H 21 74 52
Load Register Pair HL with 5274H, the text -NOTHING DONE- and a carriage return.
526E
Call 4467H to show the text at Register Pair HL on the screen up to its carriage return.
5271
Jump to 4030H, the abnormal exit of a command, which returns to DOS READY (or enters DEBUG while 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
The text at 5274H shown by 526BH: NOTHING DONE between two minus signs, and a carriage return that ends the text and the line.
5283H - AUTO: Store the Command to Run at Start-Up
The rest of the command line, 32 bytes from Register Pair HL, is copied to bytes E0H-FFH of the GAT of drive 0. At start-up SYS0/SYS runs that text unless its first byte is a carriage return (SYS0/SYS 4EDDH), so AUTO with nothing after it turns the automatic command off. The 32 bytes are copied whatever they hold: the line's carriage return and the bytes after it in the command line buffer 4318H-4357H go too.
5283
LD C,00H 0E 00
Load Register C with 00H, drive 0, the drive whose GAT SYS0/SYS reads at start-up.
5285
Call 4AF0H to read the GAT of drive Register C (drive 0) into 4D00H; the NZ FLAG and an error code in Register A if it fails.
5288
If the NZ FLAG is set (the GAT could not be read), jump to 554CH to report the error in Register A.
528B
LD D,4DH 16 4D
Load Register D with 4DH, the high byte of 4DE0H, the place of the start-up command in the GAT at 4D00H.
528D
LD E,E0H 1E E0
Load Register E with E0H: Register Pair DE is 4DE0H, GAT bytes E0H-FFH.
528F
LD BC,0020H 01 20 00
Load Register Pair BC with 0020H, the 32 bytes of the start-up command.
5292
LDIR ED B0
Copy Register Pair BC (0020H) bytes from the command line at Register Pair HL to the GAT at Register Pair DE (4DE0H).
5294
LD C,00H 0E 00
Load Register C with 00H, drive 0, for the write of its GAT.
5296
Call 4B03H to write the GAT at 4D00H back to drive Register C (drive 0) and read it back; the NZ FLAG and an error code in Register A if it fails.
5299
If the NZ FLAG is set (the GAT could not be written), jump to 554CH to report the error in Register A.
529C
RET C9
Return to 402DH, the address pushed at 5204H: DOS READY, the end of the command.
529DH - DATE: Set the Date
The text after DATE must be MM/DD/YY, three numbers of two digits separated by slashes. 52EAH reads them into 52DCH-52DEH in reverse order, so that the year goes to 4044H, the day to 4045H and the month to 4046H. No number is checked against its range.
529D
LD C,2FH 0E 2F
Load Register C with 2FH, the slash, the character that must separate the three numbers of the date.
529F
Call 52EAH to read three numbers of two digits separated by Register C from Register Pair HL into 52DEH, 52DDH and 52DCH; the Z FLAG when all three were read.
52A2
If the NZ FLAG is set (the text is not three numbers of two digits), jump to 52D3H to show BAD FORMAT.
52A5
LD HL,52DCH 21 DC 52
Load Register Pair HL with 52DCH, the three numbers just read: the year, the day and the month.
52A8
LD DE,4044H 11 44 40
Load Register Pair DE with 4044H, the date of DoubleDOS: 4044H the year, 4045H the day, 4046H the month.
52AB
LD BC,0003H 01 03 00
Load Register Pair BC with 0003H, the three bytes of the date.
52AE
LDIR ED B0
Copy Register Pair BC (0003H) bytes from Register Pair HL (52DCH) to Register Pair DE (4044H): the new date.
52B0
RET C9
Return to 402DH, the address pushed at 5204H: DOS READY, the end of the command.
52B1H - TIME: Set the Time
The text after TIME must be HH:MM:SS, three numbers of two digits separated by colons, read into 52DCH-52DEH in reverse order: the seconds go to 4041H, the minutes to 4042H and the hours to 4043H, the counters of the clock task of SYS0/SYS (45AFH). No number is checked against its range: the clock task counts each one up until it equals 60, 60 or 24 (45CCH), so a number above that runs on to 255 and round through 0 first (a bug: the Bugs part of the introduction).
52B1
LD C,3AH 0E 3A
Load Register C with 3AH, the colon, the character that must separate the three numbers of the time.
52B3
Call 52EAH to read three numbers of two digits separated by Register C from Register Pair HL into 52DEH, 52DDH and 52DCH; the Z FLAG when all three were read.
52B6
If the NZ FLAG is set (the text is not three numbers of two digits), jump to 52D3H to show BAD FORMAT.
52B9
LD HL,52DCH 21 DC 52
Load Register Pair HL with 52DCH, the three numbers just read: the seconds, the minutes and the hours.
52BC
LD DE,4041H 11 41 40
Load Register Pair DE with 4041H, the clock of DoubleDOS: 4041H the seconds, 4042H the minutes, 4043H the hours.
52BF
LD BC,0003H 01 03 00
Load Register Pair BC with 0003H, the three bytes of the time.
52C2
LDIR ED B0
Copy Register Pair BC (0003H) bytes from Register Pair HL (52DCH) to Register Pair DE (4041H): the new time.
52C4
RET C9
Return to 402DH, the address pushed at 5204H: DOS READY, the end of the command.
52C5H - CLOCK: Show the Time or Stop Showing It
CLOCK alone (or with an option that is not OFF or NO) puts the clock display task 4CA9H of SYS0/SYS in task slot 6, so that the time is shown at the right end of the top line of the screen; CLOCK (OFF) or CLOCK (NO) takes it out. The option is read by 51A0H of SYS1/SYS, which is still in memory at 4E00H.
52C5
Call 51A0H of SYS1/SYS to read the option at Register Pair HL: the Z FLAG for (OFF), (NO) or (N), the NZ FLAG for none or any other.
52C8
LD DE,4CA9H 11 A9 4C
Load Register Pair DE with 4CA9H, the task header of the clock display in SYS0/SYS.
52CB
LD A,06H 3E 06
Load Register A with 06H, the number of the task slot used for the clock display.
52CD
If the Z FLAG is set (CLOCK (OFF)), jump to 4413H, which empties task slot Register A, and return from there to DOS READY.
52D0
Jump to 4410H, which puts the task header at Register Pair DE (4CA9H) in task slot Register A (06H), and return from there to DOS READY.
52D3H - Bad Format
DATE and TIME come here when their text is not three numbers of two digits with the right separators.
52D3
LD HL,52DFH 21 DF 52
Load Register Pair HL with 52DFH, the text BAD FORMAT and a carriage return.
52D6
Call 4467H to show the text at Register Pair HL on the screen up to its carriage return.
52D9
Jump to 4030H, the abnormal exit of a command, which returns to DOS READY (or enters DEBUG while DEBUG is on).
52DC-52DE
DEFS 3
Not in the file: the three numbers read by 52EAH, 52DCH the last (the year or the seconds), 52DDH the middle, 52DEH the first (the month or the hours).
52DF-52E9
DEFM "BAD FORMAT" / DEFB 0DH 42 41 44 20 46 4F 52 4D 41 54 0D
The text at 52DFH shown by 52D3H: BAD FORMAT and a carriage return that ends the text and the line.
52EAH - Read Three Numbers
Called by DATE and TIME with Register Pair HL the text and Register C the separator. Three numbers of exactly two decimal digits each are read; the first goes to 52DEH, the second to 52DDH and the third to 52DCH. Returns the Z FLAG when the three numbers and the two separators were found; nothing after the third number is looked at.
52EA
LD DE,52DEH 11 DE 52
Load Register Pair DE with 52DEH, the place of the first number; the numbers are stored downwards.
52ED
LD B,03H 06 03
Load Register B with 03H, the count of the numbers to read.
52EF
PUSH DE D5
Save Register Pair DE, the place of this number, on the stack at the Stack Pointer, across the call.
52F0
Call 52FFH to read a number of two digits at Register Pair HL into Register A; the Z FLAG when both were digits.
52F3
POP DE D1
Restore Register Pair DE, the place of this number, from the stack at the Stack Pointer.
52F4
RET NZ C0
Return with the NZ FLAG set if the two characters were not both digits.
52F5
LD (DE),A 12
Store Register A, the number, at Register Pair DE.
52F6
DEC DE 1B
Decrement Register Pair DE to the place of the next number.
52F7
DEC B 05
Decrement Register B, the count of the numbers still to read.
52F8
RET Z C8
Return with the Z FLAG set if Register B is 00H: the three numbers were read.
52F9
LD A,(HL) 7E
Load Register A with the character at Register Pair HL, the one after the number.
52FA
INC HL 23
Increment Register Pair HL past the character.
52FB
CP C B9
Compare Register A with Register C, the separator: the Z FLAG when they agree.
52FC
If the Z FLAG is set (the separator), jump back to 52EFH to read the next number.
52FE
RET C9
Return with the NZ FLAG set: the character after the number is not the separator.
52FFH - Read a Number of Two Digits
Reads two characters at Register Pair HL and returns their value 0-99 in Register A with the Z FLAG, or the NZ FLAG when one of them is not a digit.
52FF
Call 5316H to read the first character at Register Pair HL as a digit in Register A; the C FLAG when it is one.
5302
If the NC FLAG is set (not a digit), jump to 5314H to return the NZ FLAG.
5304
LD E,A 5F
Copy Register A, the tens digit, into Register E.
5305
RLCA 07
Turn Register A to the left: the tens digit times 2.
5306
RLCA 07
Turn Register A to the left again: the tens digit times 4.
5307
ADD A,E 83
Add Register E to Register A: the tens digit times 5.
5308
RLCA 07
Turn Register A to the left: the tens digit times 10.
5309
LD E,A 5F
Copy Register A, the tens digit times ten, into Register E for the addition.
530A
Call 5316H to read the second character at Register Pair HL as a digit in Register A; the C FLAG when it is one.
530D
If the NC FLAG is set (not a digit), jump to 5314H to return the NZ FLAG.
530F
ADD A,E 83
Add Register E, the tens, to Register A, the units digit: the number 0-99.
5310
LD E,A 5F
Copy Register A, the number, into Register E.
5311
XOR A AF
Clear Register A to 00H, which sets the Z FLAG: the number was read.
5312
LD A,E 7B
Load Register A with Register E, the number; the Z FLAG stays set.
5313
RET C9
Return with Register A the number and the Z FLAG set.
5314
OR A B7
OR Register A with itself: the character minus 30H is 0AH or more, so the NZ FLAG is set.
5315
RET C9
Return with the NZ FLAG set: the character was not a digit.
5316H - Read One Digit
Returns Register A the character at Register Pair HL minus 30H, Register Pair HL past it, and the C FLAG when the character is a digit 0-9.
5316
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
5317
INC HL 23
Increment Register Pair HL past the character.
5318
SUB 30H D6 30
Subtract 30H, the digit 0, from Register A: a digit becomes 00H-09H.
531A
CP 0AH FE 0A
Compare Register A with 0AH: the C FLAG is set for a digit; a character below 30H gave a large value and the NC FLAG.
531C
RET C9
Return with Register A the value and the C FLAG for a digit.
531DH - The Reserved Command double
Command 7, double in small letters in the table of SYS1/SYS, which never matches it: DOUBLE runs DOUBLE/CMD. The entry only goes to DOS READY.
531D
Jump to 402DH, DOS READY: the reserved command 7 does nothing.
5320H - Unused Code: Show a Table of Two Letter Names
Nothing in DoubleDOS jumps to 5320H-5339H. The bytes are a routine that would go through a table at Register Pair HL of four byte entries within one page: for each entry whose first byte is not 00H it shows two characters and a carriage return. They are shown as instructions.
5320
LD A,(HL) 7E
Load Register A with the first byte of the entry at Register Pair HL (unused code).
5321
INC L 2C
Increment Register L to the second byte of the entry (unused code).
5322
OR A B7
OR Register A with itself: the Z FLAG is set when the entry's first byte is 00H (unused code).
5323
If the Z FLAG is set (an empty entry), jump to 5331H to go to the next entry (unused code).
5325
Call 0033H, the ROM's display of the character in Register A, for the first character (unused code).
5328
LD A,(HL) 7E
Load Register A with the second character of the entry at Register Pair HL (unused code).
5329
Call 0033H, the ROM's display of the character in Register A, for the second character (unused code).
532C
LD A,0DH 3E 0D
Load Register A with 0DH, a carriage return, to end the line (unused code).
532E
Call 0033H, the ROM's display of the character in Register A, for the carriage return (unused code).
5331
LD A,L 7D
Load Register A with Register L, the low byte of the place in the entry (unused code).
5332
ADD A,03H C6 03
Add 03H to Register A: the low byte of the next entry, four bytes on (unused code).
5334
LD L,A 6F
Copy Register A into Register L: Register Pair HL points at the next entry (unused code).
5335
If the NC FLAG is set (still inside the page), jump back to 5320H for the next entry (unused code).
5337
Jump to 402DH, DOS READY, at the end of the page (unused code).
533AH - LIB: Show the Library Commands
The names of the 19 entries of SYS1/SYS's table of library commands (4EBDH, eight bytes an entry: six characters and the address 4E90H) are shown four to a line, each after two spaces and followed by eight. SYS1/SYS is still in memory at 4E00H when SYS6/SYS runs. The reserved commands copy and double are shown in small letters as they are in the table.
533A
LD HL,4EBDH 21 BD 4E
Load Register Pair HL with 4EBDH, the table of the library commands in SYS1/SYS.
533D
LD C,04H 0E 04
Load Register C with 04H, the count of the names on one line. 5360H jumps back here for each new line.
533F
LD A,C2H 3E C2
Load Register A with C2H, the space compression code for two spaces.
5341
Call 0033H, the ROM's display of the character in Register A: two spaces before the first name.
5344
LD B,06H 06 06
Load Register B with 06H, the six characters of a name.
5346
LD A,(HL) 7E
Load Register A with the character of the name at Register Pair HL.
5347
INC HL 23
Increment Register Pair HL to the next character of the table.
5348
Call 0033H, the ROM's display of the character in Register A.
534B
Decrement Register B and jump back to 5346H while it is not 00H: the six characters of the name.
534D
LD A,C8H 3E C8
Load Register A with C8H, the space compression code for eight spaces.
534F
Call 0033H, the ROM's display of the character in Register A: eight spaces after the name.
5352
INC HL 23
Increment Register Pair HL past the low byte of the entry's address.
5353
INC HL 23
Increment Register Pair HL past the high byte of the entry's address, to the next entry.
5354
LD A,(HL) 7E
Load Register A with the first byte of the next entry at Register Pair HL.
5355
OR A B7
OR Register A with itself: the Z FLAG is set for 00H, the end of the table.
5356
If the Z FLAG is set (the end of the table), jump to 5362H to end the last line.
5358
DEC C 0D
Decrement Register C, the count of the names still to show on this line.
5359
If the NZ FLAG is set (room for another name), jump back to 5344H to show it.
535B
LD A,0DH 3E 0D
Load Register A with 0DH, a carriage return, after the fourth name of the line.
535D
Call 0033H, the ROM's display of the character in Register A: the line ends.
5360
Jump back to 533DH to start the next line of four names.
5362
LD A,0DH 3E 0D
Load Register A with 0DH, a carriage return, after the last name.
5364
Call 0033H, the ROM's display of the character in Register A: the last line ends.
5367
Jump to 402DH, DOS READY: the list of the library commands is complete.
536AH - PROT: Change the Master Password, Lock or Unlock a Diskette
PROT [:d] (PW, LOCK, UNLOCK). The master password of the diskette, whose hash is kept in GAT bytes CEH-CFH, must be typed first. PW asks for a new master password; LOCK gives every visible file of the diskette the master password as both its passwords, UNLOCK gives them the blank password. The routine refuses to run while bit 5 of 430FH, the chaining flag, is set; no DoubleDOS file sets it. To have the password hash of SYS2/SYS (50D1H) in memory, it opens an empty file specification, which loads SYS2/SYS at 4E00H and fails.
536A
LD A,(430FH) 3A 0F 43
Load Register A with the flags at 430FH: bit 5 is the chaining flag, set while a chain of commands runs.
536D
BIT 5,A CB 6F
Test bit 5 of Register A, the chaining flag: the NZ FLAG when it is set.
536F
If the NZ FLAG is set (a chain is running), jump to 546EH to show INVALID COMMAND DURING PROGRAM CHAINING.
5372
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, the value of a parameter that is not given.
5375
LD (53D9H),BC ED 43 D9 53
Store Register Pair BC (0000H) at 53D9H, the operand of LD DE at 53D8H: the word of the parameter PW.
5379
LD (53F9H),BC ED 43 F9 53
Store Register Pair BC (0000H) at 53F9H, the operand of LD DE at 53F8H: the word of the parameter LOCK.
537D
LD (5403H),BC ED 43 03 54
Store Register Pair BC (0000H) at 5403H, the operand of LD DE at 5402H: the word of the parameter UNLOCK.
5381
LD C,00H 0E 00
Load Register C with 00H, drive 0, the drive when the command names none.
5383
LD A,(HL) 7E
Load Register A with the first character at Register Pair HL, the rest of the command line.
5384
CP 3AH FE 3A
Compare Register A with 3AH, the colon before a drive number.
5386
If the NZ FLAG is set (no colon), jump to 538EH with drive 0 in Register C.
5388
INC HL 23
Increment Register Pair HL past the colon to the drive number.
5389
LD A,(HL) 7E
Load Register A with the character of the drive number at Register Pair HL.
538A
SUB 30H D6 30
Subtract 30H, the digit 0, from Register A: the drive number. Nothing checks that it is 0-3.
538C
LD C,A 4F
Copy Register A, the drive number, into Register C.
538D
INC HL 23
Increment Register Pair HL past the drive number.
538E
LD A,C 79
Copy Register C, the drive (00H when none was named), into Register A.
538F
LD (53BCH),A 32 BC 53
Store Register A, the drive, at 53BCH, the operand of LD C at 53BBH, where the reads and writes of the GAT and the directory take it.
5392
LD DE,54EBH 11 EB 54
Load Register Pair DE with 54EBH, the table of the parameters PW, LOCK and UNLOCK.
5395
Call 4476H, the parameter list parser of SYS1/SYS (E3H), with Register Pair HL the text and Register Pair DE the table: each parameter named stores its value (FFFFH when named alone) in its word.
5398
LD A,(53D9H) 3A D9 53
Load Register A with the low byte of the word of PW at 53D9H.
539B
LD HL,53F9H 21 F9 53
Load Register Pair HL with 53F9H, the low byte of the word of LOCK.
539E
OR (HL) B6
OR Register A with the byte at Register Pair HL (LOCK). Only the low bytes are tested, so a value whose low byte is 00H counts as not given.
539F
LD HL,5403H 21 03 54
Load Register Pair HL with 5403H, the low byte of the word of UNLOCK.
53A2
OR (HL) B6
OR Register A with the byte at Register Pair HL (UNLOCK): the Z FLAG when no parameter was given.
53A3
If the Z FLAG is set (no parameter), jump to 526BH to show -NOTHING DONE-.
53A6
LD A,03H 3E 03
Load Register A with 03H, the end mark of a file specification.
53A8
LD DE,5551H 11 51 55
Load Register Pair DE with 5551H, SYS6/SYS's first FCB.
53AB
LD (DE),A 12
Store Register A (03H) at Register Pair DE: the FCB holds an empty file specification.
53AC
Call 4424H to open the file at Register Pair DE: request code 94H loads SYS2/SYS at 4E00H, which gives error 13H for the empty name. The result is not tested; only SYS2/SYS's routines are wanted.
53AF
LD HL,54A0H 21 A0 54
Load Register Pair HL with 54A0H, the prompt MASTER PASSWORD ?.
53B2
Call 4467H to show the text at Register Pair HL on the screen up to its 03H, which leaves the cursor after the prompt.
53B5
Call 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, at 5168H, a byte pair in SYS2/SYS's work area (SYS2/SYS keeps the update password hash there).
53BB
LD C,00H 0E 00
Load Register C with the drive: the operand 53BCH holds the drive stored by 538FH.
53BD
Call 4AF0H to read the GAT of drive Register C into 4D00H; the NZ FLAG and an error code in Register A if it fails.
53C0
If the NZ FLAG is set (the GAT could not be read), jump to 554CH to report the error in Register A.
53C3
LD HL,(4DCEH) 2A CE 4D
Load Register Pair HL with the master password hash of the diskette at 4DCEH, GAT bytes CEH-CFH.
53C6
LD DE,(5168H) ED 5B 68 51
Load Register Pair DE with the hash of the password typed, kept at 5168H.
53CA
XOR A AF
Clear Register A to 00H, which also clears the C FLAG for the subtraction.
53CB
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL: the Z FLAG when the password typed is the master password.
53CD
If the Z FLAG is set (the right master password), jump to 53D8H to carry out the parameters.
53CF
LD HL,54D2H 21 D2 54
Load Register Pair HL with 54D2H, the text INVALID MASTER PASSWORD and a carriage return.
53D2
Call 4467H to show the text at Register Pair HL on the screen up to its carriage return.
53D5
Jump to 4030H, the abnormal exit of a command, which returns to DOS READY (or enters DEBUG while DEBUG is on).
53D8
LD DE,0000H 11 00 00
Load Register Pair DE with the word of PW: the operand 53D9H, 0000H unless PW was given.
53DB
LD A,D 7A
Copy Register D, the high byte of the word of PW, into Register A.
53DC
OR E B3
OR Register A with Register E: the Z FLAG when PW was not given.
53DD
If the Z FLAG is set (no PW), jump to 53F5H to go on with LOCK and UNLOCK.
53DF
LD HL,54B9H 21 B9 54
Load Register Pair HL with 54B9H, the prompt NEW MASTER PASSWORD ?.
53E2
Call 4467H to show the text at Register Pair HL on the screen up to its 03H, which leaves the cursor after the prompt.
53E5
Call 5454H to read up to eight characters from the keyboard and return their password hash in Register Pair HL.
53E8
LD (4DCEH),HL 22 CE 4D
Store Register Pair HL, the hash of the new master password, at 4DCEH, GAT bytes CEH-CFH.
53EB
LD A,(53BCH) 3A BC 53
Load Register A with the drive, the operand at 53BCH.
53EE
LD C,A 4F
Copy Register A, the drive, into Register C for the write of the GAT.
53EF
Call 4B03H to write the GAT at 4D00H back to drive Register C and read it back; the NZ FLAG and an error code in Register A if it fails.
53F2
If the NZ FLAG is set (the GAT could not be written), jump to 554CH to report the error in Register A.
53F5
LD HL,(4DCEH) 2A CE 4D
Load Register Pair HL with the master password hash at 4DCEH (the new one when PW was given), the password that LOCK gives.
53F8
LD DE,0000H 11 00 00
Load Register Pair DE with the word of LOCK: the operand 53F9H, 0000H unless LOCK was given.
53FB
LD A,D 7A
Copy Register D, the high byte of the word of LOCK, into Register A.
53FC
OR E B3
OR Register A with Register E: the NZ FLAG when LOCK was given.
53FD
If the NZ FLAG is set (LOCK), jump to 540CH with Register Pair HL the master password hash. LOCK wins when UNLOCK is given too.
53FF
LD HL,4296H 21 96 42
Load Register Pair HL with 4296H, the hash of the blank password (eight spaces), the password that UNLOCK gives.
5402
LD DE,0000H 11 00 00
Load Register Pair DE with the word of UNLOCK: the operand 5403H, 0000H unless UNLOCK was given.
5405
LD A,D 7A
Copy Register D, the high byte of the word of UNLOCK, into Register A.
5406
OR E B3
OR Register A with Register E: the NZ FLAG 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
Store Register Pair HL, the password hash to give, at 5430H, the operand of LD DE at 542FH.
540F
LD A,(53BCH) 3A BC 53
Load Register A with the drive, the operand at 53BCH.
5412
LD C,A 4F
Copy Register A, the drive, into Register C for 4B55H and the reads and writes.
5413
Call 4B55H to load Register D with the directory block of drive Register C (from 4304H-4307H).
5416
LD E,02H 1E 02
Load Register E with 02H, the first sector of the directory entries in the directory block (0 is the GAT, 1 the HIT).
5418
LD HL,4200H 21 00 42
Load Register Pair HL with 4200H, the buffer for the directory sector. 544FH jumps back here for each sector.
541B
Call 4B35H to read sector Register E of block Register D on drive Register C into Register Pair HL (4200H); the NZ FLAG and an error code in Register A if it fails.
541E
If the NZ FLAG is set (the sector could not be read), jump to 554CH to report the error in Register A.
5421
LD L,40H 2E 40
Load Register L with 40H: Register Pair HL is 4240H, entry 2 of the sector. Entries 0 and 1 of each sector are the places of the system files and are passed over.
5423
LD A,(HL) 7E
Load Register A with the attribute byte of the entry at Register Pair HL.
5424
AND F8H E6 F8
AND Register A with F8H: the bits 7-3, without the protection level in bits 2-0.
5426
CP 10H FE 10
Compare Register A with 10H: the Z FLAG for a file in use that is not an extra entry (bit 7), not a system file (bit 6) and not invisible (bit 3).
5428
If the NZ FLAG is set (not such a file), jump to 543AH to go to the next entry.
542A
LD A,L 7D
Copy Register L, the start of the entry, into Register A.
542B
ADD A,10H C6 10
Add 10H to Register A: offset 10H of the entry, the update password hash.
542D
LD L,A 6F
Copy Register A into Register L: Register Pair HL points at entry +10H.
542E
PUSH DE D5
Save Register Pair DE, the block and the sector, on the stack at the Stack Pointer.
542F
LD DE,0000H 11 00 00
Load Register Pair DE with the password hash to give: the operand 5430H (0000H in the file), stored by 540CH.
5432
LD (HL),E 73
Store Register E, the low byte of the hash, at Register Pair HL, entry +10H, the update password hash.
5433
INC L 2C
Increment Register L to entry +11H, the high byte of the update password hash.
5434
LD (HL),D 72
Store Register D, the high byte of the hash, at Register Pair HL, entry +11H.
5435
INC L 2C
Increment Register L to entry +12H, the access password hash.
5436
LD (HL),E 73
Store Register E, the low byte of the hash, at Register Pair HL, entry +12H.
5437
INC L 2C
Increment Register L to entry +13H, the high byte of the access password hash.
5438
LD (HL),D 72
Store Register D, the high byte of the hash, at Register Pair HL, entry +13H: both passwords are now the one given.
5439
POP DE D1
Restore Register Pair DE, the block and the sector, from the stack at the Stack Pointer.
543A
LD A,L 7D
Copy Register L, a place in the entry, into Register A.
543B
AND E0H E6 E0
AND Register A with E0H: the start of the entry.
543D
ADD A,20H C6 20
Add 20H to Register A: the start of the next entry; the C FLAG past the last entry of the sector.
543F
LD L,A 6F
Copy Register A into Register L: Register Pair HL points at the next entry.
5440
If the NC FLAG is set (another entry in the sector), jump back to 5423H.
5442
LD HL,4200H 21 00 42
Load Register Pair HL with 4200H, the directory sector just changed.
5445
Call 45CFH to write the buffer at Register Pair HL as sector Register E of block Register D on drive Register C with the directory's data mark and read it back; the NZ FLAG on an error.
5448
If the NZ FLAG is set (the sector could not be written), jump to 554CH to report the error in Register A.
544B
INC E 1C
Increment Register E to the next sector of the directory block.
544C
LD A,E 7B
Copy Register E, the sector, into Register A.
544D
CP 0AH FE 0A
Compare Register A with 0AH: the C FLAG for the sectors 2-9 of the entries.
544F
If the C FLAG is set (another sector of entries), jump back to 5418H.
5451
Jump to 402DH, DOS READY: every file of the diskette has the new passwords.
5454H - Read a Password and Hash It
Shows nothing itself: the caller has shown the prompt. Up to eight characters are read by the ROM's line input into 5600H, the rest is filled with spaces and 50D1H of SYS2/SYS, which PROT has loaded at 4E00H, returns the hash in Register Pair HL. When exactly eight characters are typed, Register B is 00H for the fill and DJNZ writes 256 spaces at 5608H-5707H, over the first bytes of APPEND at 5700H (a bug: the Bugs part of the introduction). BREAK is not tested.
5454
LD B,08H 06 08
Load Register B with 08H, the most characters of a password.
5456
LD HL,5600H 21 00 56
Load Register Pair HL with 5600H, the buffer for the characters typed.
5459
Call 0040H, the ROM's line input, into the buffer at Register Pair HL for up to Register B characters; it returns Register B the count typed (and the C FLAG for BREAK, not tested).
545C
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE is 5600H, the start of the password.
545D
LD H,00H 26 00
Load Register H with 00H, the high byte of the count.
545F
LD L,B 68
Copy Register B, the count of the characters typed, into Register L: Register Pair HL is the count.
5460
ADD HL,DE 19
Add Register Pair DE (5600H) to Register Pair HL: the place after the last character typed.
5461
LD A,08H 3E 08
Load Register A with 08H, the length of a password.
5463
SUB B 90
Subtract Register B, the count typed, from Register A: the spaces still needed (00H when eight were typed).
5464
LD B,A 47
Copy Register A, the count of spaces, into Register B for the DJNZ.
5465
LD A,20H 3E 20
Load Register A with 20H, a space, to fill the rest of the password.
5467
LD (HL),A 77
Store Register A (a space) at Register Pair HL.
5468
INC HL 23
Increment Register Pair HL to the next place of the password.
5469
Decrement Register B and jump back to 5467H while it is not 00H; a count of 00H gives 256 spaces.
546B
Jump to 50D1H of SYS2/SYS, the password hash of the eight characters at Register Pair DE (5600H), which returns the hash in Register Pair HL to the caller of 5454H.
546EH - Invalid During a Chain
PROT comes here when bit 5 of 430FH is set.
546E
LD HL,5477H 21 77 54
Load Register Pair HL with 5477H, the text INVALID COMMAND DURING PROGRAM CHAINING.
5471
Call 4467H to show the text at Register Pair HL on the screen up to its carriage return.
5474
Jump to 4030H, the abnormal exit of a command, which returns to DOS READY (or enters DEBUG while 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
The text at 5477H shown by 546EH: a line feed (a new line), INVALID COMMAND DURING PROGRAM CHAINING and a carriage return.
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
The prompt at 54A0H shown by 53AFH: a new line, MASTER PASSWORD ? and six spaces, then 03H, which ends the text without a new 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
The prompt at 54B9H shown by 53DFH: a new line, NEW MASTER PASSWORD ? and two spaces, then 03H, which ends the text without a new 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
The text at 54D2H shown by 53CFH when the password typed is not the master password: a new line, INVALID MASTER PASSWORD and a carriage return.
54EB-54F2
DEFM "PW " / DEFW 53D9H 50 57 20 20 20 20 D9 53
The first entry of PROT's parameter table at 54EBH: the name PW padded to six characters, and 53D9H, the operand of LD DE at 53D8H, where the value is stored.
54F3-54FA
DEFM "LOCK " / DEFW 53F9H 4C 4F 43 4B 20 20 F9 53
The parameter LOCK padded to six characters, and 53F9H, the operand of LD DE at 53F8H, where its value is stored.
54FB-5502
DEFM "UNLOCK" / DEFW 5403H 55 4E 4C 4F 43 4B 03 54
The parameter UNLOCK, six characters, and 5403H, the operand of LD DE at 5402H. Typed in full, its name fills SYS1/SYS's buffer 51AFH-51B4H, and the 03H after it goes to 51B5H, the C of CMD (SYS1/SYS bug B8).
5503
DEFB 00H 00
The end of PROT's parameter table at 5503H: 00H where the next entry's name would start, which ends the lookup of 502AH in SYS1/SYS.
5504H - VERIFY: Read Back Every Sector Written
VERIFY alone (or with an option that is not OFF or NO) makes @WRITE (4439H) jump to 47A8H, @VERF, which writes each sector and reads it back; VERIFY (OFF) puts back 478BH, the plain write. The option is read by 51A0H of SYS1/SYS.
5504
Call 51A0H of SYS1/SYS to read the option at Register Pair HL: the Z FLAG for (OFF), (NO) or (N), the NZ FLAG for none or any other.
5507
LD HL,478BH 21 8B 47
Load Register Pair HL with 478BH, @WRITE without the reading back, for VERIFY (OFF).
550A
If the Z FLAG is set (VERIFY (OFF)), jump to 550FH with Register Pair HL 478BH.
550C
LD HL,47A8H 21 A8 47
Load Register Pair HL with 47A8H, @VERF, the write that reads each sector back.
550F
LD (443AH),HL 22 3A 44
Store Register Pair HL at 443AH, the operand of the JP at 4439H, the @WRITE vector of SYS0/SYS.
5512
Jump to 402DH, DOS READY: every program's @WRITE now goes to the routine chosen.
5515H - Test for BREAK and the Pause Key
Called by APPEND, LIST, PRINT and DIR between characters or lines. While the chaining flag (430FH bit 5) is set it returns the Z FLAG at once. Otherwise BREAK held returns the NZ FLAG (stop); SHIFT and @ (the code 60H) waits until BREAK (NZ) or another key is pressed (Z, the key is dropped); no key or another key returns the Z FLAG (go on).
5515
LD A,(430FH) 3A 0F 43
Load Register A with the flags at 430FH; bit 5 is the chaining flag.
5518
AND 20H E6 20
AND Register A with 20H: 20H when the chaining flag is set, else 00H.
551A
XOR 20H EE 20
Exclusive OR Register A with 20H: the Z FLAG is set when the chaining flag is set.
551C
RET Z C8
Return with the Z FLAG set if a chain is running: no BREAK or pause during a chain.
551D
LD A,(3840H) 3A 40 38
Load Register A with 3840H, the keyboard row of ENTER, CLEAR, BREAK and the arrows and the space bar.
5520
AND 04H E6 04
AND Register A with 04H, the bit of the BREAK key.
5522
RET NZ C0
Return with the NZ FLAG set if BREAK is held: the caller stops.
5523
Call 002BH, the ROM's keyboard scan, which returns Register A the key pressed or 00H.
5526
CP 60H FE 60
Compare Register A with 60H, the code of SHIFT and @, the pause key.
5528
If the Z FLAG is set (the pause key), jump to 552CH to wait.
552A
XOR A AF
Clear Register A to 00H and set the Z FLAG: no key or another key, the caller goes on.
552B
RET C9
Return with the Z FLAG set: the caller goes on with its next byte or line.
552C
LD A,(3840H) 3A 40 38
Load Register A with 3840H, the keyboard row with the BREAK key, while the pause lasts.
552F
AND 04H E6 04
AND Register A with 04H, the bit of the BREAK key.
5531
RET NZ C0
Return with the NZ FLAG set if BREAK is held: the caller stops.
5532
Call 002BH, the ROM's keyboard scan, which returns Register A the key pressed or 00H.
5535
OR A B7
OR Register A with itself: the Z FLAG when no key was pressed.
5536
If the Z FLAG is set (no key), jump back to 552CH to go on waiting.
5538
XOR A AF
Clear Register A to 00H and set the Z FLAG: a key ends the pause and is dropped.
5539
RET C9
Return with the Z FLAG set: the caller goes on.
553AH - File Specification Required
The commands come here when the file specification cannot be parsed or names a device (it starts with an asterisk).
553A
LD HL,5591H 21 91 55
Load Register Pair HL with 5591H, the text FILE SPEC REQUIRED.
553D
Call 4467H to show the text at Register Pair HL on the screen up to its carriage return.
5540
Jump to 4030H, the abnormal exit of a command, which returns to DOS READY (or enters DEBUG while DEBUG is on).
5543H - Unused: Device Specification Required
Nothing in DoubleDOS jumps to 5543H: no command of SYS6/SYS needs a device. The text 55A5H is shown by nothing.
5543
LD HL,55A5H 21 A5 55
Load Register Pair HL with 55A5H, the text DEVICE SPEC REQUIRED (unused code).
5546
Call 4467H to show the text at Register Pair HL on the screen up to its carriage return (unused code).
5549
Jump to 4030H, the abnormal exit of a command, which returns to DOS READY (unused code).
554CH - Report an Error
Every disk error of the commands comes here with the error code in Register A. Bit 6 is set and @ERROR (4409H) is called through a jump: SYS4/SYS shows the message, and as bit 7 is clear it ends at 4030H, the abnormal exit.
554C
OR 40H F6 40
OR Register A, the error code, with 40H: bit 6 set, which tells SYS4/SYS that the FCB still holds the file specification.
554E
Jump to 4409H, @ERROR: SYS4/SYS shows the message of the code in Register A and goes to 4030H.
5551-5590
DEFS 64
Not in the file: two FCBs of 32 bytes, 5551H the first (the source file, or the file of KILL, LIST, LOAD, PRINT, DUMP, ATTRIB and RENAME) and 5571H the second (the file appended to, or the new name of RENAME).
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
The text at 5591H shown by 553AH: a new line, FILE SPEC REQUIRED and a carriage return.
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
The text at 55A5H of the unused 5543H: a new line, DEVICE SPEC REQUIRED and a carriage return. Nothing shows it.
55BB-56FF
DEFS 325
Not in the file: 55BBH-55FFH unused, and 5600H-56FFH, the sector buffer of the first FCB (APPEND, DUMP, LIST, PRINT) and the password typed for PROT (5600H-5607H).
5700H - APPEND: Add One File to the End of Another
APPEND file1 TO file2 (the word TO is passed over by the file specification parser of SYS1/SYS). Both files must exist. file2 is opened with its buffer at 6100H and positioned at its end, file1 with its buffer at 5600H; then file1 is copied byte by byte to the end of file2 until its end, BREAK, or an error. Both files are closed.
5700
LD DE,5551H 11 51 55
Load Register Pair DE with 5551H, the first FCB, for the specification of the file to append (file1).
5703
Call 441CH to parse the file specification at Register Pair HL into the FCB at Register Pair DE; the NZ FLAG when there is none.
5706
If the NZ FLAG is set (no file specification), jump to 553AH to show FILE SPEC REQUIRED.
5709
LD A,(DE) 1A
Load Register A with the first character of the specification at Register Pair DE.
570A
CP 2AH FE 2A
Compare Register A with 2AH, the asterisk that starts a device name.
570C
If the Z FLAG is set (a device), jump to 553AH to show FILE SPEC REQUIRED.
570F
LD DE,5571H 11 71 55
Load Register Pair DE with 5571H, the second FCB, for the file appended to (file2).
5712
Call 441CH to parse the next file specification at Register Pair HL into the FCB at Register Pair DE; the NZ FLAG when there is none.
5715
If the NZ FLAG is set (no second file specification), jump to 553AH to show FILE SPEC REQUIRED.
5718
LD A,(DE) 1A
Load Register A with the first character of the specification at Register Pair DE.
5719
CP 2AH FE 2A
Compare Register A with 2AH, the asterisk that starts a device name.
571B
If the Z FLAG is set (a device), jump to 553AH to show FILE SPEC REQUIRED.
571E
LD B,00H 06 00
Load Register B with 00H, the record length 256 for the open.
5720
LD HL,6100H 21 00 61
Load Register Pair HL with 6100H, the sector buffer of file2.
5723
Call 4424H to open the file of the FCB at Register Pair DE (5571H, file2), which must exist; the NZ FLAG and an error code in Register A if not.
5726
If the NZ FLAG is set (file2 could not be opened), jump to 554CH to report the error in Register A.
5729
LD B,00H 06 00
Load Register B with 00H, the record length 256 for the open.
572B
LD DE,5551H 11 51 55
Load Register Pair DE with 5551H, the FCB of file1.
572E
LD HL,5600H 21 00 56
Load Register Pair HL with 5600H, the sector buffer of file1.
5731
Call 4424H to open the file of the FCB at Register Pair DE (5551H, file1); the NZ FLAG and an error code in Register A if it fails.
5734
If the NZ FLAG is set (file1 could not be opened), jump to 554CH to report the error in Register A.
5737
LD DE,5571H 11 71 55
Load Register Pair DE with 5571H, the FCB of file2.
573A
Call 4448H, @PEOF, to position file2 of Register Pair DE at its end; it returns error 1CH, the end of file.
573D
If the Z FLAG is set (@PEOF returned no error, which it does not do), jump to 554CH with Register A 00H.
5740
CP 1CH FE 1C
Compare Register A with 1CH, the end of file: the expected result of @PEOF.
5742
If the NZ FLAG is set (another error), jump to 554CH to report the error in Register A.
5745
Jump to 57B6H, the copy of the bytes of file1 to the end of file2.
5748H - Unused: Remains of an Earlier APPEND
Nothing jumps to 5748H-57A0H. 5748H is the high byte of a CALL 4448H whose first bytes have been overwritten by the jump at 5745H; then come a test and a jump that end as at 5742H-5745H, and an earlier form of the command that copies sector by sector with @READ and @WRITE and makes file2 when it does not exist. They are shown as instructions; 57A1H is used again.
5748
DEFB 44H 44
The byte 44H at 5748H, the high byte of the address 4448H of a CALL whose first bytes were replaced by JP 57B6H at 5745H. Nothing reads or runs it.
5749
If the NZ FLAG is set, jump to 554CH to report the error in Register A (unused code).
574C
Jump to 57B6H, the copy of the bytes (unused code).
574F
LD DE,5551H 11 51 55
Load Register Pair DE with 5551H, the FCB of file1 (unused code).
5752
Call 441CH to parse the file specification at Register Pair HL into the FCB at Register Pair DE (unused code).
5755
If the NZ FLAG is set (no file specification), jump to 553AH to show FILE SPEC REQUIRED (unused code).
5758
LD DE,5571H 11 71 55
Load Register Pair DE with 5571H, the FCB of file2 (unused code).
575B
Call 441CH to parse the next file specification at Register Pair HL into the FCB at Register Pair DE (unused code).
575E
If the NZ FLAG is set (no second file specification), jump to 553AH to show FILE SPEC REQUIRED (unused code).
5761
LD B,00H 06 00
Load Register B with 00H, the record length 256 for the open (unused code).
5763
LD DE,5551H 11 51 55
Load Register Pair DE with 5551H, the FCB of file1 (unused code).
5766
LD HL,5600H 21 00 56
Load Register Pair HL with 5600H, the sector buffer of file1 (unused code).
5769
Call 4424H to open the file of the FCB at Register Pair DE (5551H) (unused code).
576C
If the NZ FLAG is set (file1 could not be opened), jump to 554CH to report the error in Register A (unused code).
576F
LD B,00H 06 00
Load Register B with 00H, the record length 256 for the open (unused code).
5771
LD DE,5571H 11 71 55
Load Register Pair DE with 5571H, the FCB of file2 (unused code).
5774
LD HL,5600H 21 00 56
Load Register Pair HL with 5600H, the same sector buffer as file1 (unused code).
5777
Call 4420H to open the file of the FCB at Register Pair DE (5571H), or make it when it does not exist (unused code).
577A
If the NZ FLAG is set (file2 could not be opened or made), jump to 554CH to report the error in Register A (unused code).
577D
LD DE,5551H 11 51 55
Load Register Pair DE with 5551H, the FCB of file1 (unused code).
5780
Call 4436H, @READ, to read the next sector of the file of Register Pair DE into the buffer (unused code).
5783
If the Z FLAG is set (a sector was read), jump to 5790H to write it (unused code).
5785
CP 1CH FE 1C
Compare Register A, the error code, with 1CH, the end of file (unused code).
5787
If the Z FLAG is set (the end of file1), jump to 57A1H to close both files (unused code).
5789
CP 1DH FE 1D
Compare Register A, the error code, with 1DH, past the end of file (unused code).
578B
If the Z FLAG is set (past the end of file1), jump to 579BH to copy its end offset (unused code).
578D
Jump to 554CH to report the error in Register A (unused code).
5790
LD DE,5571H 11 71 55
Load Register Pair DE with 5571H, the FCB of file2 (unused code).
5793
Call 4439H, @WRITE, to write the buffer as the next sector of the file of Register Pair DE (unused code).
5796
If the Z FLAG is set (the sector was written), jump back to 577DH for the next sector (unused code).
5798
Jump to 554CH to report the error in Register A (unused code).
579B
LD HL,(5559H) 2A 59 55
Load Register Pair HL with the word at 5559H, offsets 08H and 09H of file1's FCB: the end of file offset and the record length (unused code).
579E
LD (5579H),HL 22 79 55
Store Register Pair HL at 5579H, offsets 08H and 09H of file2's FCB (unused code).
57A1H - Close Both Files
The end of APPEND: file2 and then file1 are closed.
57A1
LD DE,5571H 11 71 55
Load Register Pair DE with 5571H, the FCB of file2, the file appended to.
57A4
Call 4428H to close the file of the FCB at Register Pair DE, which writes its last sector and its directory entry; the NZ FLAG on an error.
57A7
If the NZ FLAG is set (file2 could not be closed), jump to 554CH to report the error in Register A.
57AA
LD DE,5551H 11 51 55
Load Register Pair DE with 5551H, the FCB of file1.
57AD
Call 4428H to close the file of the FCB at Register Pair DE; the NZ FLAG on an error.
57B0
If the NZ FLAG is set (file1 could not be closed), jump to 554CH to report the error in Register A.
57B3
Jump to 402DH, DOS READY: the append is complete.
57B6H - Copy the Bytes
Each byte of file1 is taken by the ROM's 0013H and put into file2 by 001BH; both go through the device vector to SYS0/SYS's byte input and output of a file. The end of file1, or BREAK (5515H), closes both files.
57B6
LD DE,5551H 11 51 55
Load Register Pair DE with 5551H, the FCB of file1.
57B9
Call 0013H, the ROM's input of a byte from the device or file at Register Pair DE, into Register A; the NZ FLAG and an error code when there is none.
57BC
If the Z FLAG is set (a byte), jump to 57C5H to put it into file2.
57BE
CP 1CH FE 1C
Compare Register A, the error code, with 1CH, the end of file.
57C0
If the Z FLAG is set (the end of file1), jump to 57A1H to close both files.
57C2
Jump to 554CH to report the error in Register A.
57C5
LD B,A 47
Copy Register A, the byte, into Register B across the test of the keyboard.
57C6
Call 5515H to test for BREAK and the pause key: the NZ FLAG for BREAK.
57C9
If the NZ FLAG is set (BREAK), jump to 57A1H to close both files: file2 keeps what has been appended.
57CB
LD A,B 78
Load Register A with Register B, the byte of file1 kept across 5515H.
57CC
LD DE,5571H 11 71 55
Load Register Pair DE with 5571H, the FCB of file2.
57CF
Call 001BH, the ROM's output of the byte in Register A to the device or file at Register Pair DE; the NZ FLAG on an error.
57D2
If the NZ FLAG is set (the byte could not be written), jump to 554CH to report the error in Register A.
57D5
Jump back to 57B6H for the next byte of file1 to append.
57D7H - DUMP: Write Memory to a Program File
DUMP file (START=, END=, TRA=). The memory from START to END is written to the file (default extension CIM, made when it does not exist) as a load module: a name record of the first six letters and digits of the name, load records of 254 bytes at most, and a transfer record of TRA. START and END are 7000H and TRA 402DH (DOS READY) unless given; START must be 7000H or more and END not below START. The results of the writes of 001BH are not tested (a bug: the Bugs part of the introduction).
57D7
LD BC,7000H 01 00 70
Load Register Pair BC with 7000H, the default of START and END.
57DA
LD (5868H),BC ED 43 68 58
Store Register Pair BC (7000H) at 5868H, the operand of LD HL at 5867H, the word of START.
57DE
LD (586EH),BC ED 43 6E 58
Store Register Pair BC (7000H) at 586EH, the operand of LD HL at 586DH, the word of END.
57E2
LD BC,402DH 01 2D 40
Load Register Pair BC with 402DH, the default of TRA: the program goes to DOS READY.
57E5
LD (58ABH),BC ED 43 AB 58
Store Register Pair BC (402DH) at 58ABH, the operand of LD HL at 58AAH, the word of TRA.
57E9
LD DE,5551H 11 51 55
Load Register Pair DE with 5551H, the first FCB, for the specification of the file to write.
57EC
Call 441CH to parse the file specification at Register Pair HL into the FCB at Register Pair DE; the NZ FLAG when there is none.
57EF
If the NZ FLAG is set (no file specification), jump to 553AH to show FILE SPEC REQUIRED.
57F2
LD A,(DE) 1A
Load Register A with the first character of the specification at Register Pair DE.
57F3
CP 2AH FE 2A
Compare Register A with 2AH, the asterisk that starts a device name.
57F5
If the Z FLAG is set (a device), jump to 553AH to show FILE SPEC REQUIRED.
57F8
LD DE,58F5H 11 F5 58
Load Register Pair DE with 58F5H, the table of the parameters START, END and TRA.
57FB
Call 4476H, the parameter list parser of SYS1/SYS (E3H), with Register Pair HL the text and Register Pair DE the table; its result is not tested.
57FE
LD DE,590EH 11 0E 59
Load Register Pair DE with 590EH, the place of the name for the name record.
5801
LD HL,5551H 21 51 55
Load Register Pair HL with 5551H, the file specification 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
Load Register A with the character of the specification at Register Pair HL.
5807
CP 30H FE 30
Compare Register A with 30H, the digit 0, the lowest character copied.
5809
If the C FLAG is set (below the digits), jump to 581EH to fill the rest with spaces.
580B
CP 3AH FE 3A
Compare Register A with 3AH, the character after the digit 9.
580D
If the C FLAG is set (a digit), jump to 5817H to copy it.
580F
CP 41H FE 41
Compare Register A with 41H, the letter A, the first of the capital letters.
5811
If the C FLAG is set (between the digits and the letters), jump to 581EH to fill the rest with spaces.
5813
CP 5BH FE 5B
Compare Register A with 5BH, the character after the letter Z.
5815
If the NC FLAG is set (above the capital letters), jump to 581EH to fill the rest with spaces.
5817
LD (DE),A 12
Store Register A, a letter or a digit, at Register Pair DE, the name.
5818
INC HL 23
Increment Register Pair HL to the next character of the specification.
5819
INC DE 13
Increment Register Pair DE to the next place of the name.
581A
Decrement Register B and jump back to 5806H while it is not 00H.
581C
Jump to 5824H: the name has its six characters.
581E
LD A,20H 3E 20
Load Register A with 20H, a space. 5822H jumps back here for each place left.
5820
LD (DE),A 12
Store Register A (a space) at Register Pair DE, the name.
5821
INC DE 13
Increment Register Pair DE to the next place of the name.
5822
Decrement Register B and jump back to 581EH while it is not 00H: the name is padded with spaces.
5824
LD DE,5551H 11 51 55
Load Register Pair DE with 5551H, the FCB with the file specification.
5827
LD HL,58F2H 21 F2 58
Load Register Pair HL with 58F2H, the default extension CIM.
582A
Call 4473H to add the extension at Register Pair HL to the specification at Register Pair DE when it has none (D3H, SYS1/SYS).
582D
LD B,00H 06 00
Load Register B with 00H, the record length 256 for the open.
582F
LD HL,5600H 21 00 56
Load Register Pair HL with 5600H, the sector buffer of the file.
5832
Call 4420H to open the file of the FCB at Register Pair DE, or make it when it does not exist; the NZ FLAG and an error code in Register A on an error.
5835
If the NZ FLAG is set (the file could not be opened or made), jump to 554CH to report the error in Register A.
5838
LD A,05H 3E 05
Load Register A with 05H, the type of the name record.
583A
Call 001BH, the ROM's output of the byte in Register A to the file at Register Pair DE (not tested).
583D
LD A,06H 3E 06
Load Register A with 06H, the length of the name record: six characters.
583F
Call 001BH, the ROM's output of the byte in Register A to the file at Register Pair DE (not tested).
5842
LD B,06H 06 06
Load Register B with 06H, the six characters of the name.
5844
LD HL,590EH 21 0E 59
Load Register Pair HL with 590EH, the name made at 5806H-5822H.
5847
LD A,(HL) 7E
Load Register A with the character of the name at Register Pair HL.
5848
INC HL 23
Increment Register Pair HL to the next character of the name.
5849
Call 001BH, the ROM's output of the byte in Register A to the file at Register Pair DE (not tested).
584C
Decrement Register B and jump back to 5847H while it is not 00H: the name record is written.
584E
LD HL,(586EH) 2A 6E 58
Load Register Pair HL with END, the word at 586EH.
5851
LD BC,(5868H) ED 4B 68 58
Load Register Pair BC with START, the word at 5868H.
5855
XOR A AF
Clear Register A to 00H, which also clears the C FLAG for the subtraction.
5856
SBC HL,BC ED 42
Subtract Register Pair BC (START) from Register Pair HL (END): the C FLAG when END is below START.
5858
LD HL,58C4H 21 C4 58
Load Register Pair HL with 58C4H, the text END LESS THAN START, for 58BEH; the flags stay.
585B
If the C FLAG is set (END below START), jump to 58BEH to show the text 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 NC FLAG when START is 6FFFH or less.
5862
LD HL,58D9H 21 D9 58
Load Register Pair HL with 58D9H, the text START LESS THAN X'7000', for 58BEH; the flags stay.
5865
If the NC FLAG is set (START below 7000H), jump to 58BEH to show the text at Register Pair HL.
5867
LD HL,0000H 21 00 00
Load Register Pair HL with START: the operand 5868H (0000H in the file), stored by 57DAH or by the parameter. 589DH jumps back to 586AH with the next address.
586A
PUSH HL E5
Save Register Pair HL, the address of this load record, on the stack at the Stack Pointer.
586B
LD B,H 44
Copy Register H into Register B: Register Pair BC is the address of this record.
586C
LD C,L 4D
Copy Register L into Register C, the low byte of the address.
586D
LD HL,0000H 21 00 00
Load Register Pair HL with END: the operand 586EH (0000H in the file), stored by 57DEH or by the parameter.
5870
INC HL 23
Increment Register Pair HL to the address after END.
5871
XOR A AF
Clear Register A to 00H, which also clears the C FLAG for the subtraction.
5872
SBC HL,BC ED 42
Subtract Register Pair BC, the address of this record, from Register Pair HL: the bytes still to write.
5874
If the Z FLAG is set (none left), jump to 589FH to write the transfer record.
5876
LD B,FEH 06 FE
Load Register B with FEH, the most data bytes of a load record (254).
5878
LD A,H 7C
Copy Register H, the high byte of the count left, into Register A.
5879
OR A B7
OR Register A with itself: the NZ FLAG when 256 or more bytes are left.
587A
If the NZ FLAG is set (256 or more left), jump to 5882H with Register B FEH.
587C
LD A,L 7D
Copy Register L, the count left (below 256), into Register A.
587D
CP FFH FE FF
Compare Register A with FFH: the C FLAG when fewer than 255 bytes are left.
587F
If the NC FLAG is set (255 bytes left), jump to 5882H with Register B FEH.
5881
LD B,L 45
Copy Register L, the bytes left, into Register B: the last record holds them all.
5882
POP HL E1
Restore Register Pair HL, the address of this record, from the stack at the Stack Pointer.
5883
LD A,01H 3E 01
Load Register A with 01H, the type of a load record.
5885
Call 001BH, the ROM's output of the byte in Register A to the file at Register Pair DE (not tested).
5888
LD A,B 78
Copy Register B, the count of data bytes, into Register A.
5889
ADD A,02H C6 02
Add 02H to Register A: the record length counts the two address bytes (FEH gives 00H, which the loaders take as 254 bytes of data).
588B
Call 001BH, the ROM's output of the byte in Register A, the record length, to the file at Register Pair DE.
588E
LD A,L 7D
Copy Register L, the low byte of the load address, into Register A.
588F
Call 001BH, the ROM's output of the byte in Register A to the file at Register Pair DE.
5892
LD A,H 7C
Copy Register H, the high byte of the load address, into Register A.
5893
Call 001BH, the ROM's output of the byte in Register A to the file at Register Pair DE.
5896
LD A,(HL) 7E
Load Register A with the byte of memory at Register Pair HL.
5897
INC HL 23
Increment Register Pair HL to the next byte of memory.
5898
Call 001BH, the ROM's output of the byte in Register A to the file at Register Pair DE (not tested).
589B
Decrement Register B and jump back to 5896H while it is not 00H: the data of the record.
589D
Jump back to 586AH with Register Pair HL the address of the next record.
589F
POP HL E1
Restore Register Pair HL from the stack at the Stack Pointer: the word pushed at 586AH.
58A0
LD A,02H 3E 02
Load Register A with 02H, the type of the transfer record.
58A2
Call 001BH, the ROM's output of the byte in Register A to the file at Register Pair DE.
58A5
LD A,02H 3E 02
Load Register A with 02H, the length of the transfer record: the two bytes of the address.
58A7
Call 001BH, the ROM's output of the byte in Register A to the file at Register Pair DE.
58AA
LD HL,0000H 21 00 00
Load Register Pair HL with TRA: the operand 58ABH (0000H in the file), stored by 57E5H or by the parameter.
58AD
LD A,L 7D
Copy Register L, the low byte of the transfer address, into Register A.
58AE
Call 001BH, the ROM's output of the byte in Register A to the file at Register Pair DE.
58B1
LD A,H 7C
Copy Register H, the high byte of the transfer address, into Register A.
58B2
Call 001BH, the ROM's output of the byte in Register A to the file at Register Pair DE.
58B5
Call 4428H to close the file of the FCB at Register Pair DE, which writes its last sector and its directory entry; the NZ FLAG on an error.
58B8
If the NZ FLAG is set (the file could not be closed), jump to 554CH to report the error in Register A.
58BB
Jump to 402DH, DOS READY: the program file is written.
58BE
Call 4467H to show the text at Register Pair HL (58C4H or 58D9H) on the screen. The file opened at 5832H is not closed (a bug: the Bugs part of the introduction).
58C1
Jump to 4030H, the abnormal exit of a command, which returns to DOS READY (or enters DEBUG while DEBUG is on).
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
The text at 58C4H shown by 58BEH when END is below START: a new line, END LESS THAN START and a carriage return.
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
The text at 58D9H shown by 58BEH when START is below 7000H: a new line, START LESS THAN X'7000' and a carriage return.
58F2-58F4
DEFM "CIM" 43 49 4D
The default extension at 58F2H of the file written by DUMP, CIM, added by 4473H at 582AH when the specification has none.
58F5-58FC
DEFM "START " / DEFW 5868H 53 54 41 52 54 20 68 58
The first entry of DUMP's parameter table at 58F5H: START padded to six characters, and 5868H, the operand of LD HL at 5867H, where the first address is stored.
58FD-5904
DEFM "END " / DEFW 586EH 45 4E 44 20 20 20 6E 58
The parameter END padded to six characters, and 586EH, the operand of LD HL at 586DH, where the last address is stored.
5905-590C
DEFM "TRA " / DEFW 58ABH 54 52 41 20 20 20 AB 58
The parameter TRA padded to six characters, and 58ABH, the operand of LD HL at 58AAH, where the transfer address is stored.
590D
DEFB 00H 00
The end of DUMP's parameter table at 590DH: 00H where the next entry's name would start.
590E-5913
DEFS 6
Not in the file: the six characters of the name record of DUMP, made at 5806H-5822H from the file's name and written by 5847H.
5914H - KILL: Remove a File
KILL file. The file is opened (with the record length and buffer left in Register B and Register Pair HL by the parser, which @KILL does not use) and removed by @KILL, which frees its granules and its directory entries.
5914
LD DE,5551H 11 51 55
Load Register Pair DE with 5551H, the first FCB, for the specification of the file to remove.
5917
Call 441CH to parse the file specification at Register Pair HL into the FCB at Register Pair DE; the NZ FLAG when there is none.
591A
If the NZ FLAG is set (no file specification), jump to 553AH to show FILE SPEC REQUIRED.
591D
Call 4424H to open the file of the FCB at Register Pair DE; the NZ FLAG and an error code in Register A if it fails (a device name gives an error here).
5920
If the NZ FLAG is set (the file could not be opened), jump to 554CH to report the error in Register A.
5923
Call 442CH, @KILL, to remove the file of the FCB at Register Pair DE; the NZ FLAG on an error.
5926
If the NZ FLAG is set (the file could not be removed), jump to 554CH to report the error in Register A.
5929
Jump to 402DH, DOS READY: the file is removed.
592CH - LIST: Show a File on the Screen
LIST file (LINE=n). The file is shown byte by byte through the ROM's display until its end; BREAK at the end of a line stops it, SHIFT and @ pauses. LINE was meant to pass over the first lines, but its table 598BH is put in Register Pair BC, while the parser takes its table in Register Pair DE, which still holds 5551H, the file specification: LINE is never found and stays 0000H (a bug: the Bugs part of the introduction). The skip loop 5953H-5965H is therefore never run.
592C
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, the default of LINE: no lines passed over.
592F
LD (5954H),BC ED 43 54 59
Store Register Pair BC (0000H) at 5954H, the operand of LD BC at 5953H, the word of LINE.
5933
LD DE,5551H 11 51 55
Load Register Pair DE with 5551H, the first FCB, for the specification of the file to show.
5936
Call 441CH to parse the file specification at Register Pair HL into the FCB at Register Pair DE; the NZ FLAG when there is none.
5939
If the NZ FLAG is set (no file specification), jump to 553AH to show FILE SPEC REQUIRED.
593C
LD A,(DE) 1A
Load Register A with the first character of the specification at Register Pair DE.
593D
CP 2AH FE 2A
Compare Register A with 2AH, the asterisk that starts a device name.
593F
If the Z FLAG is set (a device), jump to 553AH to show FILE SPEC REQUIRED.
5942
LD BC,598BH 01 8B 59
Load Register Pair BC with 598BH, the table of the parameter LINE. The parser takes its table from Register Pair DE, not Register Pair BC (a bug: the Bugs part of the introduction).
5945
Call 4476H, the parameter list parser of SYS1/SYS (E3H), with Register Pair HL the text and Register Pair DE still 5551H: the parameter is looked up in the file specification text, and the result is not tested.
5948
LD B,00H 06 00
Load Register B with 00H, the record length 256 for the open.
594A
LD HL,5600H 21 00 56
Load Register Pair HL with 5600H, the sector buffer of the file.
594D
Call 4424H to open the file of the FCB at Register Pair DE (5551H); the NZ FLAG and an error code in Register A if it fails.
5950
If the NZ FLAG is set (the file could not be opened), jump to 554CH to report the error in Register A.
5953
LD BC,0000H 01 00 00
Load Register Pair BC with LINE, the operand 5954H: always 0000H, as LINE is never found.
5956
LD A,B 78
Copy Register B, the high byte of the count of lines, into Register A.
5957
OR C B1
OR Register A with Register C: the Z FLAG when no lines are to be passed over.
5958
If the Z FLAG is set (LINE is 0000H), jump to 5967H to show the file from its start.
595A
Call 0013H, the ROM's input of a byte from the file at Register Pair DE, into Register A. The NZ FLAG of the end of file is not tested, so a file with fewer lines would never leave this loop (never run).
595D
CP 0DH FE 0D
Compare Register A with 0DH, the carriage return that ends a line.
595F
If the NZ FLAG is set (inside a line), jump back to 595AH for the next byte.
5961
DEC C 0D
Decrement Register C, the low byte of the count of lines.
5962
If the NZ FLAG is set, jump back to 595AH for the next line. With Register C not 00H at the start, Register B counts one page fewer than it should (never run).
5964
DEC B 05
Decrement Register B, the high byte of the count of lines.
5965
If the NZ FLAG is set, jump back to 595AH for 256 more lines.
5967
LD DE,5551H 11 51 55
Load Register Pair DE with 5551H, the FCB of the file. 597CH jumps back here after each line.
596A
Call 0013H, the ROM's input of a byte from the file at Register Pair DE, into Register A; the NZ FLAG and an error code when there is none.
596D
If the NZ FLAG is set (no byte), jump to 597EH to end the listing.
596F
Call 0033H, the ROM's display of the character in Register A, which keeps Register A.
5972
CP 0DH FE 0D
Compare Register A with 0DH, the carriage return that ends a line.
5974
If the NZ FLAG is set (inside a line), jump back to 5967H for the next byte.
5976
Call 5515H to test for BREAK and the pause key at the end of the line: the NZ FLAG for BREAK.
5979
If the NZ FLAG is set (BREAK), jump to 4030H, the abnormal exit of a command.
597C
Jump back to 5967H for the next line of the file to show.
597E
CP 1CH FE 1C
Compare Register A, the error code, with 1CH, the end of file.
5980
If the Z FLAG is set (the end of file), jump to 402DH, DOS READY.
5983
CP 1DH FE 1D
Compare Register A, the error code, with 1DH, past the end of file.
5985
If the Z FLAG is set (past the end of file), jump to 402DH, DOS READY.
5988
Jump to 554CH to report the error in Register A.
598B-5992
DEFM "LINE " / DEFW 5954H 4C 49 4E 45 20 20 54 59
LIST's parameter table at 598BH: LINE padded to six characters, and 5954H, the operand of LD BC at 5953H. Nothing passes this table to the parser (5942H).
5993
DEFB 00H 00
The end of LIST's parameter table at 5993H: 00H where the next entry's name would start.
5994H - LOAD: Load a Program Without Running It
LOAD file. @LOAD reads the load module into memory; the command then goes to DOS READY.
5994
LD DE,5551H 11 51 55
Load Register Pair DE with 5551H, the first FCB, for the specification of the program file.
5997
Call 441CH to parse the file specification at Register Pair HL into the FCB at Register Pair DE; the NZ FLAG when there is none.
599A
If the NZ FLAG is set (no file specification), jump to 553AH to show FILE SPEC REQUIRED.
599D
LD A,(DE) 1A
Load Register A with the first character of the specification at Register Pair DE.
599E
CP 2AH FE 2A
Compare Register A with 2AH, the asterisk that starts a device name.
59A0
If the Z FLAG is set (a device), jump to 553AH to show FILE SPEC REQUIRED.
59A3
Call 4430H, @LOAD, to load the program of the FCB at Register Pair DE into memory; the Z FLAG when it is loaded.
59A6
If the Z FLAG is set (loaded), jump to 402DH, DOS READY.
59A9
Jump to 554CH to report the error in Register A.
59ACH - PRINT: Send a File to the Printer
PRINT file. The file is sent byte by byte to the printer through the ROM's 003BH until its end, with a carriage return after it; BREAK stops it, SHIFT and @ pauses.
59AC
LD DE,5551H 11 51 55
Load Register Pair DE with 5551H, the first FCB, for the specification of the file to print.
59AF
Call 441CH to parse the file specification at Register Pair HL into the FCB at Register Pair DE; the NZ FLAG when there is none.
59B2
If the NZ FLAG is set (no file specification), jump to 553AH to show FILE SPEC REQUIRED.
59B5
LD A,(DE) 1A
Load Register A with the first character of the specification at Register Pair DE.
59B6
CP 2AH FE 2A
Compare Register A with 2AH, the asterisk that starts a device name.
59B8
If the Z FLAG is set (a device), jump to 553AH to show FILE SPEC REQUIRED.
59BB
LD B,00H 06 00
Load Register B with 00H, the record length 256 for the open.
59BD
LD HL,5600H 21 00 56
Load Register Pair HL with 5600H, the sector buffer of the file.
59C0
Call 4424H to open the file of the FCB at Register Pair DE (5551H); the NZ FLAG and an error code in Register A if it fails.
59C3
If the NZ FLAG is set (the file could not be opened), jump to 554CH to report the error in Register A.
59C6
LD DE,5551H 11 51 55
Load Register Pair DE with 5551H, the FCB of the file. 59D7H jumps back here for each byte.
59C9
Call 0013H, the ROM's input of a byte from the file at Register Pair DE, into Register A; the NZ FLAG and an error code when there is none.
59CC
If the NZ FLAG is set (no byte), jump to 59DAH to end the printing.
59CE
Call 003BH, the ROM's output of the character in Register A to the printer.
59D1
Call 5515H to test for BREAK and the pause key: the NZ FLAG for BREAK.
59D4
If the NZ FLAG is set (BREAK), jump to 4030H, the abnormal exit of a command.
59D7
Jump back to 59C6H for the next byte of the file to print.
59DA
PUSH AF F5
Save Register Pair AF, the error code, on the stack at the Stack Pointer.
59DB
LD A,0DH 3E 0D
Load Register A with 0DH, a carriage return, to end the last line on the printer.
59DD
Call 003BH, the ROM's output of the character in Register A to the printer.
59E0
POP AF F1
Restore Register Pair AF, the error code, from the stack at the Stack Pointer.
59E1
CP 1CH FE 1C
Compare Register A, the error code, with 1CH, the end of file.
59E3
If the Z FLAG is set (the end of file), jump to 402DH, DOS READY.
59E6
CP 1DH FE 1D
Compare Register A, the error code, with 1DH, past the end of file.
59E8
If the Z FLAG is set (past the end of file), jump to 402DH, DOS READY.
59EB
Jump to 554CH to report the error in Register A.
59EE-5AFF
DEFS 274
Not in the file: 59EEH-5AFFH, a space between PRINT and ATTRIB that SYS6/SYS does not use.
5B00H - ATTRIB: Set the Attributes and Passwords of a File
ATTRIB file (I, PROT=level, ACC=password, UPD=password); only the first letter of each word is looked at. The file is opened (SYS2/SYS stays in memory at 4E00H with its work area 5155H-516BH), the list is read, and the file's directory entry gets: the protection level when PROT is given, else level 0; the invisible bit when I is given, else none; the access or update password hash only when ACC or UPD is given. The passwords are hashed by 50D1H of SYS2/SYS; SYS2/SYS never tests them when it opens a file (SYS2/SYS bug B13).
5B00
LD DE,5551H 11 51 55
Load Register Pair DE with 5551H, the first FCB, for the specification of the file.
5B03
Call 441CH to parse the file specification at Register Pair HL into the FCB at Register Pair DE; the NZ FLAG when there is none.
5B06
If the NZ FLAG is set (no file specification), jump to 553AH to show FILE SPEC REQUIRED.
5B09
LD A,(DE) 1A
Load Register A with the first character of the specification at Register Pair DE.
5B0A
CP 2AH FE 2A
Compare Register A with 2AH, the asterisk that starts a device name.
5B0C
If the Z FLAG is set (a device), jump to 553AH to show FILE SPEC REQUIRED.
5B0F
PUSH HL E5
Save Register Pair HL, the text after the file specification, on the stack at the Stack Pointer.
5B10
LD B,00H 06 00
Load Register B with 00H, the record length 256 for the open.
5B12
LD HL,4D00H 21 00 4D
Load Register Pair HL with 4D00H, the buffer given to the open (nothing is read into it).
5B15
Call 4424H to open the file of the FCB at Register Pair DE, which loads SYS2/SYS at 4E00H; the NZ FLAG and an error code in Register A if it fails.
5B18
If the NZ FLAG is set (the file could not be opened), jump to 554CH to report the error in Register A.
5B1B
POP HL E1
Restore Register Pair HL, the text after the file specification, from the stack at the Stack Pointer.
5B1C
LD A,(5552H) 3A 52 55
Load Register A with the access level at 5552H, offset 01H of the FCB.
5B1F
AND 07H E6 07
AND Register A with 07H, the access level: 00H is full access, which SYS2/SYS gives every file.
5B21
LD A,25H 3E 25
Load Register A with 25H, the error code of ILLEGAL ACCESS ATTEMPTED TO PROTECTED FILE; the flags of the AND stay.
5B23
If the NZ FLAG is set (not full access), jump to 554CH to report the error in Register A.
5B26
XOR A AF
Clear Register A to 00H for the two switches.
5B27
LD (5C05H),A 32 05 5C
Store Register A (00H) at 5C05H, the operand of LD D at 5C04H: the bits of the parts given (bit 0 PROT, bit 1 ACC, bit 2 UPD).
5B2A
LD (5C0DH),A 32 0D 5C
Store Register A (00H) at 5C0DH, the operand of OR at 5C0CH: the invisible bit 08H when I is given.
5B2D
LD A,(HL) 7E
Load Register A with the character at Register Pair HL. 5B38H jumps back here after a space.
5B2E
CP 28H FE 28
Compare Register A with 28H, the opening parenthesis of the list.
5B30
If the Z FLAG is set (the list), jump to 5B3AH to read its first word.
5B32
CP 20H FE 20
Compare Register A with 20H, a space before the list.
5B34
If the NZ FLAG is set (no list follows), jump to 526BH to show -NOTHING DONE-.
5B37
INC HL 23
Increment Register Pair HL past the space before the list.
5B38
Jump back to 5B2DH to look at the next character.
5B3AH - Read the Next Word of the List
Register Pair HL is at the opening parenthesis or a comma. The first letter picks the word: I, A (access), U (update) or P (protection); any other gives ATTRIBUTE SPECIFICATION ERROR.
5B3A
INC HL 23
Increment Register Pair HL past the parenthesis or the comma to the word.
5B3B
LD A,(HL) 7E
Load Register A with the first letter of the word at Register Pair HL.
5B3C
CP 49H FE 49
Compare Register A with 49H, the letter I (invisible).
5B3E
If the Z FLAG is set (I, invisible), jump to 5B97H to set the invisible bit.
5B40
CP 41H FE 41
Compare Register A with 41H, the letter A (the access password).
5B42
If the Z FLAG is set (A, ACC), jump to 5BA7H to take the access password.
5B44
CP 55H FE 55
Compare Register A with 55H, the letter U (the update password).
5B46
If the Z FLAG is set (U, UPD), jump to 5BBCH to take the update password.
5B48
CP 50H FE 50
Compare Register A with 50H, the letter P (the protection level).
5B4A
If the NZ FLAG is set (another letter), jump to 5C39H to show ATTRIBUTE SPECIFICATION ERROR.
5B4D
Call 5BD1H to copy the value after the equals sign to 5155H: the NZ FLAG when there is a value.
5B50
If the Z FLAG is set (no value), jump to 5C39H to show ATTRIBUTE SPECIFICATION ERROR.
5B53
PUSH HL E5
Save Register Pair HL, the place in the text, on the stack at the Stack Pointer.
5B54
LD B,07H 06 07
Load Register B with 07H, the count of the level names in the table at 5C61H.
5B56
LD DE,(5155H) ED 5B 55 51
Load Register Pair DE with the first two letters of the value at 5155H: Register E the first, Register D the second.
5B5A
LD HL,5C61H 21 61 5C
Load Register Pair HL with 5C61H, the table of the first two letters of the level names.
5B5D
LD A,(HL) 7E
Load Register A with the first letter of a level name at Register Pair HL.
5B5E
INC HL 23
Increment Register Pair HL to the second letter of the level name.
5B5F
CP E BB
Compare Register A with Register E, the first letter of the value.
5B60
If the Z FLAG is set (the first letters agree), call 5B69H, which compares the second letters and does not return when they agree.
5B63
INC HL 23
Increment Register Pair HL past the second letter to the next level name.
5B64
Decrement Register B and jump back to 5B5DH while it is not 00H.
5B66
Jump to 5C39H to show ATTRIBUTE SPECIFICATION ERROR: no level name agrees.
5B69
LD A,(HL) 7E
Load Register A with the second letter of the level name at Register Pair HL.
5B6A
CP D BA
Compare Register A with Register D, the second letter of the value.
5B6B
RET NZ C0
Return with the NZ FLAG set if they differ, to 5B63H for the next level name.
5B6C
POP AF F1
Restore Register Pair AF from the stack at the Stack Pointer: it takes the return address 5B63H, which is dropped.
5B6D
LD A,B 78
Copy Register B, the count left (7 for the first name, EX), into Register A.
5B6E
DEC A 3D
Decrement Register A: the protection level, 6 for EX down to 0 for FU.
5B6F
CP 05H FE 05
Compare Register A with 05H, the level of RE (READ).
5B71
If the NZ FLAG is set (not RE), jump to 5B7EH with the level in Register A.
5B73
LD A,(5157H) 3A 57 51
Load Register A with the third letter of the value at 5157H, which tells READ from RENAME.
5B76
CP 4EH FE 4E
Compare Register A with 4EH, the letter N of REN (RENAME).
5B78
LD A,05H 3E 05
Load Register A with 05H, the level of READ; the flags of the compare stay.
5B7A
If the NZ FLAG is set (READ), jump to 5B7EH with Register A 05H.
5B7C
LD A,02H 3E 02
Load Register A with 02H, the level of RENAME, the same as NA (NAME).
5B7E
LD (5C0BH),A 32 0B 5C
Store Register A, the protection level, at 5C0BH, the operand of OR at 5C0AH.
5B81
POP HL E1
Restore Register Pair HL, the place in the text, from the stack at the Stack Pointer.
5B82
LD B,01H 06 01
Load Register B with 01H, bit 0: PROT was given.
5B84
LD A,(5C05H) 3A 05 5C
Load Register A with the bits of the parts given, the operand at 5C05H. 5BBAH and 5BCFH come here too.
5B87
OR B B0
OR Register A with Register B, the bit of this part.
5B88
LD (5C05H),A 32 05 5C
Store Register A at 5C05H, the operand of LD D at 5C04H.
5B8B
LD A,(HL) 7E
Load Register A with the character at Register Pair HL after the word. 5BA5H comes here after I.
5B8C
CP 29H FE 29
Compare Register A with 29H, the closing parenthesis of the list.
5B8E
If the Z FLAG is set (the end of the list), jump to 5BF7H to change the directory entry.
5B90
CP 2CH FE 2C
Compare Register A with 2CH, the comma before another word.
5B92
If the Z FLAG is set (a comma), jump back to 5B3AH for the next word.
5B94
Jump to 5C39H to show ATTRIBUTE SPECIFICATION ERROR.
5B97
Call 5BD1H to look for a value after the word: the Z FLAG when there is none.
5B9A
If the NZ FLAG is set (I with a value), jump to 5C39H to show ATTRIBUTE SPECIFICATION ERROR.
5B9D
LD A,(5C0DH) 3A 0D 5C
Load Register A with the invisible switch, the operand at 5C0DH.
5BA0
OR 08H F6 08
OR Register A with 08H, bit 3 of the attribute byte, the invisible file.
5BA2
LD (5C0DH),A 32 0D 5C
Store Register A at 5C0DH, the operand of OR at 5C0CH.
5BA5
Jump to 5B8BH to look at the character after the word.
5BA7
Call 5BD1H to copy the value after the equals sign to 5155H: the NZ FLAG when there is a value.
5BAA
If the Z FLAG is set (no password), jump to 5C39H to show ATTRIBUTE SPECIFICATION ERROR.
5BAD
PUSH HL E5
Save Register Pair HL, the place in the text, on the stack at the Stack Pointer.
5BAE
LD DE,5155H 11 55 51
Load Register Pair DE with 5155H, the eight characters of the password.
5BB1
Call 50D1H of SYS2/SYS, which returns the hash of the password at Register Pair DE in Register Pair HL.
5BB4
LD (516AH),HL 22 6A 51
Store Register Pair HL, the hash, at 516AH, the access password hash in SYS2/SYS's work area.
5BB7
POP HL E1
Restore Register Pair HL, the place in the text, from the stack at the Stack Pointer.
5BB8
LD B,02H 06 02
Load Register B with 02H, bit 1: ACC was given.
5BBA
Jump to 5B84H to record the part and look at the next character.
5BBC
Call 5BD1H to copy the value after the equals sign to 5155H: the NZ FLAG when there is a value.
5BBF
If the Z FLAG is set (no password), jump to 5C39H to show ATTRIBUTE SPECIFICATION ERROR.
5BC2
PUSH HL E5
Save Register Pair HL, the place in the text, on the stack at the Stack Pointer.
5BC3
LD DE,5155H 11 55 51
Load Register Pair DE with 5155H, the eight characters of the password.
5BC6
Call 50D1H of SYS2/SYS, which returns the hash of the password at Register Pair DE in Register Pair HL.
5BC9
LD (5168H),HL 22 68 51
Store Register Pair HL, the hash, at 5168H, the update password hash in SYS2/SYS's work area.
5BCC
POP HL E1
Restore Register Pair HL, the place in the text, from the stack at the Stack Pointer.
5BCD
LD B,04H 06 04
Load Register B with 04H, bit 2: UPD was given.
5BCF
Jump to 5B84H to record the part and look at the next character.
5BD1H - Find the Value of a Word
Called with Register Pair HL at the first letter of the word. The rest of the word is passed over up to an equals sign; a carriage return, closing parenthesis or comma first returns the Z FLAG (no value) with Register Pair HL at it. After an equals sign up to eight letters and digits (the first a letter) are copied to 5155H, padded with spaces, by 5081H of SYS2/SYS; the NZ FLAG is returned with Register Pair HL at the character after the value.
5BD1
INC HL 23
Increment Register Pair HL to the next character of the word. 5BDEH jumps back here.
5BD2
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
5BD3
CP 0DH FE 0D
Compare Register A with 0DH, the carriage return at the end of the line.
5BD5
RET Z C8
Return with the Z FLAG set if Register A is 0DH: no value.
5BD6
CP 29H FE 29
Compare Register A with 29H, the closing parenthesis of the list.
5BD8
RET Z C8
Return with the Z FLAG set if Register A is 29H: no value.
5BD9
CP 2CH FE 2C
Compare Register A with 2CH, the comma before another word.
5BDB
RET Z C8
Return with the Z FLAG set if Register A is 2CH: no value.
5BDC
CP 3DH FE 3D
Compare Register A with 3DH, the equals sign before a value.
5BDE
If the NZ FLAG is set (still the word), jump back to 5BD1H.
5BE0
INC HL 23
Increment Register Pair HL past the equals sign to the value.
5BE1
LD DE,5155H 11 55 51
Load Register Pair DE with 5155H, the eight bytes for the value in SYS2/SYS's work area.
5BE4
LD B,08H 06 08
Load Register B with 08H, the most characters of a value.
5BE6
PUSH DE D5
Save Register Pair DE (5155H) on the stack at the Stack Pointer, across the fill.
5BE7
PUSH BC C5
Save Register Pair BC (Register B 08H) on the stack at the Stack Pointer, across the fill.
5BE8
LD A,20H 3E 20
Load Register A with 20H, a space, to clear the eight bytes of the value.
5BEA
LD (DE),A 12
Store Register A (a space) at Register Pair DE.
5BEB
INC DE 13
Increment Register Pair DE to the next byte of the value.
5BEC
Decrement Register B and jump back to 5BEAH while it is not 00H: 5155H-515CH are spaces.
5BEE
POP BC C1
Restore Register Pair BC (Register B 08H) from the stack at the Stack Pointer.
5BEF
POP DE D1
Restore Register Pair DE (5155H) from the stack at the Stack Pointer.
5BF0
Call 5081H of SYS2/SYS to copy up to Register B letters and digits from Register Pair HL to Register Pair DE (5155H); it returns past the character that ended the value.
5BF3
DEC HL 2B
Decrement Register Pair HL back to the character that ended the value.
5BF4
OR 01H F6 01
OR Register A with 01H: the NZ FLAG, a value was found.
5BF6
RET C9
Return with the NZ FLAG set and Register Pair HL at the character after the value.
5BF7H - Change the Directory Entry
The entry of the file is read, its attribute byte is rebuilt from bits 7-4 and the parts given, the password hashes given are stored, and the entry is written back.
5BF7
LD BC,(5557H) ED 4B 57 55
Load Register Pair BC with the word at 5557H, offsets 06H and 07H of the FCB: Register C the drive, Register B the directory record of the file.
5BFB
Call 4AC1H to read the directory sector of record Register B of drive Register C into 4200H; Register Pair HL returns the entry.
5BFE
If the NZ FLAG is set (the directory could not be read), jump to 554CH to report the error in Register A.
5C01
LD A,(HL) 7E
Load Register A with the attribute byte of the entry at Register Pair HL.
5C02
AND F0H E6 F0
AND Register A with F0H: the bits 7-4 stay; the invisible bit 3 and the protection level in bits 2-0 are cleared.
5C04
LD D,00H 16 00
Load Register D with the bits of the parts given: the operand 5C05H, stored by 5B88H (00H at the start).
5C06
BIT 0,D CB 42
Test bit 0 of Register D, the bit of PROT: the Z FLAG when it was not given.
5C08
If the Z FLAG is set (no PROT), jump to 5C0CH: the level stays 0.
5C0A
OR 00H F6 00
OR Register A with the protection level: the operand 5C0BH, stored by 5B7EH.
5C0C
OR 00H F6 00
OR Register A with the invisible switch: the operand 5C0DH, 08H when I was given.
5C0E
LD (HL),A 77
Store Register A, the new attribute byte, at Register Pair HL, entry +00H.
5C0F
LD A,L 7D
Copy Register L, the start of the entry, into Register A.
5C10
ADD A,10H C6 10
Add 10H to Register A: offset 10H of the entry, the update password hash.
5C12
LD L,A 6F
Copy Register A into Register L: Register Pair HL points at entry +10H.
5C13
BIT 2,D CB 52
Test bit 2 of Register D, the bit of UPD: the Z FLAG when it was not given.
5C15
If the Z FLAG is set (no UPD), jump to 5C21H: the update password hash stays.
5C17
LD A,(5168H) 3A 68 51
Load Register A with the low byte of the update password hash at 5168H.
5C1A
LD (HL),A 77
Store Register A at Register Pair HL, entry +10H.
5C1B
LD A,(5169H) 3A 69 51
Load Register A with the high byte of the update password hash at 5169H.
5C1E
INC HL 23
Increment Register Pair HL to entry +11H, the high byte of the update password hash.
5C1F
LD (HL),A 77
Store Register A at Register Pair HL, entry +11H.
5C20
DEC HL 2B
Decrement Register Pair HL back to entry +10H, as when UPD is not given.
5C21
INC HL 23
Increment Register Pair HL to entry +11H (from entry +10H in both paths).
5C22
INC HL 23
Increment Register Pair HL to entry +12H, the access password hash.
5C23
BIT 1,D CB 4A
Test bit 1 of Register D, the bit of ACC: the Z FLAG when it was not given.
5C25
If the Z FLAG is set (no ACC), jump to 5C30H: the access password hash stays.
5C27
LD A,(516AH) 3A 6A 51
Load Register A with the low byte of the access password hash at 516AH.
5C2A
LD (HL),A 77
Store Register A at Register Pair HL, entry +12H.
5C2B
LD A,(516BH) 3A 6B 51
Load Register A with the high byte of the access password hash at 516BH.
5C2E
INC HL 23
Increment Register Pair HL to entry +13H, the high byte of the access password hash.
5C2F
LD (HL),A 77
Store Register A at Register Pair HL, entry +13H.
5C30
Call 4AD6H to write the directory sector at 4200H back as the sector of record Register B of drive Register C; the NZ FLAG on an error.
5C33
If the NZ FLAG is set (the directory could not be written), jump to 554CH to report the error in Register A.
5C36
Jump to 402DH, DOS READY: the attributes are set. The file is not closed; nothing was written through its FCB.
5C39H - Attribute Specification Error
Every fault in ATTRIB's list comes here.
5C39
LD HL,5C42H 21 42 5C
Load Register Pair HL with 5C42H, the text ATTRIBUTE SPECIFICATION ERROR.
5C3C
Call 4467H to show the text at Register Pair HL on the screen up to its carriage return.
5C3F
Jump to 4030H, the abnormal exit of a command, which returns to DOS READY (or enters DEBUG while 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
The text at 5C42H shown by 5C39H: a new line, ATTRIBUTE SPECIFICATION ERROR and a carriage return.
5C61-5C62
DEFM "EX" 45 58
The first two letters of EXEC at 5C61H, the first of the seven level names read by 5B5DH: protection level 6, Register B 07H.
5C63-5C64
DEFM "RE" 52 45
The first two letters of READ at 5C63H: protection level 5, Register B 06H; with N as the third letter (RENAME) 5B7CH gives level 2.
5C65-5C66
DEFM "WR" 57 52
The first two letters of WRITE at 5C65H: protection level 4, Register B 05H.
5C67-5C68
DEFM "~~" 7E 7E
Two tildes at 5C67H in the place of level 3, Register B 04H: 5081H copies only letters and digits, so level 3 can never be given.
5C69-5C6A
DEFM "NA" 4E 41
The first two letters of NAME at 5C69H: protection level 2, Register B 03H, the same level as RENAME.
5C6B-5C6C
DEFM "KI" 4B 49
The first two letters of KILL at 5C6BH: protection level 1, Register B 02H.
5C6D-5C6E
DEFM "FU" 46 55
The first two letters of FULL at 5C6DH: protection level 0, Register B 01H, the last of the seven level names.
5C6FH - DIR: Show the Directory
DIR [:d] (A, I, S). The heading FILE DIRECTORY --- DRIVE d is shown at the top of a cleared screen, then the diskette's name and date from its GAT. The eight directory sectors are copied to 6100H-68FFH, and the entries are shown three to a line in the order of the hash index table: entry 0 of every sector, then entry 1, and so on. A file shows its NAME/EXT, then S for a system file, I for an invisible one and P when it has passwords; system files only with S, invisible ones only with I. With A every file has a line of its own with LRL, EOF (the records) and SIZE (the granules). After twelve lines DIR waits for a key; BREAK stops it. The copy at 6100H-68FFH is cleared at the end.
5C6F
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, the value of a parameter that is not given.
5C72
LD (5D9BH),BC ED 43 9B 5D
Store Register Pair BC (0000H) at 5D9BH, the operand of LD DE at 5D9AH, the word of A.
5C76
LD (5D0BH),BC ED 43 0B 5D
Store Register Pair BC (0000H) at 5D0BH, the operand of LD DE at 5D0AH, the word of I.
5C7A
LD (5CFDH),BC ED 43 FD 5C
Store Register Pair BC (0000H) at 5CFDH, the operand of LD DE at 5CFCH, the word of S.
5C7E
LD C,00H 0E 00
Load Register C with 00H, drive 0, the drive when the command names none.
5C80
LD A,(HL) 7E
Load Register A with the first character at Register Pair HL, the rest of the command line.
5C81
CP 3AH FE 3A
Compare Register A with 3AH, the colon before a drive number.
5C83
If the NZ FLAG is set (no colon), jump to 5C8BH with drive 0 in Register C.
5C85
INC HL 23
Increment Register Pair HL past the colon to the drive number.
5C86
LD A,(HL) 7E
Load Register A with the character of the drive number at Register Pair HL.
5C87
INC HL 23
Increment Register Pair HL past the drive number.
5C88
SUB 30H D6 30
Subtract 30H, the digit 0, from Register A: the drive number. Nothing checks that it is 0-3.
5C8A
LD C,A 4F
Copy Register A, the drive number, into Register C.
5C8B
PUSH BC C5
Save Register Pair BC, Register C the drive, on the stack at the Stack Pointer.
5C8C
LD A,C 79
Copy Register C, the drive (00H when none was named), into Register A.
5C8D
ADD A,30H C6 30
Add 30H to Register A: the digit of the drive.
5C8F
LD (5E9EH),A 32 9E 5E
Store Register A, the digit, at 5E9EH, the X of DRIVE X in the heading.
5C92
LD DE,5E6AH 11 6A 5E
Load Register Pair DE with 5E6AH, the table of the parameters A, I and S.
5C95
Call 4476H, the parameter list parser of SYS1/SYS (E3H), with Register Pair HL the text and Register Pair DE the table; its result is not tested.
5C98
LD HL,5E83H 21 83 5E
Load Register Pair HL with 5E83H, the heading: clear the screen, FILE DIRECTORY --- DRIVE d.
5C9B
Call 4467H to show the text at Register Pair HL on the screen up to its 03H.
5C9E
POP BC C1
Restore Register Pair BC, Register C the drive, from the stack at the Stack Pointer.
5C9F
PUSH BC C5
Save Register Pair BC, Register C the drive, on the stack again for the reading of the directory.
5CA0
Call 4B55H to load Register D with the directory block of drive Register C.
5CA3
LD E,00H 1E 00
Load Register E with 00H, sector 0 of the directory block, the GAT.
5CA5
LD HL,4200H 21 00 42
Load Register Pair HL with 4200H, the buffer for the GAT.
5CA8
Call 4B35H to read sector Register E of block Register D on drive Register C into Register Pair HL (4200H); the NZ FLAG and an error code in Register A if it fails.
5CAB
If the NZ FLAG is set (the GAT could not be read), jump to 554CH to report the error in Register A.
5CAE
LD HL,42D0H 21 D0 42
Load Register Pair HL with 42D0H, GAT byte D0H, the eight characters of the diskette's name.
5CB1
LD DE,5EA1H 11 A1 5E
Load Register Pair DE with 5EA1H, the NNNNNNNN of the line of the name and date.
5CB4
LD BC,0008H 01 08 00
Load Register Pair BC with 0008H, the eight characters of the name.
5CB7
LDIR ED B0
Copy Register Pair BC (0008H) bytes from Register Pair HL (42D0H) to Register Pair DE (5EA1H): the name.
5CB9
LD DE,5EADH 11 AD 5E
Load Register Pair DE with 5EADH, the MM/DD/YY of the line; Register Pair HL is now 42D8H, GAT byte D8H, the date.
5CBC
LD BC,0008H 01 08 00
Load Register Pair BC with 0008H, the eight characters of the date.
5CBF
LDIR ED B0
Copy Register Pair BC (0008H) bytes from Register Pair HL (42D8H) to Register Pair DE (5EADH): the date.
5CC1
LD HL,5EA1H 21 A1 5E
Load Register Pair HL with 5EA1H, the line of the name and the date.
5CC4
Call 4467H to show the text at Register Pair HL on the screen up to its carriage return.
5CC7
POP BC C1
Restore Register Pair BC, Register C the drive, from the stack at the Stack Pointer.
5CC8
LD B,00H 06 00
Load Register B with 00H, directory record 00H: entry 0 of the first directory sector.
5CCA
LD DE,6100H 11 00 61
Load Register Pair DE with 6100H, the place of the copy of the eight directory sectors.
5CCD
Call 4AC1H to read the directory sector of record Register B of drive Register C into 4200H; Register Pair HL returns the entry. 5CE0H jumps back here.
5CD0
If the NZ FLAG is set (the directory could not be read), jump to 554CH to report the error in Register A.
5CD3
LD L,00H 2E 00
Load Register L with 00H: Register Pair HL is 4200H, the start of the sector.
5CD5
PUSH BC C5
Save Register Pair BC, the record and the drive, on the stack at the Stack Pointer.
5CD6
LD BC,0100H 01 00 01
Load Register Pair BC with 0100H, the 256 bytes of a sector.
5CD9
LDIR ED B0
Copy Register Pair BC (0100H) bytes from Register Pair HL (4200H) to Register Pair DE, the next page of 6100H-68FFH.
5CDB
POP BC C1
Restore Register Pair BC, the record and the drive, from the stack at the Stack Pointer.
5CDC
INC B 04
Increment Register B to the record of the next directory sector.
5CDD
LD A,B 78
Copy Register B, the record, into Register A.
5CDE
CP 08H FE 08
Compare Register A with 08H: the Z FLAG after the eighth sector.
5CE0
If the NZ FLAG is set (more sectors), jump back to 5CCDH.
5CE2
LD HL,6100H 21 00 61
Load Register Pair HL with 6100H, entry 0 of the first sector in the copy.
5CE5
LD A,0CH 3E 0C
Load Register A with 0CH, the twelve lines shown before DIR waits for a key.
5CE7
LD (5DABH),A 32 AB 5D
Store Register A (0CH) at 5DABH, the operand of LD A at 5DAAH, the count of the lines left.
5CEA
LD B,03H 06 03
Load Register B with 03H, the three files of a line.
5CECH - Show One Entry
Register Pair HL is the entry in the copy at 6100H-68FFH, Register B the places left on the line. An entry is passed over when it is not in use (bit 4 of its attribute clear), when it is an extra entry (bit 7), when it is a system file (bit 6) and S was not given, or when it is invisible (bit 3) and I was not given.
5CEC
LD A,(HL) 7E
Load Register A with the attribute byte of the entry at Register Pair HL. 5DC4H and 5DCDH jump back here.
5CED
PUSH HL E5
Save Register Pair HL, the entry, on the stack at the Stack Pointer.
5CEE
BIT 4,A CB 67
Test bit 4 of Register A, the entry in use: the Z FLAG when it is clear.
5CF0
If the Z FLAG is set (a free entry), jump to 5DBFH to go to the next entry.
5CF3
BIT 7,A CB 7F
Test bit 7 of Register A, the extra entry of a file that has more than four extents.
5CF5
If the NZ FLAG is set (an extra entry), jump to 5DBFH to go to the next entry.
5CF8
BIT 6,A CB 77
Test bit 6 of Register A, the bit of a system file in the attribute byte.
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 word of S: the operand 5CFDH, 0000H unless S was given.
5CFF
LD A,D 7A
Copy Register D, the high byte of the word of S, into Register A.
5D00
OR E B3
OR Register A with Register E: the Z FLAG 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; its invisible bit is not tested.
5D06
BIT 3,A CB 5F
Test bit 3 of Register A, the invisible file.
5D08
If the Z FLAG is set (a visible file), jump to 5D12H to show it.
5D0A
LD DE,0000H 11 00 00
Load Register Pair DE with the word of I: the operand 5D0BH, 0000H unless I was given.
5D0D
LD A,D 7A
Copy Register D, the high byte of the word of I, into Register A.
5D0E
OR E B3
OR Register A with Register E: the Z FLAG 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
Save Register Pair BC, Register B the places left on the line, on the stack at the Stack Pointer.
5D13
LD A,L 7D
Copy Register L, the start of the entry, into Register A.
5D14
ADD A,05H C6 05
Add 05H to Register A: offset 05H of the entry, the name.
5D16
LD L,A 6F
Copy Register A into Register L: Register Pair HL points at the name.
5D17
LD C,11H 0E 11
Load Register C with 11H, the 17 characters of the column for the name and extension.
5D19
LD B,08H 06 08
Load Register B with 08H, the eight characters of the name.
5D1B
LD A,(HL) 7E
Load Register A with the character of the name at Register Pair HL.
5D1C
INC HL 23
Increment Register Pair HL to the next character.
5D1D
CP 20H FE 20
Compare Register A with 20H, a space, the end of a short name.
5D1F
If the Z FLAG is set (the end of the name), jump to 5D29H.
5D21
Call 0033H, the ROM's display of the character in Register A.
5D24
DEC C 0D
Decrement Register C, the characters left in the column.
5D25
Decrement Register B and jump back to 5D1BH while it is not 00H.
5D27
Jump to 5D2DH: Register Pair HL is at the extension.
5D29
LD A,L 7D
Copy Register L, one past the space, into Register A.
5D2A
ADD A,B 80
Add Register B, the characters of the name not yet looked at, to Register A.
5D2B
DEC A 3D
Decrement Register A: offset 0DH of the entry, the extension.
5D2C
LD L,A 6F
Copy Register A into Register L: Register Pair HL points at the extension.
5D2D
LD A,(HL) 7E
Load Register A with the first character of the extension at Register Pair HL.
5D2E
CP 20H FE 20
Compare Register A with 20H, a space: a file with 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 before the extension.
5D34
Call 0033H, the ROM's display of the character in Register A.
5D37
DEC C 0D
Decrement Register C, the characters left in the column.
5D38
LD B,03H 06 03
Load Register B with 03H, the three characters of the extension.
5D3A
LD A,(HL) 7E
Load Register A with the character of the extension at Register Pair HL.
5D3B
INC HL 23
Increment Register Pair HL to the next character.
5D3C
CP 20H FE 20
Compare Register A with 20H, a space, the end of a short extension.
5D3E
If the Z FLAG is set (the end of the extension), jump to 5D46H.
5D40
Call 0033H, the ROM's display of the character in Register A.
5D43
DEC C 0D
Decrement Register C, the characters left in the column.
5D44
Decrement Register B and jump back to 5D3AH while it is not 00H.
5D46
LD A,20H 3E 20
Load Register A with 20H, a space after the name and extension.
5D48
Call 0033H, the ROM's display of the character in Register A.
5D4B
DEC C 0D
Decrement Register C, the characters left in the column.
5D4C
LD A,L 7D
Copy Register L, a place in the entry, into Register A.
5D4D
AND E0H E6 E0
AND Register A with E0H: the start of the entry.
5D4F
LD L,A 6F
Copy Register A into Register L: Register Pair HL points at the entry.
5D50
LD B,(HL) 46
Load Register B with the attribute byte of the entry at Register Pair HL.
5D51
LD A,53H 3E 53
Load Register A with 53H, the letter S of a system file.
5D53
BIT 6,B CB 70
Test bit 6 of Register B, the bit of a system file in the attribute byte.
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 for a file that is not a system file.
5D59
Call 0033H, the ROM's display of the character in Register A.
5D5C
LD A,49H 3E 49
Load Register A with 49H, the letter I of an invisible file.
5D5E
BIT 3,B CB 58
Test bit 3 of Register B, the 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 for a visible file.
5D64
Call 0033H, the ROM's display of the character in Register A.
5D67
PUSH HL E5
Save Register Pair HL, the entry, on the stack at the Stack Pointer.
5D68
LD A,L 7D
Copy Register L, the start of the entry, into Register A.
5D69
ADD A,10H C6 10
Add 10H to Register A: offset 10H of the entry, the update password hash.
5D6B
LD L,A 6F
Copy Register A into Register L: Register Pair HL points at entry +10H.
5D6C
LD E,(HL) 5E
Load Register E with the low byte of the update password hash at Register Pair HL.
5D6D
INC L 2C
Increment Register L to entry +11H, the high byte of the update password hash.
5D6E
LD D,(HL) 56
Load Register D with the high byte of the update password hash at Register Pair HL.
5D6F
PUSH HL E5
Save Register Pair HL, entry +11H, on the stack at the Stack Pointer.
5D70
LD HL,4296H 21 96 42
Load Register Pair HL with 4296H, the hash of the blank password (eight spaces).
5D73
SBC HL,DE ED 52
Subtract Register Pair DE, the update password hash, from Register Pair HL (the C FLAG is clear): the Z FLAG when it is blank.
5D75
POP HL E1
Restore Register Pair HL, entry +11H, from the stack at the Stack Pointer.
5D76
If the Z FLAG is set (no update password), jump to 5D8CH to show a space; the access password is not looked at.
5D78
LD A,B 78
Copy Register B, the attribute byte, into Register A.
5D79
AND 07H E6 07
AND Register A with 07H, the protection level: the NZ FLAG for levels 1-7.
5D7B
LD A,50H 3E 50
Load Register A with 50H, the letter P of a file with passwords; the flags of the AND stay.
5D7D
If the NZ FLAG is set (an update password and a level above 0), jump to 5D8EH to show the P.
5D7F
INC L 2C
Increment Register L to entry +12H, the access password hash.
5D80
LD E,(HL) 5E
Load Register E with the low byte of the access password hash at Register Pair HL.
5D81
INC L 2C
Increment Register L to entry +13H, the high byte of the access password hash.
5D82
LD D,(HL) 56
Load Register D with the high byte of the access password hash at Register Pair HL.
5D83
LD HL,4296H 21 96 42
Load Register Pair HL with 4296H, the hash of the blank password (eight spaces).
5D86
SBC HL,DE ED 52
Subtract Register Pair DE, the access password hash, from Register Pair HL: the NZ FLAG when it is not blank.
5D88
LD A,50H 3E 50
Load Register A with 50H, the letter P; the flags of the subtraction stay.
5D8A
If the NZ FLAG is set (an access password too), jump to 5D8EH to show the P.
5D8C
LD A,20H 3E 20
Load Register A with 20H, a space: no P is shown for this file.
5D8E
Call 0033H, the ROM's display of the character in Register A.
5D91
POP HL E1
Restore Register Pair HL, the entry, from the stack at the Stack Pointer.
5D92
LD A,20H 3E 20
Load Register A with 20H, a space to fill the column. 5D98H jumps back here.
5D94
Call 0033H, the ROM's display of the character in Register A.
5D97
DEC C 0D
Decrement Register C, the characters left in the column.
5D98
If the NZ FLAG is set (the column is not full), jump back to 5D92H.
5D9A
LD DE,0000H 11 00 00
Load Register Pair DE with the word of A: the operand 5D9BH, 0000H unless A was given.
5D9D
LD A,D 7A
Copy Register D, the high byte of the word of A, into Register A.
5D9E
OR E B3
OR Register A with Register E: the NZ FLAG when A was given.
5D9F
POP BC C1
Restore Register Pair BC, Register B the places left on the line, from the stack at the Stack Pointer.
5DA0
If the NZ FLAG is set (A was given), call 5DF1H to show LRL, EOF and SIZE; it returns Register B 01H, so that the line ends.
5DA3
Decrement Register B, the places left on the line, and jump to 5DBFH while it is not 00H.
5DA5
LD A,0DH 3E 0D
Load Register A with 0DH, a carriage return: the line is full.
5DA7
Call 0033H, the ROM's display of the character in Register A.
5DAA
LD A,00H 3E 00
Load Register A with the count of the lines left: the operand 5DABH (00H in the file, 0CH from 5CE7H).
5DAC
DEC A 3D
Decrement Register A, the count of the lines left on the screen.
5DAD
If the NZ FLAG is set (lines left on the screen), jump to 5DB4H.
5DAF
Call 0049H, the ROM's wait for a key, after twelve lines.
5DB2
LD A,0CH 3E 0C
Load Register A with 0CH, twelve lines again.
5DB4
LD (5DABH),A 32 AB 5D
Store Register A, the lines left, at 5DABH, the operand of LD A at 5DAAH.
5DB7
Call 5515H to test for BREAK and the pause key: the NZ FLAG for BREAK.
5DBA
If the NZ FLAG is set (BREAK), jump to 5DDBH to clear the copy and end.
5DBD
LD B,03H 06 03
Load Register B with 03H, three files on the new line.
5DBFH - Go to the Next Entry
The same entry of the next sector page comes next; after page 68H, the next entry of the first page.
5DBF
POP HL E1
Restore Register Pair HL, the entry, from the stack at the Stack Pointer.
5DC0
INC H 24
Increment Register H to the page of the next directory sector in the copy.
5DC1
LD A,H 7C
Copy Register H, the page of the sector in the copy, into Register A.
5DC2
CP 69H FE 69
Compare Register A with 69H, the page after the eighth sector.
5DC4
If the NZ FLAG is set (another sector), jump back to 5CECH to show the same entry of that sector.
5DC7
LD H,61H 26 61
Load Register H with 61H, the page of the first sector again.
5DC9
LD A,L 7D
Copy Register L, the place of the entry, into Register A.
5DCA
ADD A,20H C6 20
Add 20H to Register A: the next entry; the C FLAG after entry 7.
5DCC
LD L,A 6F
Copy Register A into Register L: Register Pair HL points at the next entry of the first sector.
5DCD
If the NC FLAG is set (another entry), jump back to 5CECH.
5DD0
Call 5DE1H to clear the copy of the directory at 6100H-68FFH.
5DD3
LD A,0DH 3E 0D
Load Register A with 0DH, a carriage return after the last line.
5DD5
Call 0033H, the ROM's display of the character in Register A.
5DD8
Jump to 402DH, DOS READY: the directory is shown.
5DDB
Call 5DE1H to clear the copy of the directory at 6100H-68FFH after BREAK.
5DDE
Jump to 4030H, the abnormal exit of a command, which returns to DOS READY (or enters DEBUG while DEBUG is on).
5DE1H - Clear the Copy of the Directory
Writes 00H in 6100H-68FFH: no copy of the directory entries, with their password hashes, stays in memory after DIR.
5DE1
LD HL,6100H 21 00 61
Load Register Pair HL with 6100H, the start of the copy of the directory.
5DE4
LD B,00H 06 00
Load Register B with 00H, the byte written over the copy of the directory.
5DE6
LD (HL),B 70
Store Register B (00H) at Register Pair HL, a byte of the copy. 5DE8H and 5DEEH jump back here.
5DE7
INC L 2C
Increment Register L to the next byte of the page.
5DE8
If the NZ FLAG is set (still in the page), jump back to 5DE6H.
5DEA
INC H 24
Increment Register H to the next page of the copy of the directory.
5DEB
LD A,H 7C
Copy Register H, the page of the copy, into Register A for the test.
5DEC
CP 69H FE 69
Compare Register A with 69H, the page after the copy.
5DEE
If the NZ FLAG is set (another page), jump back to 5DE6H.
5DF0
RET C9
Return with 6100H-68FFH, the copy of the directory, cleared to 00H.
5DF1H - Show LRL, EOF and SIZE
Called for DIR (A) with Register Pair HL the entry. LRL is the record length (256 for 00H); EOF is the number of records, the three byte number at 5E67H-5E69H (the sectors of entry +14H-+15H times 256, plus the end of file byte of entry +03H) divided by the record length; SIZE is the granules of all the file's extents. Entry +14H-+15H counts the last sector even when it is only partly used, so EOF is 256 bytes too large for a file whose end of file byte is not 00H (a bug: the Bugs part of the introduction). Returns Register B 01H.
5DF1
PUSH HL E5
Save Register Pair HL, the entry, on the stack at the Stack Pointer.
5DF2
INC L 2C
Increment Register L to entry +01H, on the way to the end of file byte.
5DF3
INC L 2C
Increment Register L to entry +02H, on the way to the end of file byte.
5DF4
INC L 2C
Increment Register L to entry +03H, the end of file byte.
5DF5
LD A,(HL) 7E
Load Register A with the end of file byte at Register Pair HL, the bytes used in the last sector.
5DF6
LD (5E69H),A 32 69 5E
Store Register A at 5E69H, the low byte of the three byte number of the file's bytes.
5DF9
INC L 2C
Increment Register L to entry +04H, the record length.
5DFA
PUSH HL E5
Save Register Pair HL, entry +04H, on the stack at the Stack Pointer.
5DFB
LD L,(HL) 6E
Load Register L with the record length at Register Pair HL.
5DFC
LD A,L 7D
Copy Register L, the record length, into Register A.
5DFD
LD (5E1FH),A 32 1F 5E
Store Register A, the record length, at 5E1FH, the operand of LD C at 5E1EH, the divisor.
5E00
SUB 01H D6 01
Subtract 01H from Register A: the C FLAG for a record length of 00H.
5E02
LD A,00H 3E 00
Load Register A with 00H; the C FLAG of the subtraction stays for the ADC.
5E04
ADC A,00H CE 00
Add 00H and the C FLAG 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 is the record length, 0100H for 00H.
5E07
LD DE,5EBBH 11 BB 5E
Load Register Pair DE with 5EBBH, the place of the number after LRL=.
5E0A
Call 606CH to write Register Pair HL, the record length, as five decimal characters at Register Pair DE.
5E0D
POP HL E1
Restore Register Pair HL, entry +04H, from the stack at the Stack Pointer.
5E0E
LD A,L 7D
Copy Register L, entry +04H, into Register A.
5E0F
ADD A,10H C6 10
Add 10H to Register A: entry +14H, the number of sectors.
5E11
LD L,A 6F
Copy Register A into Register L: Register Pair HL points at entry +14H.
5E12
LD A,(HL) 7E
Load Register A with the low byte of the number of sectors at Register Pair HL.
5E13
LD (5E68H),A 32 68 5E
Store Register A at 5E68H, the middle byte of the three byte number.
5E16
INC L 2C
Increment Register L to entry +15H, the high byte of the number of sectors.
5E17
LD A,(HL) 7E
Load Register A with the high byte of the number of sectors at Register Pair HL.
5E18
LD (5E67H),A 32 67 5E
Store Register A at 5E67H, the high byte of the three byte number.
5E1B
LD HL,5E67H 21 67 5E
Load Register Pair HL with 5E67H, the three byte number, high byte first.
5E1E
LD C,00H 0E 00
Load Register C with the record length: the operand 5E1FH, stored by 5DFDH.
5E20
Call 60A7H to divide the three bytes at Register Pair HL by Register C; Register Pair DE returns the records.
5E23
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL is the number of records.
5E24
LD DE,5EC7H 11 C7 5E
Load Register Pair DE with 5EC7H, the place of the number after EOF=.
5E27
Call 606CH to write Register Pair HL, the records, as five decimal characters at Register Pair DE.
5E2A
POP HL E1
Restore Register Pair HL, the entry, from the stack at the Stack Pointer.
5E2B
Call 5E3EH to count the granules of the file's extents into Register Pair DE.
5E2E
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL is the number of granules.
5E2F
LD DE,5ED4H 11 D4 5E
Load Register Pair DE with 5ED4H, the place of the number after SIZE=.
5E32
Call 606CH to write Register Pair HL, the granules, as five decimal characters at Register Pair DE.
5E35
LD HL,5EB7H 21 B7 5E
Load Register Pair HL with 5EB7H, the line LRL= / EOF= / SIZE= GRANS.
5E38
Call 4467H to show the text at Register Pair HL on the screen up to its 03H.
5E3B
LD B,01H 06 01
Load Register B with 01H, so that the DJNZ at 5DA3H ends the line after this file.
5E3D
RET C9
Return to 5DA3H with Register B 01H, so that the line ends after this file.
5E3EH - Count the Granules of a File
Called with Register Pair HL the entry in the copy at 6100H-68FFH. The granule bytes of the extents at +16H-+1FH are added up (bits 4-0 plus 1 each); FEH and a record go on to the extents of the extra entry (its sector page 61H plus bits 2-0, its place bits 7-5), FFH ends. Returns Register Pair DE the granules.
5E3E
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the count of the granules.
5E41
LD A,L 7D
Copy Register L, the start of the entry, into Register A.
5E42
ADD A,16H C6 16
Add 16H to Register A: offset 16H of the entry, the first extent.
5E44
LD L,A 6F
Copy Register A into Register L: Register Pair HL points at the first extent.
5E45
LD A,(HL) 7E
Load Register A with the block byte of the extent at Register Pair HL. 5E52H, 5E55H and 5E65H jump back here.
5E46
INC L 2C
Increment Register L to the granule byte of the extent.
5E47
CP FEH FE FE
Compare Register A with FEH: the NC FLAG for FEH (an extra entry follows) or FFH (the end).
5E49
If the NC FLAG is set (FEH or FFH), jump to 5E57H.
5E4B
LD A,(HL) 7E
Load Register A with the granule byte of the extent at Register Pair HL.
5E4C
INC L 2C
Increment Register L to the block byte of the next extent of the entry.
5E4D
AND 1FH E6 1F
AND Register A with 1FH: the count of the granules of the extent minus 1.
5E4F
INC A 3C
Increment Register A: the granules of 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 into Register E, the low byte of the count.
5E52
If the NC FLAG is set (no carry), jump back to 5E45H for the next extent.
5E54
INC D 14
Increment Register D, the high byte of the count.
5E55
Jump back to 5E45H for the next extent, with the high byte of the count raised.
5E57
RET NZ C0
Return with the count in Register Pair DE if the NZ FLAG is set: FFH, the end of the extents.
5E58
LD B,(HL) 46
Load Register B with the byte after FEH at Register Pair HL, the directory record of the extra entry.
5E59
LD A,B 78
Copy Register B, the record, into Register A.
5E5A
AND 07H E6 07
AND Register A with 07H, the sector of the record (0-7).
5E5C
ADD A,61H C6 61
Add 61H to Register A: the page of that sector in the copy.
5E5E
LD H,A 67
Copy Register A into Register H, the page of the extra entry.
5E5F
LD A,B 78
Copy Register B, the record, into Register A.
5E60
AND E0H E6 E0
AND Register A with E0H, the place of the entry in its sector.
5E62
ADD A,16H C6 16
Add 16H to Register A: offset 16H of the extra entry, its first extent.
5E64
LD L,A 6F
Copy Register A into Register L: Register Pair HL points at the extents of the extra entry.
5E65
Jump back to 5E45H to count the extents of the extra entry.
5E67-5E69
DEFS 3
Not in the file: the three byte number of 5DF1H, high byte first: 5E67H entry +15H, 5E68H entry +14H (the sectors) and 5E69H entry +03H (the end of file byte).
5E6A-5E71
DEFM "A " / DEFW 5D9BH 41 20 20 20 20 20 9B 5D
The first entry of DIR's parameter table at 5E6AH: A padded to six characters, and 5D9BH, the operand of LD DE at 5D9AH, where the value is stored.
5E72-5E79
DEFM "I " / DEFW 5D0BH 49 20 20 20 20 20 0B 5D
The parameter I padded to six characters, and 5D0BH, the operand of LD DE at 5D0AH, where its value is stored.
5E7A-5E81
DEFM "S " / DEFW 5CFDH 53 20 20 20 20 20 FD 5C
The parameter S padded to six characters, and 5CFDH, the operand of LD DE at 5CFCH, where its value is stored.
5E82
DEFB 00H 00
The end of DIR's parameter table at 5E82H: 00H where the next entry's name would start.
5E83-5EA0
DEFB 1CH,1FH / DEFM "FILE DIRECTORY --- DRIVE X" / DEFB C5H,03H 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 58 C5 03
The heading at 5E83H shown by 5C9BH: 1CH (cursor to the top left) and 1FH (clear to the end of the screen), FILE DIRECTORY --- DRIVE and the X at 5E9EH that 5C8FH replaces with the drive's digit, C5H (five spaces) and 03H.
5EA1-5EB6
DEFM "NNNNNNNN -- MM/DD/YY" / DEFB 0AH,0DH 4E 4E 4E 4E 4E 4E 4E 4E 20 2D 2D 20 4D 4D 2F 44 44 2F 59 59 0A 0D
The line at 5EA1H shown by 5CC4H: the diskette's name at 5EA1H and its date at 5EADH, both copied from the GAT, then a line feed and a carriage return, which end the text.
5EB7-5EDF
DEFM "LRL= " / DEFB 2FH / DEFM " EOF= " / DEFB 2FH / DEFM " SIZE= GRANS" / DEFB 03H 4C 52 4C 3D 20 20 20 20 20 20 2F 20 45 4F 46 3D 20 20 20 20 20 20 2F 20 53 49 5A 45 3D 20 20 20 20 20 20 47 52 41 4E 53 03
The line at 5EB7H shown by 5E38H for DIR (A): LRL= with the number at 5EBBH, EOF= with the number at 5EC7H, SIZE= with the number at 5ED4H and GRANS, then 03H.
5EE0H - FREE: Show the Free Space of Each Drive
For drives 0-3 a line DRIVE d -- NAME MM/DD/YY nnnnn FILES, nnnnn GRANS: the diskette's name and date from the GAT, the free directory places (HIT bytes 00H in entries 2-7 of the eight sectors, the places of ordinary files) and the free granules (the 0 bits of GAT bytes 00H-BFH). A drive whose index pulses 50FDH of SYS2/SYS does not see is passed over. To have SYS2/SYS's routines in memory, an empty file specification is opened first, which loads SYS2/SYS and fails.
5EE0
LD C,00H 0E 00
Load Register C with 00H, drive 0, the first drive shown.
5EE2
LD A,03H 3E 03
Load Register A with 03H, the end mark of a file specification.
5EE4
LD DE,5551H 11 51 55
Load Register Pair DE with 5551H, SYS6/SYS's first FCB.
5EE7
LD (DE),A 12
Store Register A (03H) at Register Pair DE: the FCB holds an empty file specification.
5EE8
Call 4424H to open the file at Register Pair DE: request code 94H loads SYS2/SYS at 4E00H, which gives error 13H for the empty name. The result is not tested.
5EEB
PUSH BC C5
Save Register Pair BC, Register C the drive, on the stack at the Stack Pointer. 5F5DH jumps back here for each drive.
5EEC
Call 50FDH of SYS2/SYS to wait for the index pulses of drive Register C: the NZ FLAG when the drive does not turn (no diskette or no drive).
5EEF
If the NZ FLAG is set (no diskette), jump to 5F58H to go to the next drive.
5EF1
LD A,C 79
Copy Register C, the drive whose diskette turns, into Register A.
5EF2
ADD A,30H C6 30
Add 30H to Register A: the digit of the drive.
5EF4
LD (5F68H),A 32 68 5F
Store Register A, the digit, at 5F68H, the X of DRIVE X in the line.
5EF7
Call 4AF0H to read the GAT of drive Register C into 4D00H; the NZ FLAG and an error code in Register A if it fails.
5EFA
If the NZ FLAG is set (the GAT could not be read), jump to 554CH to report the error in Register A.
5EFD
LD HL,4DD0H 21 D0 4D
Load Register Pair HL with 4DD0H, GAT byte D0H, the eight characters of the diskette's name.
5F00
LD DE,5F6EH 11 6E 5F
Load Register Pair DE with 5F6EH, the NNNNNNNN 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 Register Pair BC (0008H) bytes from Register Pair HL (4DD0H) to Register Pair DE (5F6EH): the name.
5F08
LD DE,5F79H 11 79 5F
Load Register Pair DE with 5F79H, the MM/DD/YY of the line; Register Pair HL is now 4DD8H, GAT byte D8H, the date.
5F0B
LD BC,0008H 01 08 00
Load Register Pair BC with 0008H, the eight characters of the date.
5F0E
LDIR ED B0
Copy Register Pair BC (0008H) bytes from Register Pair HL (4DD8H) to Register Pair DE (5F79H): the date.
5F10
LD HL,4D00H 21 00 4D
Load Register Pair HL with 4D00H, the first byte of the GAT, one byte a block.
5F13
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the count of the free granules.
5F16
LD B,C0H 06 C0
Load Register B with C0H, the 192 bytes of the GAT's block map (bytes 00H-BFH).
5F18
LD A,(HL) 7E
Load Register A with the byte of the GAT at Register Pair HL: a 0 bit is a free granule. 5F23H jumps back here.
5F19
SCF 37
Set the C FLAG, so that a 1 bit comes in at the top of Register A. 5F20H jumps back here.
5F1A
RRA 1F
Turn Register A to the right through the C FLAG: the lowest bit goes to the C FLAG.
5F1B
If the C FLAG is set (a used granule), jump to 5F1EH.
5F1D
INC DE 13
Increment Register Pair DE, the count of the free granules.
5F1E
CP FFH FE FF
Compare Register A with FFH: the Z FLAG when all the bits still to look at are 1.
5F20
If the NZ FLAG is set (a 0 bit is left), jump back to 5F19H.
5F22
INC L 2C
Increment Register L to the next byte of the GAT.
5F23
Decrement Register B and jump back to 5F18H while it is not 00H.
5F25
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL is the count of the free granules.
5F26
LD DE,5F90H 11 90 5F
Load Register Pair DE with 5F90H, the place of the number before GRANS.
5F29
Call 606CH to write Register Pair HL, the free granules, as five decimal characters at Register Pair DE.
5F2C
POP BC C1
Restore Register Pair BC, Register C the drive, from the stack at the Stack Pointer.
5F2D
PUSH BC C5
Save Register Pair BC, Register C the drive, on the stack again.
5F2E
Call 512EH of SYS2/SYS to read the hash index table of drive Register C into 4D00H; the NZ FLAG and an error code in Register A if it fails.
5F31
If the NZ FLAG is set (the HIT could not be read), jump to 554CH to report the error in Register A.
5F34
LD HL,4D40H 21 40 4D
Load Register Pair HL with 4D40H, the HIT byte of record 40H, entry 2 of the first directory sector.
5F37
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the count of the free places.
5F3A
LD A,(HL) 7E
Load Register A with the HIT byte at Register Pair HL. 5F44H and 5F49H jump back here.
5F3B
OR A B7
OR Register A with itself: the Z FLAG when the byte is 00H, a free place.
5F3C
If the NZ FLAG is set (a place in use), jump to 5F3FH.
5F3E
INC DE 13
Increment Register Pair DE, the count of the free places.
5F3F
INC L 2C
Increment Register L to the HIT byte of the next record.
5F40
LD A,L 7D
Copy Register L, the record, into Register A.
5F41
AND E7H E6 E7
AND Register A with E7H: bits 4 and 3 of the record are cleared.
5F43
CP L BD
Compare Register A with Register L: the Z FLAG for the records of the sectors 0-7.
5F44
If the Z FLAG is set (a record of a directory sector), jump back to 5F3AH.
5F46
ADD A,20H C6 20
Add 20H to Register A: the record of the next entry in sector 0; it is 00H after entry 7.
5F48
LD L,A 6F
Copy Register A into Register L: Register Pair HL points at that HIT byte.
5F49
If the NZ FLAG is set (another entry), jump back to 5F3AH.
5F4B
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL is the count of the free places (48 at most).
5F4C
LD DE,5F83H 11 83 5F
Load Register Pair DE with 5F83H, the place of the number before FILES.
5F4F
Call 606CH to write Register Pair HL, the free places, as five decimal characters at Register Pair DE.
5F52
LD HL,5F62H 21 62 5F
Load Register Pair HL with 5F62H, the line DRIVE d -- NAME DATE FILES, GRANS.
5F55
Call 4467H to show the text at Register Pair HL on the screen up to its carriage return.
5F58
POP BC C1
Restore Register Pair BC, Register C the drive, from the stack at the Stack Pointer.
5F59
INC C 0C
Increment Register C to the next drive of the four, drives 0-3.
5F5A
LD A,C 79
Copy Register C, the next drive, into Register A for the test against 04H.
5F5B
CP 04H FE 04
Compare Register A with 04H: the Z FLAG after drive 3.
5F5D
If the NZ FLAG is set (another drive), jump back to 5EEBH.
5F5F
Jump to 402DH, DOS READY: the four drives are shown.
5F62-5F9B
DEFM "DRIVE X -- NNNNNNNN MM/DD/YY FILES, GRANS" / DEFB 0DH 44 52 49 56 45 20 58 20 2D 2D 20 20 4E 4E 4E 4E 4E 4E 4E 4E 20 20 20 4D 4D 2F 44 44 2F 59 59 20 20 20 20 20 20 20 20 46 49 4C 45 53 2C 20 20 20 20 20 20 20 47 52 41 4E 53 0D
The line at 5F62H shown by 5F55H for each drive: DRIVE and the digit at 5F68H, the name at 5F6EH, the date at 5F79H, the free places at 5F83H, FILES, the free granules at 5F90H, GRANS and a carriage return.
5F9CH - RENAME: Give a File a New Name
RENAME file1 TO file2. file1 is opened; file2 must have no drive of its own, gets file1's drive and must not exist. The open of file2 leaves its name and extension parsed at 515DH in SYS2/SYS's work area: they replace the name in file1's directory entry, and file1's HIT byte gets the hash of the new name. The passwords of the entry stay as they were.
5F9C
LD DE,5551H 11 51 55
Load Register Pair DE with 5551H, the first FCB, for the specification of the file to rename.
5F9F
Call 441CH to parse the file specification at Register Pair HL into the FCB at Register Pair DE; the NZ FLAG when there is none.
5FA2
If the NZ FLAG is set (no file specification), jump to 553AH to show FILE SPEC REQUIRED.
5FA5
LD A,(DE) 1A
Load Register A with the first character of the specification at Register Pair DE.
5FA6
CP 2AH FE 2A
Compare Register A with 2AH, the asterisk that starts a device name.
5FA8
If the Z FLAG is set (a device), jump to 553AH to show FILE SPEC REQUIRED.
5FAB
Call 4424H to open the file of the FCB at Register Pair DE (with the record length and buffer left in Register B and Register Pair HL by the parser); the NZ FLAG and an error code in Register A if it fails.
5FAE
If the NZ FLAG is set (the file could not be opened), jump to 554CH to report the error in Register A.
5FB1
LD DE,5571H 11 71 55
Load Register Pair DE with 5571H, the second FCB, for the new name.
5FB4
Call 441CH to parse the next file specification at Register Pair HL into the FCB at Register Pair DE; the NZ FLAG when there is none.
5FB7
If the NZ FLAG is set (no new name), jump to 553AH to show FILE SPEC REQUIRED.
5FBA
LD A,(5552H) 3A 52 55
Load Register A with the access level at 5552H, offset 01H of file1's FCB.
5FBD
AND 07H E6 07
AND Register A with 07H, the access level: SYS2/SYS gives every file 00H.
5FBF
CP 03H FE 03
Compare Register A with 03H: the NC FLAG for the levels 3-7, which may not rename.
5FC1
LD A,25H 3E 25
Load Register A with 25H, the error code of ILLEGAL ACCESS ATTEMPTED TO PROTECTED FILE; the flags of the compare stay.
5FC3
If the NC FLAG is set (a level of 3 or more), jump to 554CH to report the error in Register A.
5FC6
LD HL,5571H 21 71 55
Load Register Pair HL with 5571H, the new name in the second FCB.
5FC9
LD A,(HL) 7E
Load Register A with the character of the new name at Register Pair HL. 5FD3H jumps back here.
5FCA
CP 3AH FE 3A
Compare Register A with 3AH, the colon before a drive number.
5FCC
If the Z FLAG is set (the new name names a drive), jump to 6028H to show DRIVE SPECIFICATION ILLEGAL.
5FCE
CP 20H FE 20
Compare Register A with 20H: the C FLAG for 03H, the end of the specification.
5FD0
If the C FLAG is set (the end), jump to 5FD5H to add the drive.
5FD2
INC HL 23
Increment Register Pair HL to the next character of the new name.
5FD3
Jump back to 5FC9H to look at the next character of the new name.
5FD5
LD (HL),3AH 36 3A
Store 3AH, a colon, at Register Pair HL, over the end mark.
5FD7
INC HL 23
Increment Register Pair HL to the place of the drive number.
5FD8
LD A,(5557H) 3A 57 55
Load Register A with the drive of file1 at 5557H, offset 06H of its FCB.
5FDB
ADD A,30H C6 30
Add 30H to Register A: the digit of the drive.
5FDD
LD (HL),A 77
Store Register A, the digit, at Register Pair HL.
5FDE
INC HL 23
Increment Register Pair HL past the digit to the place of the end mark.
5FDF
LD (HL),03H 36 03
Store 03H, the end mark, at Register Pair HL: the new name is NAME/EXT:d of file1's drive.
5FE1
LD DE,5571H 11 71 55
Load Register Pair DE with 5571H, the FCB of the new name.
5FE4
Call 4424H to open the new name at Register Pair DE on file1's drive; SYS2/SYS parses it into 515DH-5167H, and error 18H is wanted.
5FE7
If the Z FLAG is set (a file of that name exists), jump to 604EH to show DUPLICATE FILE NAME.
5FEA
CP 18H FE 18
Compare Register A with 18H, the error code of FILE NOT IN DIRECTORY.
5FEC
If the NZ FLAG is set (another error), jump to 554CH to report the error in Register A.
5FEF
LD BC,(5557H) ED 4B 57 55
Load Register Pair BC with the word at 5557H, offsets 06H and 07H of file1's FCB: Register C the drive, Register B the directory record.
5FF3
PUSH BC C5
Save Register Pair BC, the record and the drive, on the stack at the Stack Pointer.
5FF4
Call 4AC1H to read the directory sector of record Register B of drive Register C into 4200H; Register Pair HL returns the entry.
5FF7
If the NZ FLAG is set (the directory could not be read), jump to 554CH to report the error in Register A.
5FFA
LD D,H 54
Copy Register H, the page of the entry, into Register D.
5FFB
LD A,L 7D
Copy Register L, the start of the entry, into Register A.
5FFC
ADD A,05H C6 05
Add 05H to Register A: offset 05H of the entry, the name.
5FFE
LD E,A 5F
Copy Register A into Register E: Register Pair DE points at the name in the entry.
5FFF
LD HL,515DH 21 5D 51
Load Register Pair HL with 515DH, the new name and extension parsed by SYS2/SYS.
6002
LD BC,000BH 01 0B 00
Load Register Pair BC with 000BH, the eleven characters of the name and the extension.
6005
LDIR ED B0
Copy Register Pair BC (000BH) bytes from Register Pair HL (515DH) to Register Pair DE, the entry.
6007
POP BC C1
Restore Register Pair BC, the record and the drive, from the stack at the Stack Pointer.
6008
Call 4AD6H to write the directory sector at 4200H back as the sector of record Register B of drive Register C; the NZ FLAG on an error.
600B
If the NZ FLAG is set (the directory could not be written), jump to 554CH to report the error in Register A.
600E
Call 512EH of SYS2/SYS to read the hash index table of drive Register C into 4D00H; the NZ FLAG and an error code in Register A if it fails.
6011
If the NZ FLAG is set (the HIT could not be read), jump to 554CH to report the error in Register A.
6014
LD D,H 54
Copy Register H (4DH, 512EH returns Register Pair HL 4D00H) into Register D.
6015
LD E,B 58
Copy Register B, the record of the entry, into Register E: Register Pair DE is its HIT byte.
6016
PUSH BC C5
Save Register Pair BC, the record and the drive, on the stack at the Stack Pointer.
6017
LD HL,515DH 21 5D 51
Load Register Pair HL with 515DH, the new name and extension.
601A
Call 509BH of SYS2/SYS to return the hash of the eleven characters at Register Pair HL in Register A.
601D
POP BC C1
Restore Register Pair BC, the record and the drive, from the stack at the Stack Pointer.
601E
LD (DE),A 12
Store Register A, the hash of the new name, at Register Pair DE, the entry's HIT byte.
601F
Call 5141H of SYS2/SYS to write the hash index table at 4D00H back to drive Register C; the NZ FLAG on an error.
6022
If the NZ FLAG is set (the HIT could not be written), jump to 554CH to report the error in Register A.
6025
Jump to 402DH, DOS READY: the file has its new name. Its extra entries keep the old hash in their HIT bytes, which no search uses.
6028
LD HL,6031H 21 31 60
Load Register Pair HL with 6031H, the text DRIVE SPECIFICATION ILLEGAL.
602B
Call 4467H to show the text at Register Pair HL on the screen up to its carriage return.
602E
Jump to 4030H, the abnormal exit of a command, which returns to DOS READY (or enters DEBUG while 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
The text at 6031H shown by 6028H when the new name of RENAME names a drive: a new line, DRIVE SPECIFICATION ILLEGAL and a carriage return.
604E
LD HL,6057H 21 57 60
Load Register Pair HL with 6057H, the text DUPLICATE FILE NAME.
6051
Call 4467H to show the text at Register Pair HL on the screen up to its carriage return.
6054
Jump to 4030H, the abnormal exit of a command, which returns to DOS READY (or enters DEBUG while 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
The text at 6057H shown by 604EH when a file of the new name exists: a new line, DUPLICATE FILE NAME and a carriage return.
606CH - Write a Number in Decimal
Called with Register Pair HL the number (0-65535) and Register Pair DE the place. Five characters are written: the ten thousands, thousands, hundreds and tens as digits once one of them is not 0, spaces before that, and the units always as a digit. Register Pair DE returns past them.
606C
LD A,20H 3E 20
Load Register A with 20H, a space, the character for a leading 0.
606E
LD BC,2710H 01 10 27
Load Register Pair BC with 2710H, 10000, the value of the first place.
6071
Call 608CH to write the digit of Register Pair BC (2710H) in Register Pair HL at Register Pair DE.
6074
LD BC,03E8H 01 E8 03
Load Register Pair BC with 03E8H, 1000, the value of the second place.
6077
Call 608CH to write the digit of Register Pair BC (03E8H) in Register Pair HL at Register Pair DE.
607A
LD BC,0064H 01 64 00
Load Register Pair BC with 0064H, 100, the value of the third place.
607D
Call 608CH to write the digit of Register Pair BC (0064H) in Register Pair HL at Register Pair DE.
6080
LD BC,000AH 01 0A 00
Load Register Pair BC with 000AH, 10, the value of the fourth place.
6083
Call 608CH to write the digit of Register Pair BC (000AH) in Register Pair HL at Register Pair DE.
6086
LD A,L 7D
Copy Register L, the units left (0-9), into Register A.
6087
ADD A,30H C6 30
Add 30H to Register A: the digit of the units.
6089
LD (DE),A 12
Store Register A, the units digit, at Register Pair DE.
608A
INC DE 13
Increment Register Pair DE past the five characters.
608B
RET C9
Return with Register Pair DE past the number.
608CH - Write One Place
Register A is the character for 0 (a space until a digit has been written, then the digit 0), Register Pair BC the value of the place. The place is subtracted from Register Pair HL as often as it goes; the count is written as a digit, or Register A when it is 0. Returns Register A 30H once a digit has been written.
608C
PUSH DE D5
Save Register Pair DE, the place of the character, on the stack at the Stack Pointer.
608D
LD E,A 5F
Copy Register A, the character for 0, into Register E.
608E
LD D,FFH 16 FF
Load Register D with FFH, so that the first increment makes the count 00H.
6090
XOR A AF
Clear Register A to 00H, which also clears the C FLAG for the first subtraction.
6091
INC D 14
Increment Register D, the count of the subtractions. 6094H jumps back here.
6092
SBC HL,BC ED 42
Subtract Register Pair BC, the value of the place, from Register Pair HL.
6094
If the NC FLAG is set (it went), jump back to 6091H.
6096
ADD HL,BC 09
Add Register Pair BC back to Register Pair HL: the remainder.
6097
LD A,E 7B
Copy Register E, the character for 0, into Register A.
6098
LD B,D 42
Copy Register D, the digit (0-9), into Register B.
6099
POP DE D1
Restore Register Pair DE, the place of the character, from the stack at the Stack Pointer.
609A
LD (DE),A 12
Store Register A, the character for 0, at Register Pair DE, for a digit of 0.
609B
INC B 04
Increment Register B, the digit, for the test that follows.
609C
DEC B 05
Decrement Register B: the Z FLAG when the digit is 0.
609D
If the Z FLAG is set (the digit is 0), jump to 60A5H: the character for 0 stays.
609F
LD A,B 78
Copy Register B, the digit 1-9 of this place, into Register A.
60A0
ADD A,30H C6 30
Add 30H to Register A: the digit's character.
60A2
LD (DE),A 12
Store Register A, the digit's character, at Register Pair DE over the character for 0.
60A3
LD A,30H 3E 30
Load Register A with 30H: from now on a 0 is written as the digit 0.
60A5
INC DE 13
Increment Register Pair DE to the place of the next character.
60A6
RET C9
Return with Register A the character for 0 of the next place.
60A7H - Divide a Three Byte Number
Called with Register Pair HL three bytes, high byte first, and Register C the divisor. Returns Register Pair DE the quotient (its low 16 bits). For Register C 00H (256) the quotient is the first two bytes. The remainder is kept in Register A and shifted left with RLA: when Register C is above 80H, a remainder of 80H or more loses its top bit, and the quotient is wrong (a bug: the Bugs part of the introduction).
60A7
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the quotient.
60AA
LD A,C 79
Copy Register C, the divisor, into Register A.
60AB
OR A B7
OR Register A with itself: the Z FLAG for a divisor of 00H, 256.
60AC
If the Z FLAG is set (256), jump to 60C9H: the quotient is the first two bytes.
60AE
XOR A AF
Clear Register A to 00H, the remainder of the division at the start.
60AF
LD B,03H 06 03
Load Register B with 03H, the three bytes of the number.
60B1
PUSH BC C5
Save Register Pair BC, Register B the bytes left and Register C the divisor, on the stack at the Stack Pointer. 60C6H jumps back here.
60B2
PUSH HL E5
Save Register Pair HL, the place of the byte, on the stack at the Stack Pointer.
60B3
LD H,(HL) 66
Load Register H with the byte of the number at Register Pair HL.
60B4
LD B,08H 06 08
Load Register B with 08H, the eight bits of the byte.
60B6
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL is the quotient. 60C1H jumps back here.
60B7
ADD HL,HL 29
Add Register Pair HL to itself: the quotient shifted one place to the left.
60B8
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE is the quotient again, Register H the byte.
60B9
RLC H CB 04
Turn Register H to the left: its top bit goes to the C FLAG.
60BB
RLA 17
Turn Register A, the remainder, to the left through the C FLAG: the bit comes in. A bit carried out of Register A is lost.
60BC
CP C B9
Compare Register A with Register C, the divisor: the NC FLAG when the remainder is as large.
60BD
If the C FLAG is set (smaller than the divisor), jump to 60C1H.
60BF
SUB C 91
Subtract Register C, the divisor, from Register A, the remainder.
60C0
INC DE 13
Increment Register Pair DE: a 1 bit in the quotient.
60C1
Decrement Register B and jump back to 60B6H while it is not 00H: the next bit.
60C3
POP HL E1
Restore Register Pair HL, the place of the byte, from the stack at the Stack Pointer.
60C4
INC HL 23
Increment Register Pair HL to the next byte of the number.
60C5
POP BC C1
Restore Register Pair BC, Register B the bytes left and Register C the divisor, from the stack at the Stack Pointer.
60C6
Decrement Register B and jump back to 60B1H while it is not 00H: the next byte.
60C8
RET C9
Return with Register Pair DE the quotient, the number of records.
60C9
LD D,(HL) 56
Load Register D with the first byte of the number at Register Pair HL, the high byte of the sectors.
60CA
INC HL 23
Increment Register Pair HL to the second byte.
60CB
LD E,(HL) 5E
Load Register E with the second byte at Register Pair HL, the low byte of the sectors.
60CC
RET C9
Return with Register Pair DE the number of 256 byte records.