DOSPLUS 3.5 for the Model III - CONVERT/CMD Disassembled
Page Customization
Page Index
CONVERT/CMD
Other Navigation
Introduction/Summary
DOSPLUS 3.5 CONVERT/CMD Disassembly - Files from TRSDOS, and Model I Directories (Model III)
CONVERT/CMD has three uses, run from the DOS command level: CONVERT :sd :dd [USING] wildmask copies files from a double density Model III TRSDOS diskette to a DOSPLUS drive; CONVERT :dr (CAT) or (DIR) lists the files of such a diskette; CONVERT :dr alone makes the directory of a Model I single density diskette readable on the Model III. Its heading reads CONVERT - DOSPLUS File conversion - 3.50. It is a load module of 5 blocks, 1206 bytes, at 5200H-56B5H with the transfer address 5200H, after the two comment records (the name CONVERT and the copyright notice). CONVERT/CMD is on the Model III master only; the manual's MOD1 parameter belongs to the Model I version and is not in this file's table.
CONVERT reads the TRSDOS diskette itself, sector by sector, with DISKIO%. It changes the drive control table of the source drive to a double density diskette of one surface with 255 sectors a track and a cylinder, so that the TRSDOS sector numbers (1-18) pass to the controller as they are, and sets the flag that the diskette is to be logged (5281H). TRSDOS's layout is built into the code: the boot sector at cylinder 0, sector 1 starts with FEH and gives the directory cylinder; the directory's sectors 3-18 hold 48 byte entries; a cylinder has six granules of three sectors (52C1H, 52DDH, 54D0H).
The Parts of CONVERT/CMD
| Address | Contents |
|---|---|
| 5200H-529FH | The buffers, EVAL@, the prompt, the source drive and its drive control table (5200H, 5235H). |
| 52A0H-5341H | The destination or CAT, the boot sector, the directory loop (52A0H, 52DDH). |
| 5342H-537BH | CAT, one name (5342H). |
| 537CH-545BH | Copy a file: QUERY, ECHO, INIT@, OVER, the sectors, CLOSE@ (537CH, 53E6H). |
| 545CH-5494H | The Model I single density directory (545CH). |
| 5495H-557BH | The messages and errors, an extent, a sector, NAME/EXT, WILD@, the questions, the flashing prompt (5495H, 54B0H, 54E1H, 54EDH, 5517H, 553EH). |
| 557CH-56B5H | The texts, the evaluation block and the parameters (557CH). |
How CONVERT Works
The first buffer is 5800H, or the page above LOW$ when that is higher, the second the page after it; both must end below HMEM$, else No memory space available (5200H). With nothing on the command line an asterisk asks for one. The source must be a drive that DCHECK finds and that is neither rigid nor 8 inch (Disk not as expected), and for a copy or a catalog not drive 0. The parameters are switches whose values EVAL@ stores into the operands of LD DE instructions, read by INC E and DEC E (or, for CAT, by reading the operand byte, 531CH).
For a copy and a catalog the boot sector must start with FEH (52CDH). Each active entry of the directory that passes SYSTEM, INVIS and the wildmask is made into NAME/EXT (54EDH); CAT shows it in a field of 15 columns, four a row, with the SPACE BAR and BREAK between rows (5342H). A copy (537CH) asks Convert ? with QUERY, or shows the name with ECHO, adds the destination drive, and opens or makes the file by INIT@ with the TRSDOS record length; an existing file is overwritten unless OVER is given and the answer to Overwrite ? is not Y. The sectors of each extent are read from the source and written by WRITE@ until the count is done (53E6H); the end of file byte and the ending record number go into the file control block and CLOSE@ writes them. Extents that end before the count give EOF exceeds allocated space and the end of CONVERT.
Without a destination and without CAT, the diskette in the drive is treated as a Model I single density diskette (545CH): its boot sector gives the directory cylinder, and each of the ten sectors of that cylinder is read and written back by DWRITA, the function that writes a sector with the address mark of a directory. On drive 0 CONVERT flashes Insert TARGET disk [ENTER] before and Insert SYSTEM disk [ENTER] after, waiting for any key; while a DO file runs it does not ask (553EH).
Differences from the Manual
The manual lists V13 as a parameter: it is in the table, but its value is stored into a byte of the source block's text, so it changes nothing; only V12 changes the work, by taking the TRSDOS sector count as it is instead of adding the sector that holds the end of the file. It does not say that the source of a copy or a catalog may not be drive 0, that a rigid or 8 inch drive is refused, that a file already on the destination is overwritten without a question unless OVER is given, or that ECHO shows nothing more when QUERY is given (the name is shown with the question). The questions take Y in either case, and anything else, ENTER alone included, is no; the prompts on drive 0 take any key, not only ENTER.
A file skipped at Overwrite ?, and an empty file, are left open after INIT@ without CLOSE@. After a copy or a catalog, the source drive's control table is left with the values CONVERT gave it, for the DOS to set again when it logs the diskette.
Variables
CONVERT/CMD Variables
| Address Size | Contents |
|---|---|
| 52A7H, 52F4H, 5302H, 5391H, 53A2H, 53D6H, 53F5H 2 bytes each | Switches CAT/DIR, SYSTEM, INVIS, QUERY, ECHO, OVER and V12, the operands of LD DE (52A6H). |
| 557CH 1 byte | Flash state 1EH the prompt cleared, 00H shown (554DH). |
| 56B5H 1 byte | Row count The names left on the catalog's row (5359H). |
| 56B6H 1 byte | Source drive (5273H). |
| 56B7H 1 byte | Record length Of the file being copied (5382H). |
| 56B8H-56B9H 2 bytes | First buffer The prompt's reply and the TRSDOS sectors (5219H). |
| 56BAH-56BBH 2 bytes | Second buffer The buffer of the copy and the replies (521EH). |
| 56BCH-56DCH 33 bytes | Source block The source field, later the file control block of the copy (5314H, 53C3H). |
| 56DDH-56FDH 33 bytes | Destination block The destination drive (52B0H). |
| 56FEH-571EH 33 bytes | Wildmask block The wildmask, later the name for the questions (52D5H, 5388H). |
Memory Outside CONVERT/CMD
| Address Size | Contents |
|---|---|
| 42A7H-42A8H 2 bytes | LOW$ The first buffer goes above it (5207H). |
| 4411H-4412H 2 bytes | HMEM$ The buffers must end below it (522BH). |
| 4297H 1 byte | SFLAG1$ Bit 5, a DO file runs (5365H, 5541H). |
Outside Routines
| Address | Contents |
|---|---|
| 4467H | SYS0/SYS: DSPLY@ (5204H). |
| 4479H | SYS0/SYS: EVAL@ (5239H). |
| 447CH | SYS0/SYS: WILD@ (551CH). |
| 4488H | SYS0/SYS: DISKIO%, DCHECK, DREAD and DWRITA (5279H, 54E3H, 5481H). |
| 44A3H | SYS0/SYS: LOCDCT% (5281H). |
| 4491H | SYS0/SYS: the 8 bit multiply (54DAH). |
| 4494H | SYS0/SYS: the 8 bit divide (54D2H). |
| 4485H | SYS0/SYS: run a routine with the registers saved (54EDH, 5547H). |
| 4420H | SYS0/SYS: INIT@ (53C9H). |
| 4439H | SYS0/SYS: WRITE@ (5422H). |
| 4428H | SYS0/SYS: CLOSE@ (5455H). |
| 4409H | SYS0/SYS: ERROR@ (54ADH). |
| 4030H | SYS0/SYS: ABORT@ (54A0H). |
| 402DH | SYS0/SYS: EXIT@ (5492H). |
| 002BH | ROM: scan the keyboard (536BH, 555DH). |
| 0033H | ROM: display a character (5248H). |
| 0040H | ROM: line input (5250H, 5530H). |
| 0049H | ROM: wait for a key (5370H). |
Disassembly
5200H - CONVERT
CONVERT/CMD's transfer address, entered from the DOS command level with Register Pair HL at the command line after the word CONVERT. Three uses: CONVERT :sd :dd [USING] wildmask copies files from a double density Model III TRSDOS diskette to a DOSPLUS drive; CONVERT :dr (CAT) or (DIR) lists the TRSDOS diskette's files; CONVERT :dr alone rewrites the directory sectors of a Model I single density diskette with the address mark the Model III reads. First the two buffers are placed on the pages above 5800H or above LOW$, and must end below HMEM$.
5235H - The Command Line
EVAL@ with the block 565AH; with nothing given, an asterisk and a new command line of up to 63 characters (BREAK is the error 30H, Terminated). The source must be a drive (no source field: the error 2FH; any other field 2BH), which DCHECK must find (08H) and which must not be a rigid or 8 inch drive (Disk not as expected). Its drive control table is set to a double density diskette of one surface and 255 sectors a track, so the TRSDOS sectors are read as numbered.
52A0H - The Destination or CAT
No destination field: with CAT or DIR the catalog of the TRSDOS diskette, without them the conversion of a Model I directory (545CH). A destination must be a drive. The source must not be drive 0 for a copy or a catalog. The TRSDOS boot sector (cylinder 0, sector 1) must start with FEH; its next byte is the directory cylinder.
52DDH - The TRSDOS Directory
Reads sectors 3 to 18 (12H) of the TRSDOS directory cylinder; each holds 48 byte entries (30H) at 00H, 30H, 60H, 90H, C0H and F0H. An entry is taken when it is active (bit 4), passes SYSTEM for a system file (bit 6) or INVIS for an invisible one (bit 3), and matches the wildmask; its name NAME/EXT is made at 56BDH, then CAT shows it (5342H) or it is copied (537CH).
5342H - CAT, One Name
Shows NAME/EXT in a field of 15 columns, four a row; at the end of a row a carriage return, then (unless a DO file runs) the SPACE BAR pauses and BREAK ends CONVERT by dropping the ten bytes of the stack down to the DOS's return address.
537CH - Copy a File
Register Pair HL = the TRSDOS entry. The record length (+04H) is kept; with QUERY the name and Convert ? (Y to copy), else with ECHO the name. NAME/EXT gets the destination drive and INIT@ opens or makes the file in sector mode; an existing file needs Y to Overwrite ? when OVER is given, and is overwritten without a question when it is not.
53E6H - The Sectors of the File
From the TRSDOS entry: the end of file byte (+03H) and the sector count (+14H-+15H; for TRSDOS 1.3, without V12, one more when the end of file byte is not 00H), then the extents from +16H, each read sector by sector from the source drive and written to the copy by WRITE@; the copy gets the end of file byte at FCB+08H and the ending record number at FCB+0CH, and CLOSE@.
545CH - A Model I Single Density Directory
The source drive alone: the diskette is read in single density; cylinder 0, sector 0 gives the directory cylinder (byte 2); its ten sectors are read and written back with DWRITA, the address mark of a directory, so the Model III can read them. On drive 0 the target and system diskettes are asked for. CONVERT ends by EXIT@.
5495H - The Messages and the Errors
5495H Disk not as expected and 549AH EOF exceeds allocated space are shown by DSPLY@ and end CONVERT through ABORT@. 54A3H, an error of the directory conversion, first asks for the system disk on drive 0. 54AAH posts the error code in Register B, 54ABH the one in Register A, with bit 6 set (no frame); with bit 7 clear ERROR@ ends through ABORT@.
54B0H - An Extent
Register Pair HL = an extent of the TRSDOS entry (the cylinder, then the starting granule in bits 7-5 and the number of granules in bits 4-0): returns the Z FLAG, Register Pair DE = its first sector and Register Pair HL = the sector after it; FEH or FFH returns the NC FLAG at once.
54E1H - Read a Sector
DREAD of cylinder Register D, sector Register E of drive Register C into Register Pair HL; the error code 06H (a sector with the directory's address mark) counts as a good read.
54EDH - NAME/EXT
Register Pair HL = the name and extension of an entry (8 and 3 bytes, padded with spaces), Register Pair DE = the place for the text: the name, a slash and the extension when there is one, then 0DH. 4485H wraps the routine, so the registers come back as they were.
5517H - WILD@ and the Questions
5517H calls WILD@ only when a wildmask was given (bit 2 of the evaluation block's flags). 5520H shows the name at 56FFH, then the question at Register Pair HL (16 spaces and a cursor up put it after the name), takes up to three characters into the second buffer (BREAK is the error 30H) and returns the Z FLAG when the reply starts with Y or y.
553EH - Flash a Prompt
553EH Insert SYSTEM disk [ENTER]; 5541H the prompt at Register Pair HL. Nothing while a DO file runs. Otherwise the prompt is shown and cleared in turn, 500 keyboard scans each, until any key is pressed; the line is then cleared. 4485H keeps the registers.
557CH - The Texts and the Parameters
Data: the state of the flashing prompt, the heading, the messages and prompts, the questions (each starting with D0H, sixteen spaces, and 1BH, the cursor up, so it stands after the name on the line above), the evaluation block and the parameter block (9 byte entries, type 20H for a logical value; V13's address is a byte of the source block, so V13 changes nothing), and the count of the catalog's row. 56B6H on is not loaded.