DOSPLUS 3.5 for the Model III - CONVERT/CMD Disassembled

Page Customization

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

AddressContents
5200H-529FHThe buffers, EVAL@, the prompt, the source drive and its drive control table (5200H, 5235H).
52A0H-5341HThe destination or CAT, the boot sector, the directory loop (52A0H, 52DDH).
5342H-537BHCAT, one name (5342H).
537CH-545BHCopy a file: QUERY, ECHO, INIT@, OVER, the sectors, CLOSE@ (537CH, 53E6H).
545CH-5494HThe Model I single density directory (545CH).
5495H-557BHThe messages and errors, an extent, a sector, NAME/EXT, WILD@, the questions, the flashing prompt (5495H, 54B0H, 54E1H, 54EDH, 5517H, 553EH).
557CH-56B5HThe 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

AddressContents
4467HSYS0/SYS: DSPLY@ (5204H).
4479HSYS0/SYS: EVAL@ (5239H).
447CHSYS0/SYS: WILD@ (551CH).
4488HSYS0/SYS: DISKIO%, DCHECK, DREAD and DWRITA (5279H, 54E3H, 5481H).
44A3HSYS0/SYS: LOCDCT% (5281H).
4491HSYS0/SYS: the 8 bit multiply (54DAH).
4494HSYS0/SYS: the 8 bit divide (54D2H).
4485HSYS0/SYS: run a routine with the registers saved (54EDH, 5547H).
4420HSYS0/SYS: INIT@ (53C9H).
4439HSYS0/SYS: WRITE@ (5422H).
4428HSYS0/SYS: CLOSE@ (5455H).
4409HSYS0/SYS: ERROR@ (54ADH).
4030HSYS0/SYS: ABORT@ (54A0H).
402DHSYS0/SYS: EXIT@ (5492H).
002BHROM: scan the keyboard (536BH, 555DH).
0033HROM: display a character (5248H).
0040HROM: line input (5250H, 5530H).
0049HROM: 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$.

5200
PUSH HL E5
Save Register Pair HL, the command line pointer after CONVERT, to the top of the stack while the heading is shown.
5201
LD HL,557DH 21 7D 55
Point Register Pair HL to 557DH, CONVERT's heading (CONVERT - DOSPLUS File conversion - 3.50) and the copyright line.
5204
GOSUB to 4467H, DSPLY@, to display the text at Register Pair HL up to and with the 0DH after the copyright line.
5207
LD HL,(42A7H) 2A A7 42
Load Register Pair HL with LOW$ from 42A7H-42A8H, the lowest address the DOS keeps.
520A
LD BC,5800H 01 00 58
Load Register Pair BC with 5800H, the first buffer when LOW$ is below it.
520D
OR A B7
OR Register A with itself, to clear the C FLAG for the SBC below.
520E
SBC HL,BC ED 42
SUBtract Register Pair BC (5800H) from Register Pair HL (LOW$) with the C FLAG: the C FLAG when LOW$ is below 5800H.
5210
If the C FLAG is set (LOW$ below 5800H), JUMP to 5219H with the first buffer at 5800H in Register Pair BC.
5212
LD BC,(42A7H) ED 4B A7 42
Load Register Pair BC with LOW$ from 42A7H-42A8H, for the page above it.
5216
LD C,00H 0E 00
Load Register C with 00H: Register Pair BC = the start of the page of LOW$.
5218
INC B 04
INCrement Register B by 1: Register Pair BC = the page above LOW$, the first buffer.
5219
LD (56B8H),BC ED 43 B8 56
Store Register Pair BC, the first buffer, into 56B8H-56B9H: the sectors read and the reply to the asterisk prompt.
521D
INC B 04
INCrement Register B by 1: Register Pair BC = the next page, the second buffer.
521E
LD (56BAH),BC ED 43 BA 56
Store Register Pair BC, the second buffer, into 56BAH-56BBH: the buffer of the file written and the replies to the questions.
5222
LD HL,0101H 21 01 01
Load Register Pair HL with 0101H, the 256 bytes of the second buffer and one more.
5225
ADD HL,BC 09
ADD Register Pair BC (the second buffer) to Register Pair HL: the address past the second buffer and one, the C FLAG when past FFFFH.
5226
LD A,21H 3E 21
Load Register A with 21H, the error code of No memory space available.
5228
If the C FLAG is set (past FFFFH), JUMP to 54ABH to post the error 21H.
522B
LD BC,(4411H) ED 4B 11 44
Load Register Pair BC with HMEM$ from 4411H-4412H, the highest address free for programs.
522F
SBC HL,BC ED 42
SUBtract Register Pair BC (HMEM$) from Register Pair HL with the C FLAG: the NC FLAG when the buffers reach HMEM$.
5231
If the NC FLAG is set (no room below HMEM$), JUMP to 54ABH to post the error 21H, No memory space available.
5234
POP HL E1
Restore Register Pair HL, the command line pointer, from the top of the stack.

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.

5235
LD IX,565AH DD 21 5A 56
Point Index Register IX to 565AH, CONVERT's evaluation block for EVAL@ (source, destination, wildmask and parameters).
5239
GOSUB to 4479H, EVAL@, to take the fields and the parameters of the command line at Register Pair HL into the blocks.
523C
If the NZ FLAG is set (EVAL@ found an error, 2EH in Register A), JUMP to 54ABH to post the error.
523F
LD A,(IX+00H) DD 7E 00
Load Register A with the flag byte of the evaluation block at Index Register IX+00H, which EVAL@ has set.
5242
AND 0FH E6 0F
AND Register A with 0FH, the bits of the source, the destination, the wildmask and the parameters.
5244
If the NZ FLAG is set (something was given), JUMP to 525AH to take the source drive.
5246
LD A,2AH 3E 2A
Load Register A with 2AH, the asterisk shown as the prompt when the command line holds nothing.
5248
GOSUB to 0033H, the ROM's display of the character in Register A, the prompt.
524B
LD HL,(56B8H) 2A B8 56
Load Register Pair HL with the first buffer from 56B8H-56B9H, the buffer for the reply.
524E
LD B,3FH 06 3F
Load Register B with 3FH, the most characters of the reply: 63.
5250
GOSUB to 0040H, the ROM's line input of up to Register B characters into the buffer at Register Pair HL; the C FLAG for BREAK.
5253
LD B,30H 06 30
Load Register B with 30H, the error code of Terminated, for BREAK.
5255
If the C FLAG is set (BREAK), JUMP to 54AAH to post the error 30H in Register B.
5258
JUMP to 5235H to evaluate the reply at Register Pair HL as the command line.
525A
BIT 0,(IX+00H) DD CB 00 46
Test bit 0 of the flag byte at Index Register IX+00H, set by EVAL@ when a source field was given.
525E
LD B,2FH 06 2F
Load Register B with 2FH, the error code of I/o field not found, for a command line without a source.
5260
If the Z FLAG is set (no source field), JUMP to 54AAH to post the error 2FH in Register B.
5263
LD A,(56BCH) 3A BC 56
Load Register A with the flag byte of the source block from 56BCH: bit 7 a device or a drive, bit 6 a name, bit 3 a drive.
5266
LD C,A 4F
Load Register C with Register A, keeping the flag byte of the source block for its drive number.
5267
AND C8H E6 C8
AND Register A with C8H, keeping bit 7 (a device or a drive), bit 6 (a name) and bit 3 (a drive).
5269
CP 88H FE 88
Compare Register A against 88H, a drive without a name: bits 7 and 3 set, bit 6 clear.
526B
LD B,2BH 06 2B
Load Register B with 2BH, the error code of Illegal devicespec, for a source that is not a drive.
526D
If the NZ FLAG is set (not a drive), JUMP to 54AAH to post the error 2BH in Register B.
5270
LD A,C 79
Load Register A with Register C, the flag byte of the source block again.
5271
AND 07H E6 07
AND Register A with 07H, keeping bits 0-2, the drive number LOCDEV@ put there.
5273
LD (56B6H),A 32 B6 56
Store Register A, the source drive, into 56B6H for the reads of the copy.
5276
LD C,A 4F
Load Register C with Register A, the source drive, for DISKIO% and LOCDCT%.
5277
LD A,00H 3E 00
Load Register A with 00H, the function DCHECK of DISKIO%, which checks that drive Register C is there.
5279
GOSUB to 4488H, DISKIO%, to check drive Register C.
527C
LD B,08H 06 08
Load Register B with 08H, the error code of Drive not available, kept for the errors below.
527E
If the NZ FLAG is set (the drive is not there), JUMP to 54AAH to post the error 08H in Register B.
5281
GOSUB to 44A3H, LOCDCT%, to point Index Register IY to the drive control table of drive Register C.
5284
LD A,(IY+03H) FD 7E 03
Load Register A with the flags of the drive from DCT+03H, Index Register IY+03H.
5287
AND A0H E6 A0
AND Register A with A0H, keeping bit 7 (an 8 inch drive) and bit 5 (a rigid drive).
5289
If the NZ FLAG is set (an 8 inch or rigid drive), JUMP to 5495H for Disk not as expected.
528C
SET 7,(IY+0BH) FD CB 0B FE
Set bit 7 of DCT+0BH at Index Register IY+0BH: the diskette is double density.
5290
LD (IY+0CH),01H FD 36 0C 01
Store 01H into DCT+0CH at Index Register IY+0CH, the surfaces of the diskette: one.
5294
LD (IY+0DH),FFH FD 36 0D FF
Store FFH into DCT+0DH at Index Register IY+0DH, the sectors per track: 255, so no sector number is past the end of a track.
5298
LD (IY+11H),FFH FD 36 11 FF
Store FFH into DCT+11H at Index Register IY+11H, the sectors per cylinder: 255.
529C
SET 0,(IY+03H) FD CB 03 C6
Set bit 0 of DCT+03H at Index Register IY+03H, the flag that the diskette is to be logged.

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.

52A0
BIT 1,(IX+00H) DD CB 00 4E
Test bit 1 of the flag byte at Index Register IX+00H, set by EVAL@ when a destination field was given.
52A4
If the NZ FLAG is set (a destination), JUMP to 52B0H to test that it is a drive.
52A6
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the operand 52A7H-52A8H where EVAL@ stores the value of CAT and DIR: FFFFH for Y, 0000H for N or none.
52A9
INC E 1C
INCrement Register E by 1, the first half of a test of Register E for zero.
52AA
DEC E 1D
DECrement Register E by 1, back to the value of CAT: the Z FLAG when it is 00H.
52AB
If the Z FLAG is set (no CAT), JUMP to 545CH to convert the directory of a Model I single density diskette.
52AE
JUMP to 52BCH for the catalog of the TRSDOS diskette, which needs no destination.
52B0
LD A,(56DDH) 3A DD 56
Load Register A with the flag byte of the destination block from 56DDH: bit 7 a device or a drive, bit 3 a drive.
52B3
AND C8H E6 C8
AND Register A with C8H, keeping bit 7 (a device or a drive), bit 6 (a name) and bit 3 (a drive).
52B5
CP 88H FE 88
Compare Register A against 88H, a drive without a name: bits 7 and 3 set, bit 6 clear.
52B7
LD B,2BH 06 2B
Load Register B with 2BH, the error code of Illegal devicespec, for a destination that is not a drive.
52B9
If the NZ FLAG is set (not a drive), JUMP to 54AAH to post the error 2BH in Register B.
52BC
LD A,C 79
Load Register A with Register C, the source drive.
52BD
OR A B7
OR Register A with itself: the Z FLAG for drive 0, the system drive.
52BE
If the Z FLAG is set (the source is drive 0), JUMP to 54AAH to post the error in Register B: 2BH, or 08H for a catalog.
52C1
LD HL,(56B8H) 2A B8 56
Load Register Pair HL with the first buffer from 56B8H-56B9H, for the TRSDOS boot sector.
52C4
LD DE,0001H 11 01 00
Load Register Pair DE with 0001H, cylinder 0 in Register D and sector 1 in Register E: TRSDOS numbers its sectors from 1.
52C7
GOSUB to 54E1H to read cylinder Register D, sector Register E of drive Register C into the buffer at Register Pair HL.
52CA
If the NZ FLAG is set (the read failed, its error code in Register A), JUMP to 54ABH to post the error.
52CD
LD A,(HL) 7E
Load Register A with the first byte of the TRSDOS boot sector at Register Pair HL.
52CE
CP FEH FE FE
Compare Register A against FEH, the first byte of a TRSDOS boot sector.
52D0
If the NZ FLAG is set (not FEH), JUMP to 5495H for Disk not as expected.
52D3
INC HL 23
INCrement Register Pair HL by 1, to the second byte of the boot sector.
52D4
LD D,(HL) 56
Load Register D with the second byte of the boot sector at Register Pair HL: the directory cylinder of the TRSDOS diskette.
52D5
LD HL,56FFH 21 FF 56
Point Register Pair HL to 56FFH, the text of the wildmask block.
52D8
LD B,01H 06 01
Load Register B with 01H, which makes WILD@ set the wildmask from the specification at Register Pair HL.
52DA
GOSUB to 5517H to call WILD@ with Register B = 01H when a wildmask field was given, so the wildmask is set.

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).

52DD
LD E,03H 1E 03
Load Register E with 03H, the first sector of the TRSDOS directory with file entries.
52DF
LD HL,(56B8H) 2A B8 56
Load Register Pair HL with the first buffer from 56B8H-56B9H, for the directory sector.
52E2
GOSUB to 54E1H to read cylinder Register D, sector Register E of drive Register C into the buffer at Register Pair HL.
52E5
If the NZ FLAG is set (the read failed, its error code in Register A), JUMP to 54ABH to post the error.
52E8
PUSH BC C5
Save Register Pair BC, the drive in Register C, to the top of the stack.
52E9
PUSH DE D5
Save Register Pair DE, the cylinder and the sector, to the top of the stack.
52EA
PUSH HL E5
Save Register Pair HL, the address of the entry in the buffer, to the top of the stack.
52EB
BIT 4,(HL) CB 66
Test bit 4 of the flag byte of the entry at Register Pair HL: set for an active file.
52ED
If the Z FLAG is set (not active), JUMP to 5328H for the next entry.
52EF
BIT 6,(HL) CB 76
Test bit 6 of the flag byte of the entry at Register Pair HL: set for a system file.
52F1
If the Z FLAG is set (not a system file), JUMP to 52FDH for the invisible test.
52F3
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the operand 52F4H-52F5H where EVAL@ stores the value of SYSTEM: FFFFH for Y, 0000H for N or none.
52F6
INC E 1C
INCrement Register E by 1, the first half of a test of Register E for zero.
52F7
DEC E 1D
DECrement Register E by 1, back to the value of SYSTEM: the Z FLAG when it is 00H.
52F8
If the Z FLAG is set (SYSTEM not given), JUMP to 5328H for the next entry: a system file is left out.
52FB
JUMP to 5308H to take the name: a system file is taken whether it is invisible or not.
52FD
BIT 3,(HL) CB 5E
Test bit 3 of the flag byte of the entry at Register Pair HL: set for an invisible file.
52FF
If the Z FLAG is set (a visible file), JUMP to 5308H to take the name.
5301
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the operand 5302H-5303H where EVAL@ stores the value of INVIS: FFFFH for Y, 0000H for N or none.
5304
INC E 1C
INCrement Register E by 1, the first half of a test of Register E for zero.
5305
DEC E 1D
DECrement Register E by 1, back to the value of INVIS: the Z FLAG when it is 00H.
5306
If the Z FLAG is set (INVIS not given), JUMP to 5328H for the next entry: an invisible file is left out.
5308
LD A,05H 3E 05
Load Register A with 05H, the offset of the name in a TRSDOS directory entry.
530A
ADD A,L 85
ADD Register A to Register L, the low byte of the entry's address: the name at +05H.
530B
LD L,A 6F
Load Register L with Register A: Register Pair HL = the name of the entry.
530C
LD B,00H 06 00
Load Register B with 00H, which makes WILD@ compare the 11 bytes at Register Pair HL with the wildmask.
530E
GOSUB to 5517H to call WILD@ with Register B = 00H when a wildmask was given; with none the Z FLAG comes back.
5311
If the NZ FLAG is set (the name does not match the wildmask), JUMP to 5328H for the next entry.
5314
LD DE,56BDH 11 BD 56
Point Register Pair DE to 56BDH, the text of the source block, where the name NAME/EXT is made.
5317
GOSUB to 54EDH to make the name and extension at Register Pair HL into NAME/EXT and 0DH at Register Pair DE.
531A
POP HL E1
Restore Register Pair HL, the address of the entry, from the top of the stack.
531B
PUSH HL E5
Save Register Pair HL, the address of the entry, to the top of the stack again for 5328H.
531C
LD A,(52A7H) 3A A7 52
Load Register A with the low byte of the value of CAT from 52A7H, the operand of LD DE at 52A6H.
531F
OR A B7
OR Register A with itself: the NZ FLAG when CAT or DIR was given.
5320
PUSH AF F5
Save Register Pair AF, the flags of the CAT test, to the top of the stack.
5321
If the NZ FLAG is set (CAT), GOSUB to 5342H to show the name in the catalog.
5324
POP AF F1
Restore Register Pair AF, the flags of the CAT test, from the top of the stack.
5325
If the Z FLAG is set (no CAT), GOSUB to 537CH to copy the file to the destination drive.
5328
POP HL E1
Restore Register Pair HL, the address of the entry in the buffer, from the top of the stack.
5329
POP DE D1
Restore Register Pair DE, the cylinder and the sector, from the top of the stack.
532A
POP BC C1
Restore Register Pair BC, the drive in Register C, from the top of the stack.
532B
LD A,30H 3E 30
Load Register A with 30H, the 48 bytes of a TRSDOS directory entry.
532D
ADD A,L 85
ADD Register A to Register L, the low byte of the entry's address: the C FLAG past the end of the sector.
532E
LD L,A 6F
Load Register L with Register A: Register Pair HL = the next entry of the sector.
532F
If the NC FLAG is set (another entry in the sector), JUMP to 52E8H for it.
5331
LD A,12H 3E 12
Load Register A with 12H, the last sector of the TRSDOS directory: 18.
5333
INC E 1C
INCrement Register E by 1, to the next sector of the directory.
5334
CP E BB
Compare Register A (12H) against Register E: the NC FLAG while Register E is not past sector 18.
5335
If the NC FLAG is set (another sector), JUMP to 52DFH to read it.
5337
LD A,(56B5H) 3A B5 56
Load Register A with the names left on the catalog's row from 56B5H.
533A
CP 04H FE 04
Compare Register A against 04H, a full row: nothing on the last row.
533C
LD A,0DH 3E 0D
Load Register A with 0DH, a carriage return to end a row of the catalog.
533E
If the NZ FLAG is set (a row was begun), GOSUB to 0033H, the ROM's display of the carriage return in Register A.
5341
RET C9
RETurn to the DOS, which called CONVERT from the command level.

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.

5342
LD HL,56BDH 21 BD 56
Point Register Pair HL to 56BDH, the name NAME/EXT made by 54EDH.
5345
LD B,0FH 06 0F
Load Register B with 0FH, the 15 columns of a name in the catalog.
5347
LD A,(HL) 7E
Load Register A with the next character of the name at Register Pair HL.
5348
INC HL 23
INCrement Register Pair HL by 1, to the next character.
5349
CP 0DH FE 0D
Compare Register A against 0DH, the carriage return that ends the name.
534B
If the Z FLAG is set (the end of the name), JUMP to 5352H for the spaces of the field.
534D
GOSUB to 0033H, the ROM's display of the character of the name in Register A.
5350
DECrement Register B and, while it is not zero, LOOP BACK to 5347H for the next character (DJNZ).
5352
LD A,20H 3E 20
Load Register A with 20H, a space of the field after the name.
5354
GOSUB to 0033H, the ROM's display of the space in Register A.
5357
DECrement Register B and, while it is not zero, LOOP BACK to 5352H for the next space (DJNZ).
5359
LD HL,56B5H 21 B5 56
Point Register Pair HL to 56B5H, the names left on the catalog's row.
535C
DEC (HL) 35
DECrement the count at Register Pair HL by 1: the Z FLAG when the row is full.
535D
RET NZ C0
If the NZ FLAG is set (room on the row), RETurn to the caller for the next name.
535E
LD (HL),04H 36 04
Store 04H, four names for the next row, into the count at Register Pair HL.
5360
LD A,0DH 3E 0D
Load Register A with 0DH, a carriage return to end the row of the catalog.
5362
GOSUB to 0033H, the ROM's display of the carriage return in Register A.
5365
LD A,(4297H) 3A 97 42
Load Register A with SFLAG1$ from 4297H, the system flags.
5368
AND 20H E6 20
AND Register A with 20H, keeping bit 5, set while a DO file runs.
536A
RET NZ C0
If the NZ FLAG is set (a DO file runs), RETurn to the caller: no pause and no BREAK.
536B
GOSUB to 002BH, the ROM's scan of the keyboard: Register A = the key pressed, or 00H.
536E
CP 20H FE 20
Compare Register A against 20H, the SPACE BAR.
5370
If the Z FLAG is set (the SPACE BAR), GOSUB to 0049H, the ROM's wait for a key: Register A = the next key.
5373
CP 01H FE 01
Compare Register A against 01H, the BREAK key.
5375
RET NZ C0
If the NZ FLAG is set (not BREAK), RETurn to the caller for the next name.
5376
LD HL,000AH 21 0A 00
Load Register Pair HL with 000AH, the ten bytes on the stack above the return to the DOS: the return, AF, HL, DE and BC.
5379
ADD HL,SP 39
ADD the Stack Pointer to Register Pair HL: the place of the DOS's return address on the stack.
537A
LD SP,HL F9
Load the Stack Pointer with Register Pair HL, dropping the ten bytes.
537B
RET C9
RETurn to the DOS after BREAK, which ends the catalog.

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.

537C
PUSH HL E5
Save Register Pair HL, the address of the entry, to the top of the stack.
537D
LD A,L 7D
Load Register A with Register L, the low byte of the entry's address.
537E
ADD A,04H C6 04
ADD 04H to Register A, the offset of the logical record length in the entry.
5380
LD L,A 6F
Load Register L with Register A: Register Pair HL = the logical record length of the entry, +04H.
5381
LD A,(HL) 7E
Load Register A with the logical record length of the file at Register Pair HL.
5382
LD (56B7H),A 32 B7 56
Store Register A, the logical record length, into 56B7H for INIT@.
5385
LD HL,56BDH 21 BD 56
Point Register Pair HL to 56BDH, the name NAME/EXT made by 54EDH.
5388
LD DE,56FFH 11 FF 56
Point Register Pair DE to 56FFH, the text of the wildmask block, which now keeps the name for the questions.
538B
LD BC,0020H 01 20 00
Load Register Pair BC with 0020H, the 32 bytes of the name's block to copy.
538E
LDIR ED B0
Copy the name: Register Pair BC bytes from Register Pair HL to Register Pair DE (LDIR).
5390
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the operand 5391H-5392H where EVAL@ stores the value of QUERY: FFFFH for Y, 0000H for N or none.
5393
INC E 1C
INCrement Register E by 1, the first half of a test of Register E for zero.
5394
DEC E 1D
DECrement Register E by 1, back to the value of QUERY: the Z FLAG when it is 00H.
5395
If the Z FLAG is set (no QUERY), JUMP to 53A1H for ECHO.
5397
LD HL,563EH 21 3E 56
Point Register Pair HL to 563EH, the question Convert ? shown after the name.
539A
GOSUB to 5520H to show the name and the question at Register Pair HL and take the reply; the Z FLAG for Y.
539D
If the Z FLAG is set (Y), JUMP to 53ACH to copy the file.
539F
POP HL E1
Restore Register Pair HL, the address of the entry, from the top of the stack: the file is not copied.
53A0
RET C9
RETurn to the caller for the next entry, the file left out.
53A1
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the operand 53A2H-53A3H where EVAL@ stores the value of ECHO: FFFFH for Y, 0000H for N or none.
53A4
INC E 1C
INCrement Register E by 1, the first half of a test of Register E for zero.
53A5
DEC E 1D
DECrement Register E by 1, back to the value of ECHO: the NZ FLAG when it is FFH.
53A6
LD HL,56FFH 21 FF 56
Point Register Pair HL to 56FFH, the name NAME/EXT ended by 0DH.
53A9
If the NZ FLAG is set (ECHO), GOSUB to 4467H, DSPLY@, to display the name at Register Pair HL.
53AC
LD HL,56BDH 21 BD 56
Point Register Pair HL to 56BDH, the name NAME/EXT, for the drive of the destination.
53AF
LD BC,0020H 01 20 00
Load Register Pair BC with 0020H, the most bytes the search for the 0DH looks at.
53B2
LD A,0DH 3E 0D
Load Register A with 0DH, the carriage return that ends the name.
53B4
CPIR ED B1
Search for the 0DH: compare Register A with the bytes from Register Pair HL until a match or Register Pair BC is zero (CPIR).
53B6
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the byte after the 0DH.
53B7
DEC DE 1B
DECrement Register Pair DE by 1, back to the 0DH, where the drive goes.
53B8
LD HL,56DEH 21 DE 56
Point Register Pair HL to 56DEH, the text of the destination block: the colon, the drive and 03H.
53BB
LD C,04H 0E 04
Load Register C with 04H, the bytes to copy: the colon, the drive digit, the 03H and one more.
53BD
LDIR ED B0
Copy the drive after the name: Register Pair BC bytes from Register Pair HL to Register Pair DE (LDIR).
53BF
LD A,(56B7H) 3A B7 56
Load Register A with the logical record length of the file from 56B7H.
53C2
LD B,A 47
Load Register B with Register A, the logical record length for INIT@.
53C3
LD DE,56BDH 11 BD 56
Point Register Pair DE to 56BDH, NAME/EXT:d, which INIT@ takes as the file control block of the copy.
53C6
LD HL,(56BAH) 2A BA 56
Load Register Pair HL with the second buffer from 56BAH-56BBH, the buffer of the copy.
53C9
GOSUB to 4420H, INIT@, to open the file of the file control block at Register Pair DE, making it when it is not there.
53CC
If the NZ FLAG is set (INIT@ failed, its error code in Register A), JUMP to 54ABH to post the error.
53CF
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the file control block.
53D0
INC HL 23
INCrement Register Pair HL by 1, to FCB+01H, the flags of the file control block.
53D1
RES 7,(HL) CB BE
Reset bit 7 of FCB+01H at Register Pair HL, the blocked flag: the copy is written in whole sectors.
53D3
If the C FLAG is set (INIT@ made the file), JUMP to 53E6H to copy it.
53D5
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the operand 53D6H-53D7H where EVAL@ stores the value of OVER: FFFFH for Y, 0000H for N or none.
53D8
INC E 1C
INCrement Register E by 1, the first half of a test of Register E for zero.
53D9
DEC E 1D
DECrement Register E by 1, back to the value of OVER: the Z FLAG when it is 00H.
53DA
If the Z FLAG is set (no OVER), JUMP to 53E6H to copy over the file that is there.
53DC
LD HL,564BH 21 4B 56
Point Register Pair HL to 564BH, the question Overwrite ? shown after the name.
53DF
GOSUB to 5520H to show the name and the question at Register Pair HL and take the reply; the Z FLAG for Y.
53E2
If the Z FLAG is set (Y), JUMP to 53E6H to copy the file over the one there.
53E4
POP HL E1
Restore Register Pair HL, the address of the entry, from the top of the stack: the file is not copied.
53E5
RET C9
RETurn to the caller for the next entry; the file opened by INIT@ is not closed.

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@.

53E6
POP HL E1
Restore Register Pair HL, the address of the entry, from the top of the stack.
53E7
INC L 2C
INCrement Register L by 1, the first of three steps to +03H.
53E8
INC L 2C
INCrement Register L by 1, the second of three steps.
53E9
INC L 2C
INCrement Register L by 1: Register Pair HL = the end of file byte of the entry, +03H.
53EA
LD D,(HL) 56
Load Register D with the end of file byte of the entry at Register Pair HL.
53EB
LD A,11H 3E 11
Load Register A with 11H, the distance from +03H to +14H, the sector count.
53ED
ADD A,L 85
ADD Register A to Register L, the low byte of the entry's address: +14H.
53EE
LD L,A 6F
Load Register L with Register A: Register Pair HL = the sector count of the entry.
53EF
LD C,(HL) 4E
Load Register C with the low byte of the sector count at Register Pair HL.
53F0
INC L 2C
INCrement Register L by 1, to the high byte of the sector count.
53F1
LD B,(HL) 46
Load Register B with the high byte at Register Pair HL: Register Pair BC = the sector count of the entry.
53F2
INC L 2C
INCrement Register L by 1: Register Pair HL = the first extent of the entry, +16H.
53F3
PUSH DE D5
Save Register Pair DE, the end of file byte in Register D, to the top of the stack around the V12 test.
53F4
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the operand 53F5H-53F6H where EVAL@ stores the value of V12: FFFFH for Y, 0000H for N or none.
53F7
INC E 1C
INCrement Register E by 1, the first half of a test of Register E for zero.
53F8
DEC E 1D
DECrement Register E by 1, back to the value of V12: the NZ FLAG when it is FFH.
53F9
POP DE D1
Restore Register Pair DE, the end of file byte in Register D, from the top of the stack.
53FA
If the NZ FLAG is set (V12, TRSDOS 1.2), JUMP to 5401H: the count stands as it is.
53FC
INC D 14
INCrement Register D by 1, the first half of a test of the end of file byte for zero.
53FD
DEC D 15
DECrement Register D by 1, back to the end of file byte: the Z FLAG when it is 00H.
53FE
If the Z FLAG is set (the last sector is full), JUMP to 5401H with the count as it is.
5400
INC BC 03
INCrement Register Pair BC by 1: for TRSDOS 1.3 the sector with the end of the file is not in the count.
5401
LD A,B 78
Load Register A with Register B, the high byte of the sectors to copy.
5402
OR C B1
OR Register A with Register C: the Z FLAG when no sector is to be copied.
5403
RET Z C8
If the Z FLAG is set (an empty file), RETurn to the caller; the file made by INIT@ is not closed.
5404
PUSH BC C5
Save Register Pair BC, the sectors to copy, to the top of the stack.
5405
PUSH DE D5
Save Register Pair DE, the end of file byte in Register D, to the top of the stack.
5406
PUSH HL E5
Save Register Pair HL, the address of the extent, to the top of the stack.
5407
GOSUB to 54B0H for the extent at Register Pair HL: Register Pair DE = its first sector, Register Pair HL = the sector after it.
540A
If the NZ FLAG is set (the end of the extents, FFH), JUMP to 549AH for EOF exceeds allocated space.
540D
PUSH BC C5
Save Register Pair BC, the sectors still to copy, to the top of the stack.
540E
PUSH HL E5
Save Register Pair HL, the sector after the extent, to the top of the stack.
540F
LD A,(56B6H) 3A B6 56
Load Register A with the source drive from 56B6H.
5412
LD C,A 4F
Load Register C with Register A, the source drive, for DISKIO%.
5413
LD HL,(56BAH) 2A BA 56
Load Register Pair HL with the second buffer from 56BAH-56BBH, the buffer of the copy.
5416
GOSUB to 54E1H to read cylinder Register D, sector Register E of drive Register C into the buffer at Register Pair HL.
5419
If the NZ FLAG is set (the read failed, its error code in Register A), JUMP to 54ABH to post the error.
541C
POP HL E1
Restore Register Pair HL, the sector after the extent, from the top of the stack.
541D
POP BC C1
Restore Register Pair BC, the sectors still to copy, from the top of the stack.
541E
PUSH DE D5
Save Register Pair DE, the cylinder and the sector read, to the top of the stack around WRITE@.
541F
LD DE,56BDH 11 BD 56
Point Register Pair DE to 56BDH, the file control block of the copy.
5422
GOSUB to 4439H, WRITE@, to write the buffer as the next sector of the copy at Register Pair DE.
5425
If the NZ FLAG is set (WRITE@ failed, its error code in Register A), JUMP to 54ABH to post the error.
5428
POP DE D1
Restore Register Pair DE, the cylinder and the sector read, from the top of the stack.
5429
DEC BC 0B
DECrement Register Pair BC by 1, one sector of the file copied.
542A
LD A,B 78
Load Register A with Register B, the high byte of the sectors still to copy.
542B
OR C B1
OR Register A with Register C: the Z FLAG when the whole file is copied.
542C
If the Z FLAG is set (all copied), JUMP to 5444H to close the copy.
542E
LD A,13H 3E 13
Load Register A with 13H, the number after the last TRSDOS sector of a track, 19.
5430
INC E 1C
INCrement Register E by 1, to the next sector of the source.
5431
SUB E 93
SUBtract Register E from Register A: the Z FLAG when Register E has reached 13H.
5432
If the NZ FLAG is set (the same cylinder), JUMP to 5437H.
5434
INC A 3C
INCrement Register A by 1: Register A = 01H, the first sector of a TRSDOS track.
5435
LD E,A 5F
Load Register E with Register A, sector 1 of the next cylinder of the source.
5436
INC D 14
INCrement Register D by 1, to the next cylinder.
5437
LD A,H 7C
Load Register A with Register H, the cylinder after the extent.
5438
CP D BA
Compare Register A against Register D, the cylinder of the next sector.
5439
If the NZ FLAG is set (not the end of the extent), JUMP to 540DH for the next sector.
543B
LD A,L 7D
Load Register A with Register L, the sector after the extent.
543C
CP E BB
Compare Register A against Register E, the next sector.
543D
If the NZ FLAG is set (not the end of the extent), JUMP to 540DH for the next sector.
543F
POP HL E1
Restore Register Pair HL, the address of the extent, from the top of the stack.
5440
INC L 2C
INCrement Register L by 1, the first of two steps to the next extent.
5441
INC L 2C
INCrement Register L by 1: Register Pair HL = the next extent of the entry.
5442
JUMP to 5406H for the next extent of the file.
5444
POP AF F1
Restore Register Pair AF from the top of the stack: the address of the extent, no longer needed.
5445
POP AF F1
Restore Register Pair AF from the top of the stack: Register A = the end of file byte, pushed as Register D.
5446
POP BC C1
Restore Register Pair BC, the sector count of the file, from the top of the stack.
5447
LD (56C5H),A 32 C5 56
Store Register A, the end of file byte, into 56C5H, FCB+08H of the copy.
544A
OR A B7
OR Register A with itself, to test the end of file byte for zero.
544B
If the Z FLAG is set (the last sector is full), JUMP to 544EH.
544D
DEC BC 0B
DECrement Register Pair BC by 1: the ending record number names the sector with the end of the file.
544E
LD (56C9H),BC ED 43 C9 56
Store Register Pair BC into 56C9H-56CAH, FCB+0CH, the ending record number of the copy.
5452
LD DE,56BDH 11 BD 56
Point Register Pair DE to 56BDH, the file control block of the copy.
5455
GOSUB to 4428H, CLOSE@, to close the copy at Register Pair DE with its end of file.
5458
If the NZ FLAG is set (CLOSE@ failed, its error code in Register A), JUMP to 54ABH to post the error.
545B
RET C9
RETurn to the caller for the next entry of the TRSDOS directory.

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@.

545C
LD HL,5608H 21 08 56
Point Register Pair HL to 5608H, the prompt Insert TARGET disk [ENTER].
545F
LD A,C 79
Load Register A with Register C, the drive of the diskette.
5460
OR A B7
OR Register A with itself: the Z FLAG for drive 0, the system drive.
5461
If the Z FLAG is set (drive 0), GOSUB to 5541H to flash the prompt at Register Pair HL until a key is pressed.
5464
RES 7,(IY+0BH) FD CB 0B BE
Reset bit 7 of DCT+0BH at Index Register IY+0BH: the diskette is single density.
5468
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, cylinder 0 in Register D and sector 0 in Register E.
546B
LD HL,(56B8H) 2A B8 56
Load Register Pair HL with the first buffer from 56B8H-56B9H, for the sectors.
546E
GOSUB to 54E1H to read cylinder Register D, sector Register E of drive Register C into the buffer at Register Pair HL.
5471
If the NZ FLAG is set (the read failed, its error code in Register A), JUMP to 54A3H to post the error.
5474
PUSH HL E5
Save Register Pair HL, the buffer, to the top of the stack.
5475
INC L 2C
INCrement Register L by 1, the first of two steps to byte 2 of the boot sector.
5476
INC L 2C
INCrement Register L by 1: Register Pair HL = byte 2 of the boot sector.
5477
LD D,(HL) 56
Load Register D with the directory cylinder of the diskette from byte 2 at Register Pair HL.
5478
POP HL E1
Restore Register Pair HL, the buffer, from the top of the stack.
5479
GOSUB to 54E1H to read cylinder Register D, sector Register E of drive Register C into the buffer at Register Pair HL.
547C
If the NZ FLAG is set (the read failed, its error code in Register A), JUMP to 54A3H to post the error.
547F
LD A,08H 3E 08
Load Register A with 08H, the function DWRITA of DISKIO%: write a sector with the directory's address mark.
5481
GOSUB to 4488H, DISKIO%, to write the sector back to cylinder Register D, sector Register E from the buffer at Register Pair HL.
5484
If the NZ FLAG is set (the write failed, its error code in Register A), JUMP to 54A3H to post the error.
5487
LD A,09H 3E 09
Load Register A with 09H, the last sector of a single density directory cylinder.
5489
INC E 1C
INCrement Register E by 1, to the next sector of the directory.
548A
CP E BB
Compare Register A (09H) against Register E: the NC FLAG while Register E is not past sector 9.
548B
If the NC FLAG is set (another sector), JUMP to 5479H to read and write it.
548D
LD A,C 79
Load Register A with Register C, the drive of the diskette.
548E
OR A B7
OR Register A with itself: the Z FLAG for drive 0, the system drive.
548F
If the Z FLAG is set (drive 0), GOSUB to 553EH to flash Insert SYSTEM disk [ENTER] until a key is pressed.
5492
JUMP to 402DH, EXIT@, back to the DOS with the directory converted.

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@.

5495
LD HL,55D7H 21 D7 55
Point Register Pair HL to 55D7H, the message Disk not as expected.
5498
JUMP to 549DH to display the message at Register Pair HL and end CONVERT.
549A
LD HL,55ECH 21 EC 55
Point Register Pair HL to 55ECH, the message EOF exceeds allocated space.
549D
GOSUB to 4467H, DSPLY@, to display the message at Register Pair HL.
54A0
JUMP to 4030H, ABORT@, which ends CONVERT and returns to the DOS.
54A3
PUSH AF F5
Save Register Pair AF, the error code in Register A, to the top of the stack.
54A4
LD A,C 79
Load Register A with Register C, the drive of the diskette.
54A5
OR A B7
OR Register A with itself: the Z FLAG for drive 0, the system drive.
54A6
If the Z FLAG is set (drive 0), GOSUB to 553EH to flash Insert SYSTEM disk [ENTER] until a key is pressed.
54A9
POP BC C1
Restore Register Pair BC from the top of the stack: Register B = the error code.
54AA
LD A,B 78
Load Register A with Register B, the error code.
54AB
OR 40H F6 40
OR Register A with 40H, setting bit 6 of the error code: ERROR@ shows the message without the frame of asterisks.
54AD
JUMP to 4409H, ERROR@, with the error code in Register A; with bit 7 clear ERROR@ does not return but 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.

54B0
LD A,(HL) 7E
Load Register A with the cylinder of the extent at Register Pair HL, or FFH at the end.
54B1
INC L 2C
INCrement Register L by 1, to the granule byte of the extent.
54B2
CP FEH FE FE
Compare Register A against FEH: the NC FLAG for FEH and FFH, which are not cylinders.
54B4
RET NC D0
If the NC FLAG is set (no more extents), RETurn to the caller, the NZ FLAG for FFH.
54B5
LD D,A 57
Load Register D with Register A, the cylinder of the extent.
54B6
LD A,(HL) 7E
Load Register A with the granule byte of the extent at Register Pair HL.
54B7
RLCA 07
Rotate Register A left one bit, the first of three that bring bits 7-5 to bits 2-0 (RLCA).
54B8
RLCA 07
Rotate Register A left one bit, the second of three (RLCA).
54B9
RLCA 07
Rotate Register A left one bit, the third of three: the starting granule in bits 2-0 (RLCA).
54BA
AND 07H E6 07
AND Register A with 07H, keeping the starting granule of the extent, 0-7.
54BC
LD E,A 5F
Load Register E with Register A: Register Pair DE = the cylinder and the starting granule.
54BD
PUSH DE D5
Save Register Pair DE, the cylinder and the starting granule, to the top of the stack.
54BE
GOSUB to 54D0H to turn the cylinder in Register D and the granule in Register E into the cylinder and the sector.
54C1
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the first sector, Register Pair DE = the granule byte.
54C2
EX (SP),HL E3
Exchange the top of the stack at the Stack Pointer with Register Pair HL: the first sector to the stack, the cylinder and starting granule to Register Pair HL.
54C3
LD A,(DE) 1A
Load Register A with the granule byte of the extent at Register Pair DE.
54C4
AND 1FH E6 1F
AND Register A with 1FH, keeping bits 4-0, the number of granules of the extent.
54C6
ADD A,L 85
ADD Register L, the starting granule, to Register A: the granule after the extent.
54C7
LD E,A 5F
Load Register E with Register A, the granule after the extent.
54C8
LD D,H 54
Load Register D with Register H: Register Pair DE = the cylinder and the granule after the extent.
54C9
GOSUB to 54D0H to turn the cylinder in Register D and the granule in Register E into the cylinder and the sector.
54CC
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the sector after the extent.
54CD
POP DE D1
Restore Register Pair DE, the first sector of the extent, from the top of the stack.
54CE
XOR A AF
Set Register A to 00H (XOR A), with the Z FLAG: an extent was found.
54CF
RET C9
RETurn to the caller with the Z FLAG and the sectors in Register Pair DE and Register Pair HL.
54D0
LD A,06H 3E 06
Load Register A with 06H, the granules of a TRSDOS cylinder of 18 sectors.
54D2
GOSUB to 4494H, the 8 bit divide: Register A = Register E divided by Register A, Register E = the remainder, the granule on its cylinder.
54D5
ADD A,D 82
ADD Register D, the cylinder, to Register A, the whole cylinders the granule number passes.
54D6
LD D,A 57
Load Register D with Register A, the cylinder of the granule.
54D7
LD A,03H 3E 03
Load Register A with 03H, the sectors of a TRSDOS granule.
54D9
PUSH DE D5
Save Register Pair DE, the cylinder and the granule, to the top of the stack around the multiply.
54DA
GOSUB to 4491H, the 8 bit multiply: Register A = Register A times Register E, the first sector of the granule less 1.
54DD
POP DE D1
Restore Register Pair DE, the cylinder in Register D, from the top of the stack.
54DE
INC A 3C
INCrement Register A by 1: TRSDOS numbers its sectors from 1.
54DF
LD E,A 5F
Load Register E with Register A: Register Pair DE = the cylinder and the sector of the granule.
54E0
RET C9
RETurn to the caller with the cylinder in Register D and the sector in Register E.

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.

54E1
LD A,03H 3E 03
Load Register A with 03H, the function DREAD of DISKIO%.
54E3
GOSUB to 4488H, DISKIO%, to read cylinder Register D, sector Register E of drive Register C into the buffer at Register Pair HL.
54E6
RET Z C8
If the Z FLAG is set (the read worked), RETurn to the caller with the Z FLAG.
54E7
SUB 06H D6 06
SUBtract 06H from Register A: the Z FLAG for the error code 06H, a sector with the directory's address mark.
54E9
RET Z C8
If the Z FLAG is set (code 06H), RETurn to the caller with the Z FLAG: a good read.
54EA
ADD A,06H C6 06
ADD 06H to Register A, back to the error code, with the NZ FLAG.
54EC
RET C9
RETurn to the caller with the NZ FLAG and the error code in Register A.

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.

54ED
GOSUB to 4485H, which runs the rest of this routine with Register Pairs BC, DE and HL and the index registers saved around it.
54F0
LD BC,0008H 01 08 00
Load Register Pair BC with 0008H, the eight characters of the name for the LDI count.
54F3
LD A,(HL) 7E
Load Register A with the next character of the name at Register Pair HL.
54F4
CP 20H FE 20
Compare Register A against 20H, the space that pads a short name.
54F6
If the Z FLAG is set (the end of the name), JUMP to 54FDH for the extension.
54F8
LDI ED A0
Copy the character from Register Pair HL to Register Pair DE, both moved on, Register Pair BC counted down (LDI).
54FA
If the PE FLAG is set (Register Pair BC is not zero), JUMP to 54F3H for the next character.
54FD
ADD HL,BC 09
ADD Register Pair BC, the characters of the name left, to Register Pair HL: the extension at +08H of the name.
54FE
LD A,(HL) 7E
Load Register A with the first character of the extension at Register Pair HL.
54FF
CP 20H FE 20
Compare Register A against 20H, a space: a file without an extension.
5501
If the Z FLAG is set (no extension), JUMP to 5513H to end the text.
5503
LD A,2FH 3E 2F
Load Register A with 2FH, the slash between the name and the extension.
5505
LD (DE),A 12
Store Register A, the slash, into the text at Register Pair DE.
5506
INC DE 13
INCrement Register Pair DE by 1, to the place of the extension.
5507
LD C,03H 0E 03
Load Register C with 03H, the three characters of the extension for the LDI count.
5509
LD A,(HL) 7E
Load Register A with the next character of the extension at Register Pair HL.
550A
CP 20H FE 20
Compare Register A against 20H, the space that pads a short extension.
550C
If the Z FLAG is set (the end of the extension), JUMP to 5513H to end the text.
550E
LDI ED A0
Copy the character from Register Pair HL to Register Pair DE, both moved on, Register Pair BC counted down (LDI).
5510
If the PE FLAG is set (Register Pair BC is not zero), JUMP to 5509H for the next character.
5513
LD A,0DH 3E 0D
Load Register A with 0DH, the carriage return that ends the text.
5515
LD (DE),A 12
Store Register A, the carriage return, into the text at Register Pair DE.
5516
RET C9
RETurn to the caller through the end of 4485H's wrapper, the registers restored.

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.

5517
BIT 2,(IX+00H) DD CB 00 56
Test bit 2 of the flag byte at Index Register IX+00H, set by EVAL@ when a wildmask field was given.
551B
RET Z C8
If the Z FLAG is set (no wildmask), RETurn to the caller with the Z FLAG, so every name matches.
551C
GOSUB to 447CH, WILD@, with Register B and Register Pair HL as the caller set them.
551F
RET C9
RETurn to the caller with the Z FLAG of WILD@, set for a match or when the wildmask was set.
5520
PUSH HL E5
Save Register Pair HL, the question, to the top of the stack while the name is shown.
5521
LD HL,56FFH 21 FF 56
Point Register Pair HL to 56FFH, the name NAME/EXT ended by 0DH.
5524
GOSUB to 4467H, DSPLY@, to display the name at Register Pair HL and the carriage return after it.
5527
POP HL E1
Restore Register Pair HL, the question, from the top of the stack.
5528
GOSUB to 4467H, DSPLY@, to display the question at Register Pair HL up to its 03H.
552B
LD B,03H 06 03
Load Register B with 03H, the most characters of the reply.
552D
LD HL,(56BAH) 2A BA 56
Load Register Pair HL with the second buffer from 56BAH-56BBH, the buffer for the reply.
5530
GOSUB to 0040H, the ROM's line input of up to Register B characters into the buffer at Register Pair HL; the C FLAG for BREAK.
5533
LD B,30H 06 30
Load Register B with 30H, the error code of Terminated, for BREAK.
5535
If the C FLAG is set (BREAK), JUMP to 54AAH to post the error 30H in Register B.
5538
LD A,(HL) 7E
Load Register A with the first character of the reply at Register Pair HL.
5539
RES 5,A CB AF
Reset bit 5 of Register A: a lower case letter becomes upper case.
553B
CP 59H FE 59
Compare Register A against 59H, the letter Y: the Z FLAG for a yes.
553D
RET C9
RETurn to the caller with the Z FLAG for Y; ENTER alone or any other reply is no.

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.

553E
LD HL,5623H 21 23 56
Point Register Pair HL to 5623H, the prompt Insert SYSTEM disk [ENTER].
5541
LD A,(4297H) 3A 97 42
Load Register A with SFLAG1$ from 4297H, the system flags.
5544
AND 20H E6 20
AND Register A with 20H, keeping bit 5, set while a DO file runs.
5546
RET NZ C0
If the NZ FLAG is set (a DO file runs), RETurn to the caller without the prompt.
5547
GOSUB to 4485H, which runs the rest of this routine with Register Pairs BC, DE and HL and the index registers saved around it.
554A
LD BC,01F4H 01 F4 01
Load Register Pair BC with 01F4H, the 500 keyboard scans of one phase of the flashing.
554D
LD A,(557CH) 3A 7C 55
Load Register A with the state of the prompt from 557CH: 1EH while it is not shown, 00H while it is.
5550
XOR 1EH EE 1E
XOR Register A with 1EH: the other state, the Z FLAG when the prompt is to be cleared.
5552
PUSH AF F5
Save Register Pair AF, the new state and its flags, to the top of the stack.
5553
If the Z FLAG is set (clear the prompt), GOSUB to 556AH to clear the line of the prompt.
5556
POP AF F1
Restore Register Pair AF, the new state and its flags, from the top of the stack.
5557
LD (557CH),A 32 7C 55
Store Register A, the new state of the flashing prompt, into 557CH.
555A
If the NZ FLAG is set (show the prompt), GOSUB to 4467H, DSPLY@, to display the prompt at Register Pair HL.
555D
GOSUB to 002BH, the ROM's scan of the keyboard: Register A = the key pressed, or 00H.
5560
OR A B7
OR Register A with itself, to test the key for zero.
5561
If the NZ FLAG is set (a key), JUMP to 556AH to clear the line and return.
5563
DEC BC 0B
DECrement Register Pair BC by 1, one scan of the phase done.
5564
LD A,B 78
Load Register A with Register B, the high byte of the scans left.
5565
OR C B1
OR Register A with Register C: the Z FLAG when Register Pair BC is zero.
5566
If the NZ FLAG is set (scans left), JUMP to 555DH to scan again.
5568
JUMP to 554AH for the next phase of the flashing.
556A
LD A,0DH 3E 0D
Load Register A with 0DH, a carriage return, the first step to the start of the prompt's line.
556C
GOSUB to 0033H, the ROM's display of the carriage return in Register A.
556F
LD A,1BH 3E 1B
Load Register A with 1BH, the code that moves the cursor up one line, back to the prompt's line.
5571
GOSUB to 0033H, the ROM's display of the cursor up in Register A.
5574
LD A,1EH 3E 1E
Load Register A with 1EH, the code that clears to the end of the line, also the state of a cleared prompt.
5576
LD (557CH),A 32 7C 55
Store Register A (1EH) into 557CH: the prompt is not shown.
5579
JUMP to 0033H, the ROM's display of the code in Register A, which clears the line and returns to the caller.

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.

557C
DEFB 1EH 1E
The state of the flashing prompt (554DH): 1EH not shown, 00H shown.
557D-55A5
DEFM "CONVERT - DOSPLUS File conversion - 3.50" / DEFB 0AH 43 4F 4E 56 45 52 54 20 2D 20 44 4F 53 50 4C 55 53 20 46 69 6C 65 20 63 6F 6E 76 65 72 73 69 6F 6E 20 2D 20 33 2E 35 30 0A
The heading (5201H): CONVERT - DOSPLUS File conversion - 3.50 and a line feed.
55A6-55D6
DEFM "(c) Copyright 1983, Micro-Systems Software Inc." / DEFB 0AH,0DH 28 63 29 20 43 6F 70 79 72 69 67 68 74 20 31 39 38 33 2C 20 4D 69 63 72 6F 2D 53 79 73 74 65 6D 73 20 53 6F 66 74 77 61 72 65 20 49 6E 63 2E 0A 0D
The copyright line, a line feed and the 0DH at which DSPLY@ stops.
55D7-55EB
DEFM "Disk not as expected" / DEFB 0DH 44 69 73 6B 20 6E 6F 74 20 61 73 20 65 78 70 65 63 74 65 64 0D
The message for a rigid or 8 inch source drive, or a boot sector that does not start with FEH (5495H).
55EC-5607
DEFM "EOF exceeds allocated space" / DEFB 0DH 45 4F 46 20 65 78 63 65 65 64 73 20 61 6C 6C 6F 63 61 74 65 64 20 73 70 61 63 65 0D
The message when the extents of the entry end before its sector count (549AH).
5608-5622
DEFM "Insert TARGET disk [ENTER]" / DEFB 03H 49 6E 73 65 72 74 20 54 41 52 47 45 54 20 64 69 73 6B 20 5B 45 4E 54 45 52 5D 03
The prompt before the directory conversion on drive 0 (545CH), ended by 03H.
5623-563D
DEFM "Insert SYSTEM disk [ENTER]" / DEFB 03H 49 6E 73 65 72 74 20 53 59 53 54 45 4D 20 64 69 73 6B 20 5B 45 4E 54 45 52 5D 03
The prompt for the system diskette in drive 0 (553EH), ended by 03H.
563E-564A
DEFB D0H,1BH / DEFM "Convert ? " / DEFB 03H D0 1B 43 6F 6E 76 65 72 74 20 3F 20 03
The question of QUERY (5397H): sixteen spaces, the cursor up, then Convert ? after the name.
564B-5659
DEFB D0H,1BH / DEFM "Overwrite ? " / DEFB 03H D0 1B 4F 76 65 72 77 72 69 74 65 20 3F 20 03
The question of OVER (53DCH): sixteen spaces, the cursor up, then Overwrite ? after the name.
565A
DEFB 00H 00
The flags of the evaluation block, set by EVAL@: bit 0 the source, 1 the destination, 2 the wildmask, 3 the parameters.
565B-565C
DEFW 56BCH BC 56
The address of the source field's block, 56BCH, the TRSDOS drive.
565D-565E
DEFW 56DDH DD 56
The address of the destination field's block, 56DDH, the DOSPLUS drive.
565F-5660
DEFW 56FEH FE 56
The address of the wildmask field's block, 56FEH.
5661-5662
DEFW 5663H 63 56
The address of the parameter block, 5663H, the nine entries.
5663-5668
DEFM "V13 " 56 31 33 20 20 20
The name of the parameter V13: TRSDOS 1.3, the default.
5669-566A
DEFW 56C1H C1 56
The address for V13's value, 56C1H, a byte of the source block's text: V13 is taken and changes nothing.
566B
DEFB 20H 20
The type byte of V13: a logical value only (bit 5).
566C-5671
DEFM "V12 " 56 31 32 20 20 20
The name of the parameter V12: TRSDOS 1.2 or earlier, whose sector count includes the last sector.
5672-5673
DEFW 53F5H F5 53
The address for V12's value, the operand of LD DE at 53F4H.
5674
DEFB 20H 20
The type byte of V12: a logical value only (bit 5).
5675-567A
DEFM "CAT " 43 41 54 20 20 20
The name of the parameter CAT: the catalog of the TRSDOS diskette.
567B-567C
DEFW 52A7H A7 52
The address for CAT's value, the operand of LD DE at 52A6H.
567D
DEFB 20H 20
The type byte of CAT: a logical value only (bit 5).
567E-5683
DEFM "DIR " 44 49 52 20 20 20
The name of the parameter DIR, the same as CAT.
5684-5685
DEFW 52A7H A7 52
The address for DIR's value, the operand of LD DE at 52A6H, the same as CAT's.
5686
DEFB 20H 20
The type byte of DIR: a logical value only (bit 5).
5687-568C
DEFM "SYSTEM" 53 59 53 54 45 4D
The name of the parameter SYSTEM (or S): system files are taken too.
568D-568E
DEFW 52F4H F4 52
The address for SYSTEM's value, the operand of LD DE at 52F3H.
568F
DEFB 20H 20
The type byte of SYSTEM: a logical value only (bit 5).
5690-5695
DEFM "INVIS " 49 4E 56 49 53 20
The name of the parameter INVIS (or I): invisible files are taken too.
5696-5697
DEFW 5302H 02 53
The address for INVIS's value, the operand of LD DE at 5301H.
5698
DEFB 20H 20
The type byte of INVIS: a logical value only (bit 5).
5699-569E
DEFM "OVER " 4F 56 45 52 20 20
The name of the parameter OVER (or O): ask before a file is written over.
569F-56A0
DEFW 53D6H D6 53
The address for OVER's value, the operand of LD DE at 53D5H.
56A1
DEFB 20H 20
The type byte of OVER: a logical value only (bit 5).
56A2-56A7
DEFM "QUERY " 51 55 45 52 59 20
The name of the parameter QUERY (or Q): ask before each file is copied.
56A8-56A9
DEFW 5391H 91 53
The address for QUERY's value, the operand of LD DE at 5390H.
56AA
DEFB 20H 20
The type byte of QUERY: a logical value only (bit 5).
56AB-56B0
DEFM "ECHO " 45 43 48 4F 20 20
The name of the parameter ECHO (or E): show the name of each file copied.
56B1-56B2
DEFW 53A2H A2 53
The address for ECHO's value, the operand of LD DE at 53A1H.
56B3
DEFB 20H 20
The type byte of ECHO: a logical value only (bit 5).
56B4
DEFB 00H 00
The 00H that ends the parameter block of CONVERT's nine parameters.
56B5
DEFB 04H 04
The names left on the row of the catalog (5359H), four a row.
56B6
DEFS 1
The source drive (5273H), read again for each sector of a copy (540FH).
56B7
DEFS 1
The logical record length of the file being copied (5382H), given to INIT@.
56B8-56B9
DEFS 2
The first buffer (5219H): the reply to the asterisk prompt and the sectors of the TRSDOS directory.
56BA-56BB
DEFS 2
The second buffer (521EH): the buffer of the copy and the reply to a question.
56BC-56DC
DEFS 33
The source field's block (565BH): its flag byte at 56BCH (5263H) and the text from 56BDH, later NAME/EXT:d, the file control block of the copy (FCB+08H 56C5H, FCB+0CH 56C9H).
56DD-56FD
DEFS 33
The destination field's block (565DH): its flag byte at 56DDH (52B0H) and the drive's text from 56DEH (53B8H).
56FE-571E
DEFS 33
The wildmask field's block (565FH): the flag byte and the text from 56FFH, given to WILD@ (52D5H), later the name for the questions (5388H).