LDOS 5.3.1 for the Model III - REPAIR/CMD Disassembled

Page Customization

Introduction/Summary

LDOS 5.3.1 REPAIR/CMD Disassembly - Making a Diskette of Another DOS Readable (Model III)

REPAIR/CMD changes the system areas of a diskette written by another operating system so that LDOS can read its files. The command is REPAIR :d. The manual (M-40-060) says it is needed on the Model III to read a non-DOS diskette made on the Model I or one made by a Model I LDOS before 5.0.2, that TRSDOS 1.2 and 1.3 diskettes must be copied with CONV instead and never repaired, and that a repaired diskette may no longer be readable by the system that made it, because the data address mark of its directory changes; it advises repairing a backup copy. Its list of what REPAIR does: the directory cylinder gets the LDOS data address mark, DIR/SYS is made readable, the excess cylinder byte is checked, the granules per cylinder byte is set, bit 7 of the directory cylinder byte of the boot sector is stripped (for DOSPLUS diskettes), and the system information sectors are written.

The file is a load module of 517 bytes: a record of type 1FH with the text Copyright 1991 MISOSYS, Inc., All rights reserved, two load blocks for 5200H-53C5H (454 bytes) and the transfer address record for 5200H. Every sector goes through one buffer beyond the file, 5400H-54FFH. REPAIR works with the disk routines of SYS0/SYS: RDSECT (4777H), WRSECT (4763H, normal data address mark), WRPROT (4768H, the deleted data mark the LDOS directory uses) and VERSEC (4772H), with Index Register IY at the drive code table that GETDCT (478FH) finds.

What REPAIR Does

StepWhat Happens
The driveThe banner is displayed; :d gives the drive (no colon: drive 0; a colon and no digit 0-7: error 20H). GETDCT points Index Register IY at its drive code table; there is no @CKDRV (5200H).
The boot sectorCylinder 0, sector 0: bit 7 of byte 02H, the directory cylinder, is cleared; the cylinder goes into the drive code table (+09H) and the sector is written back. A drive with bit 4 of +04H set (its own kind of driver, a hard disk) ends here with -Nothing done- (5225H).
The GATTwo sides only for an LDOS GAT (byte CBH 40H-6FH, bit 5 of CDH); byte CCH = the cylinders less 35, counted from the lock out table; byte CDH rebuilt from the drive code table; written back with the deleted data mark and verified (5246H).
The HIT and the directoryHIT byte 01H = C4H, the hash of DIR/SYS; sectors 2 up rewritten with the deleted data mark; in sector 3 DIR/SYS gets a blank access password, and its ending record number sets the last sector (5293H).
Cylinder 0 and the endThe boot sector is written once more with the directory cylinder; Alien disk conversion complete; Register Pair HL = 0000H, or FFFFH after an error, which ends a JCL job at @ABORT (52C2H).

About This Page

The site has no Model I page of REPAIR/CMD, so this page is written from the bytes of the Model III file alone. Every byte of the file is shown at its address. Found in the code, against the manual's list: the granules go into bits 2-0 of byte CDH of the GAT, and byte CCH gets the excess cylinders, not the granules per cylinder (5270H-528AH); the loop that would write the sectors of cylinder 0 runs once and only writes the boot sector again, so no system information sector is written (52C2H-52D9H); byte CDH is built from the drive code table alone, so bits 4 and 3 end clear, bit 3 being the directory date format of LDOS 5.3 that DATECONV sets (528AH); REPAIR does not test the drive with @CKDRV; the text REPAIR aborted (5313H) is reached by no instruction; the drive number stored at 53C6H is not read again.

Memory Map

Load Blocks in File Order

The two load blocks of the file, after the copyright record: 454 bytes, 5200H-53C5H. The transfer address is 5200H.

AddressContents
5200H-52FFH256 bytes
5300H-53C5H198 bytes

Sections of the Disassembly

AddressContents
5200HEntry: the Banner and the Drive
5225HThe Boot Sector: the Directory Cylinder Byte
5246HThe GAT: Sides, Cylinders and the Configuration Byte
5293HThe HIT and the Directory Sectors
52C2HCylinder 0 Again and the End
52F3HWrite With the Deleted Data Mark, Read, and the Error Exits
531FHThe Texts, the Drive Cell and the Buffer

Memory REPAIR/CMD Uses

AddressContents
4030H, 4409H, 428AH, 4467H@ABORT, @ERROR, @LOGOT and @DSPLY.
442BHSFLAG$: bit 5 a JCL job runs (52EAH).
4763H, 4768H, 4772H, 4777HSYS0/SYS's WRSECT, WRPROT, VERSEC and RDSECT: the sector routines, drive Register C, cylinder Register D, sector Register E, buffer Register Pair HL.
478FHGETDCT: Index Register IY = the drive code table of drive Register C (5222H).
Drive code table +03H, +04H, +08H, +09H+03H bit 6 double density; +04H bit 4 own driver, bit 5 two sides (reset and set by 5249H, 525EH), bit 7 cylinder 0 in single density; +08H bits 7-5 granules on a track less one; +09H the directory cylinder (stored 5233H).
5400H-54FFHThe sector buffer, beyond the file.

Variables

The entry points of REPAIR/CMD, then the data of the file, the operand it changes, and the cells outside the file that it uses, by address.

Entry Points

AddressContents
5200HThe start of REPAIR/CMD, the transfer address of the file.
52F3HWrite the buffer with the deleted data mark and verify it: the Z FLAG when good, else the NZ FLAG and Register A = the error.
52FCHRead cylinder Register D, sector Register E into 5400H; returns only when the read is good (or error 06H).
5309HDisplay the short message of the error in Register A and end with Register Pair HL = FFFFH (5307H: error 20H).

Data in the File

Address
Size
Contents
531FH
1 byte
DEFB 0AH
531FH: 0AH, a new line: the start of the banner displayed by 5208H.
5320H-5354H
53 bytes
DEFM "REPAIR - LDOS Diskette Repair Utility - Version 5.3.1"
5320H-5354H: the name of the program, what it is and its version.
5355H
1 byte
DEFB 0AH
5355H: 0AH, a new line: the copyright goes on the next line.
5356H-5386H
49 bytes
DEFM "Copyright 1991 MISOSYS, Inc., All rights reserved"
5356H-5386H: the copyright line, the same text as the copyright record of the file.
5387H-5388H
2 bytes
DEFB 0AH, 0DH
5387H-5388H: 0AH, a new line, and 0DH, the end of the banner.
5389H-5396H
14 bytes
DEFM "-Nothing done-"
5389H-5396H: the text of 5317H, displayed by @LOGOT for a drive whose code table has bit 4 of +04H set.
5397H
1 byte
DEFB 0DH
5397H: 0DH, the end of the line and of the text.
5398H-53B5H
30 bytes
DEFM "Alien disk conversion complete"
5398H-53B5H: the text of 52DBH, displayed by @LOGOT when every sector is done.
53B6H
1 byte
DEFB 0DH
53B6H: 0DH, the end of the line and of the text.
53B7H-53C4H
14 bytes
DEFM "REPAIR aborted"
53B7H-53C4H: the text of 5313H, which no instruction of the file reaches.
53C5H
1 byte
DEFB 0DH
53C5H: 0DH, the end of the line and of the text, the last byte of the file.
53C6H
1 byte
DEFS 1
53C6H: not in the file. The drive number, stored by 521FH and read by no instruction of REPAIR.
5400H-54FFH
256 bytes
DEFS 256
5400H-54FFH: not in the file. The buffer of every read and write (52FCH): the boot sector (directory cylinder at 5402H), the GAT (54BFH-5460H the lock out table, 54CBH-54CDH), the HIT (5401H), the directory sectors (5412H-5414H in sector 3).

Operands Changed While It Runs

Address
Size
Contents
52E5H-52E6H
2 bytes
The operand of LD SP,0000H at 52E4H: the Stack Pointer as LDOS left it (5200H).

Cells Outside the File That REPAIR/CMD Uses

Address
Size
Contents
53C6H
1 byte
The drive number (521FH), not read again.
5400H-54FFH
256 bytes
The sector buffer: the boot sector, the GAT, the HIT and the directory sectors in turn.

Disassembly

5200H - Entry: the Banner and the Drive

LDOS Ready loads REPAIR/CMD at 5200H-53C5H and jumps to 5200H, the transfer address, with Register Pair HL at the rest of the command line after the word REPAIR and the spaces after it. The command is REPAIR :d (M-40-060). The Stack Pointer is kept in the operand of LD SP at 52E4H for every exit; the banner is displayed; a colon and a digit 0-7 give the drive, no colon gives drive 0, and a colon with any other character gives error 20H, Illegal drive number. The drive is not checked by @CKDRV: GETDCT only points Index Register IY at its drive code table.

5200
LD (52E5H),SP ED 73 E5 52
Store the Stack Pointer at 52E5H-52E6H, the operand of LD SP,0000H at 52E4H: every exit of REPAIR goes through 52E4H with the stack as LDOS left it.
5204
PUSH HL E5
Save Register Pair HL (the pointer to the command line after REPAIR) to the stack across the display of the banner.
5205
LD HL,531FH 21 1F 53
Point Register Pair HL to 531FH, the banner: a new line, REPAIR - LDOS Diskette Repair Utility - Version 5.3.1, the copyright line and 0DH.
5208
GOSUB to 4467H, @DSPLY, to display the text at Register Pair HL (531FH) up to its 0DH.
520B
POP HL E1
Restore Register Pair HL from the stack: the pointer to the command line, where the drive is given.
520C
LD C,00H 0E 00
Load Register C with 00H, drive 0: the drive REPAIR works on when the command line gives none.
520E
LD A,(HL) 7E
Fetch the next character of the command line at Register Pair HL into Register A.
520F
CP 3AH FE 3A
Compare Register A (the character) against 3AH, a colon, the start of a drive specification.
5211
If the NZ FLAG is set (no colon), JUMP to 521EH with Register C = 00H: REPAIR works on drive 0.
5213
INC HL 23
INCrement Register Pair HL past the colon to the character of the drive number.
5214
LD A,(HL) 7E
Fetch the drive character at Register Pair HL into Register A.
5215
SUB 30H D6 30
SUBtract 30H, the character 0, from Register A: the digits 0-7 become 00H-07H.
5217
CP 08H FE 08
Compare Register A (the drive number) against 08H: the CARRY FLAG is set for drives 0-7.
5219
If the NO CARRY FLAG is set (not a digit 0-7), JUMP to 5307H, inside the LD BC at 5306H, to give error 20H, Illegal drive number.
521C
LD C,A 4F
Copy Register A (the drive number, 00H-07H) into Register C, the drive for GETDCT and the disk routines.
521D
INC HL 23
INCrement Register Pair HL past the drive digit. Nothing on the command line after it is read.
521E
LD A,C 79
Copy Register C (the drive number) into Register A.
521F
LD (53C6H),A 32 C6 53
Store Register A (the drive number) at 53C6H, the first byte after the file. No instruction of REPAIR reads 53C6H.
5222
GOSUB to 478FH, GETDCT, to point Index Register IY at the drive code table of drive Register C (4700H + Register C x 10). Register Pair HL is kept.

5225H - The Boot Sector: the Directory Cylinder Byte

Cylinder 0, sector 0 is read into the buffer at 5400H. Byte 02H of the boot sector is the directory cylinder (BOOT/SYS of LDOS reads it from there); some other systems keep bit 7 set in it (the manual names DOSPLUS). REPAIR clears bit 7, writes the byte back to the boot sector and into the drive code table (+09H), and writes the sector back with the normal data address mark.

5225
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H: Register D = cylinder 0, Register E = sector 0, the boot sector of the diskette.
5228
GOSUB to 52FCH to read cylinder Register D (00H), sector Register E (00H) of drive Register C into the buffer at 5400H; a read error ends REPAIR there.
522B
LD A,(5402H) 3A 02 54
Fetch byte 02H of the boot sector at 5402H into Register A: the directory cylinder.
522E
AND 7FH E6 7F
Mask Register A with 7FH: bit 7 of the directory cylinder byte is cleared, the change the manual gives for DOSPLUS diskettes.
5230
LD (5402H),A 32 02 54
Store Register A (the directory cylinder with bit 7 clear) back at 5402H, byte 02H of the boot sector in the buffer.
5233
LD (IY+09H),A FD 77 09
Store Register A (the directory cylinder) at +09H of the drive code table at Index Register IY: the drive's directory cylinder for the reads below.
5236
GOSUB to 4763H, WRSECT, to write the buffer at Register Pair HL (5400H) to cylinder Register D (00H), sector Register E (00H) of drive Register C with the normal data address mark.
5239
If the NZ FLAG is set (the write failed, Register A = the error), JUMP to 5309H to display the error and end REPAIR.
523C
LD D,(IY+09H) FD 56 09
Load Register D with +09H of the drive code table at Index Register IY: the directory cylinder, for the reads of the directory. Register E is still 00H.
523F
BIT 4,(IY+04H) FD CB 04 66
Test bit 4 of +04H of the drive code table at Index Register IY: set for a drive with its own kind of driver (a hard disk), not a floppy drive.
5243
If the NZ FLAG is set (bit 4 set), JUMP to 5317H, inside the LD IX at 5316H, to display -Nothing done- and end with an error: the boot sector is already written back.

5246H - The GAT: Sides, Cylinders and the Configuration Byte

The GAT (directory cylinder, sector 0) is read into 5400H. Two sides are taken only from a GAT of LDOS: its byte CBH (the version, 53H on this diskette) must be 40H-6FH and bit 5 of byte CDH set. The count of cylinders comes from the lock out table 60H-BFH: the last byte that is not FFH (FFH marks a cylinder the diskette does not have), and byte CCH gets the cylinders less 35. Byte CDH is rebuilt from the drive code table: bit 7 from +04H bit 7 (cylinder 0 in single density), bit 6 from +03H bit 6 (double density), bit 5 from +04H bit 5 (two sides), bits 2-0 from bits 7-5 of +08H (the granules on a track less one); bits 4-3 end clear. The GAT is written back with the deleted data mark and verified.

5246
GOSUB to 52FCH to read cylinder Register D (the directory cylinder), sector Register E (00H), the GAT, into the buffer at 5400H; Register Pair HL comes back as 5400H.
5249
RES 5,(IY+04H) FD CB 04 AE
Reset bit 5 of +04H of the drive code table at Index Register IY: one side, unless the GAT below shows an LDOS diskette with two.
524D
LD L,CBH 2E CB
Load Register L with CBH: Register Pair HL = 54CBH, byte CBH of the GAT, the version of the DOS that formatted the diskette.
524F
LD A,(HL) 7E
Fetch byte CBH of the GAT at Register Pair HL (54CBH) into Register A: 53H on this diskette (version 5.3).
5250
CP 40H FE 40
Compare Register A (the version byte) against 40H: the CARRY FLAG is set below 40H.
5252
If the CARRY FLAG is set (below 40H: not a GAT of this family), JUMP to 5262H and keep one side.
5254
CP 70H FE 70
Compare Register A (the version byte) against 70H: the NO CARRY FLAG is set for 70H and above.
5256
If the NO CARRY FLAG is set (70H or above), JUMP to 5262H and keep one side.
5258
LD L,CDH 2E CD
Load Register L with CDH: Register Pair HL = 54CDH, byte CDH of the GAT, the configuration byte.
525A
BIT 5,(HL) CB 6E
Test bit 5 of the configuration byte at Register Pair HL (54CDH): set on a diskette formatted with two sides.
525C
If the Z FLAG is set (bit 5 clear: one side), JUMP to 5262H.
525E
SET 5,(IY+04H) FD CB 04 EE
Set bit 5 of +04H of the drive code table at Index Register IY: the drive is used with two sides, as the GAT says.
5262
LD L,BFH 2E BF
Load Register L with BFH: Register Pair HL = 54BFH, the last byte of the lock out table of the GAT (60H-BFH, one byte for each cylinder).
5264
LD B,60H 06 60
Load Register B with 60H, the count of the loop: the 96 bytes of the lock out table, 54BFH down to 5460H.
5266
LD A,(HL) 7E
Fetch the lock out byte at Register Pair HL into Register A.
5267
INC A 3C
INCrement Register A: the Z FLAG is set when the byte was FFH, a cylinder the diskette does not have.
5268
If the NZ FLAG is set (not FFH: the last cylinder of the diskette), JUMP to 526DH with Register B = that cylinder + 1, the count of cylinders.
526A
DEC L 2D
DECrement Register L to the lock out byte of the cylinder before, Register Pair HL one byte lower.
526B
DECrement Register B and LOOP BACK to 5266H until it is 00H: with every byte FFH, Register B ends 00H.
526D
LD A,DDH 3E DD
Load Register A with DDH, the negative of 23H (35 decimal).
526F
ADD A,B 80
ADD Register B (the count of cylinders) to Register A: Register A = the cylinders less 35, the form of byte CCH of the GAT.
5270
LD L,CCH 2E CC
Load Register L with CCH: Register Pair HL = 54CCH, byte CCH of the GAT, the cylinders beyond 35.
5272
LD (HL),A 77
Store Register A (the cylinders less 35) at Register Pair HL (54CCH), the excess cylinder byte of the GAT.
5273
LD A,(IY+04H) FD 7E 04
Fetch +04H of the drive code table at Index Register IY into Register A.
5276
AND A0H E6 A0
Mask Register A with A0H: bit 7 (cylinder 0 in single density) and bit 5 (two sides) of +04H are kept.
5278
LD B,A 47
Copy Register A (bits 7 and 5 of +04H) into Register B, where the new configuration byte is built.
5279
LD A,(IY+03H) FD 7E 03
Fetch +03H of the drive code table at Index Register IY into Register A.
527C
AND 40H E6 40
Mask Register A with 40H: bit 6 of +03H, the drive works in double density, is kept.
527E
OR B B0
OR Register B (bits 7 and 5) into Register A: bits 7, 6 and 5 of the new configuration byte.
527F
LD B,A 47
Copy Register A (the configuration byte so far) into Register B.
5280
LD A,(IY+08H) FD 7E 08
Fetch +08H of the drive code table at Index Register IY into Register A: bits 7-5 the granules on a track less one, bits 4-0 the sectors of a granule less one.
5283
RLCA 07
Rotate Register A left (RLCA): bit 7 goes into bit 0.
5284
RLCA 07
Rotate Register A left (RLCA) again: bits 7-6 of +08H are now bits 1-0 of Register A.
5285
RLCA 07
Rotate Register A left (RLCA) a third time: bits 7-5 of +08H are now bits 2-0 of Register A.
5286
AND 07H E6 07
Mask Register A with 07H: only the granules on a track less one are kept, in bits 2-0.
5288
OR B B0
OR Register B (bits 7, 6 and 5) into Register A: the new configuration byte, bits 4-3 clear.
5289
INC L 2C
INCrement Register L to CDH: Register Pair HL = 54CDH, the configuration byte of the GAT.
528A
LD (HL),A 77
Store Register A (the new configuration byte) at Register Pair HL (54CDH). Bit 3, the date format of LDOS 5.3, is cleared even on an LDOS 5.3 diskette.
528B
LD L,00H 2E 00
Load Register L with 00H: Register Pair HL = 5400H, the start of the buffer, for the write.
528D
GOSUB to 52F3H to write the buffer at Register Pair HL (5400H) to cylinder Register D, sector Register E (00H) with the deleted data mark and verify it.
5290
If the NZ FLAG is set (the write or the verify failed, Register A = the error), JUMP to 5309H to display the error and end.

5293H - The HIT and the Directory Sectors

Sector 1 of the directory cylinder is the hash index table (HIT); its byte 01H belongs to DIR/SYS's directory record (the first record of sector 3) and gets C4H, the hash of the name DIR/SYS. Then sectors 2 up are read and written back with the deleted data mark, the mark of the LDOS directory. In sector 3 the access password of DIR/SYS (+12H-+13H of its record) becomes 4296H, the hash of a blank password, so DIR/SYS can be opened and read; the record's ending record number (+14H, the count of directory sectors) sets how many sectors are done: sectors 2 to that number less 1.

5293
INC E 1C
INCrement Register E to 01H: sector 1 of the directory cylinder, the hash index table.
5294
GOSUB to 52FCH to read cylinder Register D, sector Register E (01H) into the buffer at 5400H; Register Pair HL comes back as 5400H.
5297
INC L 2C
INCrement Register L: Register Pair HL = 5401H, byte 01H of the hash index table, the entry of DIR/SYS's record.
5298
LD (HL),C4H 36 C4
Store C4H at Register Pair HL (5401H): the hash of DIR/SYS, so a search for DIR/SYS finds its record.
529A
DEC L 2D
DECrement Register L: Register Pair HL = 5400H again, the start of the buffer, for the write.
529B
GOSUB to 52F3H to write the buffer at Register Pair HL (5400H) to cylinder Register D, sector Register E (01H) with the deleted data mark and verify it.
529E
If the NZ FLAG is set (the write or the verify failed, Register A = the error), JUMP to 5309H to display the error and end.
52A1
LD B,08H 06 08
Load Register B with 08H, the count of the loop until sector 3 gives the real count of the directory sectors.
52A3
INC E 1C
INCrement Register E to the next sector of the directory cylinder (02H first).
52A4
GOSUB to 52FCH to read cylinder Register D, sector Register E into the buffer at 5400H; Register Pair HL comes back as 5400H.
52A7
LD A,E 7B
Copy Register E (the sector just read) into Register A.
52A8
CP 03H FE 03
Compare Register A (the sector) against 03H, the sector whose first record is DIR/SYS's.
52AA
If the NZ FLAG is set (not sector 3), JUMP to 52BAH to write the sector back as it is.
52AC
PUSH HL E5
Save Register Pair HL (5400H, the buffer) to the stack.
52AD
LD HL,4296H 21 96 42
Load Register Pair HL with 4296H, the hash of a blank password (eight spaces).
52B0
LD (5412H),HL 22 12 54
Store Register Pair HL (4296H) at 5412H-5413H, +12H-+13H of DIR/SYS's record: the access password, so DIR/SYS opens for reading without one.
52B3
LD A,(5414H) 3A 14 54
Fetch +14H of DIR/SYS's record at 5414H into Register A: the low byte of its ending record number, the count of the directory's sectors.
52B6
SUB 03H D6 03
SUBtract 03H from Register A: the loop count from sector 3 on, so the last sector done is the count less 1.
52B8
LD B,A 47
Copy Register A (the new count) into Register B, the counter of the DJNZ at 52C0H.
52B9
POP HL E1
Restore Register Pair HL from the stack: 5400H, the buffer.
52BA
GOSUB to 52F3H to write the buffer at Register Pair HL (5400H) to cylinder Register D, sector Register E with the deleted data mark and verify it.
52BD
If the NZ FLAG is set (the write or the verify failed, Register A = the error), JUMP to 5309H to display the error and end.
52C0
DECrement Register B and LOOP BACK to 52A3H until it is 00H: the next directory sector.

52C2H - Cylinder 0 Again and the End

A loop meant for the sectors of cylinder 0 runs once (Register B = 01H): the boot sector is read again, gets the directory cylinder from +09H of the drive code table, the value 5230H stored, and is written back with the normal data address mark. No system information sector (cylinder 0, sector 2) is written, although the manual lists it. Then Alien disk conversion complete is displayed and REPAIR ends through 52E4H with Register Pair HL as the return code: 0000H for success, FFFFH after an error (then @ABORT during a JCL job).

52C2
LD B,01H 06 01
Load Register B with 01H, the count of the loop: only one sector of cylinder 0 is done, sector 0.
52C4
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H: Register D = cylinder 0, Register E = sector 0.
52C7
PUSH BC C5
Save Register Pair BC (Register B the count, Register C the drive) to the stack.
52C8
GOSUB to 52FCH to read cylinder Register D, sector Register E of drive Register C into the buffer at 5400H.
52CB
LD A,(IY+09H) FD 7E 09
Fetch +09H of the drive code table at Index Register IY into Register A: the directory cylinder stored at 5233H.
52CE
LD (5402H),A 32 02 54
Store Register A (the directory cylinder) at 5402H, byte 02H of the sector in the buffer, the place of the directory cylinder in the boot sector.
52D1
POP BC C1
Restore Register Pair BC from the stack: Register B the count, Register C the drive.
52D2
GOSUB to 4763H, WRSECT, to write the buffer at Register Pair HL (5400H) to cylinder Register D, sector Register E of drive Register C with the normal data address mark.
52D5
If the NZ FLAG is set (the write failed, Register A = the error), JUMP to 5309H to display the error and end.
52D8
INC DE 13
INCrement Register Pair DE to the next sector of cylinder 0.
52D9
DECrement Register B and LOOP BACK to 52C7H until it is 00H: with Register B = 01H the loop ends at once.
52DB
LD HL,5398H 21 98 53
Point Register Pair HL to 5398H, the text Alien disk conversion complete ended by 0DH.
52DE
GOSUB to 428AH, @LOGOT, to display the text at Register Pair HL (5398H) and write it to the job log.
52E1
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, the return code of a program that ended without an error.
52E4
LD SP,0000H 31 00 00
Load the Stack Pointer with the value saved at 5200H: the operand 52E5H-52E6H, 0000H in the file. 5311H comes here with Register Pair HL = FFFFH.
52E7
LD A,H 7C
Copy Register H (the high byte of the return code) into Register A.
52E8
OR L B5
OR Register L (the low byte) into Register A: the Z FLAG for the return code 0000H.
52E9
RET Z C8
If the Z FLAG is set (no error), RETurn to LDOS with Register Pair HL = 0000H.
52EA
LD A,(442BH) 3A 2B 44
Fetch SFLAG$ from 442BH into Register A: bit 5 is set while a JCL job runs.
52ED
BIT 5,A CB 6F
Test bit 5 of Register A (SFLAG$): the Z FLAG when no JCL job runs.
52EF
RET Z C8
If the Z FLAG is set (no JCL job), RETurn to LDOS with Register Pair HL = FFFFH, the return code of an error.
52F0
JUMP to 4030H, @ABORT: the JCL job is ended after the error.

52F3H - Write With the Deleted Data Mark, Read, and the Error Exits

52F3H writes a directory sector with the deleted data mark and verifies it: the verify must find that mark (error 06H), so it returns the Z FLAG only then. 52FCH reads a sector into 5400H, a read that finds the deleted data mark (06H) counts as good; any other error goes on into 5309H. 5307H (inside the LD BC at 5306H) gives error 20H, 5309H displays the short message of the error in Register A and returns, and both end with Register Pair HL = FFFFH. 5317H (inside the LD IX at 5316H) displays -Nothing done-; 5313H, which would display REPAIR aborted, is not reached by any instruction of the file.

52F3
GOSUB to 4768H, WRPROT, to write the buffer at Register Pair HL to cylinder Register D, sector Register E of drive Register C with the deleted data mark.
52F6
If the Z FLAG is set (the write worked), GOSUB to 4772H, VERSEC, to verify cylinder Register D, sector Register E: it returns Register A = 06H for a sector with the deleted data mark.
52F9
CP 06H FE 06
Compare Register A (the error of the write, or of the verify) against 06H: the Z FLAG when the verify found the deleted data mark.
52FB
RET C9
RETurn to the caller with the Z FLAG (the sector is good) or the NZ FLAG and Register A = the error.
52FC
LD HL,5400H 21 00 54
Point Register Pair HL to 5400H, the buffer beyond the file that every sector is read into.
52FF
GOSUB to 4777H, RDSECT, to read cylinder Register D, sector Register E of drive Register C into the buffer at Register Pair HL (5400H).
5302
RET Z C8
If the Z FLAG is set (read with the normal data address mark), RETurn to the caller.
5303
CP 06H FE 06
Compare Register A (the error of the read) against 06H, the sector carried the deleted data mark of a directory.
5305
RET Z C8
If the Z FLAG is set (error 06H), RETurn to the caller: the sector was read, only its mark differs.
5306
LD BC,203EH 01 3E 20
Load Register Pair BC with 203EH. Nothing uses Register Pair BC here: the 01H byte only lets the read error in Register A pass over 3EH 20H at 5307H-5308H, which the jump from 5219H takes as LD A,20H, error 20H, Illegal drive number.
5309
OR C0H F6 C0
OR C0H into Register A (the error): bit 7, @ERROR returns to the caller, and bit 6, the short message.
530B
GOSUB to 4409H, @ERROR, to display the short message of the error in Register A; with bit 7 set it returns here.
530E
LD HL,FFFFH 21 FF FF
Load Register Pair HL with FFFFH, the return code of an error. 531DH comes here after @LOGOT.
5311
JUMP to 52E4H to put back the Stack Pointer and end with the return code FFFFH.
5313
LD HL,53B7H 21 B7 53
Point Register Pair HL to 53B7H, the text REPAIR aborted ended by 0DH. No instruction of the file jumps to 5313H.
5316
LD IX,5389H DD 21 89 53
Load Index Register IX with 5389H. Nothing uses Index Register IX here: the DD byte only lets 5313H pass over 21H 89H 53H at 5317H-5319H, which the jump from 5243H takes as LD HL,5389H, the text -Nothing done-.
531A
GOSUB to 428AH, @LOGOT, to display the text at Register Pair HL (5389H, or 53B7H) and write it to the job log.
531D
JUMP to 530EH to end with Register Pair HL = FFFFH, the return code of an error.

531FH - The Texts, the Drive Cell and the Buffer

The banner, the three messages, then the cell and the buffer beyond the file.

531F
DEFB 0AH 0A
531FH: 0AH, a new line: the start of the banner displayed by 5208H.
5320-5354
DEFM "REPAIR - LDOS Diskette Repair Utility - Version 5.3.1" 52 45 50 41 49 52 20 2D 20 4C 44 4F 53 20 44 69 73 6B 65 74 74 65 20 52 65 70 61 69 72 20 55 74 69 6C 69 74 79 20 2D 20 56 65 72 73 69 6F 6E 20 35 2E 33 2E 31
5320H-5354H: the name of the program, what it is and its version.
5355
DEFB 0AH 0A
5355H: 0AH, a new line: the copyright goes on the next line.
5356-5386
DEFM "Copyright 1991 MISOSYS, Inc., All rights reserved" 43 6F 70 79 72 69 67 68 74 20 31 39 39 31 20 4D 49 53 4F 53 59 53 2C 20 49 6E 63 2E 2C 20 41 6C 6C 20 72 69 67 68 74 73 20 72 65 73 65 72 76 65 64
5356H-5386H: the copyright line, the same text as the copyright record of the file.
5387-5388
DEFB 0AH, 0DH 0A 0D
5387H-5388H: 0AH, a new line, and 0DH, the end of the banner.
5389-5396
DEFM "-Nothing done-" 2D 4E 6F 74 68 69 6E 67 20 64 6F 6E 65 2D
5389H-5396H: the text of 5317H, displayed by @LOGOT for a drive whose code table has bit 4 of +04H set.
5397
DEFB 0DH 0D
5397H: 0DH, the end of the line and of the text.
5398-53B5
DEFM "Alien disk conversion complete" 41 6C 69 65 6E 20 64 69 73 6B 20 63 6F 6E 76 65 72 73 69 6F 6E 20 63 6F 6D 70 6C 65 74 65
5398H-53B5H: the text of 52DBH, displayed by @LOGOT when every sector is done.
53B6
DEFB 0DH 0D
53B6H: 0DH, the end of the line and of the text.
53B7-53C4
DEFM "REPAIR aborted" 52 45 50 41 49 52 20 61 62 6F 72 74 65 64
53B7H-53C4H: the text of 5313H, which no instruction of the file reaches.
53C5
DEFB 0DH 0D
53C5H: 0DH, the end of the line and of the text, the last byte of the file.
53C6
DEFS 1
53C6H: not in the file. The drive number, stored by 521FH and read by no instruction of REPAIR.
5400-54FF
DEFS 256
5400H-54FFH: not in the file. The buffer of every read and write (52FCH): the boot sector (directory cylinder at 5402H), the GAT (54BFH-5460H the lock out table, 54CBH-54CDH), the HIT (5401H), the directory sectors (5412H-5414H in sector 3).