LDOS 5.3.1 for the Model III - CONV/CMD Disassembled

Page Customization

Introduction/Summary

LDOS 5.3.1 CONV/CMD Disassembly - Files from TRSDOS 1.3 (Model III)

CONV/CMD copies files from a Model III TRSDOS diskette onto an LDOS diskette; the manual (M-40-060) says two drives are needed and that TRSDOS 1.2 and 1.3 diskettes are to be copied with CONV, never repaired. The command is CONV [-][name][/ext]:s [:d] [(parameters)]: s the drive of the TRSDOS diskette (not drive 0), d the drive of the LDOS diskette. The parameters are VIS, INV and SYS (the classes of files; none given means all), NEW and OLD (only files that do not, or do, exist on the destination), QUERY (on unless QUERY=N: CONV asks before each file, and again before it replaces one), and DIR, which the manual does not name, to list the files that match and copy nothing; without :d CONV lists them too. A $ in the name or extension matches any character, and a name shorter than 8 characters matches every name that starts with it. A minus sign before the name, not named in the manual either, takes the files that do not match.

The file is a load module of 1491 bytes: a record of type 1FH with the text Copyright 1991 MISOSYS, Inc., All rights reserved, six load blocks for 5200H-5783H (1412 bytes) and the transfer address record for 5200H. CONV reads the TRSDOS diskette with SYS0/SYS's RDSECT (4777H) itself, sector by sector: it sets the highest sector in the drive code table of the source drive to 18 (TRSDOS 1.3 numbers its sectors 1-18) and puts the table back at the end. It reads the directory into 5800H-67FFH, follows the extents of each file, and writes the sectors through the file routines of LDOS (@OPEN, @INIT, @POSN, @WRITE, @REW, @CLOSE) with a buffer from 6800H to HIGH$ less 256.

What CONV Does

StepWhat Happens
The command lineThe banner; a minus sign; the name and extension over the template of $ at 56F0H; :s and :d; @PARAM with the table at 560FH (5200H, 523AH).
The directoryThe drive code table is saved and its highest sector set to 18; the TRSDOS boot sector gives the directory track (byte 01H) and the version (byte FEH); sectors 3-18 of the directory track are read (528AH).
Choosing the filesEach of the 80 records: in use and not an extension record, the class, the name against the template (52D4H); without a destination the name goes into the list (55BBH).
The destination@OPEN of NAME/EXT.P3UF:d tells whether the file exists; NEW and OLD; the questions (5372H, 53B6H).
The copyA new file is created by @INIT; the length is set by @POSN and @WRITE of the last sector, then @REW; the sectors are read by extent into the buffer and written by @WRITE; @CLOSE with the EOF byte of the TRSDOS record (540CH, 547BH, 5501H).
The endThe drive code table is put back and CONV ends at @EXIT; errors end through @ERROR or @ABORT (54BCH).

About This Page

The site has no Model I page of CONV/CMD, so this page is written from the bytes of the Model III file alone; the TRSDOS 1.3 structures it reads (boot sector, directory records, extents) are those of the TRSDOS 1.3 pages of this site. Every byte of the file is shown at its address. Found in the code: the password P3UF that CONV puts on the file specification for @OPEN has the hash code 113DH, the same as RS0LT0FF, the password of the LDOS system files, so a protected file on the destination opens and can be replaced; a new file is created without it (5417H). The parameter DIR and the minus sign before the name are not in the manual. The copy of a name from the command line (557EH) is not limited to 8 or 3 characters, so a longer name runs on into the extension of the template. On the ways out after a parameter error, a source of drive 0 or the same drive twice, 54F5H copies 57CDH-57D6H (beyond the file, not yet saved) to the address in Index Register IY, which CONV has not set at that point; BREAK before a record and BREAK at a question end at @ABORT without putting the drive code table back, so the source drive keeps 18 as its highest sector.

Memory Map

Load Blocks in File Order

The six load blocks of the file, after the copyright record: 1412 bytes, 5200H-5783H. The transfer address is 5200H.

AddressContents
5200H-52FFH256 bytes
5300H-53FFH256 bytes
5400H-54FFH256 bytes
5500H-55FFH256 bytes
5600H-56FFH256 bytes
5700H-5783H132 bytes

Sections of the Disassembly

AddressContents
5200HEntry: the Banner and the File Specification
523AHThe Drives and the Parameters
528AHRead the TRSDOS 1.3 Directory
52D4HChoose the Files
5372HOpen the File on the Destination
53B6HThe Questions
540CHCreate the File and Set Its Length
547BHCopy the Sectors
54BCHThe Next Record and the Ends
5501HRead the Next Sector of the TRSDOS 1.3 File
5558HThe Command Line Routines
55BBHThe List of the Files
560FHThe Parameter Table and the Texts
5784HThe Work Areas Beyond the File

Memory CONV/CMD Uses

AddressContents
0033H, 0040H, 0049HROM: display the character in Register A, line input (Register Pair HL the buffer, Register B the length, the CARRY FLAG after BREAK), wait for a key.
402DH, 4030H, 4409H, 428AH, 4454H, 4467H@EXIT, @ABORT, @ERROR, @LOGOT, @PARAM and @DSPLY.
4420H, 4424H, 4428H, 4439H, 443FH, 4442H@INIT, @OPEN, @CLOSE, @WRITE, @REW and @POSN, on the file control block at 57A4H.
4411H-4412HHIGH$: the data buffer ends 256 bytes below it (5480H).
429FHKFLAG$: bits 2-0 cleared at the start (5208H); bit 0, BREAK, tested before each record (52D4H).
4777H, 478FHSYS0/SYS's RDSECT and GETDCT: the reads of the TRSDOS diskette, drive Register C, cylinder Register D, sector Register E.
Drive code table +07HThe highest sector of a track: 12H while CONV reads the TRSDOS diskette (52B4H, 52BFH); the whole table kept at 57CDH.
TRSDOS 1.3 boot sector 01H, FEHThe directory track and the version byte (52AAH-52B1H).
TRSDOS 1.3 directory record+00H the attribute (bit 7 extension record, bit 6 system, bit 4 in use, bit 3 invisible), +03H the EOF byte, +04H the record length, +05H-+0FH the name and extension, +14H-+15H the ending record number, +16H on the extents (track, then the first granule in bits 7-5 and the granules in bits 4-0; FFH ends them).

Variables

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

Entry Points

AddressContents
5200HThe start of CONV/CMD, the transfer address of the file.
54EBH, 54EDHError 2CH, or the error in Register A: the drive code table is put back and @ERROR ends the program.
54F5HPut the 10 bytes at 57CDH back into the drive code table at Index Register IY.
5501HRead the next sector of the TRSDOS 1.3 file into the page at Register Pair HL; the NZ FLAG and Register A = 1CH at its end.
5558H, 555EHTake an optional or a required drive :d from the command line.
556FH, 5576H, 557EH, 5588HPass over spaces, pass over or copy the characters of a name, test a character of a name.
55A5H, 55ABHCompare Register Pair HL with Register Pair DE; turn the name compare round after a minus sign.
55BBH, 560AHDisplay a name in the list; display 0DH.

Data in the File

Address
Size
Contents
560FH-5616H
8 bytes
DEFM "QUERY " / DEFW 5272H
560FH-5616H: QUERY and 5272H, the operand of LD HL at 5271H: QUERY=N stores 0000H there.
5617H-561EH
8 bytes
DEFM "Q " / DEFW 5272H
5617H-561EH: Q, short for QUERY, and the same operand 5272H.
561FH-5626H
8 bytes
DEFM "SYS " / DEFW 5263H
561FH-5626H: SYS and 5263H, the operand of LD HL at 5262H: system files.
5627H-562EH
8 bytes
DEFM "S " / DEFW 5263H
5627H-562EH: S, short for SYS, and the same operand 5263H.
562FH-5636H
8 bytes
DEFM "INV " / DEFW 5269H
562FH-5636H: INV and 5269H, the operand of LD BC at 5268H: invisible files.
5637H-563EH
8 bytes
DEFM "I " / DEFW 5269H
5637H-563EH: I, short for INV, and the same operand 5269H.
563FH-5646H
8 bytes
DEFM "VIS " / DEFW 5266H
563FH-5646H: VIS and 5266H, the operand of LD DE at 5265H: visible files.
5647H-564EH
8 bytes
DEFM "V " / DEFW 5266H
5647H-564EH: V, short for VIS, and the same operand 5266H.
564FH-5656H
8 bytes
DEFM "OLD " / DEFW 5278H
564FH-5656H: OLD and 5278H, the operand of LD BC at 5277H: only files that exist on the destination.
5657H-565EH
8 bytes
DEFM "O " / DEFW 5278H
5657H-565EH: O, short for OLD, and the same operand 5278H.
565FH-5666H
8 bytes
DEFM "NEW " / DEFW 5275H
565FH-5666H: NEW and 5275H, the operand of LD DE at 5274H: only files that do not exist on the destination.
5667H-566EH
8 bytes
DEFM "N " / DEFW 5275H
5667H-566EH: N, short for NEW, and the same operand 5275H.
566FH-5676H
8 bytes
DEFM "DIR " / DEFW 5257H
566FH-5676H: DIR and 5257H, the operand of LD HL at 5256H: list the files, convert nothing. The manual does not name DIR.
5677H-567EH
8 bytes
DEFM "D " / DEFW 5257H
5677H-567EH: D, short for DIR, and the same operand 5257H.
567FH
1 byte
DEFB 00H
567FH: 00H, the end of the table: @PARAM stops here.
5680H-56BBH
60 bytes
DEFM "CONV - TRSDOS 1.3 -> LDOS conversion utility - Version 5.3.1"
5680H-56BBH: the name of the program, what it does and its version, the start of the banner displayed by 5204H.
56BCH
1 byte
DEFB 0AH
56BCH: 0AH, a new line: the copyright goes on the next line.
56BDH-56EDH
49 bytes
DEFM "Copyright 1991 MISOSYS, Inc., All rights reserved"
56BDH-56EDH: the copyright line, the same text as the copyright record of the file.
56EEH-56EFH
2 bytes
DEFB 0AH, 0DH
56EEH-56EFH: 0AH, a new line, and 0DH, the end of the banner.
56F0H-56FAH
11 bytes
DEFM "$$$$$$$$$$$"
56F0H-56FAH: the template, 8 characters of the name and 3 of the extension, all $; 5223H and 5234H copy the name and extension of the command line over it.
56FBH-5700H
6 bytes
DEFM ".P3UF:"
56FBH-5700H: the password P3UF (hash code 113DH, as RS0LT0FF) and the colon before the drive, put after NAME/EXT by 537CH.
5701H-5702H
2 bytes
DEFM "? "
5701H-5702H: a question mark and a space, displayed by 53D6H after Convert file NAME/EXT.
5703H
1 byte
DEFB 03H
5703H: 03H, the end of the text for @DSPLY: the cursor stays after the space.
5704H-572DH
42 bytes
DEFM "Source and Destination drives are the same"
5704H-572DH: the text of 54DBH, displayed by @LOGOT when :s and :d name one drive.
572EH
1 byte
DEFB 0DH
572EH: 0DH, the end of the line and of the text.
572FH-5746H
24 bytes
DEFM "Source cannot be drive 0"
572FH-5746H: the text of 54DFH, displayed by @LOGOT for :0 as the source.
5747H
1 byte
DEFB 0DH
5747H: 0DH, the end of the line and of the text.
5748H-5764H
29 bytes
DEFM " File exists -- replace it? "
5748H-5764H: the second question of 53F3H, after two spaces, when the file is already on the destination.
5765H
1 byte
DEFB 03H
5765H: 03H, the end of the text for @DSPLY: the cursor stays after the question.
5766H-5775H
16 bytes
DEFM "Converting file "
5766H-5775H: the text of 53BCH, displayed before the name with QUERY=N.
5776H
1 byte
DEFB 03H
5776H: 03H, the end of the text for @DSPLY: the name follows on the same line.
5777H-5783H
13 bytes
DEFM "Convert file "
5777H-5783H: the question of 53CDH; it has no end byte, @DSPLY runs on into the name copied to 5784H, the last byte of the file being 5783H.

Operands Changed While It Runs

Address
Size
Contents
5257H-5258H
2 bytes
DIR (@PARAM): FFFFH lists the files only.
5263H-5264H, 5266H-5267H, 5269H-526AH
2 bytes each
SYS, VIS and INV (@PARAM); their low bytes are read at 52F4H, 5301H and 530AH.
52ECH
1 byte
Any class given: the OR of the three low bytes (526EH).
5272H-5273H
2 bytes
QUERY (@PARAM): FFFFH in the file, 0000H for QUERY=N; read at 53B6H.
5275H-5276H, 5278H-5279H
2 bytes each
NEW and OLD (@PARAM); read at 53AAH and 53A0H.
539CH
1 byte
NEW or OLD given (527CH).
5415H-5416H
2 bytes
The place after NAME/EXT in the file control block (5372H), where 5417H writes :d without the password.
5448H
1 byte
The TRSDOS version byte (52B1H).
55ADH
1 byte
FFH after a minus sign (5217H).
55D0H-55D1H
2 bytes
The column (low byte) and line count (high byte) of the list (55E6H).

Cells Outside the File That CONV/CMD Uses

Address
Size
Contents
5784H-57A3H
32 bytes
DEFS 32
5784H-57A3H: not in the file. The copy of the 32 bytes at 57A4H made by 5363H: NAME/EXT ended by 03H, displayed after Convert file and by 55BBH.
57A4H-57C3H
32 bytes
DEFS 32
57A4H-57C3H: not in the file. The file control block of the destination file: the file specification (532EH-5387H), then the open file (+00H bit 7, +01H, +03H-+04H at 57A7H the buffer, +08H at 57ACH the EOF byte, +09H).
57C4H
1 byte
DEFS 1
57C4H: not in the file. The source drive, the TRSDOS 1.3 diskette (523DH).
57C5H
1 byte
DEFS 1
57C5H: not in the file. The destination drive, or FFH for the list only (524AH, 525FH).
57C6H-57C7H
2 bytes
DEFS 2
57C6H-57C7H: not in the file. The next sector (57C6H) and track (57C7H) of the TRSDOS 1.3 file (5524H, 5550H).
57C8H-57CCH
5 bytes
DEFS 5
57C8H-57CCH: not in the file. The answer to the questions: ROM 0040H stores up to 3 characters and the ENTER at 57C8H on.
57CDH-57D6H
10 bytes
DEFS 10
57CDH-57D6H: not in the file. The drive code table of the source drive as it was (5297H), put back by 54F5H.
5800H-67FFH
4096 bytes
DEFS 4096
5800H-67FFH: not in the file. The TRSDOS 1.3 boot sector (52A0H), then the 16 directory sectors, 80 records of 48 bytes, five to a page.
6800H-68FFH
256 bytes
DEFS 256
6800H-68FFH: not in the file. The first page of the data buffer and the buffer of the file control block; the buffer goes on to HIGH$ less 256 (5480H).

Disassembly

5200H - Entry: the Banner and the File Specification

LDOS Ready loads CONV/CMD at 5200H-5783H and jumps to 5200H, the transfer address, with Register Pair HL at the rest of the command line after the word CONV and the spaces after it. The command is CONV [-][name][/ext]:s [:d] [(parameters)] (M-40-060): s the TRSDOS 1.3 diskette, d the LDOS diskette. The banner is displayed and the BREAK, SHIFT @ and ENTER flags of KFLAG$ are cleared. A minus sign before the file specification, which the manual does not name, turns the match round: the files that do not match are taken. The name and the extension are copied over the template 56F0H-56FAH, 11 characters of $, the character that matches any character: a name shorter than 8 characters keeps $ in the rest, so it matches every name that starts with it.

5200
PUSH HL E5
Save Register Pair HL (the pointer to the command line after CONV) to the stack across the display of the banner.
5201
LD HL,5680H 21 80 56
Point Register Pair HL to 5680H, the banner: CONV - TRSDOS 1.3 -> LDOS conversion utility - Version 5.3.1, the copyright line and 0DH.
5204
GOSUB to 4467H, @DSPLY, to display the text at Register Pair HL (5680H) up to its 0DH.
5207
POP HL E1
Restore Register Pair HL from the stack: the pointer to the command line.
5208
LD A,(429FH) 3A 9F 42
Fetch KFLAG$ from 429FH into Register A: bit 0 BREAK, bit 1 SHIFT @, bit 2 ENTER, each set by the keyboard task when the key was pressed.
520B
AND F8H E6 F8
Mask Register A with F8H: bits 2-0, the three key flags, are cleared, so a BREAK pressed before CONV ran does not end it.
520D
LD (429FH),A 32 9F 42
Store Register A (KFLAG$ with bits 2-0 clear) back at 429FH.
5210
LD A,(HL) 7E
Fetch the first character of the command line at Register Pair HL into Register A.
5211
CP 2DH FE 2D
Compare Register A (the character) against 2DH, a minus sign.
5213
If the NZ FLAG is set (no minus sign), JUMP to 521BH to take the file specification.
5215
LD A,FFH 3E FF
Load Register A with FFH, the value that turns the match round.
5217
LD (55ADH),A 32 AD 55
Store Register A (FFH) at 55ADH, the operand of LD A,00H at 55ACH: 55ABH then takes a file only when its name does not match.
521A
INC HL 23
INCrement Register Pair HL past the minus sign.
521B
LD DE,56F0H 11 F0 56
Point Register Pair DE to 56F0H, the first byte of the template, the 8 characters of the name.
521E
LD B,08H 06 08
Load Register B with 08H, the length of a name. 557EH does not count with Register B: the copy stops only at a character that cannot be in a name.
5220
GOSUB to 556FH to pass over the spaces at Register Pair HL.
5223
GOSUB to 557EH to copy the letters, digits and $ at Register Pair HL to Register Pair DE (56F0H on), small letters made capitals.
5226
GOSUB to 5576H to pass over letters, digits and $ at Register Pair HL: 557EH stopped at a character that is none of them, so nothing more is passed over.
5229
LD A,(HL) 7E
Fetch the character at Register Pair HL, the one that ended the name, into Register A.
522A
CP 2FH FE 2F
Compare Register A (the character) against 2FH, the slash before an extension.
522C
If the NZ FLAG is set (no extension given), JUMP to 523AH: the extension of the template stays $$$.
522E
INC HL 23
INCrement Register Pair HL past the slash, to the first character of the extension.
522F
LD DE,56F8H 11 F8 56
Point Register Pair DE to 56F8H, the 3 characters of the extension in the template.
5232
LD B,03H 06 03
Load Register B with 03H, the length of an extension; 557EH does not count with it.
5234
GOSUB to 557EH to copy the extension at Register Pair HL to Register Pair DE (56F8H on), small letters made capitals.
5237
GOSUB to 5576H to pass over letters, digits and $ at Register Pair HL: none are left after 557EH.

523AH - The Drives and the Parameters

The source drive must follow as :s (else error 2CH) and cannot be drive 0 (Source cannot be drive 0). The destination :d may be left out: then, or with the parameter DIR, CONV only lists the files that match (the drive cell 57C5H holds FFH). @PARAM reads the table at 560FH, which stores FFFFH, or the value given, into the operands of the LD instructions at 5256H-5277H; their bytes are collected into two cells: 52ECH (any of SYS, VIS, INV given) and 539CH (NEW or OLD given). QUERY is on unless QUERY=N is given.

523A
GOSUB to 555EH to take :s at Register Pair HL: Register A = the drive number 00H-07H; anything else gives error 2CH, Parameter error.
523D
LD (57C4H),A 32 C4 57
Store Register A (the source drive) at 57C4H, the drive of the TRSDOS 1.3 diskette.
5240
AND A A7
Set the flags from Register A (AND A), the source drive: the Z FLAG for drive 0.
5241
If the Z FLAG is set (drive 0), JUMP to 54DFH, inside the LD IX at 54DEH, to display Source cannot be drive 0 and end at @ABORT.
5244
GOSUB to 556FH to pass over the spaces at Register Pair HL.
5247
GOSUB to 5558H to take :d at Register Pair HL: Register A = the drive number, or FFH when no colon follows (no destination).
524A
LD (57C5H),A 32 C5 57
Store Register A (the destination drive, or FFH) at 57C5H, the drive of the LDOS diskette.
524D
LD DE,560FH 11 0F 56
Point Register Pair DE to 560FH, the table of the parameters: QUERY, SYS, INV, VIS, OLD, NEW and DIR, each also by its first letter.
5250
GOSUB to 4454H, @PARAM, to read the parameters at Register Pair HL against the table at Register Pair DE (560FH), storing each value into its operand. The Z FLAG on success.
5253
If the NZ FLAG is set (an unknown parameter or a bad value), JUMP to 54EBH to give error 2CH, Parameter error.
5256
LD HL,0000H 21 00 00
Load Register Pair HL with the DIR parameter: the operand 5257H-5258H, 0000H in the file, FFFFH when DIR was given.
5259
LD A,H 7C
Copy Register H (the high byte of DIR) into Register A.
525A
OR L B5
OR Register L (the low byte) into Register A: the Z FLAG when DIR was not given.
525B
If the Z FLAG is set (no DIR), JUMP to 5262H with the destination drive as the command line gave it.
525D
LD A,FFH 3E FF
Load Register A with FFH, the drive value that means no destination: only the list of the files.
525F
LD (57C5H),A 32 C5 57
Store Register A (FFH) at 57C5H, the destination drive: DIR lists the files even when a destination was given.
5262
LD HL,0000H 21 00 00
Load Register Pair HL with the SYS parameter, the operand 5263H-5264H (0000H in the file, FFFFH when SYS was given); 52F4H reads its low byte.
5265
LD DE,0000H 11 00 00
Load Register Pair DE with the VIS parameter, the operand 5266H-5267H (0000H in the file, FFFFH when VIS was given); 5301H reads its low byte.
5268
LD BC,0000H 01 00 00
Load Register Pair BC with the INV parameter, the operand 5269H-526AH (0000H in the file, FFFFH when INV was given); 530AH reads its low byte.
526B
LD A,L 7D
Copy Register L (the low byte of SYS) into Register A.
526C
OR E B3
OR Register E (the low byte of VIS) into Register A.
526D
OR C B1
OR Register C (the low byte of INV) into Register A: 00H when none of the three was given.
526E
LD (52ECH),A 32 EC 52
Store Register A at 52ECH, the operand of LD A,00H at 52EBH: 00H means every class of file is taken (the manual: none given, all are considered).
5271
LD HL,FFFFH 21 FF FF
Load Register Pair HL with the QUERY parameter, the operand 5272H-5273H: FFFFH in the file, so CONV asks before each file; QUERY=N stores 0000H.
5274
LD DE,0000H 11 00 00
Load Register Pair DE with the NEW parameter, the operand 5275H-5276H (0000H in the file, FFFFH when NEW was given); 53AAH reads its low byte.
5277
LD BC,0000H 01 00 00
Load Register Pair BC with the OLD parameter, the operand 5278H-5279H (0000H in the file, FFFFH when OLD was given); 53A0H reads its low byte.
527A
LD A,E 7B
Copy Register E (the low byte of NEW) into Register A.
527B
OR C B1
OR Register C (the low byte of OLD) into Register A: 00H when neither was given.
527C
LD (539CH),A 32 9C 53
Store Register A at 539CH, the operand of LD A,00H at 539BH: 00H means a file is taken whether it exists on the destination or not.
527F
LD A,(57C4H) 3A C4 57
Fetch the source drive from 57C4H into Register A.
5282
LD C,A 4F
Copy Register A (the source drive) into Register C, the drive for GETDCT and the disk routines.
5283
LD A,(57C5H) 3A C5 57
Fetch the destination drive from 57C5H into Register A.
5286
CP C B9
Compare Register A (the destination drive) against Register C (the source drive): the Z FLAG when they are the same.
5287
If the Z FLAG is set (the same drive), JUMP to 54DBH to display Source and Destination drives are the same and end at @ABORT.

528AH - Read the TRSDOS 1.3 Directory

The drive code table of the source drive is saved at 57CDH-57D6H (54F5H puts it back at the end) and its +07H, the highest sector of a track, is set to 12H: TRSDOS 1.3 numbers its 18 sectors 1-18. Sector 1 of cylinder 0 is the TRSDOS 1.3 boot sector: its byte 01H is the directory track, byte FEH the version of TRSDOS (13H for 1.3). The 16 sectors of directory records, sectors 3-18 of the directory track, are read into 5800H-67FFH. A read that returns error 06H counts as good: TRSDOS 1.3 writes its directory with the other data address mark.

528A
GOSUB to 478FH, GETDCT, to point Index Register IY at the drive code table of the source drive, Register C.
528D
PUSH BC C5
Save Register Pair BC (Register C = the source drive) to the stack across the copy below.
528E
PUSH IY FD E5
Save Index Register IY (the drive code table) to the stack, to move it into Register Pair HL.
5290
POP HL E1
Restore it into Register Pair HL: Register Pair HL = the drive code table of the source drive.
5291
LD DE,57CDH 11 CD 57
Point Register Pair DE to 57CDH, the place beyond the file where the table is kept while CONV changes it.
5294
LD BC,000AH 01 0A 00
Load Register Pair BC with 000AH, the 10 bytes of a drive code table.
5297
LDIR ED B0
Copy the 10 bytes of the drive code table from Register Pair HL to 57CDH at Register Pair DE, Register Pair BC the count (LDIR).
5299
POP BC C1
Restore Register Pair BC from the stack: Register C = the source drive.
529A
LD DE,0001H 11 01 00
Load Register Pair DE with 0001H: Register D = cylinder 0, Register E = sector 1, the first sector of a TRSDOS 1.3 track, its boot sector.
529D
LD HL,5800H 21 00 58
Point Register Pair HL to 5800H, the buffer of the directory.
52A0
GOSUB to 4777H, RDSECT, to read cylinder Register D (00H), sector Register E (01H) of drive Register C into the buffer at Register Pair HL (5800H).
52A3
If the Z FLAG is set (the read worked), JUMP to 52AAH.
52A5
CP 06H FE 06
Compare Register A (the error of the read) against 06H, the sector carried the other data address mark.
52A7
If the NZ FLAG is set (any other error), JUMP to 54EDH to display the error, put the drive code table back and end.
52AA
INC HL 23
INCrement Register Pair HL to 5801H, byte 01H of the TRSDOS 1.3 boot sector: the directory track.
52AB
LD D,(HL) 56
Fetch the directory track from Register Pair HL (5801H) into Register D, the cylinder of the reads below.
52AC
INC H 24
INCrement Register H: Register Pair HL = 5901H, one page above.
52AD
DEC HL 2B
DECrement Register Pair HL to 5900H, on the way back to byte FEH of the boot sector.
52AE
DEC HL 2B
DECrement Register Pair HL to 58FFH, the last byte of the boot sector.
52AF
DEC HL 2B
DECrement Register Pair HL to 58FEH, byte FEH of the boot sector: the version of TRSDOS.
52B0
LD A,(HL) 7E
Fetch the version byte from Register Pair HL (58FEH) into Register A: 13H for TRSDOS 1.3.
52B1
LD (5448H),A 32 48 54
Store Register A (the version) at 5448H, the operand of LD A,00H at 5447H, where the count of sectors of each file is worked out.
52B4
LD (IY+07H),12H FD 36 07 12
Store 12H at +07H of the drive code table at Index Register IY: the highest sector of a track is 18 for the reads of the TRSDOS 1.3 diskette.
52B8
LD E,03H 1E 03
Load Register E with 03H, sector 3 of the directory track, the first sector of directory records.
52BA
LD B,10H 06 10
Load Register B with 10H, the 16 sectors 3-18 of directory records.
52BC
LD HL,5800H 21 00 58
Point Register Pair HL to 5800H, the buffer of the directory: one sector after the other, 5800H-67FFH.
52BF
LD (IY+07H),12H FD 36 07 12
Store 12H at +07H of the drive code table at Index Register IY again before each read: the highest sector, 18.
52C3
GOSUB to 4777H, RDSECT, to read cylinder Register D (the directory track), sector Register E of drive Register C into the buffer at Register Pair HL.
52C6
If the Z FLAG is set (the read worked), JUMP to 52CDH.
52C8
CP 06H FE 06
Compare Register A (the error of the read) against 06H: the directory sectors of TRSDOS 1.3 carry the other data address mark.
52CA
If the NZ FLAG is set (any other error), JUMP to 54EDH to display the error, put the drive code table back and end.
52CD
INC H 24
INCrement Register H: Register Pair HL = the next page of the buffer for the next sector.
52CE
INC E 1C
INCrement Register E to the next sector of the directory track.
52CF
DECrement Register B and LOOP BACK to 52BFH until the 16 sectors are read.
52D1
LD HL,5800H 21 00 58
Point Register Pair HL to 5800H, the first directory record: the loop below takes the 80 records, five of 48 bytes in each sector.

52D4H - Choose the Files

For each record (Index Register IX and Register Pair HL at it, its first byte the attribute): BREAK ends CONV at @ABORT; a record not in use (bit 4 clear) or an extension record (bit 7 set) is passed over. When SYS, VIS or INV was given, a system file (bit 6) needs SYS, an invisible file (bit 3) INV, and any other VIS. The name and extension (+05H-+0FH, 11 bytes padded with spaces) are compared with the template at 56F0H, $ matching any character, and 55ABH turns the answer round after a minus sign. The name of a file taken is built at 57A4H as NAME/EXT ended by 03H and copied to 5784H for the displays.

52D4
LD A,(429FH) 3A 9F 42
Fetch KFLAG$ from 429FH into Register A, before each record: bit 0 is set after BREAK.
52D7
BIT 0,A CB 47
Test bit 0 of Register A (KFLAG$): set when BREAK was pressed.
52D9
If the NZ FLAG is set (BREAK), JUMP to 4030H, @ABORT. The drive code table of the source drive is not put back on this way out: its +07H stays 12H.
52DC
LD B,(HL) 46
Fetch the first byte of the record at Register Pair HL into Register B: the attribute byte.
52DD
PUSH HL E5
Save Register Pair HL (the record) to the stack, to move it into Index Register IX.
52DE
POP IX DD E1
Restore it into Index Register IX: Index Register IX = the record, for +03H and +04H below.
52E0
PUSH HL E5
Save Register Pair HL (the record) to the stack again: 54BCH takes it back to step to the next record.
52E1
BIT 4,B CB 60
Test bit 4 of Register B (the attribute byte): set when the record is in use.
52E3
If the Z FLAG is set (a free record), JUMP to 54BCH to go on with the next record.
52E6
BIT 7,B CB 78
Test bit 7 of Register B (the attribute byte): set for an extension record, which carries more extents of a file, not a file of its own.
52E8
If the NZ FLAG is set (an extension record), JUMP to 54BCH to go on with the next record.
52EB
LD A,00H 3E 00
Load Register A with 00H, the class switch: the operand 52ECH is stored by 526EH, 00H when none of SYS, VIS and INV was given.
52ED
AND A A7
Set the flags from Register A (AND A): the Z FLAG when no class was given.
52EE
If the Z FLAG is set (no class given), JUMP to 5311H: every file is a candidate.
52F0
BIT 6,B CB 70
Test bit 6 of Register B (the attribute byte): set for a system file.
52F2
If the Z FLAG is set (not a system file), JUMP to 52FDH to look at the invisible bit.
52F4
LD A,(5263H) 3A 63 52
Fetch the low byte of the SYS parameter from 5263H, the operand of LD HL at 5262H, into Register A.
52F7
AND A A7
Set the flags from Register A (AND A): the Z FLAG when SYS was not given.
52F8
If the Z FLAG is set (a system file without SYS), JUMP to 54BCH to go on with the next record.
52FB
JUMP to 5311H to compare the name of the system file.
52FD
BIT 3,B CB 58
Test bit 3 of Register B (the attribute byte): set for an invisible file.
52FF
If the NZ FLAG is set (an invisible file), JUMP to 530AH to look at INV.
5301
LD A,(5266H) 3A 66 52
Fetch the low byte of the VIS parameter from 5266H, the operand of LD DE at 5265H, into Register A.
5304
AND A A7
Set the flags from Register A (AND A): the Z FLAG when VIS was not given.
5305
If the Z FLAG is set (a visible file without VIS), JUMP to 54BCH to go on with the next record.
5308
JUMP to 5311H to compare the name of the visible file.
530A
LD A,(5269H) 3A 69 52
Fetch the low byte of the INV parameter from 5269H, the operand of LD BC at 5268H, into Register A.
530D
AND A A7
Set the flags from Register A (AND A): the Z FLAG when INV was not given.
530E
If the Z FLAG is set (an invisible file without INV), JUMP to 54BCH to go on with the next record.
5311
LD DE,0005H 11 05 00
Load Register Pair DE with 0005H, the offset of the name in a TRSDOS 1.3 directory record.
5314
ADD HL,DE 19
ADD Register Pair DE (5) to Register Pair HL: Register Pair HL = +05H of the record, the name.
5315
PUSH HL E5
Save Register Pair HL (the name) to the stack: the compare below moves Register Pair HL.
5316
LD DE,56F0H 11 F0 56
Point Register Pair DE to 56F0H, the template: 8 characters of the name and 3 of the extension.
5319
LD B,0BH 06 0B
Load Register B with 0BH, the 11 characters of name and extension.
531B
LD A,(DE) 1A
Fetch the next character of the template at Register Pair DE into Register A.
531C
INC DE 13
INCrement Register Pair DE to the next character of the template.
531D
CP 24H FE 24
Compare Register A (the template character) against 24H, the $ that matches any character.
531F
If the Z FLAG is set ($), JUMP to 5324H without comparing: the character of the record does not matter.
5321
CP (HL) BE
Compare Register A (the template character) against the character of the record at Register Pair HL.
5322
If the NZ FLAG is set (a different character), JUMP to 5327H with the NZ FLAG: the name does not match.
5324
INC HL 23
INCrement Register Pair HL to the next character of the record.
5325
DECrement Register B and LOOP BACK to 531BH until the 11 characters are compared; the loop ends with the Z FLAG.
5327
POP HL E1
Restore Register Pair HL from the stack: +05H of the record, the name.
5328
GOSUB to 55ABH, which turns the Z FLAG (a match) round when the command line started with a minus sign.
532B
If the NZ FLAG is set (the file is not taken), JUMP to 54BCH to go on with the next record.
532E
LD DE,57A4H 11 A4 57
Point Register Pair DE to 57A4H, the file control block beyond the file, where the file specification is built.
5331
LD B,08H 06 08
Load Register B with 08H, at most 8 characters of the name.
5333
LD A,(HL) 7E
Fetch the next character of the name at Register Pair HL into Register A.
5334
CP 20H FE 20
Compare Register A (the character) against 20H, a space: the name ends at the first space.
5336
If the Z FLAG is set (a space), JUMP to 533DH with Register B = the characters not used.
5338
INC HL 23
INCrement Register Pair HL to the next character of the record.
5339
LD (DE),A 12
Store Register A (the character) at Register Pair DE, the file specification.
533A
INC DE 13
INCrement Register Pair DE to the next place of the file specification.
533B
DECrement Register B and LOOP BACK to 5333H until the 8 characters are copied.
533D
LD C,B 48
Copy Register B (the characters of the name not used) into Register C.
533E
LD B,00H 06 00
Load Register B with 00H: Register Pair BC = the characters not used.
5340
ADD HL,BC 09
ADD Register Pair BC to Register Pair HL: Register Pair HL = +0DH of the record, the extension.
5341
LD A,(HL) 7E
Fetch the first character of the extension at Register Pair HL into Register A.
5342
CP 20H FE 20
Compare Register A (the character) against 20H, a space: no extension.
5344
If the Z FLAG is set (no extension), JUMP to 5356H to end the file specification.
5346
LD A,2FH 3E 2F
Load Register A with 2FH, the slash before the extension.
5348
LD (DE),A 12
Store Register A (2FH) at Register Pair DE, the file specification.
5349
INC DE 13
INCrement Register Pair DE to the place after the slash.
534A
LD B,03H 06 03
Load Register B with 03H, at most 3 characters of the extension.
534C
LD A,(HL) 7E
Fetch the next character of the extension at Register Pair HL into Register A.
534D
INC HL 23
INCrement Register Pair HL to the next character of the record.
534E
CP 20H FE 20
Compare Register A (the character) against 20H, a space: the extension ends at a space.
5350
If the Z FLAG is set (a space), JUMP to 5356H to end the file specification.
5352
LD (DE),A 12
Store Register A (the character) at Register Pair DE, the file specification.
5353
INC DE 13
INCrement Register Pair DE to the next place of the file specification.
5354
DECrement Register B and LOOP BACK to 534CH until the 3 characters are copied.
5356
LD A,03H 3E 03
Load Register A with 03H, the end of a text for @DSPLY.
5358
LD (DE),A 12
Store Register A (03H) at Register Pair DE, after NAME/EXT: Register Pair DE keeps this place.
5359
PUSH DE D5
Save Register Pair DE (the place of the 03H) to the stack across the copy.
535A
LD DE,5784H 11 84 57
Point Register Pair DE to 5784H, the copy of the name for the displays, just after the text at 5777H.
535D
LD HL,57A4H 21 A4 57
Point Register Pair HL to 57A4H, the file specification.
5360
LD BC,0020H 01 20 00
Load Register Pair BC with 0020H, the 32 bytes of the file control block.
5363
LDIR ED B0
Copy the 32 bytes from Register Pair HL (57A4H) to Register Pair DE (5784H), Register Pair BC the count (LDIR): NAME/EXT and its 03H.
5365
POP DE D1
Restore Register Pair DE from the stack: the place of the 03H after NAME/EXT at 57A4H.
5366
LD A,(57C5H) 3A C5 57
Fetch the destination drive from 57C5H into Register A.
5369
INC A 3C
INCrement Register A: the Z FLAG when it was FFH, no destination.
536A
If the NZ FLAG is set (a destination drive), JUMP to 5372H to open the file there.
536C
GOSUB to 55BBH to display the name at 5784H in the next column of the list.
536F
JUMP to 54BCH to go on with the next record of the TRSDOS 1.3 directory.

5372H - Open the File on the Destination

The file specification gets .P3UF and :d: the password P3UF has the hash code 113DH, the same as RS0LT0FF, the password of the system files of LDOS, so an existing file on the destination opens even when it is protected. @OPEN with the buffer at 6800H tells whether the file exists (error 18H, File not in directory, when it does not). OLD takes only files that exist and NEW only those that do not.

5372
LD (5415H),DE ED 53 15 54
Store Register Pair DE (the place of the 03H after NAME/EXT) at 5415H, the operand of LD HL,0000H at 5414H, for the file specification without the password.
5376
LD HL,56FBH 21 FB 56
Point Register Pair HL to 56FBH, the text .P3UF: in the template.
5379
LD BC,0006H 01 06 00
Load Register Pair BC with 0006H, the 6 characters .P3UF:.
537C
LDIR ED B0
Copy .P3UF: from Register Pair HL (56FBH) to Register Pair DE (over the 03H), Register Pair BC the count (LDIR).
537E
LD A,(57C5H) 3A C5 57
Fetch the destination drive from 57C5H into Register A.
5381
OR 30H F6 30
OR 30H into Register A: the drive number 00H-07H becomes the digit 0-7.
5383
LD (DE),A 12
Store Register A (the drive digit) at Register Pair DE, after the colon.
5384
INC DE 13
INCrement Register Pair DE to the place after the digit.
5385
LD A,0DH 3E 0D
Load Register A with 0DH, the end of a file specification.
5387
LD (DE),A 12
Store Register A (0DH) at Register Pair DE: the file control block holds NAME/EXT.P3UF:d.
5388
LD DE,57A4H 11 A4 57
Point Register Pair DE to 57A4H, the file control block with the file specification.
538B
LD HL,6800H 21 00 68
Point Register Pair HL to 6800H, the buffer of the file, the first page of the data buffer.
538E
LD B,00H 06 00
Load Register B with 00H, the logical record length 256.
5390
GOSUB to 4424H, @OPEN, to open the file of the file control block at Register Pair DE (57A4H) with the buffer at Register Pair HL (6800H) and record length Register B. The Z FLAG when it exists.
5393
LD B,A 47
Copy Register A (00H, or the error) into Register B for the tests below.
5394
If the Z FLAG is set (the file exists on the destination), JUMP to 539BH.
5396
CP 18H FE 18
Compare Register A (the error) against 18H, File not in directory: the file is new on the destination.
5398
If the NZ FLAG is set (any other error), JUMP to 54EDH to display the error, put the drive code table back and end.
539B
LD A,00H 3E 00
Load Register A with 00H, the NEW and OLD switch: the operand 539CH is stored by 527CH, 00H when neither was given.
539D
AND A A7
Set the flags from Register A (AND A): the Z FLAG when neither NEW nor OLD was given.
539E
If the Z FLAG is set (neither), JUMP to 53B6H: the file is taken.
53A0
LD A,(5278H) 3A 78 52
Fetch the low byte of the OLD parameter from 5278H, the operand of LD BC at 5277H, into Register A.
53A3
AND A A7
Set the flags from Register A (AND A): the Z FLAG when OLD was not given.
53A4
If the Z FLAG is set (no OLD), JUMP to 53AAH to look at NEW.
53A6
XOR A AF
Set Register A to 00H (XOR A), so the OR below gives the flags of Register B alone.
53A7
OR B B0
OR Register B (the result of @OPEN) into Register A: the Z FLAG when the file exists.
53A8
If the Z FLAG is set (OLD and the file exists), JUMP to 53B6H: the file is taken.
53AA
LD A,(5275H) 3A 75 52
Fetch the low byte of the NEW parameter from 5275H, the operand of LD DE at 5274H, into Register A.
53AD
AND A A7
Set the flags from Register A (AND A): the Z FLAG when NEW was not given.
53AE
If the Z FLAG is set (no NEW, and OLD found no file), JUMP to 54BCH to go on with the next record.
53B1
XOR A AF
Set Register A to 00H (XOR A), so the OR below gives the flags of Register B alone.
53B2
OR B B0
OR Register B (the result of @OPEN) into Register A: the Z FLAG when the file exists.
53B3
If the Z FLAG is set (NEW and the file exists), JUMP to 54BCH to go on with the next record.

53B6H - The Questions

Without QUERY=N CONV asks Convert file NAME/EXT? and, when the file exists on the destination, File exists -- replace it?; only an answer starting with Y (or y) takes the file, BREAK ends at @ABORT. The text at 5777H, Convert file and a space, has no end of its own: @DSPLY runs on into the copy of the name at 5784H and stops at its 03H. With QUERY=N CONV displays Converting file NAME/EXT.

53B6
LD A,(5272H) 3A 72 52
Fetch the low byte of the QUERY parameter from 5272H, the operand of LD HL at 5271H, into Register A: FFH unless QUERY=N was given.
53B9
AND A A7
Set the flags from Register A (AND A): the Z FLAG for QUERY=N.
53BA
If the NZ FLAG is set (QUERY on), JUMP to 53CDH to ask.
53BC
LD HL,5766H 21 66 57
Point Register Pair HL to 5766H, the text Converting file ended by 03H.
53BF
GOSUB to 4467H, @DSPLY, to display the text at Register Pair HL (5766H) up to its 03H.
53C2
LD HL,5784H 21 84 57
Point Register Pair HL to 5784H, the copy of NAME/EXT ended by 03H.
53C5
GOSUB to 4467H, @DSPLY, to display the name at Register Pair HL (5784H) up to its 03H.
53C8
GOSUB to 560AH to display 0DH, the end of the line.
53CB
JUMP to 540CH to create or reuse the file on the destination.
53CD
LD HL,5777H 21 77 57
Point Register Pair HL to 5777H, the text Convert file, which runs on into the name at 5784H.
53D0
GOSUB to 4467H, @DSPLY, to display the text at Register Pair HL (5777H) and the name after it up to the 03H at its end.
53D3
LD HL,5701H 21 01 57
Point Register Pair HL to 5701H, the text ? ended by 03H.
53D6
GOSUB to 4467H, @DSPLY, to display the text at Register Pair HL (5701H): a question mark and a space.
53D9
LD HL,57C8H 21 C8 57
Point Register Pair HL to 57C8H, the buffer of the answer beyond the file.
53DC
LD B,03H 06 03
Load Register B with 03H, at most 3 characters of the answer.
53DE
GOSUB to 0040H, the ROM's line input, to take up to Register B (3) characters into the buffer at Register Pair HL (57C8H) up to ENTER; the CARRY FLAG after BREAK.
53E1
If the CARRY FLAG is set (BREAK), JUMP to 4030H, @ABORT. The drive code table of the source drive is not put back on this way out.
53E4
LD A,(HL) 7E
Fetch the first character of the answer at Register Pair HL (57C8H) into Register A.
53E5
RES 5,A CB AF
Reset bit 5 of Register A: a small y becomes the capital Y.
53E7
CP 59H FE 59
Compare Register A (the answer) against 59H, the letter Y.
53E9
If the NZ FLAG is set (not Y: N, ENTER or anything else), JUMP to 54BCH to go on with the next record.
53EC
LD A,(57A4H) 3A A4 57
Fetch +00H of the file control block from 57A4H into Register A: bit 7 is set when @OPEN opened an existing file.
53EF
BIT 7,A CB 7F
Test bit 7 of Register A: the NZ FLAG when the file exists on the destination.
53F1
If the Z FLAG is set (a new file), JUMP to 540CH to create it.
53F3
LD HL,5748H 21 48 57
Point Register Pair HL to 5748H, the text File exists -- replace it? ended by 03H, after two spaces.
53F6
GOSUB to 4467H, @DSPLY, to display the text at Register Pair HL (5748H) up to its 03H.
53F9
LD HL,57C8H 21 C8 57
Point Register Pair HL to 57C8H, the buffer of the answer.
53FC
LD B,03H 06 03
Load Register B with 03H, at most 3 characters of the answer.
53FE
GOSUB to 0040H, the ROM's line input, to take up to Register B (3) characters into the buffer at Register Pair HL (57C8H); the CARRY FLAG after BREAK.
5401
If the CARRY FLAG is set (BREAK), JUMP to 4030H, @ABORT, with the drive code table of the source drive not put back.
5404
LD A,(HL) 7E
Fetch the first character of the answer at Register Pair HL (57C8H) into Register A.
5405
RES 5,A CB AF
Reset bit 5 of Register A: a small y becomes the capital Y.
5407
CP 59H FE 59
Compare Register A (the answer) against 59H, the letter Y.
5409
If the NZ FLAG is set (not Y), JUMP to 54BCH to go on with the next record.

540CH - Create the File and Set Its Length

A new file is created by @INIT as NAME/EXT:d, the password taken off again, with the record length of the TRSDOS 1.3 file; then bit 7 of the file control block's +01H and its +09H are cleared, so the file is written in whole sectors of 256 bytes. An existing file is written over from its start. The count of sectors is the ending record number of the record (+14H-+15H), plus one for a TRSDOS 1.3 file (version 13H or above) whose last sector is not full (EOF byte +03H not 00H). @POSN to the last of them and @WRITE give the file its whole length first; @REW goes back to the start.

540C
LD DE,57A4H 11 A4 57
Point Register Pair DE to 57A4H, the file control block.
540F
LD A,(DE) 1A
Fetch +00H of the file control block at Register Pair DE (57A4H) into Register A.
5410
BIT 7,A CB 7F
Test bit 7 of Register A: set when the file is open (it exists on the destination).
5412
If the NZ FLAG is set (the file is open), JUMP to 543DH: it is written over.
5414
LD HL,0000H 21 00 00
Load Register Pair HL with the place of the 03H after NAME/EXT: the operand 5415H-5416H, 0000H in the file, stored by 5372H.
5417
LD (HL),3AH 36 3A
Store 3AH, a colon, at Register Pair HL, over the period of .P3UF: the new file gets no password.
5419
INC HL 23
INCrement Register Pair HL to the place after the colon.
541A
LD A,(57C5H) 3A C5 57
Fetch the destination drive from 57C5H into Register A.
541D
OR 30H F6 30
OR 30H into Register A: the drive number becomes the digit 0-7.
541F
LD (HL),A 77
Store Register A (the drive digit) at Register Pair HL, after the colon.
5420
INC HL 23
INCrement Register Pair HL to the place after the digit.
5421
LD (HL),0DH 36 0D
Store 0DH at Register Pair HL: the file control block holds NAME/EXT:d.
5423
LD HL,6800H 21 00 68
Point Register Pair HL to 6800H, the buffer of the file.
5426
LD B,(IX+04H) DD 46 04
Load Register B with +04H of the TRSDOS 1.3 record at Index Register IX: the logical record length of the file, kept in its new directory record.
5429
GOSUB to 4420H, @INIT, to create the file of the file control block at Register Pair DE (57A4H) with the buffer at Register Pair HL (6800H) and record length Register B. The Z FLAG on success.
542C
If the NZ FLAG is set (@INIT failed), JUMP to 54EDH to display the error, put the drive code table back and end.
542F
PUSH DE D5
Save Register Pair DE (57A4H, the file control block) to the stack.
5430
EX (SP),IX DD E3
Exchange Index Register IX with the word at the Stack Pointer: Index Register IX = 57A4H, the file control block, and the TRSDOS 1.3 record is kept on the stack.
5432
RES 7,(IX+01H) DD CB 01 BE
Reset bit 7 of +01H of the file control block at Index Register IX: the file is read and written in whole sectors, not in records.
5436
LD (IX+09H),00H DD 36 09 00
Store 00H at +09H of the file control block at Index Register IX, the record length: 256.
543A
EX (SP),IX DD E3
Exchange Index Register IX with the word at the Stack Pointer again: Index Register IX = the TRSDOS 1.3 record, the stack holds 57A4H.
543C
POP DE D1
Restore Register Pair DE from the stack: 57A4H, the file control block.
543D
POP HL E1
Restore Register Pair HL from the stack: the TRSDOS 1.3 record (pushed at 52E0H).
543E
PUSH HL E5
Save Register Pair HL (the record) to the stack again, for 54BCH.
543F
LD DE,0014H 11 14 00
Load Register Pair DE with 0014H, the offset of the ending record number in the record.
5442
ADD HL,DE 19
ADD Register Pair DE (14H) to Register Pair HL: Register Pair HL = +14H of the record.
5443
LD E,(HL) 5E
Fetch +14H, the low byte of the ending record number, at Register Pair HL into Register E.
5444
INC HL 23
INCrement Register Pair HL to +15H of the record.
5445
LD D,(HL) 56
Fetch +15H, the high byte of the ending record number, at Register Pair HL into Register D: Register Pair DE = the full sectors of the file.
5446
INC HL 23
INCrement Register Pair HL to +16H of the record, the first of its extents.
5447
LD A,00H 3E 00
Load Register A with the version byte of the TRSDOS diskette: the operand 5448H, 00H in the file, stored by 52B1H from byte FEH of its boot sector.
5449
CP 13H FE 13
Compare Register A (the version) against 13H: the CARRY FLAG for a version below 1.3.
544B
If the CARRY FLAG is set (below 13H), JUMP to 5454H: the ending record number is the count of sectors as it is.
544D
LD A,(IX+03H) DD 7E 03
Fetch +03H of the record at Index Register IX into Register A: the EOF byte, the bytes used in the last sector.
5450
AND A A7
Set the flags from Register A (AND A): the Z FLAG when the last sector is full.
5451
If the Z FLAG is set (EOF byte 00H), JUMP to 5454H with the count as it is.
5453
INC DE 13
INCrement Register Pair DE: the sector that is only partly used counts too.
5454
LD B,00H 06 00
Load Register B with 00H: no sector of the current extent is left, so 5501H starts with the first extent.
5456
PUSH DE D5
Save Register Pair DE (the count of sectors) to the stack, to move it into the other register set.
5457
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate registers (EXX): Register B 00H, Register Pair DE the count and Register Pair HL at the extents (+16H) are kept in the alternate set for 5501H; the other set is used for the buffer from here on.
5458
POP BC C1
Restore Register Pair BC from the stack: Register Pair BC = the count of sectors.
5459
LD A,B 78
Copy Register B (the high byte of the count) into Register A.
545A
OR C B1
OR Register C (the low byte) into Register A: the Z FLAG for a file of no sectors.
545B
If the Z FLAG is set (an empty file), JUMP to 547BH: there is nothing to set the length for.
545D
DEC BC 0B
DECrement Register Pair BC: the number of the last sector, counted from 0.
545E
LD DE,57A4H 11 A4 57
Point Register Pair DE to 57A4H, the file control block.
5461
GOSUB to 4442H, @POSN, to position the file of the file control block at Register Pair DE to record Register Pair BC, its last sector.
5464
If the Z FLAG is set (the position worked), JUMP to 546FH.
5466
CP 1CH FE 1C
Compare Register A (the error) against 1CH, End of file encountered.
5468
If the Z FLAG is set (error 1CH), JUMP to 546FH: a position past the end is what is wanted.
546A
CP 1DH FE 1D
Compare Register A (the error) against 1DH, Record number out of range.
546C
If the NZ FLAG is set (any other error), JUMP to 54EDH to display the error, put the drive code table back and end.
546F
GOSUB to 4439H, @WRITE, to write the buffer of the file control block at Register Pair DE (57A4H) as the last sector: the file has its whole length.
5472
If the NZ FLAG is set (@WRITE failed), JUMP to 54EDH to display the error, put the drive code table back and end.
5475
GOSUB to 443FH, @REW, to put the file of the file control block at Register Pair DE back to its first sector.
5478
If the NZ FLAG is set (@REW failed), JUMP to 54EDH to display the error, put the drive code table back and end.

547BH - Copy the Sectors

The sectors of the TRSDOS 1.3 file are read by 5501H into 6800H up, one page each, until the buffer reaches HIGH$ less 256 or the file ends; then the pages are written by @WRITE, each with +03H-+04H of the file control block pointed at it. At the end the EOF byte of the TRSDOS record goes into +08H of the file control block and @CLOSE writes the directory record.

547B
LD B,00H 06 00
Load Register B with 00H, the count of sectors in the buffer.
547D
LD HL,6800H 21 00 68
Point Register Pair HL to 6800H, the start of the data buffer.
5480
LD DE,(4411H) ED 5B 11 44
Fetch HIGH$ from 4411H-4412H into Register Pair DE.
5484
DEC D 15
DECrement Register D: Register Pair DE = HIGH$ less 256, the limit of the buffer.
5485
GOSUB to 5501H to read the next sector of the TRSDOS 1.3 file into the page at Register Pair HL: the Z FLAG, or the NZ FLAG and Register A = 1CH at its end.
5488
If the NZ FLAG is set (the file has no more sectors), JUMP to 5495H with Register A = 1CH to write what is in the buffer.
548A
INC B 04
INCrement Register B, the count of sectors in the buffer.
548B
INC H 24
INCrement Register H to the next page of the buffer.
548C
GOSUB to 55A5H to compare Register Pair HL (the next page) with Register Pair DE (the limit): the CARRY FLAG while Register Pair HL is below it.
548F
LD A,00H 3E 00
Load Register A with 00H, the sign that the file goes on: the LD does not change the flags.
5491
If the NO CARRY FLAG is set (the buffer is full), JUMP to 5495H with Register A = 00H to write it.
5493
JUMP to 5485H to read the next sector of the file into the next page.
5495
PUSH AF F5
Save Register Pair AF (Register A 00H for a full buffer, 1CH at the end of the file) to the stack.
5496
LD DE,57A4H 11 A4 57
Point Register Pair DE to 57A4H, the file control block.
5499
LD HL,6800H 21 00 68
Point Register Pair HL to 6800H, the first page of the buffer.
549C
LD (57A7H),HL 22 A7 57
Store Register Pair HL (the page) at 57A7H-57A8H, +03H-+04H of the file control block: the buffer of the next @WRITE.
549F
LD A,B 78
Copy Register B (the sectors left to write) into Register A.
54A0
AND A A7
Set the flags from Register A (AND A): the Z FLAG when there is nothing to write.
54A1
If the Z FLAG is set (no sector), JUMP to 54ACH.
54A3
GOSUB to 4439H, @WRITE, to write the page at +03H-+04H of the file control block at Register Pair DE (57A4H) as the next sector of the file.
54A6
If the NZ FLAG is set (@WRITE failed), JUMP to 54EDH to display the error, put the drive code table back and end.
54A9
INC H 24
INCrement Register H to the next page of the buffer.
54AA
DECrement Register B and LOOP BACK to 549CH until every sector of the buffer is written.
54AC
POP AF F1
Restore Register Pair AF from the stack: Register A 00H (the buffer was full) or 1CH (the end of the file).
54AD
AND A A7
Set the flags from Register A (AND A): the Z FLAG when the file goes on.
54AE
If the Z FLAG is set (more sectors), JUMP to 547BH to fill the buffer again.
54B0
LD A,(IX+03H) DD 7E 03
Fetch +03H of the TRSDOS 1.3 record at Index Register IX into Register A: the EOF byte, the bytes used in the last sector.
54B3
LD (57ACH),A 32 AC 57
Store Register A (the EOF byte) at 57ACH, +08H of the file control block, the end of the file within its last sector.
54B6
GOSUB to 4428H, @CLOSE, to close the file of the file control block at Register Pair DE (57A4H): its directory record gets the end of the file.
54B9
If the NZ FLAG is set (@CLOSE failed), JUMP to 54EDH to display the error, put the drive code table back and end.

54BCH - The Next Record and the Ends

54BCH steps 48 bytes to the next record; after the fifth record of a sector (offset F0H) it goes to the start of the next page, and after the last sector (6800H) CONV ends at @EXIT. 54DBH and 54DFH display their texts by @LOGOT and end at @ABORT; 54EBH (error 2CH) and 54EDH (the error in Register A) give the short message through @ERROR with bit 7 clear, which ends the program. Every end first puts the saved drive code table back at Index Register IY (54F5H); on the ways out from 54DBH, 54DFH and the parameter errors of 523AH-5253H the table has not been saved yet, and Index Register IY is whatever LDOS left in it, so 10 bytes from 57CDH-57D6H, beyond the file, are copied to that address.

54BC
POP HL E1
Restore Register Pair HL from the stack: the TRSDOS 1.3 record just looked at.
54BD
LD DE,0030H 11 30 00
Load Register Pair DE with 0030H, the 48 bytes of a TRSDOS 1.3 directory record.
54C0
ADD HL,DE 19
ADD Register Pair DE (48) to Register Pair HL: Register Pair HL = the next record.
54C1
LD A,L 7D
Copy Register L (the offset of the next record in its page) into Register A.
54C2
CP F0H FE F0
Compare Register A (the offset) against F0H, the place after the fifth record of a sector (5 x 48 = 240).
54C4
If the NZ FLAG is set (another record in this sector), JUMP to 54C9H.
54C6
INC H 24
INCrement Register H to the next page: the next sector of the directory.
54C7
LD L,00H 2E 00
Load Register L with 00H, the first record of that sector.
54C9
LD DE,6800H 11 00 68
Point Register Pair DE to 6800H, the end of the directory buffer.
54CC
GOSUB to 55A5H to compare Register Pair HL (the next record) with Register Pair DE (6800H): the CARRY FLAG while records are left.
54CF
If the CARRY FLAG is set (a record left), JUMP to 52D4H to look at it.
54D2
GOSUB to 560AH to display 0DH, the end of the line, after the list or the last file.
54D5
GOSUB to 54F5H to put the drive code table of the source drive back from 57CDH.
54D8
JUMP to 402DH, @EXIT, to end CONV without an error.
54DB
LD HL,5704H 21 04 57
Point Register Pair HL to 5704H, the text Source and Destination drives are the same ended by 0DH.
54DE
LD IX,572FH DD 21 2F 57
Load Index Register IX with 572FH. Nothing uses Index Register IX here: the DD byte only lets 54DBH pass over 21H 2FH 57H at 54DFH-54E1H, which the jump from 5241H takes as LD HL,572FH, the text Source cannot be drive 0.
54E2
GOSUB to 428AH, @LOGOT, to display the text at Register Pair HL (5704H or 572FH) and write it to the job log.
54E5
GOSUB to 54F5H to copy 57CDH-57D6H to the drive code table at Index Register IY, not yet saved on this way out.
54E8
JUMP to 4030H, @ABORT, to end CONV with an error.
54EB
LD A,2CH 3E 2C
Load Register A with 2CH, error 2CH, Parameter error.
54ED
OR 40H F6 40
OR 40H into Register A: bit 6, the short message of the error; bit 7 stays clear, so @ERROR does not return.
54EF
GOSUB to 54F5H to put the drive code table back from 57CDH at Index Register IY; Register A (the error) is kept.
54F2
JUMP to 4409H, @ERROR, to display the short message of the error in Register A and end the program.
54F5
PUSH IY FD E5
Save Index Register IY (the drive code table) to the stack, to move it into Register Pair DE.
54F7
POP DE D1
Restore it into Register Pair DE: Register Pair DE = the address in Index Register IY, the destination of the copy.
54F8
LD HL,57CDH 21 CD 57
Point Register Pair HL to 57CDH, the 10 bytes kept by 5297H.
54FB
LD BC,000AH 01 0A 00
Load Register Pair BC with 000AH, the 10 bytes of a drive code table.
54FE
LDIR ED B0
Copy the 10 bytes from Register Pair HL (57CDH) to Register Pair DE, Register Pair BC the count (LDIR).
5500
RET C9
RETurn to the caller; Register A and the flags are as they were.

5501H - Read the Next Sector of the TRSDOS 1.3 File

Called with Register Pair HL at the page to fill. The other register set keeps the count of sectors left (Register Pair DE), the sectors left of the current extent (Register B) and the next extent (Register Pair HL). An extent of a TRSDOS 1.3 record is two bytes: the track, then the first granule in bits 7-5 and the granules in bits 4-0; FFH as the track ends the list. A granule is three sectors, numbered from 1, so the first sector is granule x 3 + 1 and the extent has granules x 3 sectors. The next track and sector are kept at 57C6H-57C7H; after sector 18 comes sector 1 of the next track.

5501
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate registers (EXX): Register Pair DE = the sectors left of the file, Register B = the sectors left of the extent, Register Pair HL = the next extent.
5502
LD A,D 7A
Copy Register D (the high byte of the sectors left) into Register A.
5503
OR E B3
OR Register E (the low byte) into Register A: the Z FLAG when no sector of the file is left.
5504
If the NZ FLAG is set (sectors left), JUMP to 550BH.
5506
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate registers back (EXX): Register Pair HL = the page again.
5507
LD A,1CH 3E 1C
Load Register A with 1CH, End of file encountered: the sign that the file is copied.
5509
AND A A7
Set the flags from Register A (AND A): the NZ FLAG for the caller.
550A
RET C9
RETurn with the NZ FLAG and Register A = 1CH.
550B
XOR A AF
Set Register A to 00H (XOR A), so the OR below gives the flags of Register B alone.
550C
OR B B0
OR Register B (the sectors left of the extent) into Register A: the Z FLAG when the extent is used up.
550D
If the NZ FLAG is set (sectors left in the extent), JUMP to 5530H to read the next one.
550F
LD A,(HL) 7E
Fetch the first byte of the next extent at Register Pair HL into Register A: its track.
5510
CP FFH FE FF
Compare Register A (the track) against FFH, the end of the list of extents.
5512
If the Z FLAG is set (no more extents), JUMP to 5506H to give the end of the file.
5514
PUSH DE D5
Save Register Pair DE (the sectors left of the file) to the stack: Register Pair DE builds the track and sector.
5515
LD D,(HL) 56
Fetch the track of the extent at Register Pair HL into Register D.
5516
INC HL 23
INCrement Register Pair HL to the second byte of the extent.
5517
LD B,(HL) 46
Fetch the second byte of the extent at Register Pair HL into Register B: bits 7-5 the first granule, bits 4-0 the granules.
5518
INC HL 23
INCrement Register Pair HL to the next extent.
5519
LD A,B 78
Copy Register B (the second byte of the extent) into Register A.
551A
RLCA 07
Rotate Register A left (RLCA): bit 7 goes into bit 0.
551B
RLCA 07
Rotate Register A left (RLCA) again: bits 7-6 are now bits 1-0.
551C
RLCA 07
Rotate Register A left (RLCA) a third time: bits 7-5, the first granule, are now bits 2-0.
551D
AND 07H E6 07
Mask Register A with 07H: the first granule, 0-5.
551F
LD E,A 5F
Copy Register A (the first granule) into Register E.
5520
RLCA 07
Rotate Register A left (RLCA): Register A = the first granule x 2.
5521
ADD A,E 83
ADD Register E (the first granule) to Register A: the first granule x 3, its first sector counted from 0.
5522
INC A 3C
INCrement Register A: the first sector of the granule, counted from 1 as TRSDOS 1.3 numbers them.
5523
LD E,A 5F
Copy Register A (the first sector) into Register E: Register Pair DE = the track and sector to read.
5524
LD (57C6H),DE ED 53 C6 57
Store Register Pair DE at 57C6H-57C7H: Register E the sector at 57C6H, Register D the track at 57C7H.
5528
POP DE D1
Restore Register Pair DE from the stack: the sectors left of the file.
5529
LD A,B 78
Copy Register B (the second byte of the extent) into Register A.
552A
AND 1FH E6 1F
Mask Register A with 1FH: the granules of the extent.
552C
LD B,A 47
Copy Register A (the granules) into Register B.
552D
RLCA 07
Rotate Register A left (RLCA): Register A = the granules x 2.
552E
ADD A,B 80
ADD Register B (the granules) to Register A: the granules x 3, the sectors of the extent.
552F
LD B,A 47
Copy Register A (the sectors of the extent) into Register B.
5530
DEC B 05
DECrement Register B: one sector of the extent less, the one read now.
5531
DEC DE 1B
DECrement Register Pair DE: one sector of the file less.
5532
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate registers back (EXX): Register Pair HL = the page to fill, Register Pair DE the limit of the buffer, Register B the count of the caller.
5533
PUSH DE D5
Save Register Pair DE (the limit of the caller) to the stack.
5534
PUSH BC C5
Save Register Pair BC (the count of the caller) to the stack.
5535
LD DE,(57C6H) ED 5B C6 57
Fetch the track and sector from 57C6H-57C7H into Register Pair DE: Register E the sector, Register D the track.
5539
LD A,(57C4H) 3A C4 57
Fetch the source drive from 57C4H into Register A.
553C
LD C,A 4F
Copy Register A (the source drive) into Register C, the drive for RDSECT.
553D
GOSUB to 4777H, RDSECT, to read cylinder Register D, sector Register E of drive Register C into the page at Register Pair HL.
5540
If the Z FLAG is set (the read worked), JUMP to 5547H.
5542
CP 06H FE 06
Compare Register A (the error of the read) against 06H, the other data address mark.
5544
If the NZ FLAG is set (any other error), JUMP to 54EDH to display the error, put the drive code table back and end.
5547
INC E 1C
INCrement Register E to the next sector of the track for the next call.
5548
LD A,E 7B
Copy Register E (the next sector) into Register A.
5549
CP 13H FE 13
Compare Register A (the sector) against 13H, one past sector 18, the last of a track.
554B
If the NZ FLAG is set (still on the track), JUMP to 5550H.
554D
LD E,01H 1E 01
Load Register E with 01H, the first sector of a track.
554F
INC D 14
INCrement Register D to the next track, whose first sector comes next.
5550
LD (57C6H),DE ED 53 C6 57
Store Register Pair DE (the next track and sector) at 57C6H-57C7H.
5554
POP BC C1
Restore Register Pair BC from the stack: the count of the caller.
5555
POP DE D1
Restore Register Pair DE from the stack: the limit of the caller.
5556
XOR A AF
Set Register A to 00H (XOR A): the Z FLAG, the sector is read.
5557
RET C9
RETurn to the caller with the Z FLAG: the page at Register Pair HL is filled.

5558H - The Command Line Routines

5558H takes an optional drive (Register A = FFH without a colon), 555EH a required one (error 2CH without a colon or with a character that is not 0-7); 556FH passes over spaces; 5576H passes over and 557EH copies the characters of a name; 5588H tells whether Register A is a letter, a digit or $ (the Z FLAG), making a small letter a capital; 55A5H compares Register Pair HL with Register Pair DE; 55ABH turns the result of the name compare round after a minus sign.

5558
LD A,(HL) 7E
Fetch the character at Register Pair HL into Register A.
5559
CP 3AH FE 3A
Compare Register A (the character) against 3AH, a colon.
555B
LD A,FFH 3E FF
Load Register A with FFH, the drive value for no drive given: the LD does not change the flags.
555D
RET NZ C0
If the NZ FLAG is set (no colon), RETurn with Register A = FFH.
555E
LD A,(HL) 7E
Fetch the character at Register Pair HL into Register A.
555F
CP 3AH FE 3A
Compare Register A (the character) against 3AH, a colon, the start of a drive specification.
5561
If the NZ FLAG is set (no colon), JUMP to 54EBH to give error 2CH, Parameter error.
5564
INC HL 23
INCrement Register Pair HL past the colon to the character of the drive number.
5565
LD A,(HL) 7E
Fetch the drive character at Register Pair HL into Register A.
5566
SUB 30H D6 30
SUBtract 30H, the character 0, from Register A: the digits 0-7 become 00H-07H.
5568
CP 08H FE 08
Compare Register A (the drive number) against 08H: the CARRY FLAG for drives 0-7.
556A
If the NO CARRY FLAG is set (not a digit 0-7), JUMP to 54EBH to give error 2CH, Parameter error.
556D
INC HL 23
INCrement Register Pair HL past the drive digit.
556E
RET C9
RETurn with Register A = the drive number 00H-07H.
556F
LD A,(HL) 7E
Fetch the character at Register Pair HL into Register A.
5570
CP 20H FE 20
Compare Register A (the character) against 20H, a space.
5572
RET NZ C0
If the NZ FLAG is set (not a space), RETurn with Register Pair HL at the character.
5573
INC HL 23
INCrement Register Pair HL past the space to the next character of the line.
5574
JUMP to 556FH to look at the next character of the command line.
5576
LD A,(HL) 7E
Fetch the character at Register Pair HL into Register A.
5577
GOSUB to 5588H to test Register A: the Z FLAG for a letter, a digit or $.
557A
RET NZ C0
If the NZ FLAG is set (another character), RETurn with Register Pair HL at it.
557B
INC HL 23
INCrement Register Pair HL past the character.
557C
JUMP to 5576H to look at the next character of the command line.
557E
LD A,(HL) 7E
Fetch the character at Register Pair HL into Register A.
557F
GOSUB to 5588H to test Register A: the Z FLAG for a letter, a digit or $, with a small letter made a capital.
5582
RET NZ C0
If the NZ FLAG is set (another character), RETurn with Register Pair HL at it.
5583
INC HL 23
INCrement Register Pair HL past the character.
5584
LD (DE),A 12
Store Register A (the character, a capital) at Register Pair DE in the template.
5585
INC DE 13
INCrement Register Pair DE to the next place of the template.
5586
JUMP to 557EH to copy the next character; no count stops the copy, so a name of more than 8 characters runs on into the extension of the template at 56F8H.
5588
BIT 7,A CB 7F
Test bit 7 of Register A (the character): set for a graphics or special character.
558A
RET NZ C0
If the NZ FLAG is set (bit 7 set), RETurn with the NZ FLAG: not a character of a name.
558B
CP 61H FE 61
Compare Register A (the character) against 61H, the small letter a.
558D
If the CARRY FLAG is set (below 61H), JUMP to 5591H.
558F
RES 5,A CB AF
Reset bit 5 of Register A: a small letter becomes a capital.
5591
CP 24H FE 24
Compare Register A (the character) against 24H, the $ that matches any character.
5593
RET Z C8
If the Z FLAG is set ($), RETurn with the Z FLAG.
5594
CP 30H FE 30
Compare Register A (the character) against 30H, the digit 0.
5596
RET C D8
If the CARRY FLAG is set (below 0), RETurn with the NZ FLAG: not a character of a name.
5597
CP 3AH FE 3A
Compare Register A (the character) against 3AH, one past the digit 9.
5599
If the NO CARRY FLAG is set (3AH or above), JUMP to 559DH to look at the letters.
559B
CP A BF
Compare Register A against itself (CP A): the Z FLAG for a digit.
559C
RET C9
RETurn with the Z FLAG: the character in Register A is a digit.
559D
CP 41H FE 41
Compare Register A (the character) against 41H, the letter A.
559F
RET C D8
If the CARRY FLAG is set (below A), RETurn with the NZ FLAG: not a character of a name.
55A0
CP 5AH FE 5A
Compare Register A (the character) against 5AH, the letter Z: the Z FLAG for Z itself, the NO CARRY FLAG for Z and above.
55A2
RET NC D0
If the NO CARRY FLAG is set (Z or above), RETurn: with the Z FLAG for Z, the NZ FLAG for a character above it.
55A3
CP A BF
Compare Register A against itself (CP A): the Z FLAG for a letter A-Y.
55A4
RET C9
RETurn with the Z FLAG: the character in Register A is a letter.
55A5
PUSH HL E5
Save Register Pair HL to the stack, so the compare leaves it as it was.
55A6
AND A A7
Clear the CARRY FLAG (AND A) for the SBC below; Register A is not changed.
55A7
SBC HL,DE ED 52
SUBtract Register Pair DE from Register Pair HL (SBC): the CARRY FLAG when Register Pair HL is below Register Pair DE, the Z FLAG when equal.
55A9
POP HL E1
Restore Register Pair HL from the stack: the SBC has not changed it for the caller.
55AA
RET C9
RETurn with the flags of the compare of Register Pair HL and Register Pair DE.
55AB
PUSH AF F5
Save Register Pair AF (the Z FLAG of the name compare) to the stack.
55AC
LD A,00H 3E 00
Load Register A with the minus switch: the operand 55ADH, 00H in the file, FFH stored by 5217H after a minus sign.
55AE
OR A B7
Set the flags from Register A (OR A): the Z FLAG when there was no minus sign.
55AF
If the Z FLAG is set (no minus sign), JUMP to 55B9H to return the result as it is.
55B1
POP AF F1
Restore Register Pair AF from the stack: the result of the name compare.
55B2
If the Z FLAG is set (the name matched), JUMP to 55B6H to give the NZ FLAG.
55B4
XOR A AF
Set Register A to 00H (XOR A): the Z FLAG, a name that does not match is taken.
55B5
RET C9
RETurn with the Z FLAG: the file whose name did not match is taken.
55B6
OR FFH F6 FF
OR FFH into Register A: the NZ FLAG, a name that matches is not taken.
55B8
RET C9
RETurn with the NZ FLAG: the file whose name matched is passed over.
55B9
POP AF F1
Restore Register Pair AF from the stack: the result of the name compare.
55BA
RET C9
RETurn with the flags of the name compare unchanged: no minus sign was given.

55BBH - The List of the Files

Without a destination (or with DIR) the names are displayed in columns of 16 characters, a line holding four of them and ending at column 78 (4EH); the column and the line count are kept in the operand of LD HL at 55CFH. After 23 lines CONV waits for a key (ROM 0049H), moves the cursor up one line (1BH) and clears the rest of the screen (1FH), and counts again from the top.

55BB
PUSH HL E5
Save Register Pair HL to the stack, for the caller.
55BC
PUSH DE D5
Save Register Pair DE to the stack, for the caller of the list routine.
55BD
PUSH BC C5
Save Register Pair BC to the stack, for the caller of the list routine.
55BE
LD C,00H 0E 00
Load Register C with 00H, the count of the characters displayed.
55C0
LD HL,5784H 21 84 57
Point Register Pair HL to 5784H, the copy of NAME/EXT ended by 03H.
55C3
LD A,(HL) 7E
Fetch the next character of the name at Register Pair HL into Register A.
55C4
CP 03H FE 03
Compare Register A (the character) against 03H, the end of the name.
55C6
If the Z FLAG is set (the end), JUMP to 55CFH with Register C = its length.
55C8
GOSUB to 0033H, the ROM's display of the character in Register A.
55CB
INC C 0C
INCrement Register C, the characters displayed.
55CC
INC HL 23
INCrement Register Pair HL to the next character of the name.
55CD
JUMP to 55C3H to display the next character of the name at Register Pair HL.
55CF
LD HL,0000H 21 00 00
Load Register Pair HL with the place on the screen: the operand 55D0H-55D1H, Register L the column and Register H the line count, 0000H in the file and stored by 55E6H.
55D2
LD A,C 79
Copy Register C (the length of the name) into Register A.
55D3
ADD A,L 85
ADD Register L (the column where the name began) to Register A.
55D4
LD L,A 6F
Copy Register A into Register L: the column after the name.
55D5
LD A,10H 3E 10
Load Register A with 10H, the width of a column, 16.
55D7
SUB C 91
SUBtract Register C (the length of the name) from Register A: the spaces to the next column.
55D8
LD B,A 47
Copy Register A (the spaces) into Register B, the count of the loop.
55D9
LD A,20H 3E 20
Load Register A with 20H, a space, to fill the rest of the column.
55DB
GOSUB to 0033H, the ROM's display of the space in Register A.
55DE
INC L 2C
INCrement Register L, the column of the cursor on the screen.
55DF
LD A,L 7D
Copy Register L (the column) into Register A.
55E0
CP 4EH FE 4E
Compare Register A (the column) against 4EH, column 78, where the line of four names ends.
55E2
If the Z FLAG is set (column 78), JUMP to 55EDH to end the line.
55E4
DECrement Register B and LOOP BACK to 55D9H until the column is filled.
55E6
LD (55D0H),HL 22 D0 55
Store Register Pair HL (the column and the line count) at 55D0H-55D1H, the operand of LD HL at 55CFH.
55E9
POP BC C1
Restore Register Pair BC from the stack, as the caller of 55BBH had it.
55EA
POP DE D1
Restore Register Pair DE from the stack, as the caller of 55BBH had it.
55EB
POP HL E1
Restore Register Pair HL from the stack, as the caller of 55BBH had it.
55EC
RET C9
RETurn to the caller with the place on the screen kept at 55D0H-55D1H.
55ED
GOSUB to 560AH to display 0DH, the end of the line.
55F0
INC H 24
INCrement Register H, the count of the lines.
55F1
LD L,00H 2E 00
Load Register L with 00H, the column at the start of the new line.
55F3
LD A,17H 3E 17
Load Register A with 17H, 23 lines, the lines of a screen less the one of the prompt.
55F5
CP H BC
Compare Register A (23) against Register H (the lines): the Z FLAG when the screen is full.
55F6
If the NZ FLAG is set (lines left), JUMP to 55E6H to keep the place.
55F8
GOSUB to 0049H, the ROM's wait for a key: the list stops until a key is pressed.
55FB
LD A,1BH 3E 1B
Load Register A with 1BH, the code that moves the cursor up one line.
55FD
GOSUB to 0033H, the ROM's display of the code in Register A.
5600
LD A,1FH 3E 1F
Load Register A with 1FH, the code that clears the screen from the cursor to its end.
5602
GOSUB to 0033H, the ROM's display of the code in Register A.
5605
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H: column 0, line count 0.
5608
JUMP to 55E6H to keep the place at 55D0H-55D1H and return to the caller.
560A
LD A,0DH 3E 0D
Load Register A with 0DH, the end of a line, for the ROM display routine.
560C
JUMP to 0033H, the ROM's display of the character in Register A, which returns to the caller of 560AH.

560FH - The Parameter Table and the Texts

The table that @PARAM reads (8 bytes an entry: the name padded with spaces to 6 characters and the address of its operand, then 00H), the banner, the template and the texts.

560F-5616
DEFM "QUERY " / DEFW 5272H 51 55 45 52 59 20 72 52
560FH-5616H: QUERY and 5272H, the operand of LD HL at 5271H: QUERY=N stores 0000H there.
5617-561E
DEFM "Q " / DEFW 5272H 51 20 20 20 20 20 72 52
5617H-561EH: Q, short for QUERY, and the same operand 5272H.
561F-5626
DEFM "SYS " / DEFW 5263H 53 59 53 20 20 20 63 52
561FH-5626H: SYS and 5263H, the operand of LD HL at 5262H: system files.
5627-562E
DEFM "S " / DEFW 5263H 53 20 20 20 20 20 63 52
5627H-562EH: S, short for SYS, and the same operand 5263H.
562F-5636
DEFM "INV " / DEFW 5269H 49 4E 56 20 20 20 69 52
562FH-5636H: INV and 5269H, the operand of LD BC at 5268H: invisible files.
5637-563E
DEFM "I " / DEFW 5269H 49 20 20 20 20 20 69 52
5637H-563EH: I, short for INV, and the same operand 5269H.
563F-5646
DEFM "VIS " / DEFW 5266H 56 49 53 20 20 20 66 52
563FH-5646H: VIS and 5266H, the operand of LD DE at 5265H: visible files.
5647-564E
DEFM "V " / DEFW 5266H 56 20 20 20 20 20 66 52
5647H-564EH: V, short for VIS, and the same operand 5266H.
564F-5656
DEFM "OLD " / DEFW 5278H 4F 4C 44 20 20 20 78 52
564FH-5656H: OLD and 5278H, the operand of LD BC at 5277H: only files that exist on the destination.
5657-565E
DEFM "O " / DEFW 5278H 4F 20 20 20 20 20 78 52
5657H-565EH: O, short for OLD, and the same operand 5278H.
565F-5666
DEFM "NEW " / DEFW 5275H 4E 45 57 20 20 20 75 52
565FH-5666H: NEW and 5275H, the operand of LD DE at 5274H: only files that do not exist on the destination.
5667-566E
DEFM "N " / DEFW 5275H 4E 20 20 20 20 20 75 52
5667H-566EH: N, short for NEW, and the same operand 5275H.
566F-5676
DEFM "DIR " / DEFW 5257H 44 49 52 20 20 20 57 52
566FH-5676H: DIR and 5257H, the operand of LD HL at 5256H: list the files, convert nothing. The manual does not name DIR.
5677-567E
DEFM "D " / DEFW 5257H 44 20 20 20 20 20 57 52
5677H-567EH: D, short for DIR, and the same operand 5257H.
567F
DEFB 00H 00
567FH: 00H, the end of the table: @PARAM stops here.
5680-56BB
DEFM "CONV - TRSDOS 1.3 -> LDOS conversion utility - Version 5.3.1" 43 4F 4E 56 20 2D 20 54 52 53 44 4F 53 20 31 2E 33 20 2D 3E 20 4C 44 4F 53 20 63 6F 6E 76 65 72 73 69 6F 6E 20 75 74 69 6C 69 74 79 20 2D 20 56 65 72 73 69 6F 6E 20 35 2E 33 2E 31
5680H-56BBH: the name of the program, what it does and its version, the start of the banner displayed by 5204H.
56BC
DEFB 0AH 0A
56BCH: 0AH, a new line: the copyright goes on the next line.
56BD-56ED
DEFM "Copyright 1991 MISOSYS, Inc., All rights reserved" 43 6F 70 79 72 69 67 68 74 20 31 39 39 31 20 4D 49 53 4F 53 59 53 2C 20 49 6E 63 2E 2C 20 41 6C 6C 20 72 69 67 68 74 73 20 72 65 73 65 72 76 65 64
56BDH-56EDH: the copyright line, the same text as the copyright record of the file.
56EE-56EF
DEFB 0AH, 0DH 0A 0D
56EEH-56EFH: 0AH, a new line, and 0DH, the end of the banner.
56F0-56FA
DEFM "$$$$$$$$$$$" 24 24 24 24 24 24 24 24 24 24 24
56F0H-56FAH: the template, 8 characters of the name and 3 of the extension, all $; 5223H and 5234H copy the name and extension of the command line over it.
56FB-5700
DEFM ".P3UF:" 2E 50 33 55 46 3A
56FBH-5700H: the password P3UF (hash code 113DH, as RS0LT0FF) and the colon before the drive, put after NAME/EXT by 537CH.
5701-5702
DEFM "? " 3F 20
5701H-5702H: a question mark and a space, displayed by 53D6H after Convert file NAME/EXT.
5703
DEFB 03H 03
5703H: 03H, the end of the text for @DSPLY: the cursor stays after the space.
5704-572D
DEFM "Source and Destination drives are the same" 53 6F 75 72 63 65 20 61 6E 64 20 44 65 73 74 69 6E 61 74 69 6F 6E 20 64 72 69 76 65 73 20 61 72 65 20 74 68 65 20 73 61 6D 65
5704H-572DH: the text of 54DBH, displayed by @LOGOT when :s and :d name one drive.
572E
DEFB 0DH 0D
572EH: 0DH, the end of the line and of the text.
572F-5746
DEFM "Source cannot be drive 0" 53 6F 75 72 63 65 20 63 61 6E 6E 6F 74 20 62 65 20 64 72 69 76 65 20 30
572FH-5746H: the text of 54DFH, displayed by @LOGOT for :0 as the source.
5747
DEFB 0DH 0D
5747H: 0DH, the end of the line and of the text.
5748-5764
DEFM " File exists -- replace it? " 20 20 46 69 6C 65 20 65 78 69 73 74 73 20 2D 2D 20 72 65 70 6C 61 63 65 20 69 74 3F 20
5748H-5764H: the second question of 53F3H, after two spaces, when the file is already on the destination.
5765
DEFB 03H 03
5765H: 03H, the end of the text for @DSPLY: the cursor stays after the question.
5766-5775
DEFM "Converting file " 43 6F 6E 76 65 72 74 69 6E 67 20 66 69 6C 65 20
5766H-5775H: the text of 53BCH, displayed before the name with QUERY=N.
5776
DEFB 03H 03
5776H: 03H, the end of the text for @DSPLY: the name follows on the same line.
5777-5783
DEFM "Convert file " 43 6F 6E 76 65 72 74 20 66 69 6C 65 20
5777H-5783H: the question of 53CDH; it has no end byte, @DSPLY runs on into the name copied to 5784H, the last byte of the file being 5783H.

5784H - The Work Areas Beyond the File

Not in the file: the copy of the name, the file control block, the drives, the next sector, the answer, the saved drive code table, the directory and the data buffer.

5784-57A3
DEFS 32
5784H-57A3H: not in the file. The copy of the 32 bytes at 57A4H made by 5363H: NAME/EXT ended by 03H, displayed after Convert file and by 55BBH.
57A4-57C3
DEFS 32
57A4H-57C3H: not in the file. The file control block of the destination file: the file specification (532EH-5387H), then the open file (+00H bit 7, +01H, +03H-+04H at 57A7H the buffer, +08H at 57ACH the EOF byte, +09H).
57C4
DEFS 1
57C4H: not in the file. The source drive, the TRSDOS 1.3 diskette (523DH).
57C5
DEFS 1
57C5H: not in the file. The destination drive, or FFH for the list only (524AH, 525FH).
57C6-57C7
DEFS 2
57C6H-57C7H: not in the file. The next sector (57C6H) and track (57C7H) of the TRSDOS 1.3 file (5524H, 5550H).
57C8-57CC
DEFS 5
57C8H-57CCH: not in the file. The answer to the questions: ROM 0040H stores up to 3 characters and the ENTER at 57C8H on.
57CD-57D6
DEFS 10
57CDH-57D6H: not in the file. The drive code table of the source drive as it was (5297H), put back by 54F5H.
5800-67FF
DEFS 4096
5800H-67FFH: not in the file. The TRSDOS 1.3 boot sector (52A0H), then the 16 directory sectors, 80 records of 48 bytes, five to a page.
6800-68FF
DEFS 256
6800H-68FFH: not in the file. The first page of the data buffer and the buffer of the file control block; the buffer goes on to HIGH$ less 256 (5480H).