LDOS 5.3.1 for the Model III - DATECONV/CMD Disassembled
Page Customization
Page Index
DATECONV/CMD
Other Navigation
Introduction/Summary
LDOS 5.3.1 DATECONV/CMD Disassembly - Putting a Diskette's Directory into the 5.3 Date Format (Model III)
LDOS 5.3 keeps the time and a year from 1980 to 2011 in bytes +12H-+13H of each directory record, two bytes that earlier releases used for the access password of the file, and marks a diskette whose directory is kept that way with bit 3 of the configuration byte of its allocation table. DATECONV/CMD converts the directory of a diskette written by an earlier release: every file gets a time of 00:00 and the year of its date, and the diskette gets the mark. The command is DATECONV :d; the code takes nothing from the command line but the drive.
The file is a load module of 695 bytes: a record of type 1FH with the text Copyright 1991 MISOSYS, Inc., All rights reserved, three load blocks for 5200H-5473H (628 bytes) and the transfer address record for 5200H. DATECONV issues no supervisor request of its own: it calls the resident vectors of SYS0/SYS (and @CKDRV, which loads SYS2/SYS) and two ROM routines.
What DATECONV Does
| Step | What Happens |
|---|---|
| The drive | After the spaces of the command line a colon and a digit 0-7 must follow; @CKDRV must find the drive ready. Otherwise error 20H, Illegal drive number, as a short message. A write protected diskette gives Write protected drive! (520FH, 5229H). |
| The allocation table | Sector 0 of the directory cylinder (byte +09H of the drive code table) is read. When bit 3 of its configuration byte (offset CDH) is set the directory is already in this format, and only records whose +12H-+13H hold 4296H, the hash of a blank password, are changed below: any other value there is a time stamp (5241H). |
| A system diskette | On a diskette of an earlier release whose configuration byte does not have bit 7 set: when the first record of directory sector 5 (directory record 3, one of the slots of the system files) is in use, the system information sector (cylinder 0, sector 2) must start with 53H or 63H, else SYSTEM disk conversion requires a 5.3 or 6.3 disk! (524EH). |
| The directory sectors | The number of sectors comes from the ending record number of DIR/SYS (the first record of directory sector 3) less 2, at most 32 (526EH). Sectors 2 onwards are read one by one; every primary record in use with a date (+02H not zero) gets 00H at +12H and the year (bits 2-0 of +02H) at +13H, and is counted. Each sector is written back with the deleted data mark and verified (5284H). |
| BREAK | Tested after every record: Date conversion aborted!, and the sector in the buffer is not written; the sectors written before stay converted and the diskette is not marked (52C1H). |
| The mark | The allocation table is read again, bit 3 of the configuration byte set and the table written back; then n file(s) updated, conversion complete is displayed and written to the job log (52D9H). |
| The end | The program returns to whatever ran it with Register Pair HL = 0000H when it is done or FFFFH after an error or a message; during a JCL job an error ends at @ABORT instead (52FAH). |
The Directory Record's Date
Byte +01H bits 3-0 hold the month, byte +02H bits 7-3 the day and bits 2-0 the year. DATECONV leaves them as they are. In the format of this release byte +12H holds the hour (bits 7-3) and bits 5-3 of the minutes (bits 2-0), and byte +13H bits 2-0 of the minutes (bits 7-5) and the year less 1980 (bits 4-0). DATECONV writes 00H to +12H and the year of +02H, 0-7, to +13H: the time 00:00 and a value 0-7, which bits 4-0 of +13H read as the years 1980-1987.
Reading and Writing the Directory
Every sector of the directory cylinder carries the deleted data mark. RDSECT reports such a sector with error 06H after it has read it, and DATECONV takes both 06H and success as a good read (5356H). A sector is written back with WRPROT, which writes the deleted data mark, and checked with VERSEC, which must report 06H (5344H). Any other result goes to @ERROR with bits 7 and 6 of the error number set: the short message, and back to DATECONV, which leaves with Register Pair HL = FFFFH.
About This Page
The Model III file is the Model I file of the same release with the same code at the same addresses; its 11 different bytes are the operands of six calls and loads of resident addresses: @CKDRV 4209H (5229H; Model I 44B8H), @LOGOT 428AH (52F4H, 5374H; Model I 447BH), SFLAG$ 442BH (5300H; Model I 430FH), @DIV 4451H (5315H; Model I 44C4H) and KFLAG$ 429FH (5323H; Model I 4423H). The ROM's delay at 0060H is a JP 01FBH to the same kind of loop on the Model III ROM; the keyboard routine at 002BH is the same.
Every byte of the file is shown at its address, with DEFS rows for 5474H-55FFH, the bytes DATECONV does not load; 5500H-55FFH is its sector buffer. The three message entries at 5369H, 536DH and 5371H overlap: 536DH and 5371H start one byte into the LD IX rows at 536CH and 5370H, whose comments give both readings.
Memory Map
Load Blocks in File Order
The three load blocks of the file in the order LDOS loads them, after the copyright record: 628 bytes, 5200H-5473H without a gap. The transfer address is 5200H.
| Address | Contents |
|---|---|
| 5200H-52FFH | 256 bytes |
| 5300H-53FFH | 256 bytes |
| 5400H-5473H | 116 bytes |
Sections of the Disassembly
| Address | Contents |
|---|---|
| 5200H | Entry: Save the Stack and Show the Banner |
| 520FH | The Drive from the Command Line |
| 5229H | Check the Drive and Read the Allocation Table |
| 524EH | The System Diskette Test |
| 526EH | How Many Directory Sectors |
| 5284H | The Conversion Loop: Each Directory Sector |
| 5289H | Each Directory Record |
| 52C1H | The Next Record and the Next Sector |
| 52D9H | Mark the Diskette and Report |
| 52FAH | The Exit |
| 5309H | Write the Count as a Decimal Number |
| 5322H | Test for BREAK |
| 5344H | Write a Directory Sector |
| 5356H | Read a Sector, and the Disk Errors |
| 5369H | The Messages and the Way Out |
| 5381H | The Texts and the Counter |
Memory DATECONV/CMD Uses
| Address | Contents |
|---|---|
| 0060H | ROM: the delay, Register Pair BC counted down (5332H); on the Model III ROM a JP 01FBH. |
| 002BH | ROM: the keyboard routine, the next key waiting or 00H (5339H). |
| 4030H | @ABORT: the end of the program after an error during a JCL job (5306H). |
| 4409H | @ERROR: the short message of a disk error or of error 20H, then back to the program (5364H). |
| 4467H, 428AH | @DSPLY (the banner) and @LOGOT (the messages and the report, also written to the job log). |
| 4209H | @CKDRV: the check of the drive, which also reads the allocation table and stores the directory cylinder in the drive code table. |
| 4451H | @DIV: Register Pair HL divided by Register A, for the decimal count (5315H). |
| 4700H-474FH | DCT$, the drive code tables: GETDCT (478FH) points Index Register IY at the drive's table, whose +09H is the directory cylinder. |
| 4768H, 4772H, 4777H | WRPROT (write with the deleted data mark), VERSEC (verify) and RDSECT (read), the disk primitives of 5344H and 5356H. |
| 5500H-55FFH | The buffer of the sectors DATECONV reads and writes. |
Variables
The entry points of DATECONV/CMD, then the data of the file and the bytes beyond it that DATECONV uses, the operands it changes, and the cells outside the file that it uses, by address.
Entry Points
| Address | Contents |
|---|---|
| 5200H | The start of DATECONV/CMD, the transfer address of the file. |
| 5289H | Convert one directory record. |
| 52FAH | The exit: Register Pair HL = 0000H or FFFFH. |
| 5309H | Write Register Pair HL as a decimal number right justified in the five bytes at Register Pair DE. |
| 5322H | Test for BREAK: the NZ FLAG when it was pressed. |
| 5344H | Write the buffer at 5500H with the deleted data mark and verify it. |
| 5356H | Read a sector into the buffer at 5500H. |
| 5362H | A disk error (Register A) as a short message through @ERROR, then the exit. |
| 5369H | Display a message (5369H, 536DH, 5371H) through @LOGOT, then the exit. |
| 537DH | Error 20H, Illegal drive number. |
Data in the File and Beyond It
| Address Size | Contents |
|---|---|
| 5381H-53AFH 47 bytes | DEFM "DATECONV - LDOS Date Conversion - Version 5.3.1" 5381H-53AFH: the first line of the banner, displayed by @DSPLY from 520BH: the name and the version of the program. |
| 53B0H-53B0H 1 byte | DEFB 0AH 53B0H: 0AH, a line feed: the copyright goes on the next line within the same text. |
| 53B1H-53E1H 49 bytes | DEFM "Copyright 1991 MISOSYS, Inc., All rights reserved" 53B1H-53E1H: the second line of the banner, the copyright, the same text as the copyright record of the file. |
| 53E2H-53E3H 2 bytes | DEFB 0AH, 0DH 53E2H-53E3H: a line feed, then 0DH, the end of the banner: a blank line follows it on the screen. |
| 53E4H-53E9H 6 bytes | DEFM " " 53E4H-53E9H: six spaces. 5309H writes the number of files converted right justified into 53E4H-53E8H; 53E9H stays a space before the words. |
| 53EAH-540DH 36 bytes | DEFM "file(s) updated, conversion complete" 53EAH-540DH: the rest of the message displayed by @LOGOT from 52F4H when the conversion is done. |
| 540EH-540EH 1 byte | DEFB 0DH 540EH: 0DH, the end of the message at 53E4H that reports the conversion. |
| 540FH-5427H 25 bytes | DEFM "Date conversion aborted!" / DEFB 0DH 540FH-5427H: the message of 5371H, for BREAK pressed during the conversion (52C4H), ended by 0DH at 5427H. |
| 5428H-545AH 51 bytes | DEFM "SYSTEM disk conversion requires a 5.3 or 6.3 disk!" / DEFB 0DH 5428H-545AH: the message of 5369H, for a system diskette whose system information sector does not start with 53H or 63H (526BH), ended by 0DH at 545AH. |
| 545BH-5471H 23 bytes | DEFM "Write protected drive!" / DEFB 0DH 545BH-5471H: the message of 536DH, for a write protected diskette (522FH), ended by 0DH at 5471H. |
| 5472H-5473H 2 bytes | DEFW 0000H 5472H-5473H: the number of files converted, 0000H when the program is loaded; 52BEH adds one for every record converted and 52E9H takes it for the message. |
| 5474H-54FFH 140 bytes | DEFS 140 5474H-54FFH: not in the file and not used by DATECONV. |
| 5500H-55FFH 256 bytes | DEFS 256 5500H-55FFH: not in the file. The buffer of every sector DATECONV reads and writes: the allocation table (523EH, 52DBH; its configuration byte at 55CDH), directory sector 5 and the system information sector (524EH-5264H), directory sector 3 (5272H, the ending record number of DIR/SYS at 5514H) and each sector of directory records (5286H). |
Operands Changed While It Runs
| Address Size | Contents |
|---|---|
| 526FH 1 byte | The operand of LD D,00H at 526EH: the directory cylinder of the drive, stored by 5238H from +09H of its drive code table. |
| 52A2H 1 byte | The operand of LD A,00H at 52A1H: 00H for a diskette of an earlier release; the configuration byte of the diskette (bit 3 set) when its directory already has this release's date format (5249H). Not zero means only records whose +12H-+13H hold 4296H are changed. |
| 52D3H 1 byte | The operand of LD A,00H at 52D2H: the last directory sector to convert, the ending record number of DIR/SYS less 1, at most 21H (5281H). |
| 52FBH-52FCH 2 bytes | The operand of LD SP,0000H at 52FAH: the Stack Pointer at entry, stored by 5200H. |
| 5348H 1 byte | The operand of LD C,00H at 5347H: the drive given, stored by 5222H, for the writes. |
| 535AH 1 byte | The operand of LD C,00H at 5359H: the drive given, stored by 5225H, for the reads. |
Cells Outside the File That DATECONV/CMD Uses
| Address Size | Contents |
|---|---|
| 442BH 1 byte | SFLAG$, the system flags: bit 5 set while a JCL job runs (5303H). |
| 429FH 1 byte | KFLAG$, the keyboard flags: bit 0 set by the keyboard scan when BREAK is pressed, cleared by 532DH. |
| IY +09H | The directory cylinder in the drive code table of the drive given (5235H). |
| Allocation table +CDH 1 byte | The configuration byte of the diskette (55CDH in the buffer): bit 3 set when the directory has this release's date format; DATECONV tests it (5244H) and sets it when it is done (52E1H). With bit 7 set and bit 3 clear the system diskette test is skipped (524EH). |
| Directory record +00H 1 byte | The attribute byte: bit 7 an extension record, bit 4 in use (528AH, 528FH). |
| Directory record +02H 1 byte | Bits 7-3 the day, bits 2-0 the year of the date; 00H for a record with no date (5296H). |
| Directory record +12H-+13H 2 bytes | In this release's date format: +12H bits 7-3 the hour, bits 2-0 bits 5-3 of the minutes; +13H bits 7-5 bits 2-0 of the minutes, bits 4-0 the year less 1980. DATECONV stores 00H and the year from +02H (52B6H-52B9H). An earlier release keeps 4296H there for a file without an access password. |
| Directory record +14H 1 byte | The low byte of the ending record number; for DIR/SYS (directory sector 3, the first record) the number of sectors of the directory (5275H). |
| System information sector +00H 1 byte | Cylinder 0, sector 2, byte 0: 53H on a system diskette of this release; DATECONV also accepts 63H (5264H). |
Disassembly
5200H - Entry: Save the Stack and Show the Banner
LDOS Ready loads DATECONV/CMD at 5200H-5473H and jumps to 5200H, the transfer address, with Register Pair HL pointing at the rest of the command line after the word DATECONV and the Stack Pointer at the return address. DATECONV keeps the Stack Pointer for its exit, clears a BREAK left over from before, and shows its banner.
520FH - The Drive from the Command Line
The command is DATECONV :d. After the spaces a colon must follow and then a digit 0-7; anything else gives error 20H, Illegal drive number. The drive number is put into the two disk routines and checked by @CKDRV.
5229H - Check the Drive and Read the Allocation Table
@CKDRV must find the drive ready and its diskette not write protected. The directory cylinder comes from byte +09H of the drive code table, which @CKDRV has just brought into line with the diskette, and sector 0 of that cylinder, the allocation table, is read into the buffer at 5500H. Bit 3 of its configuration byte (offset CDH) says that the directory already has the date format of this release.
524EH - The System Diskette Test
A diskette of an earlier release that holds the system files is converted only when its system information sector (cylinder 0, sector 2) starts with 53H or 63H; else DATECONV stops with SYSTEM disk conversion requires a 5.3 or 6.3 disk!. The diskette counts as a system diskette when the first record of directory sector 5 (directory record 3, one of the slots the system files take) is in use. A configuration byte with bit 7 set skips the test.
526EH - How Many Directory Sectors
The first record of directory sector 3 is directory record 1, the record of DIR/SYS. Its ending record number (+14H) is the number of sectors of the directory cylinder that the directory takes; less the allocation table and the hash index table it is the number of sectors that hold directory records, at most 32. The last sector to convert is stored in the loop's compare.
5284H - The Conversion Loop: Each Directory Sector
Register D holds the directory cylinder and Register E the sector, from 2 up to the last sector. Each sector is read into 5500H, its eight records of 32 bytes are worked through, and the sector is written back with the deleted data mark and verified.
5289H - Each Directory Record
A record is converted when it is a primary record (attribute bit 7 clear), in use (bit 4 set) and dated (byte +02H not zero). The year, bits 2-0 of +02H, goes into bits 4-0 of +13H, where this release keeps the year less 1980, and +12H (the hour and part of the minutes) and the rest of +13H are set to 00H. On a diskette already in this format only records whose bytes +12H-+13H hold 4296H are changed, since any other value there is a time stamp. Each change counts one file.
52C1H - The Next Record and the Next Sector
After every record BREAK is tested: BREAK ends the program with Date conversion aborted!, and the sector in the buffer is not written. After the eighth record the sector is written back; after the last sector the loop ends.
52D9H - Mark the Diskette and Report
The allocation table is read again, bit 3 of its configuration byte is set so that the diskette counts as one in the date format of this release, and it is written back. The number of files converted is put right justified into the first five bytes of the message at 53E4H, which is displayed and written to the job log.
52FAH - The Exit
Every way out of DATECONV comes here with Register Pair HL = 0000H (done) or FFFFH (an error, BREAK or a refusal). The Stack Pointer is set back to its value at entry and the program returns to whatever ran it. When a JCL job runs and there was an error, the program ends at @ABORT instead, which ends the job.
5309H - Write the Count as a Decimal Number
Register Pair HL holds the number and Register Pair DE the start of a field of five bytes. The field is filled with spaces and the digits are stored from its last byte backwards, one division by 10 at a time, so the number ends up right justified. Register Pair DE comes back pointing at the byte after the field.
5322H - Test for BREAK
Bit 0 of KFLAG$ (429FH) is set by the keyboard scan of the interrupt routine when BREAK is pressed. When it is clear the routine returns at once with the Z FLAG. When it is set the routine clears it, waits until it stays clear (BREAK released), takes every key waiting in the keyboard, and returns with the NZ FLAG. Register A and Register Pairs BC, DE and HL are kept.
5344H - Write a Directory Sector
Writes the buffer at 5500H to cylinder Register D, sector Register E of the drive given, with the deleted data mark every sector of the directory cylinder carries, and reads it back with a verify. The verify must report error 06H, the code for a sector with the deleted data mark: anything else, a write error included, ends the program through @ERROR.
5356H - Read a Sector, and the Disk Errors
Reads cylinder Register D, sector Register E of the drive given into the buffer at 5500H-55FFH and returns with Register Pair HL = 5500H. A sector with the normal data mark (Z FLAG) and one with the deleted data mark (error 06H) are both taken. Any other result, and any failure of the write routine, ends the program at 5362H: the error number gets bits 7 and 6 set, so @ERROR shows its short message and comes back, and the program leaves with Register Pair HL = FFFFH.
5369H - The Messages and the Way Out
Three entries display a message through @LOGOT. Each entry is a LD HL with the message address; the entries before it run over its first byte, DDH, which turns the next LD HL into a LD IX that changes nothing the program uses. So 5369H shows the system diskette message, 536DH the write protect message and 5371H the BREAK message. All three, and the errors, leave with Register Pair HL = FFFFH.
5381H - The Texts and the Counter
The banner, the four messages, each ended by 0DH, and the word that counts the files converted. The message at 53E4H starts with six spaces: the first five take the count (5309H), the sixth stays a space before the words.