5200H - FORMAT Starts: Boot Sector, Title, Drive, Name, Date, Password
SYS1/SYS loads FORMAT/CMD at 5200H and jumps here. FORMAT refuses to run while bit 5 of the system flags at 430FH is set (unless 4030H holds C7H, the value the ROM itself puts there). It copies the boot sector image at 5E00H-5EFFH to 4200H, where its display routine (429AH) and sector read routine (42AAH) are used by FORMAT too, and it is written to track 0, sector 0 at the end. The command line is not looked at: the drive, the diskette name, the creation date and the master password are always asked for.
5200
DI F3
Disable interrupts: SYS0/SYS's clock and disk interrupt routines must not run while FORMAT drives the controller itself.
5201
LD SP,41FCH 31 FC 41
Load the Stack Pointer with 41FCH, the top of TRSDOS's stack area below 4200H.
5204
PUSH HL E5
Save Register Pair HL (the command line after FORMAT) onto the stack; 522DH takes it off again without using it.
5205
LD A,(4030H) 3A 30 40
Fetch the first byte of the exit after an error from 4030H into Register A: 3EH (LD A,A3H) or CDH (CALL 400FH) with TRSDOS's SYS0/SYS, C7H (RST 00H) as the ROM leaves it.
5208
CP C7H FE C7
Compare Register A against C7H, the RST 00H the ROM puts at 4030H.
520A
If the Z FLAG is set (C7H), JUMP to 521CH: the system flags are not looked at.
520C
LD A,(430FH) 3A 0F 43
Fetch the system flags from 430FH into Register A.
520F
BIT 5,A CB 6F
Test bit 5 of Register A (the system flags), the bit the refusal message calls program chaining.
5211
If the Z FLAG is set (bit 5 clear), JUMP to 521CH to start.
5213
LD HL,57C0H 21 C0 57
Point Register Pair HL to 57C0H, the message FORMAT INVALID DURING PROGRAM CHAINING!.
5216
GOSUB to SYS0/SYS's 4467H to display the text at Register Pair HL (57C0H) up to and including its 0DH.
5219
JUMP to 4030H, the exit after an error, back to TRSDOS.
521C
LD HL,5E00H 21 00 5E
Point Register Pair HL to 5E00H, the boot sector image in the file. 520AH and 5211H jump here.
521F
LD DE,4200H 11 00 42
Point Register Pair DE to 4200H, SYS0/SYS's system sector buffer, where the boot sector's code runs.
5222
LD BC,0100H 01 00 01
Load Register Pair BC with 0100H, the 256 bytes of a sector.
5225
LDIR ED B0
Copy the boot sector: LDIR moves 256 bytes from (HL) (Register Pair HL = 5E00H) to (DE) (Register Pair DE = 4200H), counting Register Pair BC down. 5EFFH is not in the file, so 42FFH gets whatever memory holds there.
5227
LD HL,57E8H 21 E8 57
Point Register Pair HL to 57E8H, the title: clear the screen, TRSDOS DISK FORMATTER PROGRAM 2.3.
522A
GOSUB to 429AH, the boot sector's display routine now at 4200H-42FFH, to show the text at Register Pair HL up to its 0DH or 03H.
522D
POP HL E1
Restore Register Pair HL (the command line, pushed at 5204H) from the stack; it is not used.
522E
LD HL,580EH 21 0E 58
Ask for the Drive
Point Register Pair HL to 580EH, the prompt WHICH DRIVE IS TO BE USED ?. 523FH and 5244H jump here.
5231
GOSUB to 429AH to display the prompt at Register Pair HL; it ends with 03H, so the cursor stays after it.
5234
LD HL,5D00H 21 00 5D
Point Register Pair HL to 5D00H, the input buffer.
5237
LD B,01H 06 01
Load Register B with 01H: one character may be typed.
5239
GOSUB to ROM routine at 0040H to read a line of at most Register B characters into the buffer at Register Pair HL; it returns Register Pair HL = 5D00H.
523C
LD A,(HL) 7E
Fetch the character typed from (HL) (Register Pair HL = 5D00H) into Register A.
523D
SUB 30H D6 30
SUBtract 30H from Register A, turning the digit into a drive number; the CARRY FLAG is set for a character below the digit 0.
523F
If the CARRY FLAG is set (not a digit), JUMP to 522EH to ask again.
5242
CP 04H FE 04
Compare Register A (the drive number) against 04H: the NO CARRY FLAG is set for 4 or more.
5244
If the NO CARRY FLAG is set (not 0-3), JUMP to 522EH to ask again.
5247
RLCA 07
Rotate Register A (the drive number 0-3) left: times 2.
5248
RLCA 07
Rotate Register A (the drive number) left again: times 4.
5249
RLCA 07
Rotate Register A left a third time: the drive number times 8, in bits 3-4.
524A
OR C7H F6 C7
OR Register A with C7H: the second byte of SET n,A (CBH C7H plus 8 times n), with n the drive number.
524C
LD (5251H),A 32 51 52
Store Register A into 5251H, the second byte of the SET instruction at 5250H.
524F
XOR A AF
Set Register A to ZERO with XOR A, the value the SET at 5250H works on.
5250
SET 0,A CB C7
SET bit n of Register A, with n the drive written into 5251H by 524CH (SET 0,A in the file): Register A = the drive's select bit, 01H, 02H, 04H or 08H.
5252
LD (5768H),A 32 68 57
Store Register A (the select bit) into 5768H, the operand of LD A,nn at 5767H, the drive select routine.
5255
GOSUB to 5767H to write the select bit to the drive select latch at 37E1H: the drive is selected and its motor starts.
5258
GOSUB to 5754H to select the drive again, send RESTORE and wait until it is done: the head goes to track 0.
525B
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, which gives the ROM's delay its longest time.
525E
GOSUB to ROM routine at 0060H to wait Register Pair BC (0000H) delay units while the motor comes up to speed.
5261
LD A,(37ECH) 3A EC 37
Wait While Busy
Fetch the controller's status from 37ECH into Register A. 5266H loops back here.
5264
BIT 0,A CB 47
Test bit 0 of Register A (the status), BUSY: set while RESTORE is still running.
5266
If the NZ FLAG is set (busy), LOOP BACK to 5261H.
5268
LD HL,586BH 21 6B 58
Point Register Pair HL to 586BH, the message DRIVE NOT READY!.
526B
BIT 7,A CB 7F
Test bit 7 of Register A (the status), NOT READY.
526D
If the NZ FLAG is set (not ready), JUMP to 56ADH to show the message at Register Pair HL, wait for ENTER and halt.
5270
LD HL,5896H 21 96 58
Point Register Pair HL to 5896H, the message DRIVE NOT IN SYSTEM!.
5273
BIT 2,A CB 57
Test bit 2 of Register A (the status), TRACK 0: a drive that is there has its head on track 0 after RESTORE.
5275
If the Z FLAG is set (not at track 0, no such drive), JUMP to 56ADH to show the message at Register Pair HL and halt.
5278
LD HL,582BH 21 2B 58
Ask for the Diskette Name
Point Register Pair HL to 582BH, the prompt DISKETTE NAME ?. 5293H jumps here.
527B
GOSUB to 429AH to display the prompt at Register Pair HL; it ends with 03H.
527E
LD HL,5778H 21 78 57
Point Register Pair HL to 5778H, eight spaces.
5281
LD DE,5CD0H 11 D0 5C
Point Register Pair DE to 5CD0H, bytes D0H-D7H of the allocation table being built at 5C00H, the diskette name.
5284
LD BC,0008H 01 08 00
Load Register Pair BC with 0008H, the eight characters of the name.
5287
LDIR ED B0
Clear the name: LDIR moves 8 spaces from (HL) (Register Pair HL = 5778H) to (DE) (Register Pair DE = 5CD0H), counting Register Pair BC down.
5289
LD HL,5D00H 21 00 5D
Point Register Pair HL to 5D00H, the input buffer.
528C
LD B,08H 06 08
Load Register B with 08H: up to eight characters may be typed.
528E
GOSUB to ROM routine at 0040H to read a line of at most Register B characters into the buffer at Register Pair HL; Register B returns the number typed and Register Pair HL = 5D00H.
5291
LD A,B 78
Copy the number of characters typed from Register B into Register A.
5292
OR A B7
OR Register A with itself: the Z FLAG is set when nothing was typed.
5293
If the Z FLAG is set (no name), JUMP to 5278H to ask again.
5295
LD C,B 48
Copy the number typed from Register B into Register C.
5296
LD B,00H 06 00
Load Register B with 00H: Register Pair BC = the number of characters typed.
5298
LD DE,5CD0H 11 D0 5C
Point Register Pair DE to 5CD0H, the name field of the table.
529B
LDIR ED B0
Copy the name: LDIR moves Register Pair BC bytes from (HL) (Register Pair HL = 5D00H) to (DE) (Register Pair DE = 5CD0H); the rest of the field stays spaces.
529D
LD HL,583CH 21 3C 58
Ask for the Creation Date
Point Register Pair HL to 583CH, the prompt CREATION DATE (MM/DD/YY) ?. 52AEH, 52B6H and 52BEH jump here.
52A0
GOSUB to 429AH to display the prompt at Register Pair HL; it ends with 03H.
52A3
LD HL,5D00H 21 00 5D
Point Register Pair HL to 5D00H, the input buffer.
52A6
LD B,08H 06 08
Load Register B with 08H: up to eight characters may be typed.
52A8
GOSUB to ROM routine at 0040H to read a line of at most Register B characters into the buffer at Register Pair HL; Register B returns the number typed.
52AB
LD A,B 78
Copy the number of characters typed from Register B into Register A.
52AC
CP 08H FE 08
Compare Register A against 08H: the date must have all eight characters.
52AE
If the NZ FLAG is set (fewer typed), JUMP to 529DH to ask again.
52B1
LD A,(5D02H) 3A 02 5D
Fetch the third character of the date from 5D02H into Register A.
52B4
CP 2FH FE 2F
Compare Register A against 2FH, the slash after MM.
52B6
If the NZ FLAG is set, JUMP to 529DH to ask again.
52B9
LD A,(5D05H) 3A 05 5D
Fetch the sixth character of the date from 5D05H into Register A.
52BC
CP 2FH FE 2F
Compare Register A against 2FH, the slash after DD; the digits themselves are not checked.
52BE
If the NZ FLAG is set, JUMP to 529DH to ask again.
52C1
LD C,B 48
Copy the number typed (8) from Register B into Register C.
52C2
LD B,00H 06 00
Load Register B with 00H: Register Pair BC = 0008H.
52C4
LD DE,5CD8H 11 D8 5C
Point Register Pair DE to 5CD8H, bytes D8H-DFH of the table, the date.
52C7
LD HL,5D00H 21 00 5D
Point Register Pair HL to 5D00H, the date typed.
52CA
LDIR ED B0
Copy the date: LDIR moves 8 bytes from (HL) (Register Pair HL = 5D00H) to (DE) (Register Pair DE = 5CD8H), counting Register Pair BC down; Register Pair DE ends at 5CE0H.
52CC
LD HL,5858H 21 58 58
Ask for the Master Password
Point Register Pair HL to 5858H, the prompt MASTER PASSWORD ?. 52DCH jumps here.
52CF
GOSUB to 429AH to display the prompt at Register Pair HL; it ends with 03H.
52D2
LD HL,5D00H 21 00 5D
Point Register Pair HL to 5D00H, the input buffer.
52D5
LD B,08H 06 08
Load Register B with 08H: up to eight characters may be typed.
52D7
GOSUB to ROM routine at 0040H to read a line of at most Register B characters into the buffer at Register Pair HL; Register B returns the number typed, Register Pair HL = 5D00H.
52DA
LD A,B 78
Copy the number of characters typed from Register B into Register A.
52DB
OR A B7
OR Register A with itself: the Z FLAG is set when nothing was typed.
52DC
If the Z FLAG is set (no password), JUMP to 52CCH to ask again.
52DE
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = 5D00H, the password, and Register Pair HL = 5CE0H (left by the LDIR at 52CAH).
52DF
ADD A,E 83
ADD Register E (00H, the low byte of 5D00H) to Register A (the number typed).
52E0
LD L,A 6F
Copy Register A (the low byte of 5D00H plus the count) into Register L.
52E1
LD A,D 7A
Copy Register D (5DH, the high byte of the buffer) into Register A.
52E2
ADC A,00H CE 00
ADD WITH CARRY 00H to Register A: the carry of the low byte addition, if any.
52E4
LD H,A 67
Copy Register A into Register H: Register Pair HL = 5D00H plus the number typed, the first byte after the password.
52E5
LD A,08H 3E 08
Load Register A with 08H, the length of a password.
52E7
SUB B 90
SUBtract Register B (the number typed) from Register A: the spaces needed.
52E8
LD B,A 47
Copy the spaces needed from Register A into Register B; 00H when eight characters were typed.
52E9
LD (HL),20H 36 20
Pad Loop
Store 20H, a space, at (HL) (Register Pair HL = the buffer pointer). 52ECH loops back here.
52EB
INC HL 23
INCrement Register Pair HL (the buffer pointer) by 1.
52EC
Pad Loop End
DECrement Register B and LOOP BACK to 52E9H until it reaches 00H; from 00H (eight characters typed) it runs 256 times and writes spaces up to 5E07H.
52EE
GOSUB to 52F6H to hash the eight bytes at Register Pair DE (5D00H) into Register Pair HL.
52F1
LD (5CCEH),HL 22 CE 5C
Store Register Pair HL (the hash) into 5CCEH, bytes CEH-CFH of the table, the master password hash.
52F4
JUMP to 5322H to build the lockout table and ask about tracks to lock out.
52F6H - Hash a Password
Register Pair DE = the eight-byte password. Combines the bytes, from the last to the first, into a sixteen-bit value in Register Pair HL. It is the same calculation as SYS2/SYS's 50D1H, so the master password typed here can be checked by PROT.
52F6
LD HL,FFFFH 21 FF FF
Load Register Pair HL with FFFFH, the starting hash. 52EEH calls here.
52F9
LD B,08H 06 08
Load Register B with 08H, the eight password bytes.
52FB
LD A,E 7B
Copy Register E (the password pointer's low byte) into Register A.
52FC
ADD A,07H C6 07
ADD 07H to Register A: the low byte of the address of the last byte.
52FE
LD E,A 5F
Copy Register A (the low byte of the address of the last byte) into Register E.
52FF
If the NO CARRY FLAG is set (no overflow), JUMP to 5302H without changing Register D.
5301
INC D 14
INCrement Register D (the password pointer's high byte) by 1 for the carry.
5302
LD A,(DE) 1A
Hash Loop
Fetch the next password byte from (DE) (Register Pair DE = the password pointer) into Register A. 531FH loops back here.
5303
PUSH DE D5
Save Register Pair DE (the password pointer) onto the stack.
5304
LD D,A 57
Copy the password byte from Register A into Register D.
5305
LD E,H 5C
Copy Register H (the hash's high byte) into Register E.
5306
LD A,L 7D
Copy Register L (the hash's low byte) into Register A.
5307
AND 07H E6 07
AND Register A with 07H, keeping the low three bits of the hash.
5309
RRCA 0F
Rotate Register A right, circularly, moving the three bits toward the top.
530A
RRCA 0F
Rotate Register A (the three low bits of the hash) right again, circularly.
530B
RRCA 0F
Rotate Register A right a third time: the three bits are now bits 5-7.
530C
XOR L AD
XOR Register A with Register L (the hash's low byte).
530D
LD L,A 6F
Copy Register A (the mixed value) into Register L.
530E
LD H,00H 26 00
Load Register H with 00H, the high byte before the shifts.
5310
ADD HL,HL 29
ADD Register Pair HL to itself: the value times two.
5311
ADD HL,HL 29
ADD Register Pair HL to itself: the value times four.
5312
ADD HL,HL 29
ADD Register Pair HL to itself: the value times eight.
5313
ADD HL,HL 29
ADD Register Pair HL to itself: the value times sixteen.
5314
XOR H AC
XOR Register A (the value before the shifts) with Register H.
5315
XOR D AA
XOR Register A with Register D (the password byte).
5316
LD D,A 57
Copy Register A into Register D, the new high byte.
5317
LD A,L 7D
Copy Register L (the shifted low byte) into Register A.
5318
ADD HL,HL 29
ADD Register Pair HL to itself once more: the value times thirty-two.
5319
XOR H AC
XOR Register A with Register H (the high byte of the shifted value).
531A
XOR E AB
XOR Register A with Register E (the old high byte of the hash).
531B
LD E,A 5F
Copy Register A into Register E, the new low byte.
531C
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the new hash.
531D
POP DE D1
Restore Register Pair DE (the password pointer) from the stack.
531E
DEC DE 1B
DECrement Register Pair DE by 1, to the byte before.
531F
Hash Loop End
DECrement Register B and LOOP BACK to 5302H until all eight bytes are mixed in.
5321
RET C9
RETURN to 52F1H with Register Pair HL = the hash.
5322H - The Lockout Table and the Tracks to Lock Out
Fills 5C00H-5C22H, one byte per track, with FCH (both granules usable) and 5C23H-5CCAH with FFH. The table at 5C00H serves as the lockout table during the format and becomes the allocation table later (55C4H copies it to 5C60H, its lockout part). Then asks whether tracks are to be locked out; a list such as 5,9-11 sets FFH for those tracks. Track 0 cannot be locked out and the highest is 34.
5322
LD HL,5C00H 21 00 5C
Point Register Pair HL to 5C00H, the table, byte 0 for track 0. 52F4H jumps here.
5325
XOR A AF
Set Register A to ZERO with XOR A, the track count.
5326
LD (HL),FCH 36 FC
Track Loop
Store FCH at (HL) (Register Pair HL = the table pointer): bits 0 and 1 clear, both granules usable. 532CH loops back here.
5328
INC HL 23
INCrement Register Pair HL (the table pointer) by 1.
5329
INC A 3C
INCrement Register A (the track count) by 1, to the next track.
532A
CP 23H FE 23
Compare Register A against 23H, the 35 tracks.
532C
Track Loop End
If the NZ FLAG is set, LOOP BACK to 5326H for the next track.
532E
CP CBH FE CB
Fill Loop
Compare Register A (the byte count) against CBH. 5336H loops back here.
5330
If the Z FLAG is set (5CCBH reached), JUMP to 533EH to ask about locking out tracks.
5332
LD (HL),FFH 36 FF
Store FFH at (HL) (Register Pair HL = the table pointer).
5334
INC HL 23
INCrement Register Pair HL (the table pointer) by 1.
5335
INC A 3C
INCrement Register A (the byte count) by 1, to the next byte of the table.
5336
Fill Loop End
LOOP BACK to 532EH for the next byte.
5338
LD HL,5963H 21 63 59
Invalid Track
Point Register Pair HL to 5963H, the message INVALID TRACK NUMBER!. 536DH, 5371H, 5376H and 5379H jump here.
533B
GOSUB to 429AH to display the message at Register Pair HL, and go on to ask again.
533E
LD HL,5926H 21 26 59
Point Register Pair HL to 5926H, the prompt DO YOU WANT TO LOCK OUT ANY TRACKS ?. 5330H jumps here.
5341
GOSUB to 429AH to display the prompt at Register Pair HL; it ends with 03H.
5344
LD HL,5D00H 21 00 5D
Point Register Pair HL to 5D00H, the input buffer.
5347
LD B,03H 06 03
Load Register B with 03H: up to three characters may be typed.
5349
GOSUB to ROM routine at 0040H to read a line of at most Register B characters into the buffer at Register Pair HL.
534C
LD A,(HL) 7E
Fetch the first character typed from (HL) (Register Pair HL = 5D00H) into Register A.
534D
CP 59H FE 59
Compare Register A against 59H, the letter Y; only the first character counts.
534F
If the NZ FLAG is set (not Y), JUMP to 539EH to check the drive and format.
5351
LD HL,594CH 21 4C 59
Point Register Pair HL to 594CH, the prompt WHICH TRACKS (1-34) ?.
5354
GOSUB to 429AH to display the prompt at Register Pair HL; it ends with 03H.
5357
LD HL,5D00H 21 00 5D
Point Register Pair HL to 5D00H, the input buffer.
535A
LD B,1EH 06 1E
Load Register B with 1EH: up to thirty characters may be typed.
535C
GOSUB to ROM routine at 0040H to read a line of at most Register B characters into the buffer at Register Pair HL; Register Pair HL = 5D00H.
535F
Number Loop
GOSUB to 5733H to read a decimal number at Register Pair HL into Register E; Register A returns the character after it and Register Pair HL is past that character. 538AH loops back here.
5362
LD D,E 53
Copy the number from Register E into Register D, the first track of the range.
5363
CP 2DH FE 2D
Compare Register A (the character after the number) against 2DH, the minus sign of a range.
5365
If the NZ FLAG is set (a single track), JUMP to 536AH with Register E = Register D.
5367
GOSUB to 5733H to read the last track of the range into Register E; Register A returns the character after it.
536A
EX AF,AF' 08
Exchange Register Pair AF with the alternate Register Pair AF', keeping the character after the number for 5387H.
536B
LD A,D 7A
Copy the first track from Register D into Register A.
536C
OR A B7
OR Register A with itself: the Z FLAG is set for track 0 (or no number at all).
536D
If the Z FLAG is set, JUMP to 5338H: INVALID TRACK NUMBER!.
536F
CP 23H FE 23
Compare Register A (the first track) against 23H: the NO CARRY FLAG is set for 35 or more.
5371
If the NO CARRY FLAG is set, JUMP to 5338H: INVALID TRACK NUMBER!.
5373
LD A,E 7B
Copy the last track from Register E into Register A.
5374
CP 23H FE 23
Compare Register A (the last track) against 23H: the NO CARRY FLAG is set for 35 or more.
5376
If the NO CARRY FLAG is set, JUMP to 5338H: INVALID TRACK NUMBER!.
5378
SUB D 92
SUBtract Register D (the first track) from Register A (the last track): the CARRY FLAG is set when the range runs backwards.
5379
If the CARRY FLAG is set, JUMP to 5338H: INVALID TRACK NUMBER!.
537B
INC A 3C
INCrement Register A by 1: the number of tracks in the range.
537C
LD B,A 47
Copy the count from Register A into Register B.
537D
PUSH HL E5
Save Register Pair HL (the input pointer) onto the stack.
537E
LD L,D 6A
Copy the first track from Register D into Register L.
537F
LD H,5CH 26 5C
Load Register H with 5CH: Register Pair HL = 5C00H plus the first track.
5381
LD (HL),FFH 36 FF
Lock Loop
Store FFH at (HL) (Register Pair HL = 5C00H plus the track): the track is locked out. 5384H loops back here.
5383
INC HL 23
INCrement Register Pair HL by 1, to the next track's byte.
5384
Lock Loop End
DECrement Register B and LOOP BACK to 5381H until the range is done.
5386
POP HL E1
Restore Register Pair HL (the input pointer) from the stack.
5387
EX AF,AF' 08
Exchange Register Pair AF with the alternate Register Pair AF' again: Register A = the character after the number.
5388
CP 0DH FE 0D
Compare Register A against 0DH, the ENTER at the end of the list.
538A
Number Loop End
If the NZ FLAG is set (more of the list), LOOP BACK to 535FH; any character other than a digit, a minus sign or ENTER separates the numbers.
538C
LD HL,5979H 21 79 59
Point Register Pair HL to 5979H, the prompt FORMAT THE LOCKED OUT TRACKS?.
538F
GOSUB to 429AH to display the prompt at Register Pair HL; it ends with 03H.
5392
LD HL,5D00H 21 00 5D
Point Register Pair HL to 5D00H, the input buffer.
5395
LD B,03H 06 03
Load Register B with 03H: up to three characters may be typed.
5397
GOSUB to ROM routine at 0040H to read a line of at most Register B characters into the buffer at Register Pair HL.
539A
LD A,(HL) 7E
Fetch the first character typed from (HL) (Register Pair HL = 5D00H) into Register A.
539B
LD (548DH),A 32 8D 54
Store Register A into 548DH, the operand of LD A,nn at 548CH, the code that would act on the answer (see 5483H).
539EH - Check the Drive and the Diskette
Selects the drive and waits, then stops with a message when the drive is not ready, has no head on track 0, or holds a write protected diskette. The index pulses are timed as BACKUP/CMD does: a pulse that does not end means no diskette, a pulse that does not come means an open door, pulses less than 1535H loop turns apart mean a hard-sectored diskette. When track 0, sector 0 can be read the diskette holds data, and 5B9CH asks whether to go on. Then the directory track is chosen.
539E
GOSUB to 5767H to select the drive: its select bit goes to the latch at 37E1H. 534FH jumps here.
53A1
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, which gives the ROM's delay its longest time.
53A4
GOSUB to ROM routine at 0060H to wait Register Pair BC (0000H) delay units for the motor.
53A7
LD A,(37ECH) 3A EC 37
Fetch the controller's status from 37ECH into Register A: bit 7 NOT READY, bit 6 WRITE PROTECT, bit 2 TRACK 0, bit 1 the index pulse.
53AA
LD HL,586BH 21 6B 58
Point Register Pair HL to 586BH, the message DRIVE NOT READY!.
53AD
BIT 7,A CB 7F
Test bit 7 of Register A (the status), NOT READY.
53AF
If the NZ FLAG is set (not ready), JUMP to 56ADH to show the message at Register Pair HL, wait for ENTER and halt.
53B2
LD HL,5896H 21 96 58
Point Register Pair HL to 5896H, the message DRIVE NOT IN SYSTEM!.
53B5
BIT 2,A CB 57
Test bit 2 of Register A (the status), TRACK 0.
53B7
If the Z FLAG is set (not at track 0), JUMP to 56ADH to show the message at Register Pair HL and halt.
53BA
LD HL,587CH 21 7C 58
Point Register Pair HL to 587CH, the message WRITE PROTECTED DISKETTE!.
53BD
BIT 6,A CB 77
Test bit 6 of Register A (the status), WRITE PROTECT.
53BF
If the NZ FLAG is set (protected), JUMP to 56ADH to show the message at Register Pair HL and halt.
53C2
LD BC,00CDH 01 CD 00
Load Register Pair BC with 00CDH, the loop turns allowed for the index pulse to end.
53C5
LD HL,58ABH 21 AB 58
Point Register Pair HL to 58ABH, the message NO DISKETTE IN DRIVE!.
53C8
DEC BC 0B
Wait for the Pulse to End
DECrement Register Pair BC (the turns left) by 1. 53D3H loops back here.
53C9
LD A,B 78
Copy Register B (the high byte of the turns left) into Register A.
53CA
OR C B1
OR Register A with Register C: the Z FLAG is set when no turns are left.
53CB
If the Z FLAG is set (out of time), JUMP to 56ADH to show the message at Register Pair HL and halt.
53CE
LD A,(37ECH) 3A EC 37
Fetch the controller's status from 37ECH into Register A.
53D1
AND 02H E6 02
AND Register A with 02H, keeping bit 1, the index pulse.
53D3
If the NZ FLAG is set (the pulse is still there), LOOP BACK to 53C8H.
53D5
LD BC,199DH 01 9D 19
Load Register Pair BC with 199DH, the loop turns allowed for the next pulse to come.
53D8
LD HL,58C1H 21 C1 58
Point Register Pair HL to 58C1H, the message DOOR NOT CLOSED ON DRIVE!.
53DB
DEC BC 0B
Wait for the Next Pulse
DECrement Register Pair BC (the turns left) by 1. 53E6H loops back here.
53DC
LD A,B 78
Copy Register B (the high byte of the turns left) into Register A.
53DD
OR C B1
OR Register A with Register C: the Z FLAG is set when no turns are left.
53DE
If the Z FLAG is set (no pulse came), JUMP to 56ADH to show the message at Register Pair HL and halt.
53E1
LD A,(37ECH) 3A EC 37
Fetch the controller's status from 37ECH into Register A.
53E4
AND 02H E6 02
AND Register A with 02H, keeping bit 1, the index pulse.
53E6
If the Z FLAG is set (no pulse yet), LOOP BACK to 53DBH.
53E8
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the count of loop turns for one revolution.
53EB
LD BC,00BAH 01 BA 00
Load Register Pair BC with 00BAH, the turns allowed for this pulse to end.
53EE
LD HL,58ABH 21 AB 58
Point Register Pair HL to 58ABH, the message NO DISKETTE IN DRIVE!.
53F1
DEC BC 0B
Count the Pulse
DECrement Register Pair BC (the turns left) by 1. 53FDH loops back here.
53F2
LD A,B 78
Copy Register B (the high byte of the turns left) into Register A.
53F3
OR C B1
OR Register A with Register C: the Z FLAG is set when no turns are left.
53F4
If the Z FLAG is set (the pulse did not end), JUMP to 56ADH to show the message at Register Pair HL and halt.
53F7
INC DE 13
INCrement Register Pair DE (the turns counted) by 1.
53F8
LD A,(37ECH) 3A EC 37
Fetch the controller's status from 37ECH into Register A.
53FB
AND 02H E6 02
AND Register A with 02H, keeping bit 1, the index pulse.
53FD
If the NZ FLAG is set (still in the pulse), LOOP BACK to 53F1H.
53FF
LD BC,1720H 01 20 17
Load Register Pair BC with 1720H, the turns allowed for the gap before the next pulse.
5402
LD HL,58C1H 21 C1 58
Point Register Pair HL to 58C1H, the message DOOR NOT CLOSED ON DRIVE!.
5405
DEC BC 0B
Count the Gap
DECrement Register Pair BC (the turns left) by 1. 5411H loops back here.
5406
LD A,B 78
Copy Register B (the high byte of the turns left) into Register A.
5407
OR C B1
OR Register A with Register C: the Z FLAG is set when no turns are left.
5408
If the Z FLAG is set (no next pulse), JUMP to 56ADH to show the message at Register Pair HL and halt.
540B
INC DE 13
INCrement Register Pair DE (the turns counted) by 1.
540C
LD A,(37ECH) 3A EC 37
Fetch the controller's status from 37ECH into Register A.
540F
AND 02H E6 02
AND Register A with 02H, keeping bit 1, the index pulse.
5411
If the Z FLAG is set (still in the gap), LOOP BACK to 5405H.
5413
LD HL,EACBH 21 CB EA
Load Register Pair HL with EACBH, 10000H minus 1535H.
5416
ADD HL,DE 19
ADD Register Pair DE (the turns of one revolution) to Register Pair HL: the CARRY FLAG is set when the count is 1535H or more.
5417
LD HL,58DBH 21 DB 58
Point Register Pair HL to 58DBH, the message DISKETTE UNUSABLE! HARD-SECTORED!; LD does not change the flags.
541A
If the NO CARRY FLAG is set (the pulses come too often), JUMP to 56ADH to show the message at Register Pair HL and halt.
541D
GOSUB to 5767H to select the drive again before reading track 0.
5420
LD BC,5D00H 01 00 5D
Point Register Pair BC to 5D00H, the sector buffer.
5423
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H: Register D = track 0, Register E = sector 0.
5426
GOSUB to 42AAH, the boot sector's read routine, to read track Register D, sector Register E into (BC); the Z FLAG when it can be read.
5429
If the Z FLAG is set (the diskette holds a readable track 0), GOSUB to 5B9CH to ask DISKETTE CONTAINS DATA, FORMAT OR NOT ?; it comes back only for Y.
542C
NOP 00
No Operation: the first of three NOP bytes after the call.
542D
NOP 00
No Operation: the second of three NOP bytes after the call.
542E
NOP 00
No Operation: the third of three NOP bytes after the call.
542FH - Choose the Directory Track
Tries track 17 (11H) first, then 18, 16, 19, 15 and so on outward, taking the first track whose byte in the lockout table is FCH. Tracks 1-34 are all tried; when none is free, CAN'T FORMAT, NO TRACKS AVAILABLE FOR DIRECTORY!. The track chosen goes into byte 2 of the boot sector at 4202H, where SYS0/SYS's 4B35H and the boot code find it.
542F
LD H,5CH 26 5C
Load Register H with 5CH, the page of the lockout table.
5431
LD L,11H 2E 11
Load Register L with 11H: Register Pair HL = 5C11H, the byte of track 17.
5433
LD C,00H 0E 00
Load Register C with 00H, the step count of the search around track 17.
5435
LD A,(HL) 7E
Try a Track
Fetch the track's lockout byte from (HL) (Register Pair HL = 5C00H plus the track) into Register A. 5444H and 544AH loop back here.
5436
CP FCH FE FC
Compare Register A against FCH, a usable track.
5438
If the Z FLAG is set (usable), JUMP to 5452H with Register L = the track.
543A
INC C 0C
INCrement Register C (the step) by 1: odd steps go up, even steps go down.
543B
LD A,C 79
Copy the step from Register C into Register A.
543C
RRCA 0F
Rotate Register A right, circularly: bit 0 goes into the CARRY FLAG, set for an odd step.
543D
LD A,L 7D
Copy the track from Register L into Register A; LD does not change the CARRY FLAG.
543E
If the NO CARRY FLAG is set (an even step), JUMP to 5448H to step down.
5440
ADD A,C 81
ADD Register C (the step) to Register A (the track): the next track above.
5441
LD L,A 6F
Copy Register A into Register L: Register Pair HL = the new track's byte.
5442
CP 23H FE 23
Compare Register A against 23H: the Z FLAG is set past track 34.
5444
If the NZ FLAG is set, LOOP BACK to 5435H to try it.
5446
JUMP to 544CH: the search passed track 34 and no track is free.
5448
SUB C 91
SUBtract Register C (the step) from Register A (the track): the next track below. 543EH jumps here.
5449
LD L,A 6F
Copy Register A into Register L; the Z FLAG of the subtraction is set at track 0.
544A
If the NZ FLAG is set (not track 0), LOOP BACK to 5435H to try it.
544C
LD HL,5998H 21 98 59
Point Register Pair HL to 5998H, the message CAN'T FORMAT, NO TRACKS AVAILABLE FOR DIRECTORY!. 5446H comes here.
544F
JUMP to 56ADH to show the message at Register Pair HL, wait for ENTER and halt.
5452
LD A,L 7D
Copy the directory track from Register L into Register A. 5438H jumps here.
5453
LD (4202H),A 32 02 42
Store Register A (the directory track) into 4202H, byte 2 of the boot sector at 4200H.
5456
GOSUB to 5726H to turn Register A into two digits: Register C = the tens, Register B = the units.
5459
LD (59EBH),BC ED 43 EB 59
Store Register Pair BC (the two digits, tens first) into 59EBH, the track number in DIRECTORY WILL BE PLACED ON TRACK 00.
545D
LD HL,59C9H 21 C9 59
Point Register Pair HL to 59C9H, the message DIRECTORY WILL BE PLACED ON TRACK tt.
5460
GOSUB to 429AH to display the message at Register Pair HL.
5463
XOR A AF
Set Register A to ZERO with XOR A, track 0, the first track to format.
5464
LD (54B1H),A 32 B1 54
Store Register A (00H) into 54B1H, the operand of LD C,nn at 54B0H: the track being formatted.
5467H - Format Each Track
For each track 0-34: shows FORMATTING TRACK tt, picks the data mark (FAH on the directory track, FBH elsewhere), builds the track image at 5F00H (gaps, ten ID fields with the sectors in the order of the table at 576DH, ten data fields of 256 E5H bytes) and writes it with WRITE TRACK (551FH), then steps the head in. 5483H was meant to treat a locked out track (FFH in its table byte) by the answer to FORMAT THE LOCKED OUT TRACKS?: skip it for an answer other than Y, else give it the F9H data mark. It reads the byte of the directory track instead of the track being formatted (Register A still holds the directory track), which is always FCH, so every track is formatted with FBH and the answer has no effect.
5467
LD A,(54B1H) 3A B1 54
Track Loop
Fetch the track being formatted from 54B1H into Register A. 551CH jumps here.
546A
GOSUB to 5726H to turn Register A into two digits: Register C = the tens, Register B = the units.
546D
LD (5A26H),BC ED 43 26 5A
Store Register Pair BC (the two digits) into 5A26H, the track number in FORMATTING TRACK 00.
5471
LD HL,5A14H 21 14 5A
Point Register Pair HL to 5A14H, the text FORMATTING TRACK tt.
5474
GOSUB to 429AH to display the text at Register Pair HL; it starts with 1DH (cursor to the start of the line) and ends with 03H.
5477
LD A,(54B1H) 3A B1 54
Fetch the track being formatted from 54B1H into Register A.
547A
LD B,A 47
Copy the track from Register A into Register B.
547B
LD A,(4202H) 3A 02 42
Fetch the directory track from 4202H into Register A.
547E
CP B B8
Compare Register A (the directory track) against Register B (the track being formatted).
547F
LD B,FAH 06 FA
Load Register B with FAH, the data mark of directory sectors; LD does not change the flags.
5481
If the Z FLAG is set (the directory track), JUMP to 5495H with FAH.
5483
LD L,A 6F
Copy Register A into Register L: Register A still holds the directory track, not the track being formatted.
5484
LD H,5CH 26 5C
Load Register H with 5CH: Register Pair HL = 5C00H plus the directory track, its lockout byte.
5486
LD A,(HL) 7E
Fetch that lockout byte from (HL) (Register Pair HL = 5C00H plus the directory track) into Register A; it is FCH, the directory track having been chosen for it at 5438H.
5487
INC A 3C
INCrement Register A by 1: the Z FLAG would be set for FFH, a locked out track.
5488
LD B,FBH 06 FB
Load Register B with FBH, the normal data mark; LD does not change the flags.
548A
If the NZ FLAG is set (always, see 5483H), JUMP to 5495H with FBH.
548C
LD A,00H 3E 00
Load Register A with the answer to FORMAT THE LOCKED OUT TRACKS?, the operand at 548DH stored by 539BH (00H in the file). Never reached.
548E
CP 59H FE 59
Compare Register A against 59H, the letter Y.
5490
If the NZ FLAG is set (not Y), JUMP to 5502H to leave the locked out track unformatted.
5493
LD B,F9H 06 F9
Load Register B with F9H, the data mark meant for a locked out track that is formatted.
5495
LD A,B 78
Copy the data mark from Register B into Register A. 5481H and 548AH jump here.
5496
LD (54DBH),A 32 DB 54
Store Register A (the data mark) into 54DBH, the operand of LD C,nn at 54DAH.
5499
LD HL,5F00H 21 00 5F
Point Register Pair HL to 5F00H, the buffer for the track image.
549C
LD DE,576DH 11 6D 57
Point Register Pair DE to 576DH, the sector order table 0, 5, 1, 6, 2, 7, 3, 8, 4, 9, ending with FFH.
549F
LD B,0EH 06 0E
Load Register B with 0EH, fourteen bytes of gap at the start of the track.
54A1
GOSUB to 5749H to store Register B bytes of FFH at (HL), moving Register Pair HL on.
54A4
LD B,06H 06 06
Sector Loop
Load Register B with 06H, six bytes of sync before the ID mark. 54F8H loops back here.
54A6
LD C,00H 0E 00
Load Register C with 00H, the byte of the sync field.
54A8
GOSUB to 574BH to store Register B (6) bytes of Register C (00H) at (HL).
54AB
LD C,FEH 0E FE
Load Register C with FEH, the ID address mark.
54AD
GOSUB to 5751H to store Register C (FEH) at (HL) and move Register Pair HL on.
54B0
LD C,00H 0E 00
Load Register C with the track being formatted, the operand at 54B1H stored by 5464H and 5506H.
54B2
GOSUB to 5751H to store Register C (the track number) at (HL), the first byte of the ID.
54B5
LD C,00H 0E 00
Load Register C with 00H, the second byte of the ID.
54B7
GOSUB to 5751H to store Register C (00H) at (HL).
54BA
LD A,(DE) 1A
Fetch the sector number from (DE) (Register Pair DE = the sector order table) into Register A.
54BB
LD C,A 4F
Copy the sector number from Register A into Register C.
54BC
GOSUB to 5751H to store Register C (the sector number) at (HL).
54BF
LD C,01H 0E 01
Load Register C with 01H, the length code of a 256-byte sector.
54C1
GOSUB to 5751H to store Register C (01H) at (HL), the last byte of the ID.
54C4
LD C,F7H 0E F7
Load Register C with F7H, which makes WRITE TRACK write the two CRC bytes of the ID.
54C6
GOSUB to 5751H to store Register C (F7H) at (HL).
54C9
LD C,FFH 0E FF
Load Register C with FFH, one byte of the gap after the ID field.
54CB
GOSUB to 5751H to store Register C (FFH) at (HL).
54CE
LD B,0BH 06 0B
Load Register B with 0BH, eleven more bytes of gap.
54D0
GOSUB to 5749H to store Register B bytes of FFH at (HL).
54D3
LD B,06H 06 06
Load Register B with 06H, six bytes of sync before the data mark.
54D5
LD C,00H 0E 00
Load Register C with 00H, the byte of the sync field.
54D7
GOSUB to 574BH to store Register B (6) bytes of Register C (00H) at (HL).
54DA
LD C,00H 0E 00
Load Register C with the data mark stored at 54DBH by 5496H (FAH or FBH; 00H in the file).
54DC
GOSUB to 5751H to store Register C (the data mark) at (HL).
54DF
LD B,00H 06 00
Load Register B with 00H, which makes the loop of 574BH run 256 times.
54E1
LD C,E5H 0E E5
Load Register C with E5H, the byte that fills a new sector.
54E3
GOSUB to 574BH to store 256 bytes of Register C (E5H) at (HL), the sector's data.
54E6
LD C,F7H 0E F7
Load Register C with F7H, which makes WRITE TRACK write the two CRC bytes of the data.
54E8
GOSUB to 5751H to store Register C (F7H) at (HL).
54EB
LD C,FFH 0E FF
Load Register C with FFH, one byte of the gap after the data field.
54ED
GOSUB to 5751H to store Register C (FFH) at (HL).
54F0
LD B,0BH 06 0B
Load Register B with 0BH, eleven more bytes of gap.
54F2
GOSUB to 5749H to store Register B bytes of FFH at (HL).
54F5
INC DE 13
INCrement Register Pair DE (the sector order pointer) by 1.
54F6
LD A,(DE) 1A
Fetch the next sector number from (DE) (Register Pair DE = the sector order pointer) into Register A.
54F7
INC A 3C
INCrement Register A by 1: the Z FLAG is set for FFH, the end of the table.
54F8
Sector Loop End
If the NZ FLAG is set (another sector), LOOP BACK to 54A4H.
54FA
LD B,5BH 06 5B
Load Register B with 5BH, 91 bytes of gap at the end of the track.
54FC
GOSUB to 5749H to store Register B bytes of FFH at (HL).
54FF
GOSUB to 551FH to write the image to the track with WRITE TRACK and check how many bytes went.
5502
LD A,(54B1H) 3A B1 54
Fetch the track just formatted from 54B1H into Register A. 5490H jumps here.
5505
INC A 3C
INCrement Register A (the track just formatted) by 1, to the next track.
5506
LD (54B1H),A 32 B1 54
Store Register A (the next track) into 54B1H, the operand of LD C,nn at 54B0H.
5509
CP 23H FE 23
Compare Register A against 23H: the Z FLAG is set after track 34.
550B
If the Z FLAG is set (all 35 tracks formatted), JUMP to 556BH to verify them.
550D
LD A,5BH 3E 5B
Load Register
A with
5BH, STEP IN with the track register updated.
| 1771 FDC Command: 5BH (01011011) | | Function Description |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | | Command=Step In (bits 7-5 = 010) u = 1: update the track register h = 1: head load and settle delay V = 0: no verify r1 r0 = 11: 15 ms stepping rate |
550F
LD (37ECH),A 32 EC 37
Store Register A (5BH) into 37ECH, the controller's command register: the head moves to the next track.
5512
PUSH AF F5
Save Register Pair AF onto the stack, a delay before the status is read.
5513
POP AF F1
Restore Register Pair AF from the stack, part of the delay.
5514
PUSH AF F5
Save Register Pair AF onto the stack again, more delay.
5515
POP AF F1
Restore Register Pair AF from the stack: the controller has had time to set BUSY.
5516
LD A,(37ECH) 3A EC 37
Wait While Busy
Fetch the controller's status from 37ECH into Register A. 551AH loops back here.
5519
RRCA 0F
Rotate Register A right: bit 0, BUSY, goes into the CARRY FLAG.
551A
Wait Loop End
If the CARRY FLAG is set (busy), LOOP BACK to 5516H.
551C
JUMP to 5467H to build and write the image of the next track.
551FH - Write One Track
Calls 5523H, and calls it a second time when it returns the NZ FLAG; 5523H returns only with the Z FLAG (it halts on the errors it finds), so the second call never runs. 5523H selects the drive, sends WRITE TRACK and feeds the image at 5F00H to the data register until the controller is done, then sends FORCE INTERRUPT. Lost data halts with CAN'T FORMAT, DISK TRANSFER RATE TOO FAST!; then the number of bytes taken is checked: fewer than 0BEDH gives CAN'T FORMAT, MOTOR SPEED TOO SLOW! and 0C69H or more gives CAN'T FORMAT, MOTOR SPEED TOO FAST!. The image holds 0C21H bytes.
551F
GOSUB to 5523H to write the track. 54FFH calls here.
5522
RET Z C8
If the Z FLAG is set (always, see above), RETURN to 5502H.
5523
GOSUB to 5767H to select the drive. 551FH calls here, and runs on into here a second time only after an NZ FLAG return.
5526
LD BC,5F00H 01 00 5F
Point Register Pair BC to 5F00H, the track image.
5529
LD HL,37ECH 21 EC 37
Point Register Pair HL to 37ECH, the controller's command and status register.
552C
LD (HL),F4H 36 F4
Store
F4H, WRITE TRACK, at
(HL) (Register Pair HL = 37ECH).
| 1771 FDC Command: F4H (11110100) | | Function Description |
| 1 | 1 | 1 | 1 | 0 | 1 | 0 | 0 | | Command=Write Track (bits 7-4 = 1111) E = 1: head load delay In the data, F7H writes the two CRC bytes and F8H-FEH are written as address marks |
552E
LD DE,37EFH 11 EF 37
Point Register Pair DE to 37EFH, the controller's data register.
5531
PUSH BC C5
Save Register Pair BC onto the stack, a delay before the status is read.
5532
POP BC C1
Restore Register Pair BC from the stack, part of the delay.
5533
PUSH BC C5
Save Register Pair BC onto the stack again, more delay.
5534
POP BC C1
Restore Register Pair BC (5F00H) from the stack.
5535
DI F3
Disable interrupts for the transfer (they are already off since 5200H).
5536
JUMP to 553BH to look at the status for the first data request.
5538
RRCA 0F
Not Asking for Data
Rotate Register A (the status) right: bit 0, BUSY, goes into the CARRY FLAG. 553EH jumps here.
5539
If the NO CARRY FLAG is set (no longer busy, the track is written), JUMP to 5546H.
553B
LD A,(HL) 7E
Transfer Loop
Fetch the controller's status from (HL) (Register Pair HL = 37ECH) into Register A. 5536H and 5543H come here.
553C
BIT 1,A CB 4F
Test bit 1 of Register A (the status), DATA REQUEST.
553E
If the Z FLAG is set (no request), JUMP to 5538H to test BUSY.
5540
LD A,(BC) 0A
Fetch the next byte of the image from (BC) (Register Pair BC = the image pointer) into Register A.
5541
LD (DE),A 12
Store Register A at (DE) (Register Pair DE = 37EFH), the data register.
5542
INC BC 03
INCrement Register Pair BC (the image pointer) by 1.
5543
Transfer Loop End
JUMP to 553BH for the next status.
5546
LD A,(HL) 7E
Fetch the controller's final status from (HL) (Register Pair HL = 37ECH) into Register A. 5539H jumps here.
5547
LD (HL),D0H 36 D0
Store
D0H, FORCE INTERRUPT, at
(HL) (Register Pair HL = 37ECH): the controller's status shows the Type I bits again.
| 1771 FDC Command: D0H (11010000) | | Function Description |
| 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | | Command=Force Interrupt (bits 7-4 = 1101) I3-I0 = 0000: end the command, no interrupt |
5549
LD HL,5A29H 21 29 5A
Point Register Pair HL to 5A29H, the message CAN'T FORMAT, DISK TRANSFER RATE TOO FAST!.
554C
BIT 2,A CB 57
Test bit 2 of Register A (the final status), LOST DATA.
554E
If the NZ FLAG is set (a byte came too late), JUMP to 56ADH to show the message at Register Pair HL and halt.
5551
LD HL,A100H 21 00 A1
Load Register Pair HL with A100H, 10000H minus 5F00H.
5554
ADD HL,BC 09
ADD Register Pair BC (the image pointer) to Register Pair HL: Register Pair HL = the bytes the controller took.
5555
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the bytes taken.
5556
LD HL,F413H 21 13 F4
Load Register Pair HL with F413H, 10000H minus 0BEDH.
5559
ADD HL,DE 19
ADD Register Pair DE (the bytes taken) to Register Pair HL: the CARRY FLAG is set for 0BEDH or more.
555A
LD HL,5A55H 21 55 5A
Point Register Pair HL to 5A55H, the message CAN'T FORMAT, MOTOR SPEED TOO SLOW!; LD does not change the flags.
555D
If the NO CARRY FLAG is set (fewer than 0BEDH bytes), JUMP to 56ADH to show the message at Register Pair HL and halt.
5560
LD HL,F397H 21 97 F3
Load Register Pair HL with F397H, 10000H minus 0C69H.
5563
ADD HL,DE 19
ADD Register Pair DE (the bytes taken) to Register Pair HL: the CARRY FLAG is set for 0C69H or more.
5564
LD HL,5A7AH 21 7A 5A
Point Register Pair HL to 5A7AH, the message CAN'T FORMAT, MOTOR SPEED TOO FAST!; LD does not change the flags.
5567
If the CARRY FLAG is set (0C69H bytes or more), JUMP to 56ADH to show the message at Register Pair HL and halt.
556A
RET C9
RETURN to 5522H; the Z FLAG is still the one BIT 2 set at 554CH.
556BH - Verify the Tracks
Reads every sector of every track not locked out, showing VERIFYING TRACK tt, SECTOR ss. RECORD NOT FOUND or a CRC error shows its message, locks the track out (5719H puts FFH in its byte at 5C00H) and goes on with the next track; lost data halts.
556B
LD A,0DH 3E 0D
Load Register A with 0DH, ENTER, to end the FORMATTING line. 550BH jumps here.
556D
GOSUB to ROM routine at 0033H to display Register A (0DH).
5570
LD D,00H 16 00
Load Register D with 00H, track 0, the first track to verify.
5572
LD L,D 6A
Track Loop
Copy the track from Register D into Register L. 55C1H jumps here.
5573
LD H,5CH 26 5C
Load Register H with 5CH: Register Pair HL = 5C00H plus the track, its lockout byte.
5575
LD A,(HL) 7E
Fetch the track's lockout byte from (HL) (Register Pair HL = 5C00H plus the track) into Register A.
5576
INC A 3C
INCrement Register A by 1: the Z FLAG is set for FFH, a locked out track.
5577
If the Z FLAG is set (locked out), JUMP to 55BDH to go to the next track.
557A
LD A,D 7A
Copy the track from Register D into Register A.
557B
GOSUB to 5726H to turn Register A into two digits: Register C = the tens, Register B = the units.
557E
LD (5AB0H),BC ED 43 B0 5A
Store Register Pair BC (the track's digits) into 5AB0H, the track in VERIFYING TRACK 00, SECTOR 00.
5582
LD E,00H 1E 00
Load Register E with 00H, sector 0, the first sector of the track.
5584
PUSH DE D5
Sector Loop
Save Register Pair DE (Register D = track, Register E = sector) onto the stack. 55BAH jumps here.
5585
LD A,D 7A
Copy the track from Register D into Register A; 5767H replaces it at once, so this has no effect.
5586
GOSUB to 5767H to select the drive before each sector read.
5589
LD A,E 7B
Copy the sector from Register E into Register A.
558A
GOSUB to 5726H to turn Register A into two digits.
558D
LD (5ABBH),BC ED 43 BB 5A
Store Register Pair BC (the sector's digits) into 5ABBH, the sector in VERIFYING TRACK 00, SECTOR 00.
5591
LD HL,5A9FH 21 9F 5A
Point Register Pair HL to 5A9FH, the text VERIFYING TRACK tt, SECTOR ss.
5594
GOSUB to 429AH to display the text at Register Pair HL; it starts with 1DH and ends with 03H, so it is rewritten on the same line.
5597
POP DE D1
Restore Register Pair DE (Register D = track, Register E = sector) from the stack.
5598
LD BC,5D00H 01 00 5D
Point Register Pair BC to 5D00H, the sector buffer.
559B
GOSUB to 42AAH to read track Register D, sector Register E into (BC); after two failed tries it returns the NZ FLAG with Register A = the status AND 5CH.
559E
LD HL,5ABEH 21 BE 5A
Point Register Pair HL to 5ABEH, the text : NOT FOUND! TRACK LOCKED OUT!.
55A1
BIT 4,A CB 67
Test bit 4 of Register A (the read status), RECORD NOT FOUND.
55A3
If the NZ FLAG is set (not found), JUMP to 5719H to show the text at Register Pair HL, lock the track out and go on with the next one.
55A6
LD HL,5ADDH 21 DD 5A
Point Register Pair HL to 5ADDH, the text : CRC ERROR! TRACK LOCKED OUT!.
55A9
BIT 3,A CB 5F
Test bit 3 of Register A (the read status), CRC ERROR.
55AB
If the NZ FLAG is set (a CRC error), JUMP to 5719H to show the text at Register Pair HL, lock the track out and go on.
55AE
LD HL,5AFCH 21 FC 5A
Point Register Pair HL to 5AFCH, the message CAN'T VERIFY, DISK TRANSFER RATE TOO FAST!.
55B1
BIT 2,A CB 57
Test bit 2 of Register A (the read status), LOST DATA.
55B3
If the NZ FLAG is set (lost data), JUMP to 56ADH to show the message at Register Pair HL, wait for ENTER and halt.
55B6
INC E 1C
INCrement Register E (the sector) by 1, to the next sector of the track.
55B7
LD A,E 7B
Copy the sector from Register E into Register A.
55B8
CP 0AH FE 0A
Compare Register A against 0AH: the Z FLAG is set after sector 9.
55BA
Sector Loop End
If the NZ FLAG is set, JUMP back to 5584H for the next sector.
55BD
INC D 14
Next Track
INCrement Register D (the track) by 1. 5577H jumps here, and 5723H comes back here after locking a track out.
55BE
LD A,D 7A
Copy the track from Register D into Register A.
55BF
CP 23H FE 23
Compare Register A against 23H: the Z FLAG is set after track 34.
55C1
Track Loop End
If the NZ FLAG is set, JUMP back to 5572H for the next track.
55C4H - Write the System Information
Copies the lockout table to 5C60H (bytes 60H-82H of the allocation table) and turns 5C00H-5CFFH into the allocation table: track 0 granule 0 used (the boot sector), the directory track fully used (FFH), the name, the date and the master password hash already in place. The directory track must not have been locked out by the verify. Then it writes the boot sector (track 0, sector 0, FBH mark), the allocation table (directory track, sector 0, FAH), the hash index table with the bytes of BOOT/SYS and DIR/SYS (sector 1), the directory entries of BOOT/SYS (sector 2) and DIR/SYS (sector 3), and zeros in sectors 4-9. Each is read back (56BDH) and its data mark checked: FBH for the boot sector, FAH for the others.
55C4
LD HL,5C00H 21 00 5C
Point Register Pair HL to 5C00H, the lockout table as the verify left it.
55C7
LD DE,5C60H 11 60 5C
Point Register Pair DE to 5C60H, bytes 60H-82H of the allocation table, the lockout table's place.
55CA
LD BC,0023H 01 23 00
Load Register Pair BC with 0023H, one byte for each of the 35 tracks.
55CD
LDIR ED B0
Copy the lockout table: LDIR moves 23H bytes from (HL) (Register Pair HL = 5C00H) to (DE) (Register Pair DE = 5C60H), counting Register Pair BC down. 5C00H-5C22H now serve as the allocation bytes.
55CF
LD HL,5B28H 21 28 5B
Point Register Pair HL to 5B28H, the message INITIALIZING SYSTEM INFORMATION.
55D2
GOSUB to 429AH to display the message at Register Pair HL.
55D5
LD HL,5C00H 21 00 5C
Point Register Pair HL to 5C00H, the allocation byte of track 0.
55D8
LD A,(HL) 7E
Fetch the allocation byte of track 0 from (HL) (Register Pair HL = 5C00H) into Register A.
55D9
OR 01H F6 01
OR Register A with 01H: granule 0 of track 0, the boot sector's granule, is in use.
55DB
LD (HL),A 77
Store Register A back at (HL) (Register Pair HL = 5C00H).
55DC
LD A,(4202H) 3A 02 42
Fetch the directory track from 4202H into Register A.
55DF
LD (57B6H),A 32 B6 57
Store Register A into 57B6H, the track of the first extent in the DIR/SYS directory entry at 57A0H.
55E2
LD L,A 6F
Copy the directory track from Register A into Register L.
55E3
LD H,5CH 26 5C
Load Register H with 5CH: Register Pair HL = 5C00H plus the directory track.
55E5
LD A,(HL) 7E
Fetch the directory track's byte from (HL) (Register Pair HL = 5C00H plus the directory track) into Register A.
55E6
INC A 3C
INCrement Register A by 1: the Z FLAG is set for FFH, the track locked out by the verify.
55E7
If the Z FLAG is set, JUMP to 56D1H to show CAN'T FORMAT, DIRECTORY TRACK FLAWED! and halt.
55EA
LD (HL),FFH 36 FF
Store FFH at (HL) (Register Pair HL = 5C00H plus the directory track): both granules of the directory track are in use.
55EC
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H: Register D = track 0, Register E = sector 0, the boot sector.
55EF
LD BC,4200H 01 00 42
Point Register Pair BC to 4200H, the boot sector with the directory track in byte 2.
55F2
LD A,A8H 3E A8
Load Register
A with
A8H, WRITE SECTOR with the normal FBH data mark.
| 1771 FDC Command: A8H (10101000) | | Function Description |
| 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | | Command=Write Sector (bits 7-5 = 101) m = 0: one sector b = 1: IBM sector length E = 0: no head load delay a1 a0 = 00: data mark FBH (normal) |
55F4
GOSUB to 56BDH to write (BC) to track Register D, sector Register E with the command in Register A, and read it back into 5D00H.
55F7
LD A,(37ECH) 3A EC 37
Fetch the controller's status after the read back from 37ECH into Register A.
55FA
AND 60H E6 60
AND Register A with 60H, keeping bits 5 and 6, the data mark read: 00H for FBH.
55FC
If the NZ FLAG is set (another mark), JUMP to 56CBH to show CAN'T INITIALIZE SYSTEM INFORMATION and halt.
55FF
LD BC,5C00H 01 00 5C
Point Register Pair BC to 5C00H, the allocation table.
5602
LD A,(4202H) 3A 02 42
Fetch the directory track from 4202H into Register A.
5605
LD D,A 57
Copy the directory track from Register A into Register D.
5606
LD E,00H 1E 00
Load Register E with 00H, sector 0 of the directory track.
5608
LD A,A9H 3E A9
Load Register
A with
A9H, WRITE SECTOR with the FAH data mark of directory sectors.
| 1771 FDC Command: A9H (10101001) | | Function Description |
| 1 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | | Command=Write Sector (bits 7-5 = 101) m = 0: one sector b = 1: IBM sector length E = 0: no head load delay a1 a0 = 01: data mark FAH |
560A
GOSUB to 56BDH to write (BC) (5C00H) to track Register D, sector Register E and read it back.
560D
LD A,(37ECH) 3A EC 37
Fetch the controller's status after the read back from 37ECH into Register A.
5610
AND 60H E6 60
AND Register A with 60H, keeping the data mark bits.
5612
CP 20H FE 20
Compare Register A against 20H, the bits of the FAH mark.
5614
If the NZ FLAG is set (another mark), JUMP to 56CBH to show CAN'T INITIALIZE SYSTEM INFORMATION and halt.
5617
LD HL,5D00H 21 00 5D
Point Register Pair HL to 5D00H, the sector buffer, for the hash index table.
561A
LD (HL),00H 36 00
Clear Loop
Store 00H at (HL) (Register Pair HL = the buffer pointer): a free entry. 561DH loops back here.
561C
INC L 2C
INCrement Register L by 1: the Z FLAG is set when it wraps to 00H after 5DFFH.
561D
Clear Loop End
If the NZ FLAG is set, LOOP BACK to 561AH; Register Pair HL ends at 5D00H again.
561F
LD (HL),A2H 36 A2
Store A2H at (HL) (Register Pair HL = 5D00H): the hash byte of BOOT/SYS for locator 00H (sector 2, entry 0).
5621
INC HL 23
INCrement Register Pair HL by 1, to 5D01H, the byte for locator 01H.
5622
LD (HL),2CH 36 2C
Store 2CH at (HL) (Register Pair HL = 5D01H): the hash byte of DIR/SYS for locator 01H (sector 3, entry 0).
5624
DEC HL 2B
DECrement Register Pair HL by 1, back to 5D00H.
5625
LD E,01H 1E 01
Load Register E with 01H, sector 1, the hash index table (Register D is still the directory track).
5627
LD BC,5D00H 01 00 5D
Point Register Pair BC to 5D00H, the hash index table.
562A
LD A,A9H 3E A9
Load Register
A with
A9H, WRITE SECTOR with the FAH data mark.
| 1771 FDC Command: A9H (10101001) | | Function Description |
| 1 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | | Command=Write Sector (bits 7-5 = 101) m = 0: one sector b = 1: IBM sector length E = 0: no head load delay a1 a0 = 01: data mark FAH |
562C
GOSUB to 56BDH to write (BC) to track Register D, sector Register E and read it back into 5D00H.
562F
LD A,(37ECH) 3A EC 37
Fetch the controller's status after the read back from 37ECH into Register A.
5632
AND 60H E6 60
AND Register A with 60H, keeping the data mark bits.
5634
CP 20H FE 20
Compare Register A against 20H, the bits of the FAH mark.
5636
If the NZ FLAG is set (another mark), JUMP to 56CBH to show CAN'T INITIALIZE SYSTEM INFORMATION and halt.
5639
LD DE,5D00H 11 00 5D
Point Register Pair DE to 5D00H, the sector buffer.
563C
LD HL,5780H 21 80 57
Point Register Pair HL to 5780H, the directory entry of BOOT/SYS.
563F
LD BC,0020H 01 20 00
Load Register Pair BC with 0020H, the 32 bytes of an entry.
5642
LDIR ED B0
Copy the entry: LDIR moves 32 bytes from (HL) (Register Pair HL = 5780H) to (DE) (Register Pair DE = 5D00H), counting Register Pair BC down; the rest of the buffer holds the zeros of the cleared table.
5644
LD A,(4202H) 3A 02 42
Fetch the directory track from 4202H into Register A.
5647
LD D,A 57
Copy the directory track from Register A into Register D.
5648
LD E,02H 1E 02
Load Register E with 02H, directory sector 2.
564A
LD BC,5D00H 01 00 5D
Point Register Pair BC to 5D00H, the sector with the BOOT/SYS entry.
564D
LD A,A9H 3E A9
Load Register
A with
A9H, WRITE SECTOR with the FAH data mark.
| 1771 FDC Command: A9H (10101001) | | Function Description |
| 1 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | | Command=Write Sector (bits 7-5 = 101) m = 0: one sector b = 1: IBM sector length E = 0: no head load delay a1 a0 = 01: data mark FAH |
564F
GOSUB to 56BDH to write (BC) to track Register D, sector Register E and read it back.
5652
LD A,(37ECH) 3A EC 37
Fetch the controller's status after the read back from 37ECH into Register A.
5655
AND 60H E6 60
AND Register A with 60H, keeping the data mark bits.
5657
CP 20H FE 20
Compare Register A against 20H, the bits of the FAH mark.
5659
If the NZ FLAG is set (another mark), JUMP to 56CBH to show CAN'T INITIALIZE SYSTEM INFORMATION and halt.
565C
LD HL,57A0H 21 A0 57
Point Register Pair HL to 57A0H, the directory entry of DIR/SYS (its extent track set at 55DFH).
565F
LD DE,5D00H 11 00 5D
Point Register Pair DE to 5D00H, the sector buffer.
5662
LD BC,0020H 01 20 00
Load Register Pair BC with 0020H, the 32 bytes of an entry.
5665
LDIR ED B0
Copy the entry: LDIR moves 32 bytes from (HL) (Register Pair HL = 57A0H) to (DE) (Register Pair DE = 5D00H), counting Register Pair BC down.
5667
LD A,(4202H) 3A 02 42
Fetch the directory track from 4202H into Register A.
566A
LD D,A 57
Copy the directory track from Register A into Register D.
566B
LD E,03H 1E 03
Load Register E with 03H, directory sector 3.
566D
LD BC,5D00H 01 00 5D
Point Register Pair BC to 5D00H, the sector with the DIR/SYS entry.
5670
LD A,A9H 3E A9
Load Register
A with
A9H, WRITE SECTOR with the FAH data mark.
| 1771 FDC Command: A9H (10101001) | | Function Description |
| 1 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | | Command=Write Sector (bits 7-5 = 101) m = 0: one sector b = 1: IBM sector length E = 0: no head load delay a1 a0 = 01: data mark FAH |
5672
GOSUB to 56BDH to write (BC) to track Register D, sector Register E and read it back.
5675
LD A,(37ECH) 3A EC 37
Fetch the controller's status after the read back from 37ECH into Register A.
5678
AND 60H E6 60
AND Register A with 60H, keeping the data mark bits.
567A
CP 20H FE 20
Compare Register A against 20H, the bits of the FAH mark.
567C
If the NZ FLAG is set (another mark), JUMP to 56CBH to show CAN'T INITIALIZE SYSTEM INFORMATION and halt.
567F
LD HL,5D00H 21 00 5D
Point Register Pair HL to 5D00H, the sector buffer.
5682
LD B,20H 06 20
Load Register B with 20H, the 32 bytes of the entry just written.
5684
LD (HL),00H 36 00
Clear Loop
Store 00H at (HL) (Register Pair HL = the buffer pointer). 5687H loops back here.
5686
INC HL 23
INCrement Register Pair HL (the buffer pointer) by 1.
5687
Clear Loop End
DECrement Register B and LOOP BACK to 5684H: the whole buffer is now zeros.
5689
LD A,(4202H) 3A 02 42
Fetch the directory track from 4202H into Register A, for the six empty directory sectors.
568C
LD D,A 57
Copy the directory track from Register A into Register D.
568D
LD E,04H 1E 04
Load Register E with 04H, directory sector 4, the first of the empty ones; 56A1H counts it up to 9.
568F
LD BC,5D00H 01 00 5D
Empty Sector Loop
Point Register Pair BC to 5D00H, the sector of zeros (the read back of the previous sector left zeros there). 56A5H loops back here.
5692
LD A,A9H 3E A9
Load Register
A with
A9H, WRITE SECTOR with the FAH data mark.
| 1771 FDC Command: A9H (10101001) | | Function Description |
| 1 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | | Command=Write Sector (bits 7-5 = 101) m = 0: one sector b = 1: IBM sector length E = 0: no head load delay a1 a0 = 01: data mark FAH |
5694
GOSUB to 56BDH to write (BC) to track Register D, sector Register E and read it back.
5697
LD A,(37ECH) 3A EC 37
Fetch the controller's status after the read back from 37ECH into Register A.
569A
AND 60H E6 60
AND Register A with 60H, keeping the data mark bits.
569C
CP 20H FE 20
Compare Register A against 20H, the bits of the FAH mark.
569E
If the NZ FLAG is set (another mark), JUMP to 56CBH to show CAN'T INITIALIZE SYSTEM INFORMATION and halt.
56A1
INC E 1C
INCrement Register E (the sector) by 1, to the next directory sector.
56A2
LD A,E 7B
Copy the sector from Register E into Register A.
56A3
CP 0AH FE 0A
Compare Register A against 0AH: the Z FLAG is set after sector 9.
56A5
Empty Sector Loop End
If the NZ FLAG is set, LOOP BACK to 568FH for the next sector (Register D and Register E are kept).
56A7
GOSUB to 5754H to select the drive and send RESTORE: the head goes back to track 0.
56AA
LD HL,5B6DH 21 6D 5B
Point Register Pair HL to 5B6DH, the message FORMATTING COMPLETE, and go on into 56ADH.
56ADH - Show a Message and Halt
Every end of FORMAT comes here (56B0H for a diskette the person chose not to format), the successful one included, with Register Pair HL = the message. Shows it, shows HIT 'ENTER' TO CONTINUE, waits until ENTER is pressed and executes HALT with interrupts disabled: the processor stops until RESET is pressed. 4200H-42FFH now hold the boot sector, so SYS0/SYS's buffer there is not what TRSDOS left.
56AD
GOSUB to 429AH to display the message at Register Pair HL. 17 places jump here.
56B0
LD HL,5B82H 21 82 5B
Point Register Pair HL to 5B82H, the text HIT 'ENTER' TO CONTINUE. 5BC6H jumps here.
56B3
GOSUB to 429AH to display the text at Register Pair HL.
56B6
LD A,(3840H) 3A 40 38
Wait for ENTER
Fetch keyboard row 6 from 3840H into Register A; bit 0 is ENTER. 56BAH loops back here.
56B9
RRCA 0F
Rotate Register A right: bit 0, ENTER, goes into the CARRY FLAG.
56BA
Wait Loop End
If the NO CARRY FLAG is set (ENTER not pressed), LOOP BACK to 56B6H.
56BC
HALT 76
HALT: with interrupts disabled the processor stops here until RESET.
56BDH - Write a Sector and Read It Back
Register A = the write command, Register Pair BC = the data, Register D = track, Register E = sector. Writes the sector (56D7H, two tries) and reads it back into 5D00H with the boot sector's 42AAH; either failing shows CAN'T INITIALIZE SYSTEM INFORMATION and halts. Returns the Z FLAG with the controller's status, data mark bits included, from the read back.
56BD
GOSUB to 56D7H to write (BC) to track Register D, sector Register E with the command in Register A. 55F4H, 560AH, 562CH, 564FH, 5672H and 5694H call here.
56C0
If the NZ FLAG is set (the write failed twice), JUMP to 56CBH.
56C2
PUSH BC C5
Save Register Pair BC (the data address) onto the stack.
56C3
LD BC,5D00H 01 00 5D
Point Register Pair BC to 5D00H, the buffer the sector is read back into.
56C6
GOSUB to 42AAH to read track Register D, sector Register E into (BC) (Register Pair BC = 5D00H).
56C9
POP BC C1
Restore Register Pair BC (the data address) from the stack.
56CA
RET Z C8
If the Z FLAG is set (read back), RETURN to the caller, which checks the data mark.
56CB
LD HL,5B49H 21 49 5B
Cannot Initialize
Point Register Pair HL to 5B49H, the message CAN'T INITIALIZE SYSTEM INFORMATION. 56C0H and the callers of 56BDH jump here.
56CE
JUMP to 56ADH to show the message at Register Pair HL, wait for ENTER and halt.
56D1
LD HL,59EEH 21 EE 59
Directory Track Flawed
Point Register Pair HL to 59EEH, the message CAN'T FORMAT, DIRECTORY TRACK FLAWED!. 55E7H jumps here.
56D4
JUMP to 56ADH to show the message at Register Pair HL, wait for ENTER and halt.
56D7H - Write a Sector
Register A = the write command, Register Pair BC = the data, Register D = track, Register E = sector. Tries 56E2H twice. 56E2H selects the drive (5767H), seeks the track, sends the command and gives the controller each byte it asks for, then returns the Z FLAG when the status AND 7CH is 0; on an error it sends FORCE INTERRUPT and returns the NZ FLAG.
56D7
LD (56F8H),A 32 F8 56
Store Register A (the write command) into 56F8H, the operand of LD (HL),nn at 56F7H. 56BDH calls here.
56DA
PUSH BC C5
Save Register Pair BC (the data address) onto the stack, for a second try.
56DB
GOSUB to 56E2H to write the sector once, the first of the two tries.
56DE
POP HL E1
Restore the data address into Register Pair HL from the stack.
56DF
RET Z C8
If the Z FLAG is set (written), RETURN to 56C0H.
56E0
LD B,H 44
Copy Register H (the high byte of the data address) into Register B.
56E1
LD C,L 4D
Copy Register L into Register C: Register Pair BC = the data address again for the second try, which runs on into 56E2H.
56E2
LD (37EEH),DE ED 53 EE 37
Store Register Pair DE into 37EEH: Register E into the sector register and Register D, the track, into the data register, where SEEK finds its target. 56DBH calls here.
56E6
PUSH DE D5
Save Register Pair DE (track and sector) onto the stack.
56E7
GOSUB to 5767H to select the drive before the seek.
56EA
LD HL,37ECH 21 EC 37
Point Register Pair HL to 37ECH, the controller's command and status register.
56ED
LD (HL),1BH 36 1B
Store
1BH, SEEK, at
(HL) (Register Pair HL = 37ECH): the head moves to the track in the data register.
| 1771 FDC Command: 1BH (00011011) | | Function Description |
| 0 | 0 | 0 | 1 | 1 | 0 | 1 | 1 | | Command=Seek (bits 7-4 = 0001) h = 1: head load and settle delay V = 0: no verify r1 r0 = 11: 15 ms stepping rate |
56EF
PUSH AF F5
Save Register Pair AF onto the stack, a delay before the status is read.
56F0
POP AF F1
Restore Register Pair AF from the stack, part of the delay.
56F1
PUSH AF F5
Save Register Pair AF onto the stack again, more delay.
56F2
POP AF F1
Restore Register Pair AF from the stack: the controller has had time to set BUSY.
56F3
LD A,(HL) 7E
Wait for the Seek
Fetch the controller's status from (HL) (Register Pair HL = 37ECH) into Register A. 56F5H loops back here.
56F4
RRCA 0F
Rotate Register A right: bit 0, BUSY, goes into the CARRY FLAG.
56F5
Wait Loop End
If the CARRY FLAG is set (busy), LOOP BACK to 56F3H.
56F7
LD (HL),00H 36 00
Store the write command at (HL) (Register Pair HL = 37ECH), the operand at 56F8H stored by 56D7H (00H in the file).
56F9
LD DE,37EFH 11 EF 37
Point Register Pair DE to 37EFH, the controller's data register.
56FC
PUSH BC C5
Save Register Pair BC onto the stack, a delay before the status is read.
56FD
POP BC C1
Restore Register Pair BC from the stack, part of the delay.
56FE
PUSH BC C5
Save Register Pair BC onto the stack again, more delay.
56FF
POP BC C1
Restore Register Pair BC (the data address) from the stack.
5700
DI F3
Disable interrupts for the transfer (they are already off since 5200H).
5701
JUMP to 5706H to look at the status for the first data request.
5703
RRCA 0F
Not Asking for Data
Rotate Register A (the status) right: bit 0, BUSY, goes into the CARRY FLAG. 5709H jumps here.
5704
If the NO CARRY FLAG is set (no longer busy), JUMP to 5711H.
5706
LD A,(HL) 7E
Transfer Loop
Fetch the controller's status from (HL) (Register Pair HL = 37ECH) into Register A. 5701H and 570EH come here.
5707
BIT 1,A CB 4F
Test bit 1 of Register A (the status), DATA REQUEST.
5709
If the Z FLAG is set (no request), JUMP to 5703H to test BUSY.
570B
LD A,(BC) 0A
Fetch the next data byte from (BC) (Register Pair BC = the data pointer) into Register A.
570C
LD (DE),A 12
Store Register A at (DE) (Register Pair DE = 37EFH), the data register.
570D
INC BC 03
INCrement Register Pair BC (the data pointer) by 1.
570E
Transfer Loop End
JUMP to 5706H for the next status.
5711
LD A,(HL) 7E
Fetch the controller's final status from (HL) (Register Pair HL = 37ECH) into Register A. 5704H jumps here.
5712
AND 7CH E6 7C
AND Register
A with
7CH, keeping the error bits of a write: the Z FLAG for success.
| 1771 Status after Read/Write Sector, AND 7CH | | Function Description |
| 0 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | | Bits kept by AND 7CH: 6: F9H/F8H mark (read), write protect 5: FAH/F8H mark (read), write fault 4: record not found 3: CRC error 2: lost data |
5714
POP DE D1
Restore Register Pair DE (track and sector) from the stack.
5715
RET Z C8
If the Z FLAG is set (no error), RETURN to 56DEH or to 56C0H.
5716
LD (HL),D0H 36 D0
Store
D0H, FORCE INTERRUPT, at
(HL) (Register Pair HL = 37ECH): the controller stops.
| 1771 FDC Command: D0H (11010000) | | Function Description |
| 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | | Command=Force Interrupt (bits 7-4 = 1101) I3-I0 = 0000: end the command, no interrupt |
5718
RET C9
RETURN with the NZ FLAG from the AND at 5712H.
5719H - Verify: Lock a Track Out
Reached from 55A3H or 55ABH with Register Pair HL = the message and Register D = the track. Shows the message (: NOT FOUND! or : CRC ERROR! TRACK LOCKED OUT!), puts FFH in the track's byte at 5C00H and goes on with the next track at 55BDH.
5719
PUSH DE D5
Save Register Pair DE (Register D = track) onto the stack. 55A3H and 55ABH jump here.
571A
GOSUB to 429AH to display the message at Register Pair HL, after the VERIFYING line already shown.
571D
POP DE D1
Restore Register Pair DE (Register D = track) from the stack.
571E
LD L,D 6A
Copy the track from Register D into Register L.
571F
LD H,5CH 26 5C
Load Register H with 5CH: Register Pair HL = 5C00H plus the track.
5721
LD (HL),FFH 36 FF
Store FFH at (HL) (Register Pair HL = 5C00H plus the track): the track is locked out.
5723
JUMP to 55BDH to verify the next track; the rest of this one is skipped.
5726H - Two Decimal Digits
Register A = a number 0-99. Returns Register C = the tens digit and Register B = the units digit as characters, so that LD (nn),BC stores them in reading order.
5726
LD C,30H 0E 30
Load Register C with 30H, the digit 0 for the tens. 5456H, 546AH, 557BH and 558AH call here.
5728
SUB 0AH D6 0A
Tens Loop
SUBtract 0AH from Register A (the number); the CARRY FLAG is set when it goes below zero. 572DH loops back here.
572A
If the CARRY FLAG is set, JUMP to 572FH: Register A = the units minus 10.
572C
INC C 0C
INCrement Register C (the tens digit) by 1 for the ten just taken off.
572D
Tens Loop End
LOOP BACK to 5728H to subtract another ten.
572F
ADD A,3AH C6 3A
ADD 3AH to Register A (the units minus 10): the units digit as a character (30H-39H).
5731
LD B,A 47
Copy the units digit from Register A into Register B.
5732
RET C9
RETURN with Register C = the tens digit and Register B = the units digit.
5733H - Read a Decimal Number
Register Pair HL = the text. Reads digits into Register E (number times 10 plus the digit, kept to 8 bits) until a character that is not a digit; returns that character in Register A with Register Pair HL past it. No digit at all gives Register E = 0.
5733
LD E,00H 1E 00
Load Register E with 00H, the number so far. 535FH and 5367H call here.
5735
LD A,(HL) 7E
Digit Loop
Fetch the next character from (HL) (Register Pair HL = the text pointer) into Register A. 5747H loops back here.
5736
INC HL 23
INCrement Register Pair HL (the text pointer) by 1, past the character.
5737
CP 30H FE 30
Compare Register A (the character) against 30H, the digit 0.
5739
RET C D8
If the CARRY FLAG is set (below the digit 0), RETURN with that character in Register A.
573A
CP 3AH FE 3A
Compare Register A against 3AH, one past the digit 9.
573C
RET NC D0
If the NO CARRY FLAG is set (above the digit 9), RETURN with that character in Register A.
573D
SUB 30H D6 30
SUBtract 30H from Register A: the digit's value.
573F
LD B,A 47
Copy the digit from Register A into Register B.
5740
LD A,E 7B
Copy the number so far from Register E into Register A.
5741
ADD A,A 87
ADD Register A to itself: the number times 2.
5742
ADD A,A 87
ADD Register A to itself: the number times 4.
5743
ADD A,E 83
ADD Register E to Register A: the number times 5.
5744
ADD A,A 87
ADD Register A to itself: the number times 10.
5745
ADD A,B 80
ADD Register B (the digit) to Register A (the number times 10).
5746
LD E,A 5F
Copy the new number from Register A into Register E.
5747
Digit Loop End
LOOP BACK to 5735H for the next character.
5749H - Store Bytes into the Track Image
5749H stores Register B bytes of FFH, 574BH stores Register B bytes of Register C (256 when Register B is 00H), 5751H stores one byte of Register C; each at (HL), moving Register Pair HL on.
5749
LD C,FFH 0E FF
Load Register C with FFH, the gap byte. 54A1H, 54D0H, 54F2H and 54FCH call here.
574B
Store Loop
GOSUB to 5751H to store Register C at (HL) and move Register Pair HL on. 54A8H, 54D7H and 54E3H call here; 574EH loops back here.
574E
Store Loop End
DECrement Register B and LOOP BACK to 574BH until Register B bytes are stored.
5750
RET C9
RETURN to the format code with Register Pair HL past the bytes stored.
5751
LD (HL),C 71
Store Register C at (HL) (Register Pair HL = the image pointer). The format code calls here for single bytes.
5752
INC HL 23
INCrement Register Pair HL (the image pointer) by 1.
5753
RET C9
RETURN with Register Pair HL at the next byte of the image.
5754H - Select and Restore
Selects the drive, sends RESTORE (the head goes to track 0) and waits until BUSY clears; there is no time limit.
5754
GOSUB to 5767H to select the drive. 5258H and 56A7H call here.
5757
LD A,0BH 3E 0B
Load Register
A with
0BH, RESTORE.
| 1771 FDC Command: 0BH (00001011) | | Function Description |
| 0 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | | Command=Restore (bits 7-4 = 0000) h = 1: head load and settle delay V = 0: no verify r1 r0 = 11: 15 ms stepping rate |
5759
LD (37ECH),A 32 EC 37
Store Register A (0BH) into 37ECH, the controller's command register.
575C
PUSH AF F5
Save Register Pair AF onto the stack, a delay before the status is read.
575D
POP AF F1
Restore Register Pair AF from the stack, part of the delay.
575E
PUSH AF F5
Save Register Pair AF onto the stack again, more delay.
575F
POP AF F1
Restore Register Pair AF from the stack: the controller has had time to set BUSY.
5760
LD A,(37ECH) 3A EC 37
Wait While Busy
Fetch the controller's status from 37ECH into Register A. 5764H loops back here.
5763
RRCA 0F
Rotate Register A right: bit 0, BUSY, goes into the CARRY FLAG.
5764
Wait Loop End
If the CARRY FLAG is set (busy), LOOP BACK to 5760H.
5766
RET C9
RETURN with the head on track 0 and the status in the controller.
5767H - Select the Drive
Writes the drive's select bit to the drive select latch at 37E1H; there is no wait for the motor here.
5767
LD A,00H 3E 00
Load Register A with the drive's select bit, the operand at 5768H stored by 5252H (00H in the file). Eight places call here.
5769
LD (37E1H),A 32 E1 37
Store Register A into 37E1H, the drive select latch: the drive is selected and its motor runs.
576C
RET C9
RETURN with the drive selected; the caller waits for the motor when it needs to.
576DH - Tables and Directory Entries
The sector order of a formatted track, eight spaces for clearing the name, and the two directory entries FORMAT writes: BOOT/SYS (directory sector 2, entry 0) and DIR/SYS (sector 3, entry 0).
576D-5777
DEFB 00H, 05H, 01H, 06H, 02H, 07H, 03H, 08H, 04H, 09H, FFH 00 05 01 06 02 07 03 08 04 09 FF
The order of the sector numbers around a formatted track (549CH, 54BAH): 0, 5, 1, 6, 2, 7, 3, 8, 4, 9; FFH ends the table.
5778-577F
DEFM " " 20 20 20 20 20 20 20 20
Eight spaces, copied into the name field at 5CD0H by 5287H before the name typed.
5780
DEFB 5EH 5E
BOOT/SYS entry, attribute byte: bit 6 system file, bit 4 in use, bit 3 invisible, bits 0-2 access level 6.
5781-5784
DEFB 00H, 00H, 00H, 00H 00 00 00 00
BOOT/SYS entry bytes 01H-04H: 00H (no primary entry), 00H, the end-of-file byte 00H and the record length 00H (256).
5785-578F
DEFM "BOOT SYS" 42 4F 4F 54 20 20 20 20 53 59 53
BOOT/SYS entry bytes 05H-0FH: the name and extension, padded with spaces.
5790-5791
DEFW 7F60H 60 7F
BOOT/SYS entry bytes 10H-11H: the owner password hash.
5792-5793
DEFW B21FH 1F B2
BOOT/SYS entry bytes 12H-13H: the user password hash.
5794-5795
DEFW 0005H 05 00
BOOT/SYS entry bytes 14H-15H: the ending record number, 5 sectors.
5796-5797
DEFB 00H, 00H 00 00
BOOT/SYS entry first extent: track 0, granule byte 00H (granule 0, one granule).
5798-5799
DEFB FFH, FFH FF FF
BOOT/SYS entry second extent: FFH, the end of the extents.
579A-579F
DEFB 00H, 00H, 00H, 00H, 00H, 00H 00 00 00 00 00 00
BOOT/SYS entry bytes 1AH-1FH: the unused extents.
57A0
DEFB 5DH 5D
DIR/SYS entry, attribute byte: bit 6 system file, bit 4 in use, bit 3 invisible, bits 0-2 access level 5.
57A1-57A4
DEFB 00H, 00H, 00H, 00H 00 00 00 00
DIR/SYS entry bytes 01H-04H: 00H (no primary entry), 00H, the end-of-file byte 00H and the record length 00H (256).
57A5-57AF
DEFM "DIR SYS" 44 49 52 20 20 20 20 20 53 59 53
DIR/SYS entry bytes 05H-0FH: the name and extension, padded with spaces.
57B0-57B1
DEFW 1DA7H A7 1D
DIR/SYS entry bytes 10H-11H: the owner password hash.
57B2-57B3
DEFW E5F9H F9 E5
DIR/SYS entry bytes 12H-13H: the user password hash.
57B4-57B5
DEFW 000AH 0A 00
DIR/SYS entry bytes 14H-15H: the ending record number, the 10 sectors of the directory track.
57B6-57B7
DEFB 11H, 01H 11 01
DIR/SYS entry first extent: track 11H, replaced by the directory track at 55DFH, and granule byte 01H (granule 0, two granules: the whole track).
57B8-57B9
DEFB FFH, FFH FF FF
DIR/SYS entry second extent: FFH, the end of the extents.
57BA-57BF
DEFB 00H, 00H, 00H, 00H, 00H, 00H 00 00 00 00 00 00
DIR/SYS entry bytes 1AH-1FH: the unused extents.
57C0H - Messages
The texts FORMAT shows. Prompts end with 03H so the answer follows on the line; the progress lines start with 1DH (cursor to the start of the line), so each is written over the last; their digits are filled in through 5726H.
57C0-57E7
DEFM "FORMAT INVALID DURING PROGRAM CHAINING!" / DEFB 0DH 46 4F 52 4D 41 54 20 49 4E 56 41 4C 49 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 21 0D
Shown by 5213H when bit 5 of the system flags at 430FH is set.
57E8-580D
DEFB 1CH, 1FH / DEFM "TRSDOS DISK FORMATTER PROGRAM 2.3" / DEFB 0AH, 0DH 1C 1F 54 52 53 44 4F 53 20 44 49 53 4B 20 46 4F 52 4D 41 54 54 45 52 20 50 52 4F 47 52 41 4D 20 20 32 2E 33 0A 0D
The title shown by 5227H: cursor to the top left, erase to the end of the screen, the text, a line feed and 0DH.
580E-582A
DEFM "WHICH DRIVE IS TO BE USED ? " / DEFB 03H 57 48 49 43 48 20 44 52 49 56 45 20 49 53 20 54 4F 20 42 45 20 55 53 45 44 20 3F 20 03
The prompt of 522EH for the drive number; 03H leaves the cursor after it.
582B-583B
DEFM "DISKETTE NAME ? " / DEFB 03H 44 49 53 4B 45 54 54 45 20 4E 41 4D 45 20 3F 20 03
The prompt of 5278H for the diskette name; 03H leaves the cursor after it.
583C-5857
DEFM "CREATION DATE (MM/DD/YY) ? " / DEFB 03H 43 52 45 41 54 49 4F 4E 20 44 41 54 45 20 28 4D 4D 2F 44 44 2F 59 59 29 20 3F 20 03
The prompt of 529DH for the creation date; 03H leaves the cursor after it.
5858-586A
DEFM "MASTER PASSWORD ? " / DEFB 03H 4D 41 53 54 45 52 20 50 41 53 53 57 4F 52 44 20 3F 20 03
The prompt of 52CCH for the master password; 03H leaves the cursor after it.
586B-587B
DEFM "DRIVE NOT READY!" / DEFB 0DH 44 52 49 56 45 20 4E 4F 54 20 52 45 41 44 59 21 0D
Shown by 526DH and 53AFH when the status has NOT READY set.
587C-5895
DEFM "WRITE PROTECTED DISKETTE!" / DEFB 0DH 57 52 49 54 45 20 50 52 4F 54 45 43 54 45 44 20 44 49 53 4B 45 54 54 45 21 0D
Shown by 53BFH when the status has WRITE PROTECT set.
5896-58AA
DEFM "DRIVE NOT IN SYSTEM!" / DEFB 0DH 44 52 49 56 45 20 4E 4F 54 20 49 4E 20 53 59 53 54 45 4D 21 0D
Shown by 5275H and 53B7H when the head is not on track 0 after RESTORE.
58AB-58C0
DEFM "NO DISKETTE IN DRIVE!" / DEFB 0DH 4E 4F 20 44 49 53 4B 45 54 54 45 20 49 4E 20 44 52 49 56 45 21 0D
Shown by 53CBH and 53F4H when the index pulse does not end in time.
58C1-58DA
DEFM "DOOR NOT CLOSED ON DRIVE!" / DEFB 0DH 44 4F 4F 52 20 4E 4F 54 20 43 4C 4F 53 45 44 20 4F 4E 20 44 52 49 56 45 21 0D
Shown by 53DEH and 5408H when no next index pulse comes in time.
58DB-58FC
DEFM "DISKETTE UNUSABLE! HARD-SECTORED!" / DEFB 0DH 44 49 53 4B 45 54 54 45 20 55 4E 55 53 41 42 4C 45 21 20 48 41 52 44 2D 53 45 43 54 4F 52 45 44 21 0D
Shown by 541AH when the index pulses come less than 1535H loop turns apart.
58FD-5925
DEFM "DISKETTE CONTAINS DATA, FORMAT OR NOT ? " / DEFB 03H 44 49 53 4B 45 54 54 45 20 43 4F 4E 54 41 49 4E 53 20 44 41 54 41 2C 20 46 4F 52 4D 41 54 20 4F 52 20 4E 4F 54 20 3F 20 03
The prompt of 5B9CH, asked when track 0, sector 0 can be read.
5926-594B
DEFM "DO YOU WANT TO LOCK OUT ANY TRACKS ? " / DEFB 03H 44 4F 20 59 4F 55 20 57 41 4E 54 20 54 4F 20 4C 4F 43 4B 20 4F 55 54 20 41 4E 59 20 54 52 41 43 4B 53 20 3F 20 03
The prompt of 533EH; only a first character Y counts as yes.
594C-5962
DEFM "WHICH TRACKS (1-34) ? " / DEFB 03H 57 48 49 43 48 20 54 52 41 43 4B 53 20 28 31 2D 33 34 29 20 3F 20 03
The prompt of 5351H for a list such as 5,9-11; 03H leaves the cursor after it.
5963-5978
DEFM "INVALID TRACK NUMBER!" / DEFB 0DH 49 4E 56 41 4C 49 44 20 54 52 41 43 4B 20 4E 55 4D 42 45 52 21 0D
Shown by 5338H for a track outside 1-34 or a range that runs backwards.
5979-5997
DEFM "FORMAT THE LOCKED OUT TRACKS? " / DEFB 03H 46 4F 52 4D 41 54 20 54 48 45 20 4C 4F 43 4B 45 44 20 4F 55 54 20 54 52 41 43 4B 53 3F 20 03
The prompt of 538CH; its answer is stored at 548DH but never acted on (see 5483H).
5998-59C8
DEFM "CAN'T FORMAT, NO TRACKS AVAILABLE FOR DIRECTORY!" / DEFB 0DH 43 41 4E 27 54 20 46 4F 52 4D 41 54 2C 20 4E 4F 20 54 52 41 43 4B 53 20 41 56 41 49 4C 41 42 4C 45 20 46 4F 52 20 44 49 52 45 43 54 4F 52 59 21 0D
Shown by 544CH when every track from 1 to 34 is locked out.
59C9-59EA
DEFM "DIRECTORY WILL BE PLACED ON TRACK " 44 49 52 45 43 54 4F 52 59 20 57 49 4C 4C 20 42 45 20 50 4C 41 43 45 44 20 4F 4E 20 54 52 41 43 4B 20
Shown by 545DH, followed by the track number.
59EB-59EC
DEFM "00" 30 30
The directory track, as two digits stored by 5459H.
59ED
DEFB 0DH 0D
End of the DIRECTORY WILL BE PLACED line: 0DH (ENTER).
59EE-5A13
DEFM "CAN'T FORMAT, DIRECTORY TRACK FLAWED!" / DEFB 0DH 43 41 4E 27 54 20 46 4F 52 4D 41 54 2C 20 44 49 52 45 43 54 4F 52 59 20 54 52 41 43 4B 20 46 4C 41 57 45 44 21 0D
Shown by 56D1H when the verify locked out the directory track.
5A14-5A25
DEFB 1DH / DEFM "FORMATTING TRACK " 1D 46 4F 52 4D 41 54 54 49 4E 47 20 54 52 41 43 4B 20
Start of the progress line of the format, shown by 5474H.
5A26-5A27
DEFM "00" 30 30
The track being formatted, as two digits stored by 546DH.
5A28
DEFB 03H 03
End of the FORMATTING line: 03H ends the text without moving to a new line.
5A29-5A54
DEFB 0AH / DEFM "CAN'T FORMAT, DISK TRANSFER RATE TOO FAST!" / DEFB 0DH 0A 43 41 4E 27 54 20 46 4F 52 4D 41 54 2C 20 44 49 53 4B 20 54 52 41 4E 53 46 45 52 20 52 41 54 45 20 54 4F 4F 20 46 41 53 54 21 0D
Shown by 554EH when WRITE TRACK ends with LOST DATA.
5A55-5A79
DEFB 0AH / DEFM "CAN'T FORMAT, MOTOR SPEED TOO SLOW!" / DEFB 0DH 0A 43 41 4E 27 54 20 46 4F 52 4D 41 54 2C 20 4D 4F 54 4F 52 20 53 50 45 45 44 20 54 4F 4F 20 53 4C 4F 57 21 0D
Shown by 555DH when WRITE TRACK took fewer than 0BEDH bytes.
5A7A-5A9E
DEFB 0AH / DEFM "CAN'T FORMAT, MOTOR SPEED TOO FAST!" / DEFB 0DH 0A 43 41 4E 27 54 20 46 4F 52 4D 41 54 2C 20 4D 4F 54 4F 52 20 53 50 45 45 44 20 54 4F 4F 20 46 41 53 54 21 0D
Shown by 5567H when WRITE TRACK took 0C69H bytes or more.
5A9F-5AAF
DEFB 1DH / DEFM "VERIFYING TRACK " 1D 56 45 52 49 46 59 49 4E 47 20 54 52 41 43 4B 20
Start of the progress line of the verify, shown by 5594H.
5AB0-5AB1
DEFM "00" 30 30
The track being verified, as two digits stored by 557EH.
5AB2-5ABA
DEFM ", SECTOR " 2C 20 53 45 43 54 4F 52 20
Between the track and the sector of the VERIFYING line.
5ABB-5ABC
DEFM "00" 30 30
The sector being verified, as two digits stored by 558DH.
5ABD
DEFB 03H 03
End of the VERIFYING line: 03H ends the text without moving to a new line.
5ABE-5ADC
DEFM ": NOT FOUND! TRACK LOCKED OUT!" / DEFB 0DH 3A 20 4E 4F 54 20 46 4F 55 4E 44 21 20 54 52 41 43 4B 20 4C 4F 43 4B 45 44 20 4F 55 54 21 0D
Shown by 5719H after the VERIFYING line when a sector is not found.
5ADD-5AFB
DEFM ": CRC ERROR! TRACK LOCKED OUT!" / DEFB 0DH 3A 20 43 52 43 20 45 52 52 4F 52 21 20 54 52 41 43 4B 20 4C 4F 43 4B 45 44 20 4F 55 54 21 0D
Shown by 5719H after the VERIFYING line when a sector has a CRC error.
5AFC-5B27
DEFB 0AH / DEFM "CAN'T VERIFY, DISK TRANSFER RATE TOO FAST!" / DEFB 0DH 0A 43 41 4E 27 54 20 56 45 52 49 46 59 2C 20 44 49 53 4B 20 54 52 41 4E 53 46 45 52 20 52 41 54 45 20 54 4F 4F 20 46 41 53 54 21 0D
Shown by 55B3H when a sector read ends with LOST DATA.
5B28-5B48
DEFB 0AH / DEFM "INITIALIZING SYSTEM INFORMATION" / DEFB 0DH 0A 49 4E 49 54 49 41 4C 49 5A 49 4E 47 20 53 59 53 54 45 4D 20 49 4E 46 4F 52 4D 41 54 49 4F 4E 0D
Shown by 55CFH before the boot sector, the allocation table and the directory are written.
5B49-5B6C
DEFM "CAN'T INITIALIZE SYSTEM INFORMATION" / DEFB 0DH 43 41 4E 27 54 20 49 4E 49 54 49 41 4C 49 5A 45 20 53 59 53 54 45 4D 20 49 4E 46 4F 52 4D 41 54 49 4F 4E 0D
Shown by 56CBH when a system sector cannot be written, read back or has the wrong data mark.
5B6D-5B81
DEFB 0AH / DEFM "FORMATTING COMPLETE" / DEFB 0DH 0A 46 4F 52 4D 41 54 54 49 4E 47 20 43 4F 4D 50 4C 45 54 45 0D
Shown by 56AAH-56ADH at the end of a successful format.
5B82-5B9B
DEFB 0AH, 0AH / DEFM "HIT 'ENTER' TO CONTINUE" / DEFB 0DH 0A 0A 48 49 54 20 27 45 4E 54 45 52 27 20 54 4F 20 43 4F 4E 54 49 4E 55 45 0D
Shown by 56B0H after every final message, before the HALT.
5B9CH - A Diskette That Holds Data
Called by 5429H when track 0, sector 0 of the diskette can be read. Asks DISKETTE CONTAINS DATA, FORMAT OR NOT ?: N ends FORMAT (after a short pause, with HIT 'ENTER' TO CONTINUE and the HALT); Y selects the drive again, waits and returns to format; anything else asks again.
5B9C
LD HL,58FDH 21 FD 58
Point Register Pair HL to 58FDH, the prompt DISKETTE CONTAINS DATA, FORMAT OR NOT ?. 5429H calls here; 5BB2H jumps here.
5B9F
GOSUB to 429AH to display the prompt at Register Pair HL; it ends with 03H.
5BA2
LD HL,5D00H 21 00 5D
Point Register Pair HL to 5D00H, the input buffer.
5BA5
LD B,01H 06 01
Load Register B with 01H: one character may be typed.
5BA7
GOSUB to ROM routine at 0040H to read a line of at most Register B characters into the buffer at Register Pair HL.
5BAA
LD A,(HL) 7E
Fetch the character typed from (HL) (Register Pair HL = 5D00H) into Register A.
5BAB
CP 4EH FE 4E
Compare Register A against 4EH, the letter N.
5BAD
If the Z FLAG is set (N), JUMP to 5BC0H to stop.
5BB0
CP 59H FE 59
Compare Register A against 59H, the letter Y.
5BB2
If the NZ FLAG is set (neither), JUMP to 5B9CH to ask again.
5BB5
NOP 00
No Operation: a byte of padding before the Y path.
5BB6
GOSUB to 5767H to select the drive again before the format starts.
5BB9
LD BC,8000H 01 00 80
Load Register Pair BC with 8000H, the length of the pause.
5BBC
GOSUB to ROM routine at 0060H to wait Register Pair BC (8000H) delay units.
5BBF
RET C9
RETURN to 542CH to choose the directory track and format.
5BC0
LD BC,1000H 01 00 10
Do Not Format
Load Register Pair BC with 1000H, the length of the pause. 5BADH jumps here.
5BC3
GOSUB to ROM routine at 0060H to wait Register Pair BC (1000H) delay units.
5BC6
JUMP to 56B0H to show HIT 'ENTER' TO CONTINUE, wait for ENTER and halt; the CALL's return address stays on the stack.
5BC9H - The Allocation Table Being Built and the Buffers
5C00H-5CFFH becomes the new diskette's granule allocation table; 5C00H-5CCAH are not in the file and are filled at 5322H, while 5CCBH-5CFFH come from the file with the name, date and AUTO fields ready for the answers. 5D00H-5DFFH is the input and sector buffer; 5E00H-5EFFH holds the boot sector image.
5BC9-5BFF
DEFS 55
Not in the file and not used by FORMAT: the 55 bytes between the last message and the allocation table at 5C00H.
5C00-5C22
DEFS 35
Not in the file: one byte per track. 5326H fills it with FCH (usable), the lock out list and the verify put FFH for locked tracks; the LDIR at 55CDH copies it to 5C60H as the lockout table, and the bytes left here become the allocation bytes (55DBH marks track 0 granule 0 used, 55EAH stores FFH for the directory track, both granules used).
5C23-5CCA
DEFS 168
Not in the file: filled with FFH by 5332H, so every granule past track 34 reads as used; the LDIR at 55CDH copies the 35 track bytes of 5C00H-5C22H into 5C60H-5C82H, the lockout table part of the allocation sector.
5CCB-5CCD
DEFB 21H, 00H, 00H 21 00 00
Bytes CBH-CDH of the allocation table as the file has them; FORMAT does not change them.
5CCE-5CCF
DEFW 0000H 00 00
Bytes CEH-CFH, the master password hash, stored by 52F1H.
5CD0-5CD7
DEFM " " 20 20 20 20 20 20 20 20
Bytes D0H-D7H, the diskette name, cleared by 5287H and filled by 529BH.
5CD8-5CDF
DEFM "MM/DD/YY" 4D 4D 2F 44 44 2F 59 59
Bytes D8H-DFH, the creation date, filled by 52CAH.
5CE0
DEFB 0DH 0D
Byte E0H, the first byte of the AUTO command: 0DH, no command.
5CE1-5CFF
DEFM " " 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
Bytes E1H-FFH, the rest of the AUTO command area, spaces.
5D00-5DFF
DEFS 256
Not in the file: the input buffer of the prompts, the sector buffer of the verify and the read backs, and the buffer of the hash index table and directory sectors written at 5617H-56A5H.
4200H - The Boot Sector (Runs at 4200H, Loaded at 5E00H)
The rows from here to 42FEH show the bytes the file loads at 5E00H-5EFEH, at the addresses they run at after 5225H has copied them to 4200H: file address = address shown plus 1C00H. This is the sector FORMAT writes to track 0, sector 0 at 55F4H. When the computer is started, the ROM reads track 0, sector 0 of drive 0 into 4200H and jumps to 4200H; this code then finds SYS0/SYS through the directory and loads it. While FORMAT runs, it uses two routines of this sector itself: 429AH to display text and 42AAH to read a sector.
4200
5E00H
NOP 00
No Operation: byte 0 of the boot sector. Execution starts here when the ROM jumps to 4200H; 00H does nothing and the next instruction follows.
4201
5E01H
CP 00H FE 00
Compare Register A against the byte at 4202H: a compare whose result is not used, so the byte at 4202H can hold the directory track. FORMAT puts the track it chose there at 5453H; BOOT/SYS holds 11H (track 17) in the same place.
4203
5E03H
DI F3
Disable interrupts: no interrupt is to run while SYS0/SYS is read in and loaded over low memory.
4204
5E04H
LD SP,41FCH 31 FC 41
Load the Stack Pointer with 41FCH, the same stack top TRSDOS uses below 4200H.
4207
5E07H
LD HL,42E2H 21 E2 42
Point Register Pair HL to 42E2H, the text 1CH (cursor to the top left), 1FH (erase to the end of the screen), 03H (end of the text).
420A
5E0AH
GOSUB to 429AH to display the text at Register Pair HL: the screen is cleared.
420D
5E0DH
LD A,01H 3E 01
Load Register A with 01H, the select bit of drive 0 (bit 0).
420F
5E0FH
LD (37E1H),A 32 E1 37
Store Register A (01H) into the drive select latch at 37E1H: drive 0 is selected and its motor turns on.
4212
5E12H
LD A,(4202H) 3A 02 42
Fetch the directory track from 4202H, byte 2 of this sector, into Register A.
4215
5E15H
LD D,A 57
Copy the directory track from Register A into Register D, the track for the read.
4216
5E16H
LD E,04H 1E 04
Load Register E with 04H, directory sector 4: entry 0 of sector 4 is locator 02H, the entry of SYS0/SYS.
4218
5E18H
LD BC,4D00H 01 00 4D
Point Register Pair BC to 4D00H, the buffer for the directory sector.
421B
5E1BH
GOSUB to 42AAH to read track Register D, sector Register E into (BC) (Register Pair BC = 4D00H); the Z FLAG is set when the sector was read.
421E
5E1EH
If the NZ FLAG is set (the directory sector could not be read in two tries), JUMP to 4290H to show DISK ERROR and halt.
4220
5E20H
LD A,(4D00H) 3A 00 4D
Fetch byte 00H of the SYS0/SYS entry, its attributes, from 4D00H into Register A.
4223
5E23H
AND 10H E6 10
AND Register A (the attributes) with 10H, keeping bit 4, the bit of an entry in use: the Z FLAG is set when the entry is free.
4225
5E25H
LD HL,42E5H 21 E5 42
Point Register Pair HL to 42E5H, the message NO SYSTEM; LD does not change the flags.
4228
5E28H
If the Z FLAG is set (no SYS0/SYS on this diskette), JUMP to 4293H to show the message at Register Pair HL and halt. A diskette fresh from FORMAT goes this way: 568FH writes sector 4 as zeros.
422A
5E2AH
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set: Register Pairs BC', DE' and HL' now hold the read position used by 4275H.
422B
5E2BH
LD HL,(4D16H) 2A 16 4D
Fetch bytes 16H-17H of the SYS0/SYS entry, its first extent, from 4D16H into Register Pair HL: Register L = the starting track, Register H = the granule byte (bits 5-7 the first granule, bits 0-4 the granule count minus one).
422E
5E2EH
LD D,L 55
Copy the starting track from Register L into Register D, the track of the first sector to read.
422F
5E2FH
LD A,H 7C
Copy the granule byte from Register H into Register A.
4230
5E30H
RLCA 07
Rotate Register A left, circularly: bit 7 of the granule byte goes to bit 0.
4231
5E31H
RLCA 07
Rotate Register A left again, circularly: bits 6-7 of the granule byte are now bits 0-1.
4232
5E32H
RLCA 07
Rotate Register A left a third time, circularly: bits 5-7 of the granule byte, the first granule, are now bits 0-2.
4233
5E33H
AND 07H E6 07
AND Register A with 07H, keeping bits 0-2: Register A = the number of the first granule on its track.
4235
5E35H
LD H,A 67
Copy the granule number from Register A into Register H.
4236
5E36H
RLCA 07
Rotate Register A (the granule number) left, circularly: the granule number times two.
4237
5E37H
RLCA 07
Rotate Register A left again, circularly: the granule number times four.
4238
5E38H
ADD A,H 84
ADD Register H (the granule number) to Register A (four times it): the granule number times five, the sector where the granule starts, as each granule is five sectors.
4239
5E39H
LD E,A 5F
Copy the first sector from Register A into Register E: Register Pair DE = the track and sector of the first sector of SYS0/SYS.
423A
5E3AH
LD BC,4DFFH 01 FF 4D
Load Register Pair BC with 4DFFH: Register B = 4DH, the page of the buffer, Register C = FFH, so the first INC C at 4276H gives 00H and a sector is read before the first byte is taken.
423D
5E3DH
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set again: the read position stays in the alternate registers while Register Pairs BC, DE and HL serve the loader.
423E
5E3EH
Record Loop
GOSUB to 4275H to fetch the next byte of SYS0/SYS into Register A: the type of the next load record. 4252H, 4267H loop back here.
4241
5E41H
DEC A 3D
DECrement Register A (the record type) by 1: the Z FLAG is set for type 01H, a block of data to load.
4242
5E42H
If the NZ FLAG is set (not type 01H), JUMP to 425BH to look at the other types.
4244
5E44H
GOSUB to 4275H to fetch the record's length byte into Register A: the count of the load address and data bytes that follow.
4247
5E47H
LD B,A 47
Copy the length from Register A into Register B, the count of bytes still to take.
4248
5E48H
GOSUB to 4275H to fetch the low byte of the load address into Register A.
424B
5E4BH
LD L,A 6F
Copy the low byte of the load address from Register A into Register L.
424C
5E4CH
DEC B 05
DECrement Register B (the count) by 1 for the low address byte; the zero result of a length of 01H is not tested here.
424D
5E4DH
GOSUB to 4275H to fetch the high byte of the load address into Register A.
4250
5E50H
LD H,A 67
Copy the high byte from Register A into Register H: Register Pair HL = the load address.
4251
5E51H
DEC B 05
Data Loop
DECrement Register B (the count) by 1, for the high address byte the first time and for each data byte after it. 4259H loops back here.
4252
5E52H
If the Z FLAG is set (the count is used up), LOOP BACK to 423EH for the next record. A length of 02H loads no bytes, 00H loads 254, 01H loads 255.
4254
5E54H
GOSUB to 4275H to fetch the next data byte into Register A.
4257
5E57H
LD (HL),A 77
Store the data byte from Register A into memory at (HL), Register Pair HL = the load address.
4258
5E58H
INC HL 23
INCrement Register Pair HL (the load address) by 1.
4259
5E59H
Data Loop End
JUMP to 4251H to count the byte and take the next one.
425B
5E5BH
DEC A 3D
DECrement Register A by 1 again: it was the record type minus 1, so the Z FLAG is set for type 02H, the transfer address. 4242H jumps here.
425C
5E5CH
If the Z FLAG is set (type 02H), JUMP to 4269H to fetch the transfer address and go there.
425E
5E5EH
GOSUB to 4275H to fetch the length byte of a record of another type into Register A.
4261
5E61H
LD B,A 47
Copy the length from Register A into Register B, the count of bytes to skip; 00H skips 256.
4262
5E62H
Skip Loop
GOSUB to 4275H to fetch a byte of the record into Register A; it is not used. 4265H loops back here.
4265
5E65H
Skip Loop End
DECrement Register B (the bytes left to skip) and LOOP BACK to 4262H until the record is passed.
4267
5E67H
The record is skipped: LOOP BACK to 423EH to fetch the type of the next record.
4269
5E69H
GOSUB to 4275H to fetch the length byte of the transfer record into Register A; it is not used. 425CH jumps here.
426C
5E6CH
GOSUB to 4275H to fetch the low byte of the transfer address into Register A.
426F
5E6FH
LD L,A 6F
Copy the low byte of the transfer address from Register A into Register L.
4270
5E70H
GOSUB to 4275H to fetch the high byte of the transfer address into Register A.
4273
5E73H
LD H,A 67
Copy the high byte from Register A into Register H: Register Pair HL = the transfer address of SYS0/SYS.
4274
5E74H
JP (HL) E9
JUMP to the address in Register Pair HL, the transfer address of SYS0/SYS, which now runs with interrupts still disabled.
4275H - Fetch the Next Byte of SYS0/SYS
Returns the next byte of the file in Register A. The read position is kept in the alternate registers: Register Pair BC' = the buffer pointer, Register D' = the track, Register E' = the sector. When the buffer is used up the next sector is read into 4D00H, and the sector number runs on to the next track after sector 9.
4275
5E75H
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set: Register Pair BC = the buffer pointer, Register Pair DE = the track and sector of the next read. Called by 423EH and the other loader rows.
4276
5E76H
INC C 0C
INCrement Register C (the low byte of the buffer pointer) by 1: the Z FLAG is set when it wraps from FFH to 00H, the buffer used up.
4277
5E77H
If the NZ FLAG is set (bytes left in the buffer), JUMP to 428DH to fetch the byte at (BC).
4279
5E79H
PUSH BC C5
Save Register Pair BC (4D00H, the start of the buffer) onto the stack, as the read moves Register Pair BC.
427A
5E7AH
LD A,01H 3E 01
Load Register A with 01H, the select bit of drive 0.
427C
5E7CH
LD (37B6H),A 32 B6 37
Store Register A (01H) into 37B6H. BOOT/SYS has E1H in byte 7DH, so its boot sector stores to the drive select latch at 37E1H here to keep drive 0 selected; the B6H in FORMAT's copy sends the byte to 37B6H, which is not the latch. A diskette FORMAT writes stops at 4228H with NO SYSTEM before this row runs.
427F
5E7FH
GOSUB to 42AAH to read track Register D, sector Register E into (BC) (Register Pair BC = 4D00H); the Z FLAG is set when the sector was read.
4282
5E82H
If the NZ FLAG is set (the sector could not be read in two tries), JUMP to 4290H to show DISK ERROR and halt.
4284
5E84H
POP BC C1
Restore Register Pair BC (4D00H, the start of the buffer) from the stack; the read left it at 4E00H.
4285
5E85H
INC E 1C
INCrement Register E (the sector) by 1, to the next sector of SYS0/SYS.
4286
5E86H
LD A,E 7B
Copy the sector from Register E into Register A.
4287
5E87H
SUB 0AH D6 0A
SUBtract 0AH from Register A (the sector): the Z FLAG is set after sector 9, the last of a track, and Register A = 00H.
4289
5E89H
If the NZ FLAG is set (still on the track), JUMP to 428DH to fetch the first byte.
428B
5E8BH
LD E,A 5F
Copy Register A (00H) into Register E: sector 0 of the next track. The sectors are read one after the other from the first extent's start; the other extents of the entry are not looked at.
428C
5E8CH
INC D 14
INCrement Register D (the track) by 1, to the next track.
428D
5E8DH
LD A,(BC) 0A
Fetch the next byte from (BC) (Register Pair BC = the buffer pointer) into Register A. 4277H and 4289H jump here.
428E
5E8EH
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set: the loader's Register Pairs BC, DE and HL are back, Register A = the byte.
428F
5E8FH
RET C9
RETURN to the caller with the byte in Register A.
4290H - Show an Error and Halt
4290H shows DISK ERROR; 4293H shows the message at Register Pair HL (NO SYSTEM from 4228H). Then waits for ENTER and halts.
4290
5E90H
LD HL,42F1H 21 F1 42
Point Register Pair HL to 42F1H, the message DISK ERROR. 421EH and 4282H jump here.
4293
5E93H
GOSUB to 429AH to display the message at Register Pair HL (42F1H, or 42E5H for NO SYSTEM from 4228H).
4296
5E96H
GOSUB to ROM routine at 0040H, the line input, to wait for a line to be typed into the message's own bytes at Register Pair HL, up to Register B characters (Register B = 4DH or 4EH, the high byte the sector read left in Register Pair BC); only ENTER or BREAK ends it.
4299
5E99H
HALT 76
HALT with interrupts disabled since 4203H: the processor stops until RESET is pressed.
429AH - Display Text
Register Pair HL = the text. Shows each character through the ROM up to and including 0DH, or up to 03H without showing it, and returns with Register Pair HL unchanged.
429A
5E9AH
PUSH HL E5
Save Register Pair HL (the text) onto the stack, so the caller gets it back. Register Pair HL = the text, which ends with 0DH (shown) or 03H (not shown). FORMAT calls it at 522AH and 16 more places.
429B
5E9BH
LD A,(HL) 7E
Display Loop
Fetch the next character from (HL) (Register Pair HL = the text pointer) into Register A. 42A6H loops back here.
429C
5E9CH
CP 03H FE 03
Compare Register A against 03H, the end of a text that leaves the cursor after it.
429E
5E9EH
If the Z FLAG is set (03H), JUMP to 42A8H to return without showing it.
42A0
5EA0H
GOSUB to ROM routine at 0033H to display the character in Register A at the cursor; it leaves Register A unchanged and Register Pair DE = 401DH, the display's control block.
42A3
5EA3H
INC HL 23
INCrement Register Pair HL (the text pointer) by 1.
42A4
5EA4H
CP 0DH FE 0D
Compare Register A (the character just shown) against 0DH, ENTER, the other end of a text.
42A6
5EA6H
Display Loop End
If the NZ FLAG is set, LOOP BACK to 429BH for the next character.
42A8
5EA8H
POP HL E1
Restore Register Pair HL (the start of the text) from the stack. 429EH jumps here.
42A9
5EA9H
RET C9
RETURN to the caller with Register Pair HL = the start of the text.
42AAH - Read a Sector
Register D = track, Register E = sector, Register Pair BC = the buffer. Seeks to the track and reads the sector, trying twice. Returns the Z FLAG when read, or the NZ FLAG with Register A = the status AND 5CH.
42AA
5EAAH
PUSH BC C5
Save Register Pair BC (the buffer address) onto the stack for a second try. Register D = track, Register E = sector, Register Pair BC = the buffer. FORMAT calls it at 5426H, 559BH and 56C6H.
42AB
5EABH
GOSUB to 42B2H for the first try to read track Register D, sector Register E into (BC); it returns the Z FLAG when the read succeeded.
42AE
5EAEH
POP HL E1
Restore the buffer address from the stack into Register Pair HL.
42AF
5EAFH
RET Z C8
If the Z FLAG is set (read), RETURN to the caller.
42B0
5EB0H
LD B,H 44
Copy Register H (the high byte of the buffer address) into Register B.
42B1
5EB1H
LD C,L 4D
Copy Register L (the low byte of the buffer address) into Register C: Register Pair BC = the buffer again, and the second try follows; its result goes to the caller.
42B2
5EB2H
LD (37EEH),DE ED 53 EE 37
One Try
Store Register Pair DE into 37EEH-37EFH: Register E (the sector) into the sector register at 37EEH, Register D (the track) into the data register at 37EFH, the track for the SEEK. 42ABH calls here.
42B6
5EB6H
LD HL,37ECH 21 EC 37
Point Register Pair HL to 37ECH, the controller's command and status register.
42B9
5EB9H
LD (HL),1BH 36 1B
Store
1BH into
(HL) (Register Pair HL = 37ECH): SEEK, loading the head, to the track in the data register.
| 1771 FDC Command: 1BH (00011011) | | Function Description |
| 0 | 0 | 0 | 1 | 1 | 0 | 1 | 1 | | Command=Seek (bits 7-4 = 0001) h = 1: head load and settle delay V = 0: no verify r1 r0 = 11: 15 ms stepping rate |
42BB
5EBBH
PUSH AF F5
Save Register Pair AF onto the stack: PUSH and POP pass time while the controller sets its BUSY bit.
42BC
5EBCH
POP AF F1
Restore Register Pair AF from the stack; with 42BBH, 42BDH and 42BEH a short delay after the command.
42BD
5EBDH
PUSH AF F5
Save Register Pair AF onto the stack, the second PUSH of the delay after the command.
42BE
5EBEH
POP AF F1
Restore Register Pair AF from the stack, the end of the delay after the SEEK command.
42BF
5EBFH
LD A,(HL) 7E
Wait for the Seek
Fetch the controller's status from (HL) (Register Pair HL = 37ECH) into Register A. 42C1H loops back here.
42C0
5EC0H
RRCA 0F
Rotate Register A (the status) right, circularly: bit 0, BUSY, goes into the CARRY FLAG.
42C1
5EC1H
If the CARRY FLAG is set (BUSY), LOOP BACK to 42BFH until the SEEK ends.
42C3
5EC3H
LD (HL),88H 36 88
Store
88H into
(HL) (Register Pair HL = 37ECH): READ SECTOR for the sector in the sector register.
| 1771 FDC Command: 88H (10001000) | | Function Description |
| 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | | Command=Read Sector (bits 7-5 = 100) m = 0: one sector b = 1: IBM sector length E = 0: no head load delay |
42C5
5EC5H
PUSH DE D5
Save Register Pair DE (the track and sector) onto the stack, as Register Pair DE serves as the pointer to the data register.
42C6
5EC6H
LD DE,37EFH 11 EF 37
Point Register Pair DE to 37EFH, the controller's data register.
42C9
5EC9H
PUSH BC C5
Save Register Pair BC (the buffer pointer) onto the stack; with 42CAH a delay after the command.
42CA
5ECAH
POP BC C1
Restore Register Pair BC (the buffer pointer) from the stack, the end of the delay after READ SECTOR.
42CB
5ECBH
JUMP to 42D8H, which goes on to 42D0H to look at the status.
42CD
5ECDH
RRCA 0F
Not Ready for a Byte
Rotate Register A (the status) right, circularly: bit 0, BUSY, goes into the CARRY FLAG. 42D3H jumps here.
42CE
5ECEH
If the NO CARRY FLAG is set (no longer BUSY: the read has ended), JUMP to 42DAH to check the result.
42D0
5ED0H
LD A,(HL) 7E
Read Loop
Fetch the controller's status from (HL) (Register Pair HL = 37ECH) into Register A. 42D8H jumps here.
42D1
5ED1H
BIT 1,A CB 4F
Test bit 1 of Register A (the status), DATA REQUEST: set when a byte is waiting in the data register.
42D3
5ED3H
If the Z FLAG is set (no byte waiting), JUMP to 42CDH to see whether the read is still going on.
42D5
5ED5H
LD A,(DE) 1A
Fetch the byte from the data register at (DE) (Register Pair DE = 37EFH) into Register A.
42D6
5ED6H
LD (BC),A 02
Store the byte from Register A into (BC) (Register Pair BC = the buffer pointer).
42D7
5ED7H
INC BC 03
INCrement Register Pair BC (the buffer pointer) by 1.
42D8
5ED8H
Read Loop End
JUMP to 42D0H for the next status check. 42CBH jumps here.
42DA
5EDAH
LD A,(HL) 7E
Fetch the controller's final status from (HL) (Register Pair HL = 37ECH) into Register A. 42CEH jumps here.
42DB
5EDBH
AND 5CH E6 5C
AND Register
A with
5CH, keeping the error bits of a read: the Z FLAG is set when the read succeeded.
| 1771 Status after Read Sector, AND 5CH | | Function Description |
| 0 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | | Bits kept by AND 5CH: 6: F9H or F8H data mark 4: record not found 3: CRC error 2: lost data Bit 5 (FAH or F8H mark) is not kept |
42DD
5EDDH
POP DE D1
Restore Register Pair DE (the track and sector) from the stack.
42DE
5EDEH
RET Z C8
If the Z FLAG is set (no error), RETURN with Register A = 00H.
42DF
5EDFH
LD (HL),D0H 36 D0
Store
D0H into
(HL) (Register Pair HL = 37ECH): FORCE INTERRUPT, stopping the controller after the error.
| 1771 FDC Command: D0H (11010000) | | Function Description |
| 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | | Command=Force Interrupt (bits 7-4 = 1101) I3-I0 = 0000: end the command, no interrupt |
42E1
5EE1H
RET C9
RETURN with the NZ FLAG set and Register A = the error bits of the status.
42E2H - The Texts of the Boot Sector
The screen clear and the two messages, shown through 429AH.
42E2-42E4
5EE2H-5EE4H
DEFB 1CH, 1FH, 03H 1C 1F 03
Shown by 4207H: 1CH moves the cursor to the top left, 1FH erases to the end of the screen, 03H ends the text.
42E5-42F0
5EE5H-5EF0H
DEFB 17H, E8H / DEFM "NO SYSTEM" / DEFB 0DH 17 E8 4E 4F 20 53 59 53 54 45 4D 0D
Shown by 4228H: 17H selects 32 characters per line, E8H gives 40 spaces (C0H plus 40), then the text and ENTER.
42F1-42FD
5EF1H-5EFDH
DEFB 17H, E8H / DEFM "DISK ERROR" / DEFB 0DH 17 E8 44 49 53 4B 20 45 52 52 4F 52 0D
Shown by 4290H: 17H selects 32 characters per line, E8H gives 40 spaces (C0H plus 40), then the text and ENTER.
42FE
5EFEH
DEFB EBH EB
Byte FEH of the boot sector, not used by the code; BOOT/SYS holds the same EBH here.
5EFF
DEFS 1
Not in the file: the load records end at 5EFEH, so the LDIR at 5225H copies whatever memory holds at 5EFFH into 42FFH, the last byte of the boot sector FORMAT writes.