LDOS 5.3.1 for the Model III - REPAIR/CMD Disassembled
Page Customization
Page Index
REPAIR/CMD
Other Navigation
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
| Step | What Happens |
|---|---|
| The drive | The 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 sector | Cylinder 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 GAT | Two 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 directory | HIT 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 end | The 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.
| Address | Contents |
|---|---|
| 5200H-52FFH | 256 bytes |
| 5300H-53C5H | 198 bytes |
Sections of the Disassembly
| Address | Contents |
|---|---|
| 5200H | Entry: the Banner and the Drive |
| 5225H | The Boot Sector: the Directory Cylinder Byte |
| 5246H | The GAT: Sides, Cylinders and the Configuration Byte |
| 5293H | The HIT and the Directory Sectors |
| 52C2H | Cylinder 0 Again and the End |
| 52F3H | Write With the Deleted Data Mark, Read, and the Error Exits |
| 531FH | The Texts, the Drive Cell and the Buffer |
Memory REPAIR/CMD Uses
| Address | Contents |
|---|---|
| 4030H, 4409H, 428AH, 4467H | @ABORT, @ERROR, @LOGOT and @DSPLY. |
| 442BH | SFLAG$: bit 5 a JCL job runs (52EAH). |
| 4763H, 4768H, 4772H, 4777H | SYS0/SYS's WRSECT, WRPROT, VERSEC and RDSECT: the sector routines, drive Register C, cylinder Register D, sector Register E, buffer Register Pair HL. |
| 478FH | GETDCT: 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-54FFH | The 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
| Address | Contents |
|---|---|
| 5200H | The start of REPAIR/CMD, the transfer address of the file. |
| 52F3H | Write the buffer with the deleted data mark and verify it: the Z FLAG when good, else the NZ FLAG and Register A = the error. |
| 52FCH | Read cylinder Register D, sector Register E into 5400H; returns only when the read is good (or error 06H). |
| 5309H | Display 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.
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.
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.
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.
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).
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.
531FH - The Texts, the Drive Cell and the Buffer
The banner, the three messages, then the cell and the buffer beyond the file.