4D00H - The Disk BASIC Vector Table
147 bytes that the start-up copies to 4152H-41E4H (5C44H-5C4DH), forty-nine three byte entries, one for each Disk BASIC vector and DOS exit of the Level II ROM (the RAM addresses page names each). Forty-seven entries are the same as in the table of TRSDOS 2.1's BASIC/CMD (at 54C3H there); DBLDOS changed the error vector 41A6H, which now loads SYS7/SYS, and the print exit 41CAH. Once copied, the block 4D00H-4DE8H is free: SYS7/SYS loads here for each error message, and SYS0/SYS can read the GAT here (B2 on the SYS0/SYS page). The comments give each entry as it stands at its place in 4152H-41E4H.
4D00-4D02
DEFB C3H,46H,5EH C3 46 5E
At 4152H after the copy: JP 5E46H, the vector of the CVI function. The same entry as in TRSDOS 2.1's table.
4D03-4D05
DEFB C3H,8EH,55H C3 8E 55
At 4155H after the copy: JP 558EH, the vector of FN, the user function call of DEF FN. The same entry as in TRSDOS 2.1's table.
4D06-4D08
DEFB C3H,49H,5EH C3 49 5E
At 4158H after the copy: JP 5E49H, the vector of the CVS function. The same entry as in TRSDOS 2.1's table.
4D09-4D0B
DEFB C3H,55H,56H C3 55 56
At 415BH after the copy: JP 5655H, the vector of the DEF statement (DEF FN, DEFUSR). The same entry as in TRSDOS 2.1's table.
4D0C-4D0E
DEFB C3H,4CH,5EH C3 4C 5E
At 415EH after the copy: JP 5E4CH, the vector of the CVD function. The same entry as in TRSDOS 2.1's table.
4D0F-4D11
DEFB C3H,EBH,61H C3 EB 61
At 4161H after the copy: JP 61EBH, the vector of the EOF function. The same entry as in TRSDOS 2.1's table.
4D12-4D14
DEFB C3H,31H,62H C3 31 62
At 4164H after the copy: JP 6231H, the vector of the LOC function. The same entry as in TRSDOS 2.1's table.
4D15-4D17
DEFB C3H,42H,62H C3 42 62
At 4167H after the copy: JP 6242H, the vector of the LOF function. The same entry as in TRSDOS 2.1's table.
4D18-4D1A
DEFB C3H,2DH,5EH C3 2D 5E
At 416AH after the copy: JP 5E2DH, the vector of the MKI$ function. The same entry as in TRSDOS 2.1's table.
4D1B-4D1D
DEFB C3H,30H,5EH C3 30 5E
At 416DH after the copy: JP 5E30H, the vector of the MKS$ function. The same entry as in TRSDOS 2.1's table.
4D1E-4D20
DEFB C3H,33H,5EH C3 33 5E
At 4170H after the copy: JP 5E33H, the vector of the MKD$ function. The same entry as in TRSDOS 2.1's table.
4D21-4D23
DEFB C3H,C4H,56H C3 C4 56
At 4173H after the copy: JP 56C4H, the vector of the CMD statement. The same entry as in TRSDOS 2.1's table.
4D24-4D26
DEFB C3H,14H,57H C3 14 57
At 4176H after the copy: JP 5714H, the vector of the TIME$ function. The same entry as in TRSDOS 2.1's table.
4D27-4D29
DEFB C3H,49H,63H C3 49 63
At 4179H after the copy: JP 6349H, the vector of the OPEN statement. The same entry as in TRSDOS 2.1's table.
4D2A-4D2C
DEFB C3H,ABH,60H C3 AB 60
At 417CH after the copy: JP 60ABH, the vector of the FIELD statement. The same entry as in TRSDOS 2.1's table.
4D2D-4D2F
DEFB C3H,7CH,62H C3 7C 62
At 417FH after the copy: JP 627CH, the vector of the GET statement. The same entry as in TRSDOS 2.1's table.
4D30-4D32
DEFB C3H,7BH,62H C3 7B 62
At 4182H after the copy: JP 627BH, the vector of the PUT statement. The same entry as in TRSDOS 2.1's table.
4D33-4D35
DEFB C3H,6FH,60H C3 6F 60
At 4185H after the copy: JP 606FH, the vector of the CLOSE statement. The same entry as in TRSDOS 2.1's table.
4D36-4D38
DEFB C3H,7BH,5FH C3 7B 5F
At 4188H after the copy: JP 5F7BH, the vector of the LOAD command. The same entry as in TRSDOS 2.1's table.
4D39-4D3B
DEFB C3H,0BH,60H C3 0B 60
At 418BH after the copy: JP 600BH, the vector of the MERGE command. The same entry as in TRSDOS 2.1's table.
4D3C-4D3E
DEFB C3H,46H,63H C3 46 63
At 418EH after the copy: JP 6346H, the vector of the NAME keyword. The same entry as in TRSDOS 2.1's table.
4D3F-4D41
DEFB C3H,C0H,63H C3 C0 63
At 4191H after the copy: JP 63C0H, the vector of the KILL command. The same entry as in TRSDOS 2.1's table.
4D42-4D44
DEFB C3H,B7H,58H C3 B7 58
At 4194H after the copy: JP 58B7H, the vector of the &H and &O constants. The same entry as in TRSDOS 2.1's table.
4D45-4D47
DEFB C3H,E6H,60H C3 E6 60
At 4197H after the copy: JP 60E6H, the vector of the LSET statement. The same entry as in TRSDOS 2.1's table.
4D48-4D4A
DEFB C3H,E5H,60H C3 E5 60
At 419AH after the copy: JP 60E5H, the vector of the RSET statement. The same entry as in TRSDOS 2.1's table.
4D4B-4D4D
DEFB C3H,2FH,58H C3 2F 58
At 419DH after the copy: JP 582FH, the vector of the INSTR function. The same entry as in TRSDOS 2.1's table.
4D4E-4D50
DEFB C3H,44H,60H C3 44 60
At 41A0H after the copy: JP 6044H, the vector of the SAVE command. The same entry as in TRSDOS 2.1's table.
4D51-4D53
DEFB C3H,56H,57H C3 56 57
At 41A3H after the copy: JP 5756H, the vector of LINE INPUT. The same entry as in TRSDOS 2.1's table.
4D54-4D56
DEFB 3EH,89H,EFH 3E 89 EF
At 41A6H after the copy: LD A,89H and RST 28H, so the error vector of the ROM (called at 19ECH) loads and runs SYS7/SYS, overlay 9, which shows the long error message; TRSDOS 2.1 has JP 57B2H here.
4D57-4D59
DEFB C3H,79H,56H C3 79 56
At 41A9H after the copy: JP 5679H, the DOS link for USR n, called at 27FEH. The same entry as in TRSDOS 2.1's table.
4D5A-4D5C
DEFB C3H,FCH,5FH C3 FC 5F
At 41ACH after the copy: JP 5FFCH, the DOS link for the READY prompt, called at 1A1CH. The same entry as in TRSDOS 2.1's table.
4D5D-4D5F
DEFB C3H,8EH,59H C3 8E 59
At 41AFH after the copy: JP 598EH, the DOS exit from 0368H, the keyboard line input. 598EH goes on in DBLDOS's code at 5238H.
4D60-4D62
DEFB C3H,33H,60H C3 33 60
At 41B2H after the copy: JP 6033H, the DOS exit from 1AA1H, after a line has been tokenized. The same entry as in TRSDOS 2.1's table.
4D63-4D65
DEFB C3H,7DH,5BH C3 7D 5B
At 41B5H after the copy: JP 5B7DH, the DOS exit from 1AECH, after the program line table is updated. The same entry as in TRSDOS 2.1's table.
4D66-4D68
DEFB C3H,8CH,5BH C3 8C 5B
At 41B8H after the copy: JP 5B8CH, the DOS exit from 1AF2H, after the line table update and CLEAR. The same entry as in TRSDOS 2.1's table.
4D69-4D6B
DEFB C3H,A1H,60H C3 A1 60
At 41BBH after the copy: JP 60A1H, the DOS exit from 1B8CH and 1DB0H, NEW and END (close the files). The same entry as in TRSDOS 2.1's table.
4D6C-4D6E
DEFB C3H,7CH,57H C3 7C 57
At 41BEH after the copy: JP 577CH, the PRINT # and PRINT output hook, called from 2174H. The same entry as in TRSDOS 2.1's table.
4D6F-4D71
DEFB C3H,BEH,59H C3 BE 59
At 41C1H after the copy: JP 59BEH, the byte output to any device, called from 032CH. The same entry as in TRSDOS 2.1's table.
4D72-4D74
DEFB C3H,CDH,59H C3 CD 59
At 41C4H after the copy: JP 59CDH, the keyboard scan hook called from 0358H (INKEY$ and the BREAK test). The same entry as in TRSDOS 2.1's table.
4D75-4D77
DEFB C3H,78H,5FH C3 78 5F
At 41C7H after the copy: JP 5F78H, the DOS exit from 1EA6H, RUN with a file name or line number. The same entry as in TRSDOS 2.1's table.
4D78-4D7A
DEFB C3H,15H,5AH C3 15 5A
At 41CAH after the copy: JP 5A15H, the DOS exit from 206FH, print processing that checks for PRINT #. TRSDOS 2.1 has JP 5A5BH here.
4D7B-4D7D
DEFB C3H,9AH,5BH C3 9A 5B
At 41CDH after the copy: JP 5B9AH, the DOS exit from 20C6H, after a number is made ASCII and before it is printed. The same entry as in TRSDOS 2.1's table.
4D7E-4D80
DEFB C3H,99H,5BH C3 99 5B
At 41D0H after the copy: JP 5B99H, the DOS exit from 2103H, after PRINT sends its carriage return. The same entry as in TRSDOS 2.1's table.
4D81-4D83
DEFB C3H,65H,5BH C3 65 5B
At 41D3H after the copy: JP 5B65H, the DOS exit from 2108H and 2141H, the comma tabs and TAB. The same entry as in TRSDOS 2.1's table.
4D84-4D86
DEFB C3H,84H,57H C3 84 57
At 41D6H after the copy: JP 5784H, the INPUT # hook called from 219EH. The same entry as in TRSDOS 2.1's table.
4D87-4D89
DEFB C3H,0DH,59H C3 0D 59
At 41D9H after the copy: JP 590DH, the left side MID$ hook, a JP at 2AECH. The same entry as in TRSDOS 2.1's table.
4D8A-4D8C
DEFB C3H,63H,5EH C3 63 5E
At 41DCH after the copy: JP 5E63H, the READ and INPUT variable assignment, called from 222DH. The same entry as in TRSDOS 2.1's table.
4D8D-4D8F
DEFB C3H,9CH,57H C3 9C 57
At 41DFH after the copy: JP 579CH, the DOS exit from 2278H and 2B44H, after an INPUT assignment and in LIST. The same entry as in TRSDOS 2.1's table.
4D90-4D92
DEFB C3H,51H,5BH C3 51 5B
At 41E2H after the copy: JP 5B51H, the SYSTEM command hook called from 02B2H before its prompt for a tape file name. The same entry as in TRSDOS 2.1's table.
4D93H - The Disk BASIC Banner
The first part of the banner, shown by 5CBFH-5CC2H through 4467H; the second part, DBLDOS ADAPTATIONS COPYRIGHT 1980 BY PERCOM., follows from 5D25H (5CC5H). The text is TRSDOS 2.1's.
4D93-4DB4
DEFM "RADIO SHACK DISK BASIC VERSION 1.1" 52 41 44 49 4F 20 53 48 41 43 4B 20 44 49 53 4B 20 42 41 53 49 43 20 56 45 52 53 49 4F 4E 20 31 2E 31
The first line of the banner at 4D93H, RADIO SHACK DISK BASIC VERSION 1.1, shown by 5CC2H through 4467H.
4DB5-4DB6
DEFB 0AH,0AH 0A 0A
Two line feeds at 4DB5H-4DB6H after the first line of the banner, which leave one blank line on the screen.
4DB7-4DE7
DEFM "THIS BASIC COPYRIGHTED BY TANDY CORPORATION 1979 " 54 48 49 53 20 42 41 53 49 43 20 43 4F 50 59 52 49 47 48 54 45 44 20 42 59 20 54 41 4E 44 59 20 43 4F 52 50 4F 52 41 54 49 4F 4E 20 31 39 37 39 20
The second line of the banner at 4DB7H, THIS BASIC COPYRIGHTED BY TANDY CORPORATION 1979 and a space.
4DE8
DEFB 0DH 0D
The carriage return at 4DE8H that ends the text for 4467H; the text at 5D25H shown next (5CC8H) goes on the next line.
5200H - Make the Rest of a Line Capitals (Never Run)
Twenty-two bytes that no instruction of any DoubleDOS file reaches: nothing jumps to 5200H, and the vector table puts JP 6033H, not 5200H, at the exit 41B2H (4D60H). As instructions they would change every small letter of the line after Register Pair HL to a capital and go on to 6033H. TRSDOS 2.1's BASIC/CMD has JP 5BA4H and its error messages here; DBLDOS put its own code at 5200H-5548H.
5200
PUSH AF F5
Save Register Pair AF on the stack, the flags and Register A of the caller (never run: no instruction reaches 5200H).
5201
PUSH HL E5
Save Register Pair HL, the line pointer of the caller, on the stack for the end at 5211H (never run).
5202
RST 10H D7
RST 10H: Register A is the next character of the line after Register Pair HL, spaces passed over (never run).
5203
CP 60H FE 60
Compare Register A with 60H; the C FLAG is set for a character below 60H, which is left as it is (never run).
5205
If the C FLAG is set (Register A below 60H), jump to 520EH, leaving the character in the line unchanged (never run).
5207
CP 7BH FE 7B
Compare Register A with 7BH; the NC FLAG is set for a character from 7BH on, which is left as it is (never run).
5209
If the NC FLAG is set (Register A 7BH or more), jump to 520EH, leaving the character unchanged (never run).
520B
SUB 20H D6 20
Subtract 20H from Register A: a small letter becomes its capital, and 60H would become 40H (never run).
520D
LD (HL),A 77
Store Register A, the capital, back in the line at Register Pair HL (never run: no instruction reaches 5200H).
520E
OR A B7
Set the flags from Register A: the Z FLAG is set at the 00H that ends the line (never run).
520F
If the NZ FLAG is set (not the end of the line), jump back to 5202H for the next character (never run).
5211
POP HL E1
Restore Register Pair HL, the line pointer saved at 5201H, from the stack (never run: nothing reaches 5200H).
5212
POP AF F1
Restore Register Pair AF, saved at 5200H, from the stack (never run: no instruction reaches 5200H).
5213
Jump to 6033H, the routine of the exit 41B2H after a line has been tokenized (never run).
5216H - OPEN Mode E
Called from the OPEN statement at 6372H after the modes O (02H), I (01H) and R (03H) were tested: DBLDOS adds the mode E, 04H, which opens a file to add records at its end. TRSDOS 2.1's BASIC/CMD has JP NZ,63E3H at 6372H, so any other letter was Bad file mode there.
5216
RET Z C8
If the Z FLAG is set (the letter is R, Register D 03H from 636EH), return to 6375H with the mode R.
5217
LD D,04H 16 04
Load Register D with 04H, the mode number of E, which 638AH and the open at 63A7H pass on.
5219
CP 45H FE 45
Compare Register A, the mode letter of the OPEN statement, with 45H, the letter E.
521B
If the NZ FLAG is set (the letter is not O, I, R or E), jump to 63E3H for the error Bad file mode.
521E
RET C9
Return to 6375H with Register D 04H, the mode E; the open at 63A7H then uses 4420H, which also makes a new file.
521FH - OPEN Mode E: Position to the End
Reached by the jump at 63B6H after the file was opened (63ABH or 63B0H) without an error. For the mode E the file is positioned at its end with @PEOF and is then marked as open for output (mode 02H), so that PRINT # and PUT add to it. TRSDOS 2.1 has POP HL, POP AF and LD (HL),A at 63B6H, which this replaces.
521F
POP HL E1
Restore Register Pair HL from the stack: the place of the mode byte in BASIC's file area, pushed at 639AH.
5220
POP AF F1
Restore Register Pair AF from the stack: Register A is the mode number (01H-04H), pushed at 6399H.
5221
CP 04H FE 04
Compare Register A, the mode number, with 04H, the mode E; the Z FLAG is set for E.
5223
If the NZ FLAG is set (the mode is O, I or R), jump to 5234H to store the mode unchanged.
5225
PUSH AF F5
Save Register Pair AF, the mode 04H, on the stack while the file is positioned.
5226
Call 4448H, @PEOF, with Register Pair DE the file control block: position the file to its end.
5229
If the Z FLAG is set (@PEOF returned without its end of file code), jump to 63FDH, the disk error exit.
522C
CP 1CH FE 1C
Compare Register A, the code @PEOF returned, with 1CH, END OF FILE ENCOUNTERED, which it gives on success.
522E
If the NZ FLAG is set (another error), jump to 63FDH, which turns the code in Register A into a BASIC error.
5231
POP AF F1
Restore Register Pair AF, the mode 04H saved at 5225H, from the stack.
5232
LD A,02H 3E 02
Load Register A with 02H, the mode O: a file opened with E is then written like a file opened for output.
5234
LD (HL),A 77
Store Register A, the mode, at Register Pair HL, the mode byte of the file in BASIC's file area.
5235
Jump to 63B9H, the rest of OPEN: the next byte is cleared and the statement ends.
5238H - The Keyboard Line Input Exit (41AFH)
598EH, reached through the exit 41AFH from the ROM's line input at 0368H, loads (5B2AH) and jumps here. TRSDOS 2.1's BASIC/CMD has OR L, POP HL and RET Z at 5993H, so with no command file open the ROM took the line from the keyboard. DBLDOS's version does the same for an INPUT, but for the command line after READY it does the ROM's work itself, to show the command given after BASIC on the DOS line at the first READY (5D02H).
5238
OR L B5
OR Register L into Register A, the high byte of the word at 5B2AH: the Z FLAG is set when the word is 0000H.
5239
POP HL E1
Restore Register Pair HL, the buffer pointer saved by 598EH, from the stack.
523A
If the NZ FLAG is set (5B2AH holds a file, the commands come from it), jump to 5996H to read the line from the file.
523D
POP HL E1
Load Register Pair HL with the top of the stack and so discard it: the return address 036BH of the call 41AFH at 0368H in the ROM.
523E
POP HL E1
Load Register Pair HL with the next word of the stack: the return address of the caller of ROM 0361H.
523F
PUSH HL E5
Put Register Pair HL, that return address, back on the stack for the ROM's line input to return to.
5240
LD DE,1A7EH 11 7E 1A
Load Register Pair DE with 1A7EH, the return address of the CALL 0361H at 1A7BH, the command line after READY.
5243
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE; the Z FLAG is set when the caller is the command input.
5244
JP NZ,036BH C2 6B 03
If the NZ FLAG is set (an INPUT or LINE INPUT), jump to 036BH, so the ROM reads the line as usual.
5247
LD A,0EH 3E 0E
Load Register A with 0EH, the control code that turns the cursor on, as ROM 05DAH does.
5249
Call 0033H to show the cursor; the start-up changes this operand to 5D02H (5CF8H) when a command followed BASIC.
524C
Call 0049H, the ROM's wait for a key: Register A is the first key pressed, as at ROM 05E0H.
524F
PUSH BC C5
Save Register Pair BC on the stack, as ROM 036BH does before the line input.
5250
LD HL,5303H 21 03 53
Load Register Pair HL with 5303H, the address the line input returns to in place of ROM 0374H.
5253
PUSH HL E5
Save Register Pair HL, the return address 5303H, on the stack for the line input at 05E3H.
5254
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the word at 40A7H, the address of the input buffer, as ROM 036CH does.
5257
PUSH HL E5
Save Register Pair HL, the buffer address, on the stack, as ROM 05D9H does at the start of the line input.
5258
LD B,F0H 06 F0
Load Register B with F0H, the length of the input buffer, 240 characters, as ROM 036FH does.
525A
LD C,B 48
Load Register C with Register B, the buffer length F0H, as ROM 05DFH does.
525B
Jump to 05E3H in the ROM's line input, with Register A the key already pressed: it takes the rest of the line.
525EH - Line Recall by Arrow Keys (Never Run)
165 bytes that no instruction reaches. As instructions, they take the key in Register A: SHIFT and up arrow (1BH) or down arrow (1AH) would look for the line before or after the current line (40ECH) and list it with the ROM's LIST (2B33H) in place of the input, the line READY being overwritten. The live code at 5247H-525DH takes the key and goes straight to the ROM's line input instead. The text READY and five spaces at 52F9H-5302H belongs to it.
525E
DEC E 1D
Decrement Register E by one (never run: no instruction of any DoubleDOS file reaches 525EH).
525F
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the word at 40A4H, the start of the BASIC program (never run).
5262
CP 1BH FE 1B
Compare Register A, the key pressed, with 1BH, SHIFT and up arrow (never run).
5264
If the Z FLAG is set (up arrow), jump to 52B9H with Register Pair HL the start of the program (never run).
5266
LD DE,FFFFH 11 FF FF
Load Register Pair DE with FFFFH, the highest line number, for the down arrow search (never run).
5269
CP 1AH FE 1A
Compare Register A, the key pressed, with 1AH, SHIFT and down arrow (never run).
526B
If the Z FLAG is set (down arrow), jump to 5280H to look for the line (never run).
526D
PUSH BC C5
Save Register Pair BC on the stack, as ROM 036BH does before the line input (never run).
526E
LD HL,5303H 21 03 53
Load Register Pair HL with 5303H, the return address of the line input (never run).
5271
PUSH HL E5
Save Register Pair HL, the return address 5303H, on the stack for the line input (never run).
5272
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the word at 40A7H, the address of the input buffer (never run).
5275
PUSH HL E5
Save Register Pair HL, the buffer address, on the stack as ROM 05D9H does (never run).
5276
LD B,F0H 06 F0
Load Register B with F0H, the input buffer length of 240 characters (never run).
5278
LD C,B 48
Load Register C with Register B, the buffer length F0H (never run).
5279
Jump to 05E3H in the ROM's line input with the key in Register A (never run).
527C
LD DE,(40ECH) ED 5B EC 40
Load Register Pair DE with the word at 40ECH, the number of the current line (never run).
5280
PUSH AF F5
Save Register Pair AF, the key and its flags, on the stack (never run).
5281
Call 1B2CH, the ROM's search for the line numbered Register Pair DE; Register Pair BC is the line found (never run).
5284
POP DE D1
Restore Register Pair DE from the stack: Register D is the key pressed, saved at 5280H (never run).
5285
PUSH DE D5
Save Register Pair DE, the key in Register D, on the stack again (never run).
5286
LD A,D 7A
Load Register A with Register D, the key pressed (never run: no instruction reaches 525EH).
5287
If the NC FLAG is set (no line from the number on), jump to 529DH (never run).
5289
CP 2EH FE 2E
Compare Register A with 2EH, a period (never run: no instruction reaches 525EH).
528B
If the Z FLAG is set (a period), jump to 52B7H with the line found (never run).
528D
CP 2CH FE 2C
Compare Register A with 2CH, a comma (never run: no instruction reaches 525EH).
528F
If the Z FLAG is set (a comma), jump to 52B7H with the line found (never run).
5291
CP 0AH FE 0A
Compare Register A with 0AH, a line feed, the down arrow without SHIFT (never run).
5293
If the NZ FLAG is set (another key), jump to 529FH (never run).
5295
LD A,(HL) 7E
Load Register A with the low byte of the link of the line at Register Pair HL (never run).
5296
INC HL 23
Increment Register Pair HL to the high byte of the link (never run: no instruction reaches 525EH).
5297
OR (HL) B6
OR the high byte of the link at Register Pair HL into Register A: the Z FLAG is set at the end of the program (never run).
5298
DEC HL 2B
Decrement Register Pair HL back to the start of the line (never run).
5299
If the NZ FLAG is set (a next line exists), jump to 52B9H (never run).
529B
Jump to 52B7H with the line found (never run: no instruction reaches 525EH).
529D
If the Z FLAG is set (the line was found exactly), jump to 52A3H (never run).
529F
CP 5BH FE 5B
Compare Register A with 5BH, the up arrow without SHIFT (never run).
52A1
If the NZ FLAG is set (another key), jump to 52B7H (never run).
52A3
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the word at 40A4H, the start of the BASIC program (never run).
52A6
OR A B7
OR Register A with itself to clear the C FLAG for the subtraction (never run: no instruction reaches 525EH).
52A7
SBC HL,BC ED 42
Subtract Register Pair BC, the line found, from Register Pair HL; the Z FLAG is set at the first line (never run).
52A9
If the Z FLAG is set (no line before it), jump to 52B7H (never run).
52AB
ADD HL,BC 09
Add Register Pair BC back to Register Pair HL, the start of the program again (never run).
52AC
LD D,B 50
Load Register D with Register B, the high byte of the line found (never run).
52AD
LD E,C 59
Load Register E with Register C: Register Pair DE is the line found (never run).
52AE
LD B,H 44
Load Register B with Register H, the high byte of the line being looked at (never run).
52AF
LD C,L 4D
Load Register C with Register L: Register Pair BC is the line being looked at (never run).
52B0
LD A,(HL) 7E
Load Register A with the low byte of the link at Register Pair HL (never run).
52B1
INC HL 23
Increment Register Pair HL to the high byte of the link (never run: no instruction reaches 525EH).
52B2
LD H,(HL) 66
Load Register H with the high byte of the link at Register Pair HL (never run).
52B3
LD L,A 6F
Load Register L with Register A: Register Pair HL is the next line (never run).
52B4
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE, the line found (never run).
52B5
If the NZ FLAG is set (not yet the line found), jump back to 52AEH (never run).
52B7
LD H,B 60
Load Register H with Register B, the high byte of the line chosen (never run).
52B8
LD L,C 69
Load Register L with Register C: Register Pair HL is the line chosen (never run).
52B9
POP AF F1
Restore Register Pair AF, the key, from the stack (never run: no instruction reaches 525EH).
52BA
POP BC C1
Restore Register Pair BC from the stack (never run: no instruction reaches 525EH).
52BB
LD B,H 44
Load Register B with Register H, the high byte of the line chosen (never run).
52BC
LD C,L 4D
Load Register C with Register L: Register Pair BC is the line chosen (never run).
52BD
INC HL 23
Increment Register Pair HL past the low byte of the link (never run).
52BE
INC HL 23
Increment Register Pair HL to the line number of the line (never run).
52BF
LD E,(HL) 5E
Load Register E with the low byte of the line number at Register Pair HL (never run).
52C0
INC HL 23
Increment Register Pair HL to the high byte of the line number (never run).
52C1
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE is the number of the line chosen (never run).
52C2
CP 2CH FE 2C
Compare Register A, the key, with 2CH, a comma (never run: no instruction reaches 525EH).
52C4
If the Z FLAG is set (a comma), jump to 2E65H, the ROM's EDIT of the line numbered Register Pair DE (never run).
52C7
PUSH DE D5
Save Register Pair DE, the line number, on the stack for the ROM's LIST (never run).
52C8
PUSH BC C5
Save Register Pair BC, the line, on the stack for the ROM's LIST (never run).
52C9
LD A,0FH 3E 0F
Load Register A with 0FH, the control code that turns the cursor off (never run).
52CB
Call 0033H to send the control code in Register A to the display (never run).
52CE
LD A,1DH 3E 1D
Load Register A with 1DH, the control code that moves the cursor to the start of its line (never run).
52D0
Call 0033H to move the cursor to the start of the line (never run).
52D3
LD HL,(4020H) 2A 20 40
Load Register Pair HL with the word at 4020H, the cursor address on the screen (never run).
52D6
LD DE,FFC0H 11 C0 FF
Load Register Pair DE with FFC0H, minus 64, one screen line (never run).
52D9
ADD HL,DE 19
Add Register Pair DE to Register Pair HL: the start of the screen line above the cursor (never run).
52DA
LD A,H 7C
Load Register A with Register H, the high byte of that address (never run).
52DB
CP 3CH FE 3C
Compare Register A with 3CH, the first page of the screen at 3C00H (never run).
52DD
If the C FLAG is set (the cursor is on the top line), jump to 52F1H (never run).
52DF
LD B,0AH 06 0A
Load Register B with 0AH, the length of the text at 52F9H (never run).
52E1
LD DE,52F9H 11 F9 52
Load Register Pair DE with 52F9H, the text READY and five spaces (never run).
52E4
LD A,(DE) 1A
Load Register A with the next character of the text at Register Pair DE (never run).
52E5
CP (HL) BE
Compare Register A with the character of the screen at Register Pair HL (never run).
52E6
If the NZ FLAG is set (the line above is not READY), jump to 52F1H (never run).
52E8
INC DE 13
Increment Register Pair DE to the next character of the text (never run).
52E9
INC HL 23
Increment Register Pair HL to the next place on the screen (never run).
52EA
Decrement Register B and jump back to 52E4H until the ten characters are compared (never run).
52EC
LD A,1BH 3E 1B
Load Register A with 1BH, the control code that moves the cursor up one line (never run).
52EE
Call 0033H to move the cursor up onto the line READY (never run).
52F1
LD A,1EH 3E 1E
Load Register A with 1EH, the control code that clears to the end of the line (never run).
52F3
Call 0033H to clear the rest of the line at the cursor (never run).
52F6
Jump to 2B33H, the ROM's LIST loop, with the line and its number on the stack (never run).
52F9-5302
DEFM "READY " 52 45 41 44 59 20 20 20 20 20
The text READY and five spaces at 52F9H-5302H that 52DFH-52EAH compares with the screen line above the cursor (never run).
5303H - The Return of the Line Input
5250H puts 5303H on the stack as the return address of the ROM's line input, in place of ROM 0374H: the flags of the line input are saved and the ROM goes on at 0375H as after its own call.
5303
PUSH AF F5
Save Register Pair AF, the flags of the line input (C FLAG for BREAK), as ROM 0374H does.
5304
Jump to 0375H in the ROM: the line in the buffer gets its 00H end and Register Pair HL the buffer address minus one.
5307H - Abbreviations and REF/RENUM (Never Run)
157 bytes that no instruction reaches. As instructions they look at a command line just typed (made capitals by 5D80H): a line starting with L, E or D and a period or a number would get the rest of a keyword from the texts at 5D58H, 5D5EH or 5D63H inserted, and a line starting REF or RENUM would load overlay 8EH or 8DH (directory records 26H and 25H, which hold no file on a DBLDOS diskette) and go on to READY. The texts at 5D58H-5D69H are 04H and zeros in the shipped file, the start-up's command line buffer (5D59H).
5307
Call 5D80H to make the line at Register Pair HL capitals outside quotes; the Z FLAG is set when it starts with R (never run).
530A
If the Z FLAG is set (the line starts with R), jump to 5363H to test for REF and RENUM (never run).
530C
LD HL,5D58H 21 58 5D
Load Register Pair HL with 5D58H, the text for the letter L (never run: no instruction reaches 5307H).
530F
CP 4CH FE 4C
Compare Register A, the first character of the line, with 4CH, the letter L (never run).
5311
If the Z FLAG is set (L), jump to 5321H with Register Pair HL the text at 5D58H (never run).
5313
LD HL,5D5EH 21 5E 5D
Load Register Pair HL with 5D5EH, the text for the letter E (never run: no instruction reaches 5307H).
5316
CP 45H FE 45
Compare Register A, the first character of the line, with 45H, the letter E (never run).
5318
If the Z FLAG is set (E), jump to 5321H with Register Pair HL the text at 5D5EH (never run).
531A
LD HL,5D63H 21 63 5D
Load Register Pair HL with 5D63H, the text for the letter D (never run: no instruction reaches 5307H).
531D
CP 44H FE 44
Compare Register A, the first character of the line, with 44H, the letter D (never run).
531F
If the NZ FLAG is set (not L, E or D), jump to 535FH to leave the line as it is (never run).
5321
LD A,(HL) 7E
Load Register A with the first byte of the text at Register Pair HL, its length (never run).
5322
LD (535AH),A 32 5A 53
Store Register A, the length, at 535AH, the operand of LD C at 5359H for the copy (never run).
5325
DEC A 3D
Decrement Register A: the number of characters the line grows by (never run).
5326
LD (533DH),A 32 3D 53
Store Register A at 533DH, the operand of ADD A at 533CH (never run: no instruction reaches 5307H).
5329
INC HL 23
Increment Register Pair HL to the characters of the text after its length byte (never run).
532A
LD (5357H),HL 22 57 53
Store Register Pair HL at 5357H, the operand of LD HL at 5356H, the source of the copy (never run).
532D
POP HL E1
Load Register Pair HL with the word on the top of the stack, the address left there by the caller (never run).
532E
PUSH HL E5
Put Register Pair HL back on the stack for 535FH (never run: no instruction reaches 5307H).
532F
RST 10H D7
RST 10H: Register A is the next character after Register Pair HL; the C FLAG is set for a digit (never run).
5330
If the C FLAG is set (a line number follows the letter), jump to 5336H (never run).
5332
CP 2EH FE 2E
Compare Register A with 2EH, a period, the current line (never run: no instruction reaches 5307H).
5334
If the NZ FLAG is set (neither a number nor a period), jump to 535FH (never run).
5336
Call 5397H to scan the line for = or ( (never run: no instruction reaches 5307H).
5339
If the Z FLAG is set (an assignment or an array, not a command), jump to 535FH (never run).
533B
LD A,B 78
Load Register A with Register B, the number of characters typed (never run).
533C
ADD A,00H C6 00
Add the operand at 533DH, stored by 5326H, to Register A: the length after the insertion (never run).
533E
CP C B9
Compare Register A with Register C, the length of the buffer (never run: no instruction reaches 5307H).
533F
If the NC FLAG is set (the line would not fit), jump to 1997H, the ROM's Syntax error (never run).
5342
POP HL E1
Restore Register Pair HL from the stack, the address left by the caller (never run).
5343
PUSH HL E5
Save Register Pair HL on the stack again for 535FH (never run: no instruction reaches 5307H).
5344
PUSH DE D5
Save Register Pair DE on the stack for 535EH (never run: no instruction reaches 5307H).
5345
LD E,B 58
Load Register E with Register B, the number of characters typed (never run).
5346
LD B,A 47
Load Register B with Register A, the length after the insertion (never run).
5347
SUB E 93
Subtract Register E from Register A: Register A is the number of characters to insert (never run).
5348
PUSH BC C5
Save Register Pair BC on the stack for 535DH (never run: no instruction reaches 5307H).
5349
LD B,00H 06 00
Load Register B with 00H for the 16 bit length in Register Pair BC (never run).
534B
LD C,E 4B
Load Register C with Register E: Register Pair BC is the number of characters typed (never run).
534C
ADD HL,BC 09
Add Register Pair BC to Register Pair HL: the end of the line typed (never run).
534D
ADD A,L 85
Add Register L to Register A, the characters to insert (never run: no instruction reaches 5307H).
534E
LD E,A 5F
Load Register E with Register A, the low byte of the new end of the line (never run).
534F
LD A,H 7C
Load Register A with Register H, the high byte of the end of the line (never run).
5350
ADC A,00H CE 00
Add the carry to Register A, the high byte of the new end (never run).
5352
LD D,A 57
Load Register D with Register A: Register Pair DE is the new end of the line (never run).
5353
LDDR ED B8
LDDR: move the line, Register Pair BC bytes, from Register Pair HL to Register Pair DE, downward (never run).
5355
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL: Register Pair DE is the place for the text (never run).
5356
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, the operand at 5357H that 532AH replaces with the text address (never run).
5359
LD C,00H 0E 00
Load Register C with the length stored at 535AH by 5322H (never run: no instruction reaches 5307H).
535B
LDIR ED B0
LDIR: copy Register Pair BC bytes of the text from Register Pair HL into the line at Register Pair DE (never run).
535D
POP BC C1
Restore Register Pair BC from the stack, saved at 5348H (never run).
535E
POP DE D1
Restore Register Pair DE from the stack, saved at 5344H (never run).
535F
POP HL E1
Restore Register Pair HL from the stack, the address left by the caller (never run).
5360
Jump to 0375H in the ROM's line input, which ends the line with 00H (never run).
5363
RST 10H D7
RST 10H: Register A is the next character after Register Pair HL, the second letter of the line (never run).
5364
CP 45H FE 45
Compare Register A with 45H, the letter E of REF and RENUM (never run).
5366
If the NZ FLAG is set (not RE), jump to 535FH (never run: no instruction reaches 5307H).
5368
RST 10H D7
RST 10H: Register A is the next character after Register Pair HL, the third letter (never run).
5369
CP 46H FE 46
Compare Register A with 46H, the letter F of REF (never run: no instruction reaches 5307H).
536B
If the NZ FLAG is set (not REF), jump to 5385H to test for RENUM (never run).
536D
LD A,8EH 3E 8E
Load Register A with 8EH, the request code of the overlay for REF (never run).
536F
POP DE D1
Restore Register Pair DE from the stack, the first of four words of the line input discarded (never run).
5370
POP DE D1
Restore Register Pair DE from the stack, the second word discarded (never run).
5371
POP DE D1
Restore Register Pair DE from the stack, the third word discarded (never run).
5372
POP DE D1
Restore Register Pair DE from the stack, the fourth word discarded (never run).
5373
PUSH AF F5
Save Register Pair AF, the request code 8EH or 8DH, on the stack (never run).
5374
PUSH HL E5
Save Register Pair HL, the line pointer, on the stack (never run: no instruction reaches 5307H).
5375
Call 5397H to scan the line for = or ( (never run: no instruction reaches 5307H).
5378
If the Z FLAG is set (= or ( found), jump to 1997H, the ROM's Syntax error (never run).
537B
POP HL E1
Restore Register Pair HL, the line pointer, from the stack (never run).
537C
RST 10H D7
RST 10H: Register A is the next character after Register Pair HL (never run).
537D
POP AF F1
Restore Register Pair AF, the request code, from the stack (never run: no instruction reaches 5307H).
537E
Call 5384H, the RST 28H below, to load and run the overlay of the request code in Register A (never run).
5381
Jump to 1A25H, the ROM's READY, after the overlay returns (never run).
5384
RST 28H EF
RST 28H: the overlay dispatcher 4BA2H loads and calls the overlay of the code in Register A (never run).
5385
CP 4EH FE 4E
Compare Register A, the third letter, with 4EH, the letter N of RENUM (never run).
5387
If the NZ FLAG is set (not REN), jump to 535FH (never run: no instruction reaches 5307H).
5389
RST 10H D7
RST 10H: Register A is the next character after Register Pair HL (never run).
538A
CP 55H FE 55
Compare Register A with 55H, the letter U of RENUM (never run: no instruction reaches 5307H).
538C
If the NZ FLAG is set (not RENU), jump to 535FH (never run).
538E
RST 10H D7
RST 10H: Register A is the next character after Register Pair HL (never run).
538F
CP 4DH FE 4D
Compare Register A with 4DH, the letter M of RENUM (never run: no instruction reaches 5307H).
5391
If the NZ FLAG is set (not RENUM), jump to 535FH (never run).
5393
LD A,8DH 3E 8D
Load Register A with 8DH, the request code of the overlay for RENUM (never run).
5395
Jump to 536FH to load the overlay of Register A (never run: no instruction reaches 5307H).
5397H - Scan for = or ( (Never Run)
Used only by 5336H and 5375H, which nothing reaches: Z when = or ( comes before the carriage return, NZ at the carriage return.
5397
RST 10H D7
RST 10H: Register A is the next character after Register Pair HL, spaces passed over (never run).
5398
CP 3DH FE 3D
Compare Register A with 3DH, the equals sign (never run: nothing reaches 5397H).
539A
RET Z C8
Return with the Z FLAG set if Register A is the equals sign (never run).
539B
CP 28H FE 28
Compare Register A with 28H, an open parenthesis (never run: nothing reaches 5397H).
539D
RET Z C8
Return with the Z FLAG set if Register A is an open parenthesis (never run).
539E
CP 0DH FE 0D
Compare Register A with 0DH, the carriage return at the end of the line (never run).
53A0
If the NZ FLAG is set (not the end), jump back to 5397H for the next character (never run).
53A2
OR A B7
OR Register A with itself, 0DH: the NZ FLAG is set (never run: nothing reaches 5397H).
53A3
RET C9
Return with the NZ FLAG set: no = or ( in the line (never run).
53A4H - The Memory Check of CMD with a DOS Command (Never Run)
Used only by the code at 53EEH-552AH, which nothing reaches. 53A4H fills the 64 bytes at the address in 53D5H with A5H and folds into them, by XOR, every byte from the address in 54D6H to that place and from 64 bytes after it to the top of memory (40B1H) plus one; 53AEH folds again without the fill. Folding the same bytes twice gives A5H again, so the Z FLAG at the end says the memory is unchanged since the first fold.
53A4
LD HL,(53D5H) 2A D5 53
Load Register Pair HL with the word at 53D5H, the address of the 64 byte check area (never run).
53A7
LD B,40H 06 40
Load Register B with 40H, the 64 bytes of the check area (never run: nothing reaches 53A4H).
53A9
LD (HL),A5H 36 A5
Store A5H at Register Pair HL, the next byte of the check area (never run).
53AB
INC HL 23
Increment Register Pair HL to the next byte of the check area (never run).
53AC
Decrement Register B and jump back to 53A9H until the 64 bytes are A5H (never run).
53AE
LD DE,(54D6H) ED 5B D6 54
Load Register Pair DE with the word at 54D6H, the operand of LD DE at 54D5H, 5200H: the start of the fold (never run).
53B2
LD BC,(53D5H) ED 4B D5 53
Load Register Pair BC with the word at 53D5H, the check area: the end of the first fold (never run).
53B6
Call 53D4H to fold the bytes from Register Pair DE up to Register Pair BC into the check area (never run).
53B9
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL for the addition (never run: nothing reaches 53A4H).
53BA
LD BC,0040H 01 40 00
Load Register Pair BC with 0040H, the length of the check area (never run).
53BD
ADD HL,BC 09
Add Register Pair BC to Register Pair HL: past the check area (never run: nothing reaches 53A4H).
53BE
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL: Register Pair DE is the first byte after the check area (never run).
53BF
LD BC,(40B1H) ED 4B B1 40
Load Register Pair BC with the word at 40B1H, the top of the memory BASIC may use (never run).
53C3
INC BC 03
Increment Register Pair BC: the fold ends one past the top (never run: nothing reaches 53A4H).
53C4
Call 53E3H to go on folding from Register Pair DE to Register Pair BC (never run).
53C7
LD HL,(53D5H) 2A D5 53
Load Register Pair HL with the word at 53D5H, the check area (never run: nothing reaches 53A4H).
53CA
LD B,40H 06 40
Load Register B with 40H, the 64 bytes to test (never run: nothing reaches 53A4H).
53CC
LD A,(HL) 7E
Load Register A with the byte of the check area at Register Pair HL (never run).
53CD
XOR A5H EE A5
XOR Register A with A5H: the Z FLAG is set when the byte is still A5H (never run).
53CF
RET NZ C0
Return with the NZ FLAG set if Register A shows a byte that changed (never run).
53D0
INC HL 23
Increment Register Pair HL to the next byte of the check area (never run).
53D1
Decrement Register B and jump back to 53CCH until the 64 bytes are tested (never run).
53D3
RET C9
Return with the Z FLAG set: the memory folded is unchanged (never run).
53D4
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, the operand at 53D5H: the check area, stored by 545DH (never run).
53D7
LD A,40H 3E 40
Load Register A with 40H, the 64 bytes of the check area, for the count in Register A' (never run).
53D9
EX AF,AF' 08
Exchange Register Pair AF with Register Pair AF': the count is kept in Register A' (never run).
53DA
LD A,(DE) 1A
Load Register A with the byte of memory at Register Pair DE (never run: nothing reaches 53A4H).
53DB
XOR (HL) AE
XOR Register A with the byte of the check area at Register Pair HL (never run).
53DC
LD (HL),A 77
Store Register A back in the check area at Register Pair HL (never run).
53DD
INC DE 13
Increment Register Pair DE to the next byte of memory (never run: nothing reaches 53A4H).
53DE
INC HL 23
Increment Register Pair HL to the next byte of the check area (never run).
53DF
LD A,D 7A
Load Register A with Register D, the high byte of the memory address (never run).
53E0
CP B B8
Compare Register A with Register B, the high byte of the end (never run: nothing reaches 53A4H).
53E1
If the Z FLAG is set (the same page as the end), jump to 53E9H to compare the low bytes (never run).
53E3
EX AF,AF' 08
Exchange Register Pair AF with Register Pair AF': Register A is the count of the check area (never run).
53E4
DEC A 3D
Decrement Register A, the bytes left in this turn of the check area (never run).
53E5
If the NZ FLAG is set (bytes left), jump back to 53D9H for the next byte (never run).
53E7
Jump to 53D4H to start again at the first byte of the check area (never run).
53E9
LD A,E 7B
Load Register A with Register E, the low byte of the memory address (never run).
53EA
CP C B9
Compare Register A with Register C, the low byte of the end (never run: nothing reaches 53A4H).
53EB
If the NZ FLAG is set (not yet the end), jump to 53E3H (never run).
53ED
RET C9
Return: the bytes from Register Pair DE to Register Pair BC are folded (never run).
53EEH - CMD with a DOS Command (Never Run)
317 bytes that no instruction reaches. As instructions they would take a CMD string of 2 to 63 characters (with Register A its length and Register Pair HL its descriptor, as CMD leaves them at 56CBH) as a DOS command: the string, or the string variable it names when it ends with $, is copied in capitals to 4318H; BASIC 5200H-6FFFH and the area 407DH-41FFH are copied below the stack; the DOS return 402DH, the abnormal exit 4030H and the @ERROR vector (440AH, through 4358H) are pointed at the copy of 54C3H-54CEH; and the command is run through 4405H. Back from the DOS, BASIC is copied back to 5200H, the fold of 53AEH must show the memory unchanged (or 0000H, RESET, is jumped to), and BASIC goes on after the CMD, with a DOS error made a BASIC error. CMD at 56C4H-56CDH now accepts only one character (TRSDOS 2.1 has OR A and JP Z,1E4AH at 56CCH), and nothing jumps here.
53EE
If the Z FLAG is set (an empty string), jump to 1E4AH, the ROM's Illegal function call (never run).
53F1
CP 02H FE 02
Compare Register A, the length of the string, with 02H (never run: nothing reaches 53EEH).
53F3
RET C D8
Return with the C FLAG set for a string of one character, the CMD letters (never run).
53F4
CP 40H FE 40
Compare Register A, the length, with 40H: 64 characters or more do not fit at 4318H (never run).
53F6
If the NC FLAG is set (64 or more characters), jump to 1E4AH, the ROM's Illegal function call (never run).
53F9
INC HL 23
Increment Register Pair HL to the low byte of the string address in the descriptor (never run).
53FA
LD E,(HL) 5E
Load Register E with the low byte of the string address at Register Pair HL (never run).
53FB
INC HL 23
Increment Register Pair HL to the high byte of the string address (never run).
53FC
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE is the string (never run).
53FD
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL: Register Pair HL is the string (never run).
53FE
LD DE,4318H 11 18 43
Load Register Pair DE with 4318H, the command line buffer of SYS0/SYS (never run).
5401
PUSH DE D5
Save Register Pair DE, the buffer 4318H, on the stack (never run: nothing reaches 53EEH).
5402
LD C,A 4F
Load Register C with Register A, the length of the string (never run).
5403
LD B,A 47
Load Register B with Register A, the count for the copy (never run: nothing reaches 53EEH).
5404
Call 5D9CH to copy Register B characters from Register Pair HL to Register Pair DE in capitals (never run).
5407
POP HL E1
Restore Register Pair HL, the buffer 4318H, from the stack (never run).
5408
LD A,0DH 3E 0D
Load Register A with 0DH, the carriage return that ends a DOS command line (never run).
540A
LD (DE),A 12
Store Register A, the carriage return, at Register Pair DE after the command (never run).
540B
DEC DE 1B
Decrement Register Pair DE to the character before (never run: nothing reaches 53EEH).
540C
LD A,(DE) 1A
Load Register A with the character at Register Pair DE, the last of the command (never run).
540D
CP 20H FE 20
Compare Register A with 20H, a space (never run: nothing reaches 53EEH).
540F
If the Z FLAG is set (a trailing space), jump back to 540BH to pass over it (never run).
5411
CP 24H FE 24
Compare Register A, the last character, with 24H, the dollar sign of a string variable (never run).
5413
If the NZ FLAG is set (not a variable), jump to 5428H to run the command (never run).
5415
Call 2611H, the ROM's search for the variable named at Register Pair HL; Register Pair DE is its value (never run).
5418
LD A,(40AFH) 3A AF 40
Load Register A with the byte at 40AFH, the type of the variable found (never run).
541B
CP 03H FE 03
Compare Register A with 03H, the type of a string (never run: nothing reaches 53EEH).
541D
If the NZ FLAG is set (not a string), jump to 1E4AH, the ROM's Illegal function call (never run).
5420
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL: Register Pair HL is the descriptor of the string (never run).
5421
LD A,(HL) 7E
Load Register A with the length of the string at Register Pair HL (never run).
5422
OR A B7
Set the flags from Register A: the Z FLAG is set for an empty string (never run).
5423
If the Z FLAG is set (an empty string), jump to 1E4AH, the ROM's Illegal function call (never run).
5426
Jump to 53F4H to copy the value of the variable to 4318H (never run: nothing reaches 53EEH).
5428
POP AF F1
Restore Register Pair AF from the stack, a word left by the caller (never run).
5429
LD HL,(402EH) 2A 2E 40
Load Register Pair HL with the word at 402EH, the address of the DOS return JP at 402DH (never run).
542C
LD (54F8H),HL 22 F8 54
Store Register Pair HL at 54F8H, the operand of LD HL at 54F7H, to put it back afterward (never run).
542F
LD A,(4030H) 3A 30 40
Load Register A with the byte at 4030H, the first byte of the abnormal exit (never run).
5432
LD (5504H),A 32 04 55
Store Register A at 5504H, the operand of LD A at 5503H, to put it back afterward (never run).
5435
LD HL,(4031H) 2A 31 40
Load Register Pair HL with the word at 4031H, the rest of the abnormal exit (never run).
5438
LD (54FEH),HL 22 FE 54
Store Register Pair HL at 54FEH, the operand of LD HL at 54FDH, to put it back afterward (never run).
543B
LD HL,(440AH) 2A 0A 44
Load Register Pair HL with the word at 440AH, the target of the @ERROR jump at 4409H (never run).
543E
LD (5509H),HL 22 09 55
Store Register Pair HL at 5509H, the operand of LD HL at 5508H, to put it back afterward (never run).
5441
LD (435AH),HL 22 5A 43
Store Register Pair HL at 435AH, the jump of the error hook 4358H for codes with bit 7 set (never run).
5444
LD HL,4358H 21 58 43
Load Register Pair HL with 4358H, the error hook of SYS0/SYS (never run: nothing reaches 53EEH).
5447
LD (440AH),HL 22 0A 44
Store Register Pair HL at 440AH: @ERROR at 4409H now jumps to 4358H (never run).
544A
LD HL,(5BA8H) 2A A8 5B
Load Register Pair HL with the word at 5BA8H, the target of 4312H that the start-up saved (never run).
544D
LD (4313H),HL 22 13 43
Store Register Pair HL at 4313H, which restores the jump at 4312H for the DOS command (never run).
5450
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H for the addition of the stack pointer (never run).
5453
ADD HL,SP 39
Add the Stack Pointer to Register Pair HL: Register Pair HL is the stack of BASIC (never run).
5454
LD (54EAH),HL 22 EA 54
Store Register Pair HL at 54EAH, the operand of LD SP at 54E9H, the stack to come back to (never run).
5457
LD DE,00C0H 11 C0 00
Load Register Pair DE with 00C0H, 192 bytes left for the stack (never run).
545A
OR A B7
OR Register A with itself to clear the C FLAG for the subtraction (never run).
545B
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL: 192 bytes below the stack (never run).
545D
LD (53D5H),HL 22 D5 53
Store Register Pair HL at 53D5H, the check area of 53A4H (never run: nothing reaches 53EEH).
5460
LD DE,(54B3H) ED 5B B3 54
Load Register Pair DE with the word at 54B3H, the operand of LD BC at 54B2H, 0183H (never run).
5464
OR A B7
OR Register A with itself to clear the C FLAG for the subtraction (never run).
5465
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL: room for 407DH-41FFH (never run).
5467
LD BC,(54D9H) ED 4B D9 54
Load Register Pair BC with the word at 54D9H, the operand of LD BC at 54D8H, 1E00H (never run).
546B
OR A B7
OR Register A with itself to clear the C FLAG for the subtraction (never run).
546C
SBC HL,BC ED 42
Subtract Register Pair BC from Register Pair HL: room for BASIC 5200H-6FFFH (never run).
546E
LD (54D3H),HL 22 D3 54
Store Register Pair HL at 54D3H, the operand of LD HL at 54D2H: where BASIC is kept (never run).
5471
PUSH HL E5
Save Register Pair HL, the place of the copy, on the stack (never run: nothing reaches 53EEH).
5472
LD DE,(40FDH) ED 5B FD 40
Load Register Pair DE with the word at 40FDH, the end of the memory BASIC uses (never run).
5476
OR A B7
OR Register A with itself to clear the C FLAG for the subtraction (never run).
5477
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL; the C FLAG is set when the copy would cover memory in use (never run).
5479
If the C FLAG is set (no room), jump to 553DH for the ROM's Out of memory (never run).
547C
POP DE D1
Restore Register Pair DE from the stack: the place of the copy (never run: nothing reaches 53EEH).
547D
LD HL,(54D6H) 2A D6 54
Load Register Pair HL with the word at 54D6H, 5200H, the start of BASIC/CMD (never run).
5480
PUSH HL E5
Save Register Pair HL, 5200H, on the stack for the copy (never run: nothing reaches 53EEH).
5481
ADD HL,BC 09
Add Register Pair BC, 1E00H, to Register Pair HL (never run: nothing reaches 53EEH).
5482
DEC HL 2B
Decrement Register Pair HL: 6FFFH, the last byte copied (never run: nothing reaches 53EEH).
5483
OR A B7
OR Register A with itself to clear the C FLAG for the subtraction (never run).
5484
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL; the NC FLAG is set when the copy would overlap BASIC (never run).
5486
If the NC FLAG is set (overlap), jump to 553DH for the ROM's Out of memory (never run).
5489
POP HL E1
Restore Register Pair HL, 5200H, from the stack (never run: nothing reaches 53EEH).
548A
PUSH HL E5
Save Register Pair HL, 5200H, on the stack again for 54ACH (never run).
548B
PUSH DE D5
Save Register Pair DE, the place of the copy, on the stack for 54ABH (never run).
548C
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL for the subtraction (never run).
548D
OR A B7
OR Register A with itself to clear the C FLAG for the subtraction (never run).
548E
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL: the distance from 5200H to the copy (never run).
5490
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL: Register Pair DE is the distance (never run).
5491
LD HL,54CCH 21 CC 54
Load Register Pair HL with 54CCH, the entry for a normal DOS return (never run).
5494
ADD HL,DE 19
Add Register Pair DE, the distance, to Register Pair HL: 54CCH in the copy (never run).
5495
LD (402EH),HL 22 2E 40
Store Register Pair HL at 402EH: the DOS return at 402DH jumps to the copy of 54CCH (never run).
5498
LD HL,54C8H 21 C8 54
Load Register Pair HL with 54C8H, the entry for the abnormal exit (never run).
549B
ADD HL,DE 19
Add Register Pair DE, the distance, to Register Pair HL: 54C8H in the copy (never run).
549C
LD (4031H),HL 22 31 40
Store Register Pair HL at 4031H, the operand of the abnormal exit at 4030H (never run).
549F
LD A,C3H 3E C3
Load Register A with C3H, the opcode JP (never run: nothing reaches 53EEH).
54A1
LD (4030H),A 32 30 40
Store Register A at 4030H: the abnormal exit becomes a JP to the copy of 54C8H (never run).
54A4
LD HL,54C3H 21 C3 54
Load Register Pair HL with 54C3H, the entry for an error with bit 7 clear (never run).
54A7
ADD HL,DE 19
Add Register Pair DE, the distance, to Register Pair HL: 54C3H in the copy (never run).
54A8
LD (435DH),HL 22 5D 43
Store Register Pair HL at 435DH, the jump of the error hook 4358H for codes with bit 7 clear (never run).
54AB
POP DE D1
Restore Register Pair DE, the place of the copy, from the stack (never run).
54AC
POP HL E1
Restore Register Pair HL, 5200H, from the stack (never run: nothing reaches 53EEH).
54AD
LDIR ED B0
LDIR: copy Register Pair BC, 1E00H bytes, of BASIC from Register Pair HL to Register Pair DE (never run).
54AF
LD HL,407DH 21 7D 40
Load Register Pair HL with 407DH, the RAM area of BASIC under 4200H (never run).
54B2
LD BC,0183H 01 83 01
Load Register Pair BC with 0183H, the length of 407DH-41FFH (never run: nothing reaches 53EEH).
54B5
LDIR ED B0
LDIR: copy Register Pair BC bytes from Register Pair HL to Register Pair DE, after the copy of BASIC (never run).
54B7
LD SP,41FCH 31 FC 41
Load the Stack Pointer with 41FCH, the stack of the DOS (never run: nothing reaches 53EEH).
54BA
Call 53A4H to fill the check area and fold the memory into it (never run).
54BD
LD HL,4318H 21 18 43
Load Register Pair HL with 4318H, the command copied there (never run: nothing reaches 53EEH).
54C0
Jump to 4405H, which runs the DOS command line at Register Pair HL (never run).
54C3
LD C,A 4F
Load Register C with Register A, the error code given to @ERROR (never run: nothing sets 435DH).
54C4
LD B,02H 06 02
Load Register B with 02H, the mark of an error (never run: nothing sets 435DH).
54C6
Jump to 54CEH (never run: nothing sets 435DH to the copy of 54C3H).
54C8
LD B,00H 06 00
Load Register B with 00H, the mark of the abnormal exit (never run: nothing sets 4030H).
54CA
Jump to 54CEH (never run: nothing sets 4030H to the copy of 54C8H).
54CC
LD B,01H 06 01
Load Register B with 01H, the mark of a normal return to the DOS (never run: nothing sets 402EH).
54CE
LD SP,41FCH 31 FC 41
Load the Stack Pointer with 41FCH, the stack of the DOS (never run).
54D1
PUSH BC C5
Save Register Pair BC, the mark in Register B and the error code in Register C, on the stack (never run).
54D2
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, the operand at 54D3H: the place of the copy, stored by 546EH (never run).
54D5
LD DE,5200H 11 00 52
Load Register Pair DE with 5200H, the start of BASIC/CMD (never run).
54D8
LD BC,1E00H 01 00 1E
Load Register Pair BC with 1E00H, the length of 5200H-6FFFH (never run).
54DB
LDIR ED B0
LDIR: copy BASIC back from Register Pair HL to Register Pair DE, 5200H, Register Pair BC bytes (never run).
54DD
Jump to 54E0H, now in the copy of BASIC at its own place (never run).
54E0
PUSH HL E5
Save Register Pair HL, the copy of 407DH-41FFH that follows, on the stack (never run).
54E1
Call 53AEH to fold the memory again into the check area (never run: nothing reaches 53EEH).
54E4
If the NZ FLAG is set (the memory changed), jump to 0000H, the start of the ROM, as RESET does (never run).
54E7
POP HL E1
Restore Register Pair HL, the copy of 407DH-41FFH, from the stack (never run).
54E8
POP BC C1
Restore Register Pair BC, the mark and the error code, from the stack (never run).
54E9
LD SP,0000H 31 00 00
Load the Stack Pointer with 0000H, the operand at 54EAH: BASIC's stack, stored by 5454H (never run).
54EC
PUSH BC C5
Save Register Pair BC, the mark and the error code, on BASIC's stack (never run).
54ED
LD DE,(54B0H) ED 5B B0 54
Load Register Pair DE with the word at 54B0H, the operand of LD HL at 54AFH, 407DH (never run).
54F1
LD BC,(54B3H) ED 4B B3 54
Load Register Pair BC with the word at 54B3H, 0183H, the length of 407DH-41FFH (never run).
54F5
LDIR ED B0
LDIR: copy 407DH-41FFH, Register Pair BC bytes, back from Register Pair HL to Register Pair DE (never run).
54F7
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, the operand at 54F8H: the old target of 402DH, stored by 542CH (never run).
54FA
LD (402EH),HL 22 2E 40
Store Register Pair HL at 402EH: the DOS return at 402DH is as before (never run).
54FD
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, the operand at 54FEH: the old 4031H, stored by 5438H (never run).
5500
LD (4031H),HL 22 31 40
Store Register Pair HL at 4031H: the abnormal exit is as before (never run).
5503
LD A,00H 3E 00
Load Register A with 00H, the operand at 5504H: the old 4030H, stored by 5432H (never run).
5505
LD (4030H),A 32 30 40
Store Register A at 4030H, the first byte of the abnormal exit (never run).
5508
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, the operand at 5509H: the old @ERROR target, stored by 543EH (never run).
550B
LD (440AH),HL 22 0A 44
Store Register Pair HL at 440AH: @ERROR at 4409H is as before (never run).
550E
LD HL,5BA4H 21 A4 5B
Load Register Pair HL with 5BA4H, BASIC's handler of the requests with bit 7 clear (never run).
5511
LD (4313H),HL 22 13 43
Store Register Pair HL at 4313H: the jump at 4312H goes to 5BA4H again (never run).
5514
LD HL,430FH 21 0F 43
Load Register Pair HL with 430FH, the flags of SYS0/SYS (never run: nothing reaches 53EEH).
5517
RES 4,(HL) CB A6
Reset bit 4 of the flags at Register Pair HL, 430FH: SYS6/SYS is no longer at 5200H (never run).
5519
POP BC C1
Restore Register Pair BC from the stack: Register B the mark, Register C the error code (never run).
551A
Decrement Register B; if Register B is not zero (an error or the abnormal exit), jump to 551EH (never run).
551C
POP HL E1
Restore Register Pair HL, BASIC's line pointer, from the stack (never run: nothing reaches 53EEH).
551D
RET C9
Return to BASIC after the CMD (never run: nothing reaches 53EEH).
551E
Decrement Register B; if Register B is not zero (the abnormal exit), jump to 5526H (never run).
5520
LD A,C 79
Load Register A with Register C, the error code given to @ERROR (never run).
5521
AND 3FH E6 3F
AND Register A with 3FH, the error number without bits 7 and 6 (never run).
5523
Jump to 63FDH, which turns the DOS error in Register A into a BASIC error (never run).
5526
LD E,26H 1E 26
Load Register E with 26H, the BASIC error code of Unprintable error (never run).
5528
Jump to 19A2H, the ROM's error routine, with Register E the error code (never run).
552BH - LOAD: The Room for a Program File
Called from LOAD at 5FD5H with Register Pair HL the start of the string space (40A0H) less 56H, and Index Register IX the file control block. The size of the file is taken from its end of file sector and offset and checked against the room from the start of the program (40A4H) at 57B2H. TRSDOS 2.1 has other code here; DBLDOS's 5FD2H-5FD5H calls this.
552B
LD DE,(40A4H) ED 5B A4 40
Load Register Pair DE with the word at 40A4H, the start of the BASIC program text.
552F
SBC HL,DE ED 52
Subtract Register Pair DE and the C FLAG left by the ADD at 5FD4H from Register Pair HL: the room for the program, one byte less than the true room (a bug: the Bugs part of the introduction).
5531
LD A,(IX+0DH) DD 7E 0D
Load Register A with FCB+0DH through Index Register IX, the high byte of the end of file sector number.
5534
LD B,(IX+0CH) DD 46 0C
Load Register B with FCB+0CH through Index Register IX, the low byte of the end of file sector number.
5537
LD C,(IX+08H) DD 4E 08
Load Register C with FCB+08H through Index Register IX, the end of file offset in the last sector.
553A
Jump to 57B2H with Register Pair BC the size of the file in bytes and Register A above it, to test it against Register Pair HL.
553DH - CMD with a DOS Command: No Room (Never Run)
Reached only from 5479H and 5486H, which nothing reaches: the vectors are put back by 54F7H and the return at 551DH goes to 197AH.
553D
LD HL,197AH 21 7A 19
Load Register Pair HL with 197AH, the ROM's Out of memory error (never run).
5540
PUSH HL E5
Save Register Pair HL, 197AH, on the stack as the address 551DH returns to (never run).
5541
LD BC,0100H 01 00 01
Load Register Pair BC with 0100H: Register B 01H, the mark of a normal return (never run).
5544
PUSH BC C5
Save Register Pair BC on the stack, the word 551CH pops (never run: nothing reaches 553DH).
5545
PUSH BC C5
Save Register Pair BC on the stack, the word 5519H pops (never run: nothing reaches 553DH).
5546
Jump to 54F7H to put back the vectors and return to 197AH (never run).
5549-5555
DEFB 57H,C3H,0DH,59H,C3H,63H,5EH,C3H,9CH,57H,C3H,51H,5BH 57 C3 0D 59 C3 63 5E C3 9C 57 C3 51 5B
The last 13 bytes of TRSDOS 2.1's vector table, which DBLDOS left in place after its code: the high byte of JP 5784H, then JP 590DH, JP 5E63H, JP 579CH and JP 5B51H. Nothing reads them; the table used is the copy at 4D00H.
5556H - FN: Save the Value of a Parameter
TRSDOS 2.1's code, unchanged from here to 56CBH. Reached by the jump at 55BFH with Register Pair HL the value of a variable named in the parameter list of DEF FN and the C FLAG set: its old value is pushed on the stack, two bytes at a time, so that 5604H can put it back after the function. The type at 40AFH (02H integer, 03H string, 04H single, 08H double) says how many bytes.
5556
LD A,(40AFH) 3A AF 40
Load Register A with the byte at 40AFH, the type of the parameter variable found by 260DH.
5559
DEC A 3D
Decrement Register A, the type, by one; three decrements leave the type less 3.
555A
DEC A 3D
Decrement Register A again: the type at 40AFH less 2.
555B
DEC A 3D
Decrement Register A again: the type less 3, which is 00H for a string, FFH for an integer, 01H for single, 05H for double.
555C
OR A B7
Set the flags from Register A: Z for a string, M for an integer, odd parity for single precision.
555D
SCF 37
Set the C FLAG; OR A at 555CH cleared it, so the C FLAG is always set at 5571H and 557FH (a bug: the Bugs part of the introduction).
555E
If the Z FLAG is set (a string), jump to 55C2H to save the string's descriptor.
5561
LD C,(HL) 4E
Load Register C with the first byte of the value at Register Pair HL.
5562
INC HL 23
Increment Register Pair HL to the second byte of the value.
5563
LD B,(HL) 46
Load Register B with the second byte at Register Pair HL: Register Pair BC is the first word of the value.
5564
PUSH BC C5
Save Register Pair BC, the first word of the old value, on the stack.
5565
If the M FLAG is set (an integer, two bytes), jump to 557FH: the value is saved.
5568
INC HL 23
Increment Register Pair HL to the third byte of the value.
5569
LD C,(HL) 4E
Load Register C with the third byte of the value at Register Pair HL.
556A
INC HL 23
Increment Register Pair HL to the fourth byte of the value.
556B
LD B,(HL) 46
Load Register B with the fourth byte at Register Pair HL: Register Pair BC is the second word.
556C
PUSH BC C5
Save Register Pair BC, the second word of the old value, on the stack.
556D
If the P/O FLAG shows odd parity (single precision, four bytes), jump to 557FH: the value is saved.
5570
INC HL 23
Increment Register Pair HL to the fifth byte of a double precision value.
5571
If the C FLAG is set, always so here (555DH), jump to 5576H with Register Pair HL the fifth byte.
5573
LD HL,411DH 21 1D 41
Load Register Pair HL with 411DH, the low word of the double precision accumulator (never run: the C FLAG is always set at 5571H).
5576
LD C,(HL) 4E
Load Register C with the fifth byte of the value at Register Pair HL.
5577
INC HL 23
Increment Register Pair HL to the sixth byte of the value.
5578
LD B,(HL) 46
Load Register B with the sixth byte at Register Pair HL: Register Pair BC is the third word.
5579
INC HL 23
Increment Register Pair HL to the seventh byte of the value.
557A
PUSH BC C5
Save Register Pair BC, the third word of the old value, on the stack.
557B
LD C,(HL) 4E
Load Register C with the seventh byte of the value at Register Pair HL.
557C
INC HL 23
Increment Register Pair HL to the eighth byte of the value.
557D
LD B,(HL) 46
Load Register B with the eighth byte at Register Pair HL: Register Pair BC is the fourth word.
557E
PUSH BC C5
Save Register Pair BC, the fourth word of the old value, on the stack.
557F
If the C FLAG is set, always so here, jump to 55CCH to go on with the parameter list.
5582H - FN: Find the Function's Name
Called from FN (558EH) and DEF FN (5659H) with Register Pair HL at the token FN: the name after it is looked up by the ROM as a variable whose first letter has bit 7 set, so the functions do not mix with the variables.
5582
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (5583H).
5583
DEFB BEH BE
The byte for the RST 08H at 5582H: BEH, the token FN; any other byte gives a Syntax error.
5584
LD A,80H 3E 80
Load Register A with 80H, the flag of the name of a function.
5586
LD (40DCH),A 32 DC 40
Store Register A at 40DCH, the flag that no array may be found, for the search at 2612H.
5589
OR (HL) B6
OR the first letter of the name at Register Pair HL into Register A: the letter with bit 7 set.
558A
LD B,A 47
Load Register B with Register A, the first letter with bit 7 set, as the ROM's search takes it.
558B
Jump to 2612H, the ROM's variable search after its first letter; Register Pair DE is the place of the function's value.
558EH - FN: Call a User Function
The vector 4155H. The value of the function's name is the address of its DEF FN text after the name (stored by DEF at 565FH). The parameters named there get the values of the expressions given, their old values being saved on the stack (5556H); the expression of the definition is evaluated, the old values are put back (5604H) and the result is left in the accumulator with the function's type.
558E
Call 5582H to check the token FN and find the function's name: Register Pair DE is its value.
5591
LD A,(40AFH) 3A AF 40
Load Register A with the byte at 40AFH, the type of the function's name.
5594
OR A B7
Set the flags from Register A, the type, for the end of the function (5604H).
5595
PUSH AF F5
Save Register Pair AF, the type of the function and its flags, on the stack: the end mark for 5604H.
5596
LD (40F3H),HL 22 F3 40
Store Register Pair HL, the text after the name in the FN call, at 40F3H.
5599
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL: Register Pair HL is the value of the function's name.
559A
LD A,(HL) 7E
Load Register A with the low byte of the address of the definition at Register Pair HL.
559B
INC HL 23
Increment Register Pair HL to the high byte of the address.
559C
LD H,(HL) 66
Load Register H with the high byte of the address of the definition at Register Pair HL.
559D
LD L,A 6F
Load Register L with Register A: Register Pair HL is the DEF FN text after the name.
559E
OR H B4
OR Register H into Register A: the Z FLAG is set when the address is 0000H, a function never defined.
559F
If the Z FLAG is set (no DEF FN for it), jump to 56BAH for Undefined USER function.
55A2
LD A,(HL) 7E
Load Register A with the character of the definition at Register Pair HL.
55A3
CP 28H FE 28
Compare Register A with 28H, the open parenthesis of a parameter list.
55A5
If the NZ FLAG is set (no parameters), jump to 55F5H, the PUSH DE inside the instruction at 55F4H.
55A8
RST 10H D7
RST 10H: Register A is the next character after Register Pair HL, the first parameter name.
55A9
LD (40D8H),HL 22 D8 40
Store Register Pair HL, the parameter list of the definition, at 40D8H for 55DAH.
55AC
Jump to 55B0H for the first parameter, which has no comma before it.
55AE
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (55AFH).
55AF
DEFB 2CH 2C
The byte for the RST 08H at 55AEH: 2CH, the comma between two parameter names of the definition.
55B0
LD C,04H 0E 04
Load Register C with 04H, the number of words that the stack must still have room for.
55B2
Call 1963H, the ROM's test of the room left for the stack (Out of memory when Register C words do not fit).
55B5
LD A,80H 3E 80
Load Register A with 80H, the flag that no array may be found.
55B7
LD (40DCH),A 32 DC 40
Store Register A at 40DCH so that the search at 260DH takes the parameter as a simple variable.
55BA
Call 260DH, the ROM's search for the variable named at Register Pair HL; Register Pair DE is its value.
55BD
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL: Register Pair HL is the value of the parameter.
55BE
SCF 37
Set the C FLAG for 5556H (555DH sets it again in any case).
55BF
Jump to 5556H to save the old value of the parameter on the stack.
55C2
JP NC,2423H D2 23 24
If the NC FLAG is set, jump to 2423H in the ROM (never taken: 555DH set the C FLAG).
55C5
PUSH DE D5
Save Register Pair DE, the text pointer of the definition, on the stack.
55C6
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL: Register Pair DE is the descriptor of the string parameter.
55C7
Call 2888H in the ROM, which puts a copy of the descriptor at Register Pair DE in the pool of temporary strings.
55CA
POP DE D1
Restore Register Pair DE, the text pointer of the definition, from the stack.
55CB
XOR A AF
XOR Register A with itself: 00H, with the Z FLAG, the mark of a saved string.
55CC
PUSH HL E5
Save Register Pair HL on the stack: the place of the saved value, or of the string's temporary.
55CD
PUSH AF F5
Save Register Pair AF on the stack: the type mark of the saved value for 5604H.
55CE
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL: Register Pair HL is the text of the definition.
55CF
LD A,(HL) 7E
Load Register A with the character of the definition at Register Pair HL.
55D0
CP 29H FE 29
Compare Register A with 29H, the close parenthesis at the end of the parameter list.
55D2
If the NZ FLAG is set (more parameters), jump to 55AEH, which expects a comma.
55D4
LD HL,(40F3H) 2A F3 40
Load Register Pair HL with the word at 40F3H, the text of the FN call after the name.
55D7
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (55D8H).
55D8
DEFB 28H 28
The byte for the RST 08H at 55D7H: 28H, the open parenthesis of the values in the FN call.
55D9
PUSH HL E5
Save Register Pair HL, the text of the call at its first value, on the stack.
55DA
LD HL,(40D8H) 2A D8 40
Load Register Pair HL with the word at 40D8H, the parameter list of the definition.
55DD
Call 260DH, the ROM's search for the parameter named at Register Pair HL; Register Pair DE is its value.
55E0
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: Register Pair HL is the text of the call, the definition is saved.
55E1
Call 1F2BH in the ROM's LET: evaluate the expression at Register Pair HL and store it in the variable at Register Pair DE.
55E4
LD A,(HL) 7E
Load Register A with the character of the call at Register Pair HL after the value.
55E5
CP 29H FE 29
Compare Register A with 29H, the close parenthesis after the last value.
55E7
If the Z FLAG is set (the last value), jump to 55F0H.
55E9
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (55EAH).
55EA
DEFB 2CH 2C
The byte for the RST 08H at 55E9H: 2CH, the comma between two values of the call.
55EB
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: Register Pair HL is the definition, the call is saved.
55EC
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (55EDH).
55ED
DEFB 2CH 2C
The byte for the RST 08H at 55ECH: 2CH, the comma between two parameter names of the definition.
55EE
Jump back to 55DDH for the next parameter and its value.
55F0
RST 10H D7
RST 10H: pass over the close parenthesis of the call; Register Pair HL is the text after FN and Register A its next character.
55F1
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: Register Pair HL is the definition, the call's text is saved.
55F2
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (55F3H).
55F3
DEFB 29H 29
The byte for the RST 08H at 55F2H: 29H, the close parenthesis after the parameter names.
55F4
LD A,D5H 3E D5
Load Register A with D5H, which passes over the byte at 55F5H; entered at 55F5H by the jump at 55A5H, D5H is PUSH DE, saving Register Pair DE.
55F6
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (55F7H).
55F7
DEFB D5H D5
The byte for the RST 08H at 55F6H: D5H, the token =, which comes before the expression of the definition.
55F8
Call 2337H, the ROM's expression evaluator, on the definition's expression at Register Pair HL.
55FB
DEC HL 2B
Decrement Register Pair HL for the RST 10H that follows.
55FC
RST 10H D7
RST 10H: Register A is the character after the expression at Register Pair HL; the Z FLAG is set at its end.
55FD
If the NZ FLAG is set (more after the expression), jump to 1997H, the ROM's Syntax error.
5600
RST 20H E7
RST 20H: the ROM's test of the type of the result; the Z FLAG is set for a string.
5601
If the Z FLAG is set (a string result), jump to 5632H to keep it out of the way of the parameters.
5603
POP DE D1
Restore Register Pair DE from the stack: the text of the FN call after the close parenthesis.
5604
POP AF F1
Restore Register Pair AF from the stack: the type mark of the next saved value, or the end mark of 5595H.
5605
If the Z FLAG is set (a saved string), jump to 5646H.
5607
If the NC FLAG is set (the end mark of 5595H, no more values), jump to 5625H.
5609
POP HL E1
Restore Register Pair HL from the stack, the place of the saved value (the last byte of it).
560A
POP BC C1
Restore Register Pair BC from the stack, the last word of the saved value.
560B
LD (HL),B 70
Store Register B, the high byte of the word, at Register Pair HL.
560C
DEC HL 2B
Decrement Register Pair HL to the byte before.
560D
LD (HL),C 71
Store Register C, the low byte of the word, at Register Pair HL.
560E
If the M FLAG is set (an integer, done), jump back to 5604H for the next value.
5611
DEC HL 2B
Decrement Register Pair HL to the byte before.
5612
POP BC C1
Restore Register Pair BC from the stack, the next word of the saved value.
5613
LD (HL),B 70
Store Register B, the high byte of the word, at Register Pair HL.
5614
DEC HL 2B
Decrement Register Pair HL to the byte before.
5615
LD (HL),C 71
Store Register C, the low byte of the word, at Register Pair HL.
5616
If the P/O FLAG shows odd parity (single precision, done), jump back to 5604H.
5619
DEC HL 2B
Decrement Register Pair HL to the byte before.
561A
POP BC C1
Restore Register Pair BC from the stack, the next word of a double precision value.
561B
LD (HL),B 70
Store Register B, the high byte of the word, at Register Pair HL.
561C
DEC HL 2B
Decrement Register Pair HL to the byte before.
561D
LD (HL),C 71
Store Register C, the low byte of the word, at Register Pair HL.
561E
DEC HL 2B
Decrement Register Pair HL to the byte before.
561F
POP BC C1
Restore Register Pair BC from the stack, the first word of the double precision value.
5620
LD (HL),B 70
Store Register B, the high byte of the word, at Register Pair HL.
5621
DEC HL 2B
Decrement Register Pair HL to the byte before.
5622
LD (HL),C 71
Store Register C, the low byte of the word, at Register Pair HL.
5623
Jump back to 5604H for the next saved value: this one was double precision.
5625
PUSH DE D5
Save Register Pair DE, the text of the FN call, on the stack.
5626
PUSH AF F5
Save Register Pair AF, the type of the function, on the stack.
5627
RST 20H E7
RST 20H: the ROM's test of the type of the result; the Z FLAG is set for a string.
5628
LD DE,40D3H 11 D3 40
Load Register Pair DE with 40D3H, the ROM's temporary string descriptor.
562B
If the Z FLAG is set (a string result), call 2888H to put the descriptor at Register Pair DE in the temporary pool.
562E
POP AF F1
Restore Register Pair AF, the type of the function, from the stack.
562F
Jump to 281AH in the ROM, which makes the result the type in Register A and returns to the caller of FN.
5632
LD HL,(40B3H) 2A B3 40
Load Register Pair HL with the word at 40B3H, the next free place of the temporary string pool.
5635
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL: Register Pair DE is that place.
5636
LD HL,(4121H) 2A 21 41
Load Register Pair HL with the word at 4121H, the descriptor of the string result.
5639
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE; the C FLAG is set when the result is a temporary below it.
563A
If the C FLAG is set, jump to 5641H to move the temporary.
563C
Call 2843H in the ROM, which makes a new copy of the string whose descriptor is at Register Pair HL.
563F
Jump to 5603H to put back the saved values of the parameters.
5641
POP DE D1
Restore Register Pair DE from the stack, the text of the FN call.
5642
LD HL,40D3H 21 D3 40
Load Register Pair HL with 40D3H, the ROM's temporary string descriptor.
5645
PUSH HL E5
Save Register Pair HL, 40D3H, on the stack for 564DH.
5646
Call 29F5H, the ROM's FRETMS: Register Pair HL is the last temporary descriptor, Register Pair BC its string, freed when it is the one at Register Pair DE.
5649
LD A,(HL) 7E
Load Register A with the length of the string at Register Pair HL, the last temporary descriptor.
564A
LD (40B3H),HL 22 B3 40
Store Register Pair HL at 40B3H, the next free place of the temporary pool: that descriptor is freed.
564D
POP HL E1
Restore Register Pair HL from the stack, the descriptor to fill.
564E
LD (HL),A 77
Store Register A, the length, at Register Pair HL.
564F
INC HL 23
Increment Register Pair HL to the low byte of the address.
5650
LD (HL),C 71
Store Register C, the low byte of the string's address, at Register Pair HL.
5651
INC HL 23
Increment Register Pair HL to the high byte of the address.
5652
LD (HL),B 70
Store Register B, the high byte of the string's address, at Register Pair HL.
5653
Jump back to 5604H for the next saved value: this one was a string.
5655H - DEF: DEF FN and DEFUSR
The vector 415BH. DEF USR goes to 56ABH. DEF FN, allowed only in a program, stores the address of the text after the function's name as the value of the name (5582H) and makes each parameter a variable, then passes over the rest of the statement with the ROM's DATA (1F05H): the expression is evaluated only when FN calls it.
5655
CP C1H FE C1
Compare Register A, the token after DEF, with C1H, the token USR.
5657
If the Z FLAG is set (DEF USR), jump to 56ABH.
5659
Call 5582H to check the token FN and find the function's name: Register Pair DE is its value.
565C
Call 2828H, the ROM's test that refuses a statement typed without a line number (Illegal direct).
565F
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL: Register Pair HL is the value of the function's name.
5660
LD (HL),E 73
Store Register E, the low byte of the text pointer after the name, at Register Pair HL.
5661
INC HL 23
Increment Register Pair HL to the high byte of the value.
5662
LD (HL),D 72
Store Register D, the high byte of the text pointer, at Register Pair HL: FN finds its definition there.
5663
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL: Register Pair HL is the text after the name again.
5664
LD A,(HL) 7E
Load Register A with the character after the name at Register Pair HL.
5665
CP 28H FE 28
Compare Register A with 28H, the open parenthesis of a parameter list.
5667
If the NZ FLAG is set (no parameters), jump to 1F05H, the ROM's DATA, which passes over the rest of the statement.
566A
RST 10H D7
RST 10H: Register A is the next character after Register Pair HL, the first parameter name.
566B
Call 260DH, the ROM's search for the variable named at Register Pair HL, which makes it if it is new.
566E
LD A,(HL) 7E
Load Register A with the character after the parameter name at Register Pair HL.
566F
CP 29H FE 29
Compare Register A with 29H, the close parenthesis after the last parameter.
5671
If the Z FLAG is set (the last parameter), jump to 1F05H, the ROM's DATA, past the rest of the statement.
5674
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (5675H).
5675
DEFB 2CH 2C
The byte for the RST 08H at 5674H: 2CH, the comma between two parameter names.
5676
Jump back to 566BH for the next parameter name of the list.
5679H - USR: Call a Machine Language Routine
The DOS link 41A9H, called at 27FEH for USR. The digit after USR (none is 0) picks one of the ten addresses at 5B14H-5B27H set by DEFUSR; the argument in parentheses is evaluated and the routine is entered with Register A the type of the argument and Register Pair HL 4121H, the accumulator, returning to the ROM at 26E7H.
5679
POP AF F1
Restore Register Pair AF from the stack and so discard the return address of the call to 41A9H.
567A
Call 5699H for the digit after USR: Register Pair DE is its place in the table at 5B14H.
567D
PUSH DE D5
Save Register Pair DE, the place of the address in the table, on the stack.
567E
Call 252CH, the ROM's PARCHK: evaluate the argument in parentheses at Register Pair HL into the accumulator.
5681
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: Register Pair HL is the place in the table.
5682
LD C,(HL) 4E
Load Register C with the low byte of the routine's address at Register Pair HL.
5683
INC HL 23
Increment Register Pair HL to the high byte of the address.
5684
LD B,(HL) 46
Load Register B with the high byte at Register Pair HL: Register Pair BC is the address of the routine.
5685
LD HL,26E7H 21 E7 26
Load Register Pair HL with 26E7H, the place in the ROM the routine returns to.
5688
PUSH HL E5
Save Register Pair HL, the return address 26E7H, on the stack.
5689
PUSH BC C5
Save Register Pair BC, the routine's address, on the stack for the RET at 5698H.
568A
LD A,(40AFH) 3A AF 40
Load Register A with the byte at 40AFH, the type of the argument.
568D
PUSH AF F5
Save Register Pair AF, the type, on the stack.
568E
CP 03H FE 03
Compare Register A, the type, with 03H, a string.
5690
If the Z FLAG is set (a string argument), call 29DAH, the ROM's FREFAC, to free its temporary.
5693
POP AF F1
Restore Register Pair AF, the type of the argument, from the stack.
5694
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL: Register Pair DE is the text pointer after the argument.
5695
LD HL,4121H 21 21 41
Load Register Pair HL with 4121H, the accumulator, where the argument is.
5698
RET C9
Return, which enters the routine at the address pushed at 5689H.
5699H - USR and DEFUSR: The Digit
Register Pair DE is 5B14H plus twice the digit after USR (00H when there is none).
5699
RST 10H D7
RST 10H: Register A is the next character after Register Pair HL; the C FLAG is set for a digit.
569A
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, the offset for USR without a digit.
569D
If the NC FLAG is set (no digit), jump to 56A4H with the offset 0000H.
569F
SUB 30H D6 30
Subtract 30H from Register A: the value of the digit, 0-9; the C FLAG is clear.
56A1
RLA 17
Rotate Register A left through the C FLAG: twice the digit, the offset of its address.
56A2
LD C,A 4F
Load Register C with Register A: Register Pair BC is the offset in the table.
56A3
RST 10H D7
RST 10H: Register A is the next character after Register Pair HL, past the digit.
56A4
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL to keep the text pointer in Register Pair DE.
56A5
LD HL,5B14H 21 14 5B
Load Register Pair HL with 5B14H, the table of the ten USR addresses.
56A8
ADD HL,BC 09
Add Register Pair BC, the offset, to Register Pair HL: the place of the address.
56A9
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL: Register Pair DE is the place, Register Pair HL the text.
56AA
RET C9
Return to the caller with Register Pair DE the place of the USR address in the table.
56AB
Call 5699H for the digit after DEF USR: Register Pair DE is its place in the table at 5B14H.
56AE
PUSH DE D5
Save Register Pair DE, the place in the table, on the stack.
56AF
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (56B0H).
56B0
DEFB D5H D5
The byte for the RST 08H at 56AFH: D5H, the token = after DEF USRn.
56B1
Call 2B02H, the ROM's evaluation of an address: Register Pair DE is the value after =.
56B4
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: Register Pair HL is the place in the table.
56B5
LD (HL),E 73
Store Register E, the low byte of the address, at Register Pair HL.
56B6
INC HL 23
Increment Register Pair HL to the high byte of the entry.
56B7
LD (HL),D 72
Store Register D, the high byte of the address, at Register Pair HL.
56B8
POP HL E1
Restore Register Pair HL, the text pointer after the value, from the stack.
56B9
RET C9
Return to the ROM, which goes on with the next statement after DEF USR.
56BA
LD E,2EH 1E 2E
Load Register E with 2EH, the BASIC error code of Undefined USER function (error 24).
56BC
Jump to 19A2H, the ROM's error routine, with Register E the error code.
56BF-56C3
DEFB 0EH,02H,C3H,EAH,5DH 0E 02 C3 EA 5D
Five bytes that no instruction reaches: as instructions LD C,02H and JP 5DEAH. TRSDOS 2.1's BASIC/CMD has the same bytes here.
56C4H - CMD
The vector 4173H. The argument must be a string of exactly one character (DBLDOS's 56CCH: TRSDOS 2.1 has OR A and JP Z,1E4AH, which took any string that is not empty). CMD"D" enters DEBUG, CMD"E" shows the long text of the last disk error, CMD"T" and CMD"R" turn the clock interrupt off and on (the RST 38H vector 4012H made RET or JP), CMD"S" and CMD"A" go back to the DOS (5B52H, CMD"A" with the C FLAG set). CMD"X" is refused: TRSDOS 2.1 has JP Z,57E1H at 56F4H, DBLDOS JP Z,1E4AH. Other letters are Illegal function call.
56C4
Call 2337H, the ROM's expression evaluator, on the argument of CMD at Register Pair HL.
56C7
PUSH HL E5
Save Register Pair HL, the text pointer after the argument, on the stack.
56C8
Call 29D7H, the ROM's FRESTR: the argument must be a string; Register Pair HL is its descriptor.
56CB
LD A,(HL) 7E
Load Register A with the length of the string at Register Pair HL.
56CC
DEC A 3D
Decrement Register A: the Z FLAG is set only for a string of one character (changed by DBLDOS).
56CD
If the NZ FLAG is set (not one character), jump to 1E4AH, the ROM's Illegal function call.
56D0
INC HL 23
Increment Register Pair HL to the low byte of the string's address.
56D1
LD E,(HL) 5E
Load Register E with the low byte of the string's address at Register Pair HL.
56D2
INC HL 23
Increment Register Pair HL to the high byte of the address.
56D3
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE is the string.
56D4
LD A,(DE) 1A
Load Register A with the character of the string at Register Pair DE.
56D5
CP 44H FE 44
Compare Register A with 44H, the letter D, the character of the CMD string at Register Pair DE.
56D7
If the Z FLAG is set (CMD"D"), jump to 5705H, DEBUG.
56DA
CP 45H FE 45
Compare Register A with 45H, the letter E, the character of the CMD string at Register Pair DE.
56DC
If the Z FLAG is set (CMD"E"), jump to 570AH, the text of the last disk error.
56DF
CP 54H FE 54
Compare Register A with 54H, the letter T, the character of the CMD string at Register Pair DE.
56E1
If the Z FLAG is set (CMD"T"), jump to 56FDH, which makes the RST 38H vector a RET.
56E3
CP 52H FE 52
Compare Register A with 52H, the letter R, the character of the CMD string at Register Pair DE.
56E5
If the Z FLAG is set (CMD"R"), jump to 56FAH, which makes the RST 38H vector a JP again.
56E7
CP 53H FE 53
Compare Register A with 53H, the letter S, the character of the CMD string at Register Pair DE.
56E9
If the Z FLAG is set (CMD"S"), jump to 5B52H, the return to the DOS.
56EC
CP 41H FE 41
Compare Register A with 41H, the letter A, the character of the CMD string at Register Pair DE.
56EE
SCF 37
Set the C FLAG, which tells 5B52H that the return is CMD"A".
56EF
If the Z FLAG is set (CMD"A"), jump to 5B52H with the C FLAG set.
56F2
CP 58H FE 58
Compare Register A with 58H, the letter X, the character of the CMD string at Register Pair DE.
56F4
If the Z FLAG is set (CMD"X"), jump to 1E4AH, Illegal function call (TRSDOS 2.1 has JP Z,57E1H here).
56F7
Jump to 1E4AH, the ROM's Illegal function call, for any other letter.
56FA
LD A,C3H 3E C3
Load Register A with C3H, the opcode JP, for CMD"R"; the instruction at 56FCH passes over LD A,C9H.
56FC
LD BC,C93EH 01 3E C9
Load Register Pair BC with C93EH, which passes over 56FDH-56FEH; entered at 56FDH for CMD"T", 3EH C9H is LD A,C9H, the opcode RET.
56FF
LD (4012H),A 32 12 40
Store Register A, JP or RET, at 4012H, the RST 38H vector: the clock and disk interrupts are taken or ignored.
5702
POP HL E1
Restore Register Pair HL, the text pointer after the argument, from the stack.
5703
EI FB
Enable the interrupts again, which CMD"T" leaves on with the vector a RET.
5704
RET C9
Return to the ROM, which goes on with the next statement after CMD.
5705
Call 440DH, DEBUG of SYS0/SYS (SYS5/SYS), for CMD"D".
5708
POP HL E1
Restore Register Pair HL, the text pointer after the argument, from the stack.
5709
RET C9
Return to the ROM after DEBUG, which goes on with the next statement.
570A
LD A,(5B29H) 3A 29 5B
Load Register A with the byte at 5B29H, the code of the last disk error, stored by 6405H.
570D
OR C0H F6 C0
OR Register A with C0H: bit 7 makes SYS4/SYS return to the caller after the message; bit 6 has no effect there (B18).
570F
Call 4409H, @ERROR of SYS0/SYS, which shows the message of the error code in Register A through SYS4/SYS.
5712
POP HL E1
Restore Register Pair HL, the text pointer after the argument, from the stack.
5713
RET C9
Return to the ROM after the message, which goes on with the next statement.
5714H - TIME$
The vector 4176H. A string of 17 characters is made from the six bytes 4046H down to 4041H: the date as DATE shows it, a space, and the hours, minutes and seconds of the clock (4043H, 4042H, 4041H), each two digits, with slashes and colons between.
5714
RST 10H D7
RST 10H: pass over the token TIME$; Register A is the next character after Register Pair HL.
5715
PUSH HL E5
Save Register Pair HL, the text pointer after TIME$, on the stack.
5716
LD A,11H 3E 11
Load Register A with 11H, the length of the string, 17 characters.
5718
Call 2857H, the ROM's STRINI: room for a string of Register A characters, its descriptor at 40D3H.
571B
LD HL,(40D4H) 2A D4 40
Load Register Pair HL with the word at 40D4H, the address of the new string's characters.
571E
LD DE,4046H 11 46 40
Load Register Pair DE with 4046H, the first of the six date and time bytes, taken downward.
5721
Call 5745H to store the byte at Register Pair DE, 4046H, as two digits at Register Pair HL.
5724
LD (HL),2FH 36 2F
Store 2FH, a slash, at Register Pair HL after the first two digits of the date.
5726
INC HL 23
Increment Register Pair HL to the next character of the string.
5727
Call 5745H to store the byte at Register Pair DE, 4045H, as two digits at Register Pair HL.
572A
LD (HL),2FH 36 2F
Store 2FH, a slash, at Register Pair HL after the second two digits of the date.
572C
INC HL 23
Increment Register Pair HL to the next character of the string.
572D
Call 5745H to store the byte at Register Pair DE, 4044H, as two digits at Register Pair HL.
5730
LD (HL),20H 36 20
Store 20H, a space, at Register Pair HL between the date and the time.
5732
INC HL 23
Increment Register Pair HL to the next character of the string.
5733
Call 5745H to store the byte at Register Pair DE, 4043H, the hours, as two digits at Register Pair HL.
5736
LD (HL),3AH 36 3A
Store 3AH, a colon, at Register Pair HL after the hours.
5738
INC HL 23
Increment Register Pair HL to the next character of the string.
5739
Call 5745H to store the byte at Register Pair DE, 4042H, the minutes, as two digits at Register Pair HL.
573C
LD (HL),3AH 36 3A
Store 3AH, a colon, at Register Pair HL after the minutes.
573E
INC HL 23
Increment Register Pair HL to the next character of the string.
573F
Call 5745H to store the byte at Register Pair DE, 4041H, the seconds, as two digits at Register Pair HL.
5742
Jump to 2884H in the ROM, which puts the descriptor 40D3H in the pool of temporary strings as the result.
5745
LD A,(DE) 1A
Load Register A with the date or time byte at Register Pair DE, a number 0-99.
5746
DEC DE 1B
Decrement Register Pair DE to the next byte, downward.
5747
LD B,2FH 06 2F
Load Register B with 2FH, one less than the digit 0, for the tens.
5749
SUB 0AH D6 0A
Subtract 0AH, ten, from Register A; the C FLAG is set when it goes below zero.
574B
INC B 04
Increment Register B, the tens digit, by one for each ten taken away.
574C
If the NC FLAG is set (Register A not yet below zero), jump back to 5749H.
574F
ADD A,3AH C6 3A
Add 3AH to Register A: the units, less ten, become the digit 0-9.
5751
LD (HL),B 70
Store Register B, the tens digit, at Register Pair HL.
5752
INC HL 23
Increment Register Pair HL to the place of the units digit.
5753
LD (HL),A 77
Store Register A, the units digit, at Register Pair HL.
5754
INC HL 23
Increment Register Pair HL past the two digits.
5755
RET C9
Return with Register Pair HL past the two digits and Register Pair DE at the next byte.
5756H - LINE INPUT
The vector 41A3H. LINE INPUT # goes to 5E7AH. Otherwise the optional prompt is shown (21CDH), the variable named must be a string (0AF4H), a line is taken from the keyboard by the ROM's 0361H and the whole of it, commas and quotation marks included, is made a string (2868H with the end byte 00H) and given to the variable by the ROM's LET (1F32H).
5756
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (5757H).
5757
DEFB 89H 89
The byte for the RST 08H at 5756H: 89H, the token INPUT, which must follow LINE; any other byte gives a Syntax error.
5758
CP 23H FE 23
Compare Register A, the character after INPUT, with 23H, the sign # of LINE INPUT # for a disk file.
575A
If the Z FLAG is set (LINE INPUT #), jump to 5E7AH, which takes the line from the file instead.
575D
Call 21CDH in the ROM, which shows the prompt in quotation marks at Register Pair HL when there is one.
5760
Call 260DH in the ROM, which finds the variable named at Register Pair HL: Register Pair DE is its address.
5763
Call 0AF4H in the ROM, which gives a Type mismatch error unless the variable just found (40AFH) is a string.
5766
PUSH DE D5
Save Register Pair DE, the address of the string variable, on the stack.
5767
PUSH HL E5
Save Register Pair HL, the text pointer after the variable's name, on the stack.
5768
Call 0361H in the ROM, the keyboard line input: Register Pair HL is the buffer less one, the C FLAG set for BREAK.
576B
POP DE D1
Restore Register Pair DE with the text pointer after the variable's name, saved at 5767H.
576C
POP BC C1
Restore Register Pair BC with the address of the string variable, saved at 5766H.
576D
If the C FLAG is set (BREAK was pressed), jump to 1DBEH in the ROM, which stops the program as STOP does.
5770
PUSH BC C5
Save Register Pair BC, the address of the variable, on the stack again for the ROM's LET at 1F32H.
5771
PUSH DE D5
Save Register Pair DE, the text pointer after the variable's name, on the stack for 5777H.
5772
LD B,00H 06 00
Load Register B with 00H, the end byte for 2868H: only the 00H at the end of the line ends the string.
5774
Call 2868H in the ROM, which makes a temporary string of the characters after Register Pair HL up to the byte of Register B.
5777
POP HL E1
Restore Register Pair HL with the text pointer after the variable's name, saved at 5771H.
5778
XOR A AF
Clear Register A to 00H for 1F32H, whose ADD A,03H makes it 03H, the type of a string.
5779
Jump to 1F32H in the ROM, the end of LET, which gives the string to the variable whose address is on the stack.
577CH - The End of a PRINT: Back to the Screen
The hook 41BEH, called from 2174H at the end of each PRINT and PRINT # with Register A 00H (2170H): the word at 5B2AH, the area of the file a PRINT # or INPUT # uses, is cleared, so that the next output goes to the screen again.
577C
PUSH HL E5
Save Register Pair HL, the text pointer of the ROM, on the stack while the word at 5B2AH is cleared.
577D
LD L,A 6F
Load Register L with Register A, 00H from the ROM's XOR A at 2170H.
577E
LD H,A 67
Load Register H with Register A, 00H, so that Register Pair HL is 0000H.
577F
LD (5B2AH),HL 22 2A 5B
Store Register Pair HL, 0000H, at 5B2AH: no file is in use for PRINT # or INPUT # any more.
5782
POP HL E1
Restore Register Pair HL, the text pointer of the ROM, from the stack.
5783
RET C9
Return to the ROM at 2177H, the end of the PRINT, with the word at 5B2AH cleared.
5784H - INPUT #: Choose the File
The hook 41D6H, called from 219EH at the start of INPUT with Register A the character at Register Pair HL. INPUT without # and INPUT #-1, the cassette, go back to the ROM. INPUT #n chooses the file (5DE8H) and enters the ROM's input of data at 21EBH, where the values are read as READ reads DATA; the characters come from the file through the hook 41AFH (598EH, 5996H).
5784
PUSH HL E5
Save Register Pair HL, the text pointer at the character after INPUT, on the stack.
5785
CP 23H FE 23
Compare Register A, the character after INPUT, with 23H, the sign #.
5787
If the NZ FLAG is set (no #), jump to 26E7H in the ROM, which restores Register Pair HL and returns to the ROM's INPUT.
578A
RST 10H D7
RST 10H: Register A is the next character after the # at Register Pair HL, spaces passed over.
578B
CP CEH FE CE
Compare Register A with CEH, the token of the minus sign, for INPUT #-1, the cassette.
578D
POP HL E1
Restore Register Pair HL with the text pointer at the character after INPUT, saved at 5784H.
578E
LD A,(HL) 7E
Load Register A with the character at Register Pair HL again, for the ROM's INPUT.
578F
RET Z C8
If the Z FLAG is set (INPUT #-1), return to the ROM's INPUT, which reads from the cassette.
5790
POP BC C1
Remove the return address 21A1H into Register Pair BC: the ROM's INPUT is not taken up again.
5791
Call 5DE8H, which takes the file number after the # at Register Pair HL and makes its area the one in use (5B2AH).
5794
PUSH HL E5
Save Register Pair HL, the text pointer at the first variable after the file number, on the stack.
5795
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the word at 40A7H, the address of the ROM's input buffer.
5798
DEC HL 2B
Decrement Register Pair HL to the byte before the input buffer, where 21EBH stores a comma.
5799
Jump to 21EBH in the ROM, which goes on with the variables as READ does, each value read from the file.
579CH - The End of an INPUT # or a LIST Line
The hook 41DFH, called from 2278H at the end of READ and INPUT and from 2B44H in LIST. With no file in use (5B2AH 0000H) nothing changes. With a file: an INPUT # ends at 2282H, without the ROM's EXTRA IGNORED test; a LIST to a file (SAVE with A, 604EH) goes on at 2B4AH, which passes over the ROM's BREAK test at 2B47H.
579C
PUSH HL E5
Save Register Pair HL, the text pointer of the ROM, on the stack.
579D
LD HL,(5B2AH) 2A 2A 5B
Load Register Pair HL with the word at 5B2AH, the area of the file in use, 0000H when there is none.
57A0
LD A,H 7C
Load Register A with Register H, the high byte of the word at 5B2AH.
57A1
OR L B5
OR Register L into Register A: the Z FLAG is set when the word at 5B2AH is 0000H, no file in use.
57A2
POP HL E1
Restore Register Pair HL, the text pointer of the ROM, from the stack.
57A3
RET Z C8
If the Z FLAG is set (no file in use), return to the ROM, which goes on as without a disk.
57A4
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: Register Pair HL is the return address into the ROM.
57A5
PUSH DE D5
Save Register Pair DE on the stack while Register Pair HL is compared.
57A6
LD DE,2B2EH 11 2E 2B
Load Register Pair DE with 2B2EH, the start of LIST in the ROM, to tell the two callers apart.
57A9
RST 18H DF
RST 18H: compare Register Pair HL, the return address, with Register Pair DE, 2B2EH; the C FLAG is set when it is lower.
57AA
POP DE D1
Restore Register Pair DE from the stack after the compare with 2B2EH.
57AB
POP HL E1
Restore Register Pair HL, the text pointer, from the stack; the return address is dropped.
57AC
If the NC FLAG is set (called from LIST at 2B44H), jump to 2B4AH in the ROM, the next line of the listing.
57AF
Jump to 2282H in the ROM, the end of INPUT, without the ?EXTRA IGNORED test of 227BH.
57B2H - LOAD: Read the Program into Memory
Entered from 553AH with Register Pair BC the size of the file, Register A the byte above it, Register Pair HL the room, Index Register IX the FCB and its first sector in the buffer (5FBBH). A file of 65536 bytes or more, or larger than the room, gives Out of memory (6005H). The bytes after the first (FFH, the mark of a BASIC program in memory form) are copied to the start of the program (40A4H), a sector being read each 256 bytes. DBLDOS's code: TRSDOS 2.1's BASIC/CMD has here (57B2H-57E9H) the routine that shows the long error messages, which DBLDOS moved to SYS7/SYS.
57B2
OR A B7
OR Register A with itself, the high byte of the file's size: the Z FLAG is set when the size is below 65536 bytes.
57B3
If the NZ FLAG is set (the file is too large), jump to 6005H, which clears the program and gives Out of memory.
57B6
SBC HL,BC ED 42
Subtract Register Pair BC, the size, from Register Pair HL, the room (the C FLAG is clear after OR A).
57B8
If the C FLAG is set (the program does not fit), jump to 6005H, which clears the program and gives Out of memory.
57BB
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL is the start of the program, the word at 40A4H.
57BC
LD A,C 79
Load Register A with Register C, the low byte of the size, which the count in Register C meets again each 256 bytes.
57BD
LD (57C7H),A 32 C7 57
Store Register A at 57C7H, the operand of the CP at 57C6H, the count at which the next sector is read.
57C0
Call 57DEH, which loads Register Pair DE with the address of the file's buffer (FCB+03H) through Index Register IX.
57C3
Jump to 57CEH, which passes over the first byte of the buffer, the FFH of the memory form.
57C5
LD A,C 79
Load Register A with Register C, the low byte of the count of the bytes still to be copied.
57C6
CP 00H FE 00
Compare Register A with the byte at 57C7H, stored by 57BDH: the Z FLAG is set when 256 more bytes have been copied.
57C8
If the Z FLAG is set (the buffer has been used up), call 57D5H, which reads the next sector into the buffer.
57CB
LD A,(DE) 1A
Load Register A with the byte of the file at Register Pair DE in the buffer.
57CC
LD (HL),A 77
Store Register A at Register Pair HL, the next byte of the program in memory.
57CD
INC HL 23
Increment Register Pair HL to the next byte of the program.
57CE
INC DE 13
Increment Register Pair DE to the next byte of the buffer.
57CF
DEC BC 0B
Decrement Register Pair BC, the count of the bytes still to be copied.
57D0
LD A,B 78
Load Register A with Register B, the high byte of the count in Register Pair BC.
57D1
OR C B1
OR Register C into Register A: the Z FLAG is set when the count in Register Pair BC is 0000H.
57D2
If the NZ FLAG is set (bytes are left), jump back to 57C5H for the next byte.
57D4
RET C9
Return to 5FD8H with Register Pair HL past the last byte of the program.
57D5H - Read the Next Sector
Called from 57C8H, and from LOAD at 5FBBH for the first sector, with Index Register IX the FCB. A disk error goes to 63FDH; else Register Pair DE is the buffer's address.
57D5
PUSH IX DD E5
Save Index Register IX, the FCB of the file, on the stack.
57D7
POP DE D1
Restore Register Pair DE with the FCB, the register 4436H takes it in.
57D8
Call 4436H, @READ of SYS0/SYS, which reads the next sector of the file of the FCB at Register Pair DE into its buffer.
57DB
If the NZ FLAG is set (a disk error, its code in Register A), jump to 63FDH, which keeps the code and gives the error.
57DE
LD E,(IX+03H) DD 5E 03
Load Register E with FCB+03H through Index Register IX, the low byte of the address of the file's buffer.
57E1
LD D,(IX+04H) DD 56 04
Load Register D with FCB+04H through Index Register IX, the high byte of the address of the file's buffer.
57E4
RET C9
Return with Register Pair DE the address of the file's buffer.
57E5H - SAVE: Write the Program in Memory Form
Entered from 606CH with Register Pair BC the length of the program plus one, Register Pair HL its start (40A4H), Register A the low byte of the length and Index Register IX the FCB of the new file. FFH and the program are put in the buffer, each full buffer written (57EFH); the offset of the last byte goes to FCB+05H and the last sector is written. The file is then set back to its start and read to its end, so that a disk error shows now. DBLDOS's code: TRSDOS 2.1 has the end of CMD"X" here and at 57F0H its text THIS BASIC WAS AUTHORED AND IS COPYRIGHTED BY MICROSOFT, 1978.
57E5
LD (57FAH),A 32 FA 57
Store Register A, the low byte of the length, at 57FAH, the operand of the CP at 57F9H, the count at which a sector is written.
57E8
Call 57DEH, which loads Register Pair DE with the address of the file's buffer (FCB+03H) through Index Register IX.
57EB
LD A,FFH 3E FF
Load Register A with FFH, the first byte of a program saved in memory form, which LOAD tests at 5FBFH.
57ED
Jump to 5800H, which stores Register A as the first byte of the buffer and counts it.
57EF
PUSH IX DD E5
Save Index Register IX, the FCB of the file, on the stack.
57F1
POP DE D1
Restore Register Pair DE with the FCB, the register 4439H takes it in.
57F2
Call 4439H, @WRITE of SYS0/SYS, which writes the buffer as the next sector of the file of the FCB at Register Pair DE.
57F5
Jump to 57DBH, which gives a disk error through 63FDH, or loads Register Pair DE with the buffer's address and returns.
57F8
LD A,C 79
Load Register A with Register C, the low byte of the count of the bytes still to be put in the buffer.
57F9
CP 00H FE 00
Compare Register A with the byte at 57FAH, stored by 57E5H: the Z FLAG is set when the buffer holds 256 bytes.
57FB
If the Z FLAG is set (the buffer is full), call 57EFH, which writes it and loads Register Pair DE with its address again.
57FE
LD A,(HL) 7E
Load Register A with the next byte of the program at Register Pair HL.
57FF
INC HL 23
Increment Register Pair HL to the next byte of the program.
5800
LD (DE),A 12
Store Register A at Register Pair DE, the next byte of the buffer.
5801
INC DE 13
Increment Register Pair DE to the next byte of the buffer.
5802
DEC BC 0B
Decrement Register Pair BC, the count of the bytes still to be put in the buffer.
5803
LD A,B 78
Load Register A with Register B, the high byte of the count in Register Pair BC.
5804
OR C B1
OR Register C into Register A: the Z FLAG is set when the count in Register Pair BC is 0000H.
5805
If the NZ FLAG is set (bytes are left), jump back to 57F8H for the next byte.
5807
LD A,E 7B
Load Register A with Register E, the low byte of the address after the last byte put in the buffer.
5808
SUB (IX+03H) DD 96 03
Subtract FCB+03H through Index Register IX, the low byte of the buffer's address, from Register A: the number of bytes in the last sector.
580B
LD (IX+05H),A DD 77 05
Store Register A at FCB+05H through Index Register IX, the offset in the sector, which @WRITE keeps as the end of the file.
580E
Call 57EFH, which writes the last sector of the file through 4439H.
5811
PUSH IX DD E5
Save Index Register IX, the FCB of the file, on the stack.
5813
POP DE D1
Restore Register Pair DE with the FCB, the register 443FH takes it in.
5814
Call 443FH, @REW of SYS0/SYS, which sets the file of the FCB at Register Pair DE back to its first sector.
5817
If the NZ FLAG is set (a disk error, its code in Register A), jump to 63FDH, which keeps the code and gives the error.
581A
Call 4436H, @READ of SYS0/SYS, which reads the next sector of the file of the FCB at Register Pair DE.
581D
If the Z FLAG is set (the sector was read), jump back to 581AH for the next one.
581F
CP 1CH FE 1C
Compare Register A, the error code, with 1CH, END OF FILE ENCOUNTERED: the whole file has been read.
5821
If the Z FLAG is set (error 1CH), jump to 5827H, the end of SAVE.
5823
CP 1DH FE 1D
Compare Register A, the error code, with 1DH, RECORD NUMBER OUT OF RANGE, the other end of the file.
5825
If the NZ FLAG is set (another error), jump to 5817H, which gives it through 63FDH.
5827
Jump to 5FFCH, which closes the file and ends SAVE at the ROM's READY.
582AH - Data Not Used
Five bytes left from TRSDOS 2.1's text, after DBLDOS's 57E5H-5829H.
582A-582E
DEFB 39H,37H,38H,0DH,00H 39 37 38 0D 00
The last five bytes of TRSDOS 2.1's text at 57F0H, 978 (the end of 1978), 0DH and 00H, left after DBLDOS's code; nothing reads them.
582FH - INSTR
The vector 419DH. INSTR([n,] string1, string2): the place of string2 in string1, searched from character n (1 when n is not given; n 0 is Illegal function call). The result is 0 when n is past the end of string1, when string1 is empty or when string2 is not found, and n when string2 is empty. The result goes back as an integer through 27F8H, and 26E7H restores the text pointer. TRSDOS 2.1's code.
582F
RST 10H D7
RST 10H: Register A is the next character after the token INSTR at Register Pair HL, spaces passed over.
5830
Call 2335H in the ROM, which checks the open parenthesis and evaluates the first expression into 4121H.
5833
RST 20H E7
RST 20H: test the type of the value in 4121H; the Z FLAG is set when it is a string (no start given).
5834
LD A,01H 3E 01
Load Register A with 01H, the place to start from when none is given.
5836
PUSH AF F5
Save Register Pair AF, the place to start from in Register A, on the stack.
5837
If the Z FLAG is set (the first value is string1), jump to 584AH for string2.
5839
POP AF F1
Remove the start 01H into Register Pair AF: a start was given.
583A
Call 2B1FH in the ROM, which makes the value in 4121H a byte 0-255 in Register A, the place to start from.
583D
OR A B7
OR Register A with itself, the place to start from: the Z FLAG is set when it is 0.
583E
If the Z FLAG is set (a start of 0), jump to 1E4AH in the ROM, Illegal function call.
5841
PUSH AF F5
Save Register Pair AF, the place to start from in Register A, on the stack.
5842
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (5843H).
5843
DEFB 2CH 2C
The byte for the RST 08H at 5842H: 2CH, the comma after the place to start from.
5844
Call 2337H in the ROM, which evaluates the expression at Register Pair HL, string1, into 4121H.
5847
Call 0AF4H in the ROM, which gives a Type mismatch error unless the value in 4121H is a string.
584A
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (584BH).
584B
DEFB 2CH 2C
The byte for the RST 08H at 584AH: 2CH, the comma between string1 and string2.
584C
PUSH HL E5
Save Register Pair HL, the text pointer at string2, on the stack.
584D
LD HL,(4121H) 2A 21 41
Load Register Pair HL with the word at 4121H, the address of the descriptor of string1.
5850
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: the descriptor of string1 is saved, Register Pair HL is the text.
5851
Call 2337H in the ROM, which evaluates the expression at Register Pair HL, string2, into 4121H.
5854
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (5855H).
5855
DEFB 29H 29
The byte for the RST 08H at 5854H: 29H, the close parenthesis that ends INSTR.
5856
PUSH HL E5
Save Register Pair HL, the text pointer after the close parenthesis, on the stack.
5857
Call 29D7H in the ROM, which checks that string2 is a string and frees it as a temporary: Register Pair HL is its descriptor.
585A
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE is the descriptor of string2.
585B
POP BC C1
Restore Register Pair BC with the text pointer after the close parenthesis, saved at 5856H.
585C
POP HL E1
Restore Register Pair HL with the descriptor of string1, saved at 5850H.
585D
POP AF F1
Restore Register Pair AF with the place to start from in Register A, saved at 5836H or 5841H.
585E
PUSH BC C5
Save Register Pair BC, the text pointer, on the stack for 26E7H.
585F
LD BC,26E7H 01 E7 26
Load Register Pair BC with 26E7H, the ROM's POP HL and RET, which restores the text pointer at the end.
5862
PUSH BC C5
Save Register Pair BC, 26E7H, on the stack as the second return address.
5863
LD BC,27F8H 01 F8 27
Load Register Pair BC with 27F8H, the ROM's code that makes Register A the integer result in 4121H.
5866
PUSH BC C5
Save Register Pair BC, 27F8H, on the stack: each RET below gives Register A as the result through it.
5867
PUSH AF F5
Save Register Pair AF, the place to start from, on the stack while string1 is freed.
5868
PUSH DE D5
Save Register Pair DE, the descriptor of string2, on the stack while string1 is freed.
5869
Call 29DDH in the ROM, which frees the descriptor at Register Pair HL, string1, as a temporary.
586C
POP DE D1
Restore Register Pair DE with the descriptor of string2, saved at 5868H.
586D
POP AF F1
Restore Register Pair AF with the place to start from in Register A, saved at 5867H.
586E
LD B,A 47
Load Register B with Register A, the place to start from (1 for the first character).
586F
DEC A 3D
Decrement Register A to the number of characters of string1 passed over before the search.
5870
LD C,A 4F
Load Register C with Register A, the number of characters passed over.
5871
CP (HL) BE
Compare Register A with the length of string1 at Register Pair HL: the NC FLAG is set when the start is past its end.
5872
LD A,00H 3E 00
Load Register A with 00H, the result when string2 is not found.
5874
RET NC D0
If the NC FLAG is set (the start is past the end of string1), return with the result 00H.
5875
LD A,(HL) 7E
Load Register A with the length of string1, the first byte of its descriptor at Register Pair HL.
5876
OR A B7
OR Register A with itself: the Z FLAG is set when string1 is empty (and Register A is the result 00H).
5877
RET Z C8
If the Z FLAG is set (string1 is empty), return with the result 00H.
5878
LD A,(DE) 1A
Load Register A with the length of string2, the first byte of its descriptor at Register Pair DE.
5879
OR A B7
OR Register A with itself: the Z FLAG is set when string2 is empty.
587A
LD A,B 78
Load Register A with Register B, the place to start from, the result when string2 is empty.
587B
RET Z C8
If the Z FLAG is set (string2 is empty), return with the place to start from as the result.
587C
LD A,(HL) 7E
Load Register A with the length of string1 at Register Pair HL.
587D
INC HL 23
Increment Register Pair HL to the address of the characters of string1 in its descriptor.
587E
LD B,(HL) 46
Load Register B with the low byte of the address of the characters of string1 at Register Pair HL.
587F
INC HL 23
Increment Register Pair HL to the high byte of the address of the characters.
5880
LD H,(HL) 66
Load Register H with the high byte of the address of the characters of string1 at Register Pair HL.
5881
LD L,B 68
Load Register L with Register B: Register Pair HL is the address of the first character of string1.
5882
LD B,00H 06 00
Load Register B with 00H, so that Register Pair BC is the number of characters passed over.
5884
ADD HL,BC 09
Add Register Pair BC to Register Pair HL: Register Pair HL is the first character of string1 searched.
5885
SUB C 91
Subtract Register C, the characters passed over, from Register A, the length: the characters left to search.
5886
LD B,A 47
Load Register B with Register A, the number of characters of string1 left to search.
5887
PUSH BC C5
Save Register Pair BC on the stack: Register B the characters left, Register C those passed over, for the result.
5888
PUSH DE D5
Save Register Pair DE, the descriptor of string2, on the stack.
5889
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: Register Pair HL is the descriptor of string2.
588A
LD C,(HL) 4E
Load Register C with the length of string2, the first byte of its descriptor at Register Pair HL.
588B
INC HL 23
Increment Register Pair HL to the address of the characters of string2 in its descriptor.
588C
LD E,(HL) 5E
Load Register E with the low byte of the address of the characters of string2 at Register Pair HL.
588D
INC HL 23
Increment Register Pair HL to the high byte of the address of the characters.
588E
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE is the address of the first character of string2.
588F
POP HL E1
Restore Register Pair HL with the first character of string1 to search, saved by 5889H.
5890
PUSH HL E5
Save Register Pair HL, the character of string1 at which this try starts, on the stack.
5891
PUSH DE D5
Save Register Pair DE, the first character of string2, on the stack.
5892
PUSH BC C5
Save Register Pair BC on the stack: Register B the characters of string1 left, Register C the length of string2.
5893
LD A,(DE) 1A
Load Register A with the next character of string2 at Register Pair DE.
5894
CP (HL) BE
Compare Register A with the character of string1 at Register Pair HL.
5895
If the NZ FLAG is set (the characters differ), jump to 58AEH to try one character further on.
5897
INC DE 13
Increment Register Pair DE to the next character of string2.
5898
DEC C 0D
Decrement Register C, the characters of string2 still to match.
5899
If the Z FLAG is set (all of string2 matched), jump to 58A5H, which works out the place.
589B
INC HL 23
Increment Register Pair HL to the next character of string1.
589C
DEC B 05
Decrement Register B, the characters of string1 left.
589D
If the NZ FLAG is set (string1 has characters left), jump back to 5893H to compare the next pair.
589F
POP DE D1
Remove the saved Register Pair BC of 5892H into Register Pair DE: string1 ended inside a partial match.
58A0
POP DE D1
Remove the saved Register Pair DE of 5891H into Register Pair DE.
58A1
POP BC C1
Remove the saved Register Pair HL of 5890H into Register Pair BC.
58A2
POP DE D1
Remove the word saved at 5887H into Register Pair DE, which leaves the return address 27F8H on top.
58A3
XOR A AF
Clear Register A to 00H, the result: string2 was not found.
58A4
RET C9
Return through 27F8H with the result 00H in Register A.
58A5
POP HL E1
Restore Register Pair HL with the word of 5892H: Register H the characters of string1 left when this try began.
58A6
POP DE D1
Remove the saved Register Pair DE of 5891H into Register Pair DE.
58A7
POP DE D1
Remove the saved Register Pair HL of 5890H into Register Pair DE.
58A8
POP BC C1
Restore Register Pair BC with the word of 5887H: Register B the characters left at the start, Register C those passed over.
58A9
LD A,B 78
Load Register A with Register B, the characters of string1 left at the start of the search.
58AA
SUB H 94
Subtract Register H from Register A, those left at the start of the try that matched: the characters tried before it.
58AB
ADD A,C 81
Add Register C, the characters passed over before the search, to Register A.
58AC
INC A 3C
Increment Register A: the place of string2 in string1, counted from 1.
58AD
RET C9
Return through 27F8H with the place in Register A as the result.
58AE
POP BC C1
Restore Register Pair BC with the word of 5892H: Register B the characters of string1 left, Register C the length.
58AF
POP DE D1
Restore Register Pair DE with the first character of string2, saved at 5891H.
58B0
POP HL E1
Restore Register Pair HL with the character of string1 where this try began, saved at 5890H.
58B1
INC HL 23
Increment Register Pair HL to the next character of string1, where the next try begins.
58B2
DEC B 05
Decrement Register B, the characters of string1 left.
58B3
If the Z FLAG is set (no characters left), jump to 58A2H: string2 was not found.
58B5
Jump back to 5890H for the next try, one character further on in string1.
58B7H - &H and &O Constants
The vector 4194H, entered with Register Pair HL at the sign &. &H takes up to four hexadecimal digits 0-9 and A-F (capitals only), a fifth gives Overflow; &O or & alone takes octal digits 0-7 until the number passes 65535 (Overflow); 8 or 9 is a Syntax error. The value goes to 4121H as an integer (0A9AH). TRSDOS 2.1's code.
58B7
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the value before the first digit.
58BA
RST 10H D7
RST 10H: Register A is the character after the sign & at Register Pair HL, spaces passed over.
58BB
CP 4FH FE 4F
Compare Register A with 4FH, the letter O, for an octal number.
58BD
If the Z FLAG is set (&O), jump to 58EBH, which takes octal digits.
58BF
CP 48H FE 48
Compare Register A with 48H, the letter H, for a hexadecimal number.
58C1
If the NZ FLAG is set (& then a digit), jump to 58EAH, which takes octal digits from this character.
58C3
LD B,05H 06 05
Load Register B with 05H: the fifth hexadecimal digit gives Overflow.
58C5
INC HL 23
Increment Register Pair HL to the next character of the number.
58C6
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
58C7
Call 1E3EH in the ROM, which tests Register A for a letter A-Z: the NC FLAG is set for a letter.
58CA
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL is the value, Register Pair DE the text pointer.
58CB
If the NC FLAG is set (a letter), jump to 58D7H, which takes A-F.
58CD
CP 3AH FE 3A
Compare Register A with 3AH, one more than the digit 9.
58CF
If the NC FLAG is set (not a digit), jump to 5908H, the end of the number.
58D1
SUB 30H D6 30
Subtract 30H, the digit 0, from Register A: the value of the digit.
58D3
If the C FLAG is set (a character below 0), jump to 5908H, the end of the number.
58D5
Jump to 58DDH, which puts the digit of Register A into the value.
58D7
CP 47H FE 47
Compare Register A with 47H, the letter G, one more than F.
58D9
If the NC FLAG is set (a letter after F), jump to 5908H, the end of the number.
58DB
SUB 37H D6 37
Subtract 37H from Register A: the letters A-F become 0AH-0FH.
58DD
ADD HL,HL 29
Add Register Pair HL to itself: the value times 2.
58DE
ADD HL,HL 29
Add Register Pair HL to itself: the value times 4.
58DF
ADD HL,HL 29
Add Register Pair HL to itself: the value times 8.
58E0
ADD HL,HL 29
Add Register Pair HL to itself: the value times 16, room for the new digit.
58E1
OR L B5
OR Register L into Register A, the new digit.
58E2
LD L,A 6F
Load Register L with Register A: the digit is in the low four bits of Register Pair HL.
58E3
DEC B 05
Decrement Register B, the count of the digits allowed.
58E4
If the Z FLAG is set (a fifth digit), jump to 07B2H in the ROM, Overflow.
58E7
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL is the text pointer, Register Pair DE the value.
58E8
Jump back to 58C5H for the next hexadecimal digit.
58EA
DEC HL 2B
Decrement Register Pair HL, so that the RST 10H at 58EBH takes the character after & again.
58EB
RST 10H D7
RST 10H: Register A is the next character at Register Pair HL; the C FLAG is set for a digit 0-9.
58EC
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL is the value, Register Pair DE the text pointer.
58ED
If the NC FLAG is set (not a digit), jump to 5908H, the end of the number.
58EF
CP 38H FE 38
Compare Register A, the digit, with 38H, the digit 8, the first that is not octal.
58F1
If the NC FLAG is set (the digit 8 or 9), jump to 1997H in the ROM, Syntax error.
58F4
LD BC,07B2H 01 B2 07
Load Register Pair BC with 07B2H, the ROM's Overflow.
58F7
PUSH BC C5
Save Register Pair BC, 07B2H, on the stack: a RET C below gives Overflow.
58F8
ADD HL,HL 29
Add Register Pair HL to itself: the value times 2.
58F9
RET C D8
If the C FLAG is set (the value passed 65535), return to 07B2H, Overflow.
58FA
ADD HL,HL 29
Add Register Pair HL to itself: the value times 4.
58FB
RET C D8
If the C FLAG is set (the value passed 65535), return to 07B2H, Overflow.
58FC
ADD HL,HL 29
Add Register Pair HL to itself: the value times 8, room for the new digit.
58FD
RET C D8
If the C FLAG is set (the value passed 65535), return to 07B2H, Overflow.
58FE
POP BC C1
Remove 07B2H from the stack into Register Pair BC.
58FF
LD B,00H 06 00
Load Register B with 00H, so that Register Pair BC is the digit when Register C is loaded.
5901
SUB 30H D6 30
Subtract 30H, the digit 0, from Register A: the value of the octal digit.
5903
LD C,A 4F
Load Register C with Register A: Register Pair BC is the digit.
5904
ADD HL,BC 09
Add Register Pair BC, the digit, to Register Pair HL, the value.
5905
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL is the text pointer, Register Pair DE the value.
5906
Jump back to 58EBH for the next octal digit with the value in Register Pair DE.
5908
Call 0A9AH in the ROM, which stores Register Pair HL, the value, at 4121H as an integer.
590B
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL is the text pointer after the number.
590C
RET C9
Return to the ROM with the constant in 4121H.
590DH - MID$ on the Left of =
The vector 41D9H, a JP at 2AECH. MID$(v$, n [, m]) = x$ puts the characters of x$ into v$ from character n, at most m of them (all when m is not given), never past the end of v$; the length of v$ does not change. A string of v$ that is still in the program text is first copied into the string space (2843H), so that the program is not changed. n of 0 or past the end of v$ is Illegal function call. TRSDOS 2.1's code.
590D
INC HL 23
Increment Register Pair HL past the token MID$ to the open parenthesis.
590E
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (590FH).
590F
DEFB 28H 28
The byte for the RST 08H at 590EH: 28H, the open parenthesis after MID$.
5910
Call 260DH in the ROM, which finds the variable named at Register Pair HL: Register Pair DE is its address.
5913
Call 0AF4H in the ROM, which gives a Type mismatch error unless the variable just found (40AFH) is a string.
5916
PUSH HL E5
Save Register Pair HL, the text pointer after the variable's name, on the stack.
5917
PUSH DE D5
Save Register Pair DE, the address of the variable, its descriptor, on the stack.
5918
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL is the descriptor of the variable.
5919
INC HL 23
Increment Register Pair HL to the address of the characters in the descriptor.
591A
LD E,(HL) 5E
Load Register E with the low byte of the address of the characters at Register Pair HL.
591B
INC HL 23
Increment Register Pair HL to the high byte of the address of the characters.
591C
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE is the address of the characters of the variable.
591D
LD HL,(40A0H) 2A A0 40
Load Register Pair HL with the word at 40A0H, the start of the string space.
5920
RST 18H DF
RST 18H: compare Register Pair HL, 40A0H's value, with Register Pair DE; the C FLAG is set when the string is in the string space.
5921
If the C FLAG is set (the string is in the string space), jump to 592DH.
5923
POP HL E1
Restore Register Pair HL with the descriptor of the variable, saved at 5917H.
5924
PUSH HL E5
Save Register Pair HL, the descriptor, on the stack again.
5925
Call 2843H in the ROM, which copies the string of the descriptor at Register Pair HL into the string space.
5928
POP HL E1
Restore Register Pair HL with the descriptor of the variable.
5929
PUSH HL E5
Save Register Pair HL, the descriptor, on the stack again.
592A
Call 09D3H in the ROM, which copies the new descriptor at Register Pair DE to the variable at Register Pair HL.
592D
POP HL E1
Restore Register Pair HL with the descriptor of the variable, saved at 5917H or 5929H.
592E
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: the descriptor is saved, Register Pair HL is the text pointer.
592F
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (5930H).
5930
DEFB 2CH 2C
The byte for the RST 08H at 592FH: 2CH, the comma after the variable's name.
5931
Call 2B1CH in the ROM, which evaluates the expression at Register Pair HL as a byte in Register A, the place n.
5934
OR A B7
OR Register A with itself, the place n: the Z FLAG is set when it is 0.
5935
If the Z FLAG is set (a place of 0), jump to 1E4AH in the ROM, Illegal function call.
5938
PUSH AF F5
Save Register Pair AF, the place n in Register A, on the stack.
5939
LD A,(HL) 7E
Load Register A with the character at Register Pair HL, a comma or the close parenthesis, for 5980H.
593A
Call 5980H, which takes the optional count m into Register E (FFH when none is given) and the close parenthesis.
593D
PUSH DE D5
Save Register Pair DE, the count m in Register E, on the stack.
593E
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (593FH).
593F
DEFB D5H D5
The byte for the RST 08H at 593EH: D5H, the token of the equals sign.
5940
Call 2337H in the ROM, which evaluates the expression at Register Pair HL, the new characters x$, into 4121H.
5943
PUSH HL E5
Save Register Pair HL, the text pointer after the expression, on the stack.
5944
Call 29D7H in the ROM, which checks that x$ is a string and frees it as a temporary: Register Pair HL is its descriptor.
5947
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE is the descriptor of x$.
5948
POP HL E1
Restore Register Pair HL with the text pointer after the expression, saved at 5943H.
5949
POP BC C1
Restore Register Pair BC with the count m in Register C, saved at 593DH.
594A
POP AF F1
Restore Register Pair AF with the place n in Register A, saved at 5938H.
594B
LD B,A 47
Load Register B with Register A, the place n.
594C
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: Register Pair HL is the descriptor of the variable.
594D
PUSH HL E5
Save Register Pair HL, the descriptor of the variable, on the stack.
594E
LD HL,26E7H 21 E7 26
Load Register Pair HL with 26E7H, the ROM's POP HL and RET.
5951
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: 26E7H is the return address, which restores the text pointer.
5952
LD A,C 79
Load Register A with Register C, the count m.
5953
OR A B7
OR Register A with itself: the Z FLAG is set when the count m is 0.
5954
RET Z C8
If the Z FLAG is set (a count of 0), return through 26E7H: nothing is changed.
5955
LD A,(HL) 7E
Load Register A with the length of the variable's string at Register Pair HL.
5956
SUB B 90
Subtract Register B, the place n, from Register A.
5957
If the C FLAG is set (the place n is past the end of the string), jump to 1E4AH in the ROM, Illegal function call.
595A
INC A 3C
Increment Register A: the number of characters from the place n to the end of the string.
595B
CP C B9
Compare Register A with Register C, the count m: the C FLAG is set when fewer characters are left.
595C
If the C FLAG is set (fewer characters left than m), jump to 595FH with that smaller number in Register A.
595E
LD A,C 79
Load Register A with Register C, the count m, the number of characters to replace.
595F
LD C,B 48
Load Register C with Register B, the place n.
5960
DEC C 0D
Decrement Register C: the number of characters before the place n.
5961
LD B,00H 06 00
Load Register B with 00H, so that Register Pair BC is the number of characters before the place n.
5963
PUSH DE D5
Save Register Pair DE, the descriptor of x$, on the stack.
5964
INC HL 23
Increment Register Pair HL to the address of the characters in the descriptor of the variable.
5965
LD E,(HL) 5E
Load Register E with the low byte of the address of the characters at Register Pair HL.
5966
INC HL 23
Increment Register Pair HL to the high byte of the address of the characters.
5967
LD H,(HL) 66
Load Register H with the high byte of the address of the characters at Register Pair HL.
5968
LD L,E 6B
Load Register L with Register E: Register Pair HL is the address of the characters of the variable.
5969
ADD HL,BC 09
Add Register Pair BC to Register Pair HL: Register Pair HL is the character at the place n.
596A
LD B,A 47
Load Register B with Register A, the number of characters that may be replaced.
596B
POP DE D1
Restore Register Pair DE with the descriptor of x$, saved at 5963H.
596C
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL is the descriptor of x$, Register Pair DE the place.
596D
LD C,(HL) 4E
Load Register C with the length of x$, the first byte of its descriptor at Register Pair HL.
596E
INC HL 23
Increment Register Pair HL to the address of the characters of x$.
596F
LD A,(HL) 7E
Load Register A with the low byte of the address of the characters of x$ at Register Pair HL.
5970
INC HL 23
Increment Register Pair HL to the high byte of the address of the characters.
5971
LD H,(HL) 66
Load Register H with the high byte of the address of the characters of x$ at Register Pair HL.
5972
LD L,A 6F
Load Register L with Register A: Register Pair HL is the address of the characters of x$.
5973
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE is x$, Register Pair HL the place in the variable.
5974
LD A,C 79
Load Register A with Register C, the length of x$.
5975
OR A B7
OR Register A with itself: the Z FLAG is set when x$ is empty.
5976
RET Z C8
If the Z FLAG is set (x$ is empty), return through 26E7H: nothing is changed.
5977
LD A,(DE) 1A
Load Register A with the next character of x$ at Register Pair DE.
5978
LD (HL),A 77
Store Register A at Register Pair HL, in the string of the variable.
5979
INC DE 13
Increment Register Pair DE to the next character of x$.
597A
INC HL 23
Increment Register Pair HL to the next character of the variable.
597B
DEC C 0D
Decrement Register C, the characters of x$ left.
597C
RET Z C8
If the Z FLAG is set (all of x$ is used), return through 26E7H.
597D
Decrement Register B, the characters that may still be replaced, and jump back to 5977H while it is not zero.
597F
RET C9
Return through 26E7H when the characters that may be replaced are used up.
5980H - MID$: The Optional Count
Called from 593AH with Register A the character at Register Pair HL. Register E is FFH when the close parenthesis follows, else the byte after the comma; the close parenthesis is checked in both cases.
5980
LD E,FFH 1E FF
Load Register E with FFH, the count when none is given: as many characters as there are.
5982
CP 29H FE 29
Compare Register A with 29H, the close parenthesis.
5984
If the Z FLAG is set (no count), jump to 598BH, which checks the close parenthesis.
5986
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (5987H).
5987
DEFB 2CH 2C
The byte for the RST 08H at 5986H: 2CH, the comma before the count.
5988
Call 2B1CH in the ROM, which evaluates the expression at Register Pair HL as a byte in Register E and Register A, the count.
598B
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (598CH).
598C
DEFB 29H 29
The byte for the RST 08H at 598BH: 29H, the close parenthesis before the equals sign.
598D
RET C9
Return to 593DH with the count in Register E.
598EH - The Keyboard Line Input Exit
The DOS exit 41AFH, called at 0368H by the ROM's keyboard line input. The word at 5B2AH, the area of the file in use, is loaded and the work goes on in DBLDOS's code at 5238H (TRSDOS 2.1 has OR L, POP HL and RET Z here, at 5993H-5995H).
598E
PUSH HL E5
Save Register Pair HL, the buffer pointer of the ROM's line input, on the stack for 5239H.
598F
LD HL,(5B2AH) 2A 2A 5B
Load Register Pair HL with the word at 5B2AH, the area of the file in use, 0000H when there is none.
5992
LD A,H 7C
Load Register A with Register H, the high byte of the word at 5B2AH, which 5238H ORs with Register L.
5993
Jump to 5238H, DBLDOS's line input; TRSDOS 2.1 has OR L, POP HL and RET Z at 5993H-5995H.
5996H - A Line from the File
Reached from 523AH when a file is in use (an INPUT # or LINE INPUT # line, or a program loaded in ASCII form). The characters are taken by the ROM's 0384H, whose keyboard scan the hook 41C4H (59CDH) turns into a byte from the file, into the ROM's input buffer (40A7H) up to 0DH or 240 characters; a line feed before the first character is passed over. The line ends with 00H, and the ROM goes on with Register Pair HL the buffer less one, as after a keyboard line.
5996
POP AF F1
Remove the return address 036BH of the call at 0368H into Register Pair AF: the RET at 59BDH returns to the caller of 0361H.
5997
PUSH BC C5
Save Register Pair BC on the stack while Register B counts the characters.
5998
LD B,F0H 06 F0
Load Register B with F0H, the most characters a line may have, 240.
599A
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the word at 40A7H, the address of the ROM's input buffer.
599D
Call 0384H in the ROM, which waits for a character through 0358H: from the file, through 41C4H (59CDH).
59A0
LD (HL),A 77
Store Register A, the character, at Register Pair HL in the input buffer.
59A1
CP 0DH FE 0D
Compare Register A with 0DH, the carriage return that ends a line.
59A3
If the Z FLAG is set (the end of the line), jump to 59B6H.
59A6
CP 0AH FE 0A
Compare Register A, the character from the file, with 0AH, a line feed.
59A8
If the NZ FLAG is set (another character), jump to 59B1H, which keeps it.
59AB
LD A,B 78
Load Register A with Register B, the count of the characters still allowed.
59AC
CP F0H FE F0
Compare Register A with F0H: the Z FLAG is set when no character has been kept yet.
59AE
If the Z FLAG is set (a line feed at the start of the line), jump back to 599DH and leave it out.
59B1
INC HL 23
Increment Register Pair HL to the next place in the input buffer.
59B2
DEC B 05
Decrement Register B, the count of the characters still allowed.
59B3
If the NZ FLAG is set (room is left), jump back to 599DH for the next character.
59B6
XOR A AF
Clear Register A to 00H, the end mark of a line in the buffer; the Z FLAG and NC FLAG are set (no BREAK).
59B7
LD (HL),A 77
Store Register A, 00H, at Register Pair HL in place of the carriage return.
59B8
POP BC C1
Restore Register Pair BC from the stack, saved at 5997H.
59B9
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the word at 40A7H, the address of the ROM's input buffer.
59BC
DEC HL 2B
Decrement Register Pair HL to the byte before the buffer, as the ROM's line input returns it.
59BD
RET C9
Return to the caller of 0361H with the line in the buffer.
59BEH - Output of a Character
The hook 41C1H, called at 032CH by the ROM's output of the character in Register C. With no file in use the ROM goes on; with a file the character is written to it (624FH) and the ROM's output is passed over.
59BE
PUSH HL E5
Save Register Pair HL on the stack while the word at 5B2AH is tested.
59BF
LD HL,(5B2AH) 2A 2A 5B
Load Register Pair HL with the word at 5B2AH, the area of the file in use, 0000H when there is none.
59C2
LD A,H 7C
Load Register A with Register H, the high byte of the word at 5B2AH.
59C3
OR L B5
OR Register L into Register A: the Z FLAG is set when no file is in use.
59C4
POP HL E1
Restore Register Pair HL from the stack, saved at 59BEH.
59C5
LD A,C 79
Load Register A with Register C, the character to be sent, as the ROM had it.
59C6
RET Z C8
If the Z FLAG is set (no file in use), return to the ROM at 032FH, which sends the character to the device.
59C7
POP AF F1
Remove the return address 032FH into Register Pair AF: the ROM's output is passed over.
59C8
LD A,C 79
Load Register A with Register C, the character to be written to the file.
59C9
POP BC C1
Restore Register Pair BC, saved by the ROM at 032AH.
59CA
Jump to 624FH, which writes the character of Register A to the file and returns to the caller of 032AH.
59CDH - The Keyboard Scan Hook
The hook 41C4H, called at 0358H, the ROM's keyboard scan used by INKEY$, the BREAK test and 0384H. Only when the caller is 0384H (the line input of 5996H) and a file is in use is a byte taken from the file (62E5H); at the end of the file all files are closed (5FFCH), and the program is run (LOAD with R, 5B4EH) or READY is shown and the line ended with 0DH. Any other caller stores Register A at 40A9H, the cassette input flag, and scans the keyboard (035BH). TRSDOS 2.1's code.
59CD
INC SP 33
Increment the Stack Pointer: the return address 035BH of the call at 0358H is being dropped.
59CE
INC SP 33
Increment the Stack Pointer again: the return address 035BH is dropped.
59CF
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: Register Pair HL is the return address of the caller of 0358H.
59D0
PUSH DE D5
Save Register Pair DE on the stack while the return address is compared.
59D1
LD DE,0387H 11 87 03
Load Register Pair DE with 0387H, the return address of the call at 0384H in the ROM.
59D4
RST 18H DF
RST 18H: compare Register Pair HL, the return address, with Register Pair DE, 0387H; the Z FLAG is set when they are equal.
59D5
POP DE D1
Restore Register Pair DE from the stack after the compare with 0387H.
59D6
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: the return address is back, Register Pair HL restored.
59D7
If the NZ FLAG is set (another caller), jump to 5A0EH, which scans the keyboard.
59DA
PUSH HL E5
Save Register Pair HL on the stack while the word at 5B2AH is tested.
59DB
LD HL,(5B2AH) 2A 2A 5B
Load Register Pair HL with the word at 5B2AH, the area of the file in use, 0000H when there is none.
59DE
LD A,H 7C
Load Register A with Register H, the high byte of the word at 5B2AH.
59DF
OR L B5
OR Register L into Register A: the Z FLAG is set when no file is in use.
59E0
POP HL E1
Restore Register Pair HL from the stack, saved at 59DAH.
59E1
If the Z FLAG is set (no file in use), jump to 035BH in the ROM, the keyboard scan.
59E4
PUSH HL E5
Save Register Pair HL on the stack, for 26E7H or 5A0CH.
59E5
Call 62E5H, which reads the next byte of the file in use into Register A; the C FLAG is set at its end.
59E8
If the NC FLAG is set (a byte was read), jump to 26E7H in the ROM, which restores Register Pair HL and returns it to 0387H.
59EB
PUSH BC C5
Save Register Pair BC on the stack while the files are closed.
59EC
PUSH DE D5
Save Register Pair DE on the stack while the files are closed.
59ED
PUSH HL E5
Save Register Pair HL on the stack while the files are closed.
59EE
Call 5FFCH, which closes all files at the end of the file.
59F1
POP HL E1
Restore Register Pair HL from the stack, saved at 59EDH.
59F2
POP DE D1
Restore Register Pair DE from the stack, saved at 59ECH.
59F3
POP BC C1
Restore Register Pair BC from the stack, saved at 59EBH.
59F4
LD A,(5B4EH) 3A 4E 5B
Load Register A with the byte at 5B4EH, not 00H when the program is to be run after it is loaded (LOAD with R).
59F7
OR A B7
OR Register A with itself: the Z FLAG is set when the program is not to be run.
59F8
LD HL,1D1EH 21 1E 1D
Load Register Pair HL with 1D1EH, the ROM's NEWSTT, the return address for RUN.
59FB
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: 1D1EH is saved, Register Pair HL restored.
59FC
If the NZ FLAG is set (LOAD with R), jump to 1B5DH in the ROM, RUN, which returns to 1D1EH.
59FF
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: Register Pair HL is restored, 1D1EH dropped later.
5A00
PUSH BC C5
Save Register Pair BC on the stack while READY is shown.
5A01
PUSH DE D5
Save Register Pair DE on the stack while READY is shown.
5A02
LD HL,1929H 21 29 19
Load Register Pair HL with 1929H, the ROM's text READY and 0DH.
5A05
Call 28A7H in the ROM, which shows the text at Register Pair HL.
5A08
POP DE D1
Restore Register Pair DE from the stack, saved at 5A01H.
5A09
POP BC C1
Restore Register Pair BC from the stack, saved at 5A00H.
5A0A
LD A,0DH 3E 0D
Load Register A with 0DH, the carriage return, given back as the character that ends the line.
5A0C
POP HL E1
Restore Register Pair HL, saved at 59FFH with the exchange.
5A0D
RET C9
Return to 0387H with the carriage return in Register A.
5A0E
LD (40A9H),A 32 A9 40
Store Register A, as the caller left it, at 40A9H, the ROM's cassette input flag (the same in TRSDOS 2.1).
5A11
Jump to 035BH in the ROM, the keyboard scan, for every caller other than 0384H.
5A14
DEFB 00H 00
A byte 00H whose address 5B83H and 5F9CH store at 5B2CH: the file table entry with no file before the program's own.
5A15H - PRINT #: Choose the File
The DOS exit 41CAH, called at 206FH by PRINT with Register A the character at Register Pair HL. PRINT #-1, the cassette, goes back to the ROM; PRINT #n chooses the file, which must be open for output (mode 02H, 5DEAH). TRSDOS 2.1 has the same code at 5A5BH, and its vector 41CAH points there; DBLDOS moved it to 5A15H, where TRSDOS 2.1 has zeros.
5A15
PUSH HL E5
Save Register Pair HL, the text pointer of the ROM, on the stack.
5A16
RST 10H D7
RST 10H: Register A is the next character after Register Pair HL, the one after the sign #.
5A17
CP CEH FE CE
Compare Register A with CEH, the token of the minus sign, for PRINT #-1, the cassette.
5A19
POP HL E1
Restore Register Pair HL, the text pointer, from the stack.
5A1A
LD A,(HL) 7E
Load Register A with the character at Register Pair HL again, for the ROM.
5A1B
RET Z C8
If the Z FLAG is set (PRINT #-1), return to the ROM, which writes to the cassette.
5A1C
LD C,02H 0E 02
Load Register C with 02H, the mode the file must be open in: output.
5A1E
Jump to 5DEAH, which chooses the file after the # when there is one and checks its mode.
5A21H - Unused Space
243 bytes that nothing reads or runs: zeros, with at 5A5BH-5A66H the PRINT # code of TRSDOS 2.1 left where TRSDOS 2.1 has it. DBLDOS's vector 41CAH points to its copy at 5A15H, so these twelve bytes are never run. TRSDOS 2.1's BASIC/CMD has the same 243 bytes here.
5A21-5A5A
DEFB 00H x 58 00 x 58
Fifty-eight bytes 00H at 5A21H-5A5AH that no instruction reads or runs; TRSDOS 2.1 has the same zeros here.
5A5B
PUSH HL E5
Save Register Pair HL on the stack (never run: the vector 41CAH is JP 5A15H, which holds the same code).
5A5C
RST 10H D7
RST 10H: Register A is the next character after Register Pair HL (never run: TRSDOS 2.1's copy of 5A16H).
5A5D
CP CEH FE CE
Compare Register A with CEH, the token of the minus sign, for PRINT #-1 (never run: the copy at 5A17H is used).
5A5F
POP HL E1
Restore Register Pair HL from the stack (never run: no instruction of any DoubleDOS file reaches 5A5BH).
5A60
LD A,(HL) 7E
Load Register A with the character at Register Pair HL (never run: the copy at 5A1AH is used instead).
5A61
RET Z C8
If the Z FLAG is set, return (never run: TRSDOS 2.1's vector 41CAH is JP 5A5BH, DBLDOS's is JP 5A15H).
5A62
LD C,02H 0E 02
Load Register C with 02H, the output mode (never run: the copy at 5A1CH is used instead of this one).
5A64
Jump to 5DEAH, which chooses the file (never run: TRSDOS 2.1's code left in place by DBLDOS at 5A5BH-5A66H).
5A67-5B13
DEFB 00H x 173 00 x 173
173 bytes 00H at 5A67H-5B13H that no instruction reads or runs; TRSDOS 2.1 has the same zeros here.
5B14H - The Variables of Disk BASIC
The USR addresses, the GET/PUT switch, the last disk error, the file in use, the table of the file areas and the LOAD switches. The start-up (5C5BH-5C83H) fills the table: file 0, the area of LOAD, SAVE, RUN and MERGE, is at 6431H, then one area of 290 bytes (0122H) for each of the files (BASIC F, 3 when none is given); the program text starts after them. The bytes are as in the file.
5B14-5B27
DEFW 1E4AH,1E4AH,1E4AH,1E4AH,1E4AH,1E4AH,1E4AH,1E4AH,1E4AH,1E4AH 4A 1E 4A 1E 4A 1E 4A 1E 4A 1E 4A 1E 4A 1E 4A 1E 4A 1E 4A 1E
The ten USR addresses for USR0-USR9, set by DEFUSR (56ABH) and taken by 5699H; each is 1E4AH, the ROM's Illegal function call, until it is set.
5B28
DEFB 00H 00
The GET or PUT switch: 00H for GET (627CH), AFH for PUT (627BH), stored by 627DH and tested by 62B9H and 62C8H.
5B29
DEFB 00H 00
The code of the last disk error, stored by 6405H when a disk error is given and shown again by CMD"E" (570AH).
5B2A-5B2B
DEFW 0000H 00 00
The area of the file in use for PRINT #, INPUT #, a LIST to a file or a LOAD in ASCII form; 0000H for none (the screen and the keyboard).
5B2C-5B4B
DEFW 0000H x 16 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
The table of the file areas, one word for each file number 0-15 (5E18H): 5C6BH-5C6DH store the areas at start-up; file 0 is set to 5A14H while a line is stored (5B88H) and back from 5B4CH (5B95H).
5B4C-5B4D
DEFW 0000H 00 00
The area of file 0, 6431H after the start-up (5C67H), which 5B92H and LOAD (5FADH) put back in the table at 5B2CH.
5B4E
DEFB 00H 00
The switch of LOAD with R: not 00H when the program is run after it is loaded (5F99H), tested by 59F4H and 5FF2H.
5B4F
DEFB 00H 00
The number of files kept by LOAD (5F83H, 5FE4H) while the byte at 5B50H is changed, and put back from here (5FA7H, 5FECH).
5B50
DEFB 00H 00
The highest file number that may be used, the F of BASIC F (5C5DH); 5E0EH gives an error for a higher one.
5B51H - The SYSTEM Command Hook
The hook 41E2H, called from 02B2H before SYSTEM asks for a tape file name: nothing is done.
5B51
RET C9
Return to the ROM at once: SYSTEM goes on as without a disk (the same in TRSDOS 2.1).
5B52H - Back to the DOS
Entered from CMD"S" (56E9H) and CMD"A" (56EFH, the C FLAG set), and from 5CEEH at start-up when the memory size is not memory. The target of RST 28H for a code with bit 7 clear is put back (5BA8H, saved by 5C29H) and the BREAK flag 4315H set to C3H again; then 402DH, or 4030H for CMD"A".
5B52
PUSH AF F5
Save Register Pair AF on the stack: the C FLAG tells CMD"A" from CMD"S".
5B53
LD HL,(5BA8H) 2A A8 5B
Load Register Pair HL with the word at 5BA8H, the old target of the JP at 4312H, saved at start-up; TRSDOS 2.1 has LD HL,(5C8FH) here.
5B56
LD (4313H),HL 22 13 43
Store Register Pair HL at 4313H, the operand of the JP at 4312H of SYS0/SYS, as it was before BASIC.
5B59
LD A,C3H 3E C3
Load Register A with C3H, the value of the BREAK flag that the start-up cleared at 5C33H.
5B5B
LD (4315H),A 32 15 43
Store Register A, C3H, at 4315H, the BREAK flag of SYS0/SYS, as TRSDOS 2.1 does; the dispatcher clears it again (4BF5H) when DOS READY calls SYS1/SYS.
5B5E
POP AF F1
Restore Register Pair AF from the stack, the C FLAG of CMD"A".
5B5F
If the C FLAG is set (CMD"A"), jump to 4030H, the DOS's exit after an error.
5B62
Jump to 402DH, the DOS's normal exit to DOS READY.
5B65H - Comma and TAB to a File
The DOS exit 41D3H, called from 2108H (the comma of PRINT) and 2141H (TAB). With a file in use the position in its line is the second byte of the file's area, and the ROM's code goes on at 2130H (comma) or 2156H (TAB) with it in Register A, instead of the position on the screen or printer.
5B65
LD HL,(5B2AH) 2A 2A 5B
Load Register Pair HL with the word at 5B2AH, the area of the file in use, 0000H when there is none.
5B68
LD A,H 7C
Load Register A with Register H, the high byte of the word at 5B2AH.
5B69
OR L B5
OR Register L into Register A: the Z FLAG is set when no file is in use.
5B6A
RET Z C8
If the Z FLAG is set (no file in use), return to the ROM, which uses the position on the screen or printer.
5B6B
INC HL 23
Increment Register Pair HL to the second byte of the file's area, the position in the line written to the file.
5B6C
LD A,(HL) 7E
Load Register A with the position in the line at Register Pair HL.
5B6D
POP HL E1
Remove the return address into Register Pair HL: 210BH from the comma, 2144H from TAB.
5B6E
PUSH DE D5
Save Register Pair DE on the stack while the return address is compared.
5B6F
PUSH AF F5
Save Register Pair AF, the position in Register A, on the stack.
5B70
LD DE,2130H 11 30 21
Load Register Pair DE with 2130H, the address between the two callers.
5B73
RST 18H DF
RST 18H: compare Register Pair HL, the return address, with Register Pair DE, 2130H; the C FLAG is set when it is lower.
5B74
POP DE D1
Restore Register Pair DE with the saved Register Pair AF: Register D is the position in the line.
5B75
LD A,D 7A
Load Register A with Register D, the position in the line of the file.
5B76
POP DE D1
Restore Register Pair DE from the stack, saved at 5B6EH.
5B77
If the C FLAG is set (the comma, called from 2108H), jump to 2130H, the ROM's tab to the next 16 columns.
5B7A
Jump to 2156H, the ROM's TAB, with Register A the position in the line of the file.
5B7DH - A Line Is Stored: Keep the File
The DOS exit 41B5H, called from 1AECH after a program line has been put in the program, before the ROM's 1B5DH clears the variables. 1B5DH also closes the files through 41BBH (60A1H, from 1B8CH). The file in use is kept at 40F3H, and file 0 is marked closed by the table entry 5A14H (a byte 00H), so that 60A1H passes over it; 41B8H (5B8CH) puts both back. So a program loaded in ASCII form (file 0, a line at a time) goes on being read, while files 1 to F are closed when a line is stored.
5B7D
LD HL,(5B2AH) 2A 2A 5B
Load Register Pair HL with the word at 5B2AH, the area of the file in use, 0000H when there is none.
5B80
LD (40F3H),HL 22 F3 40
Store Register Pair HL at 40F3H, a word of the ROM's work space, until 5B8CH takes it back.
5B83
LD HL,5A14H 21 14 5A
Load Register Pair HL with 5A14H, a byte that stands for a file area that is not open.
5B86
LD (HL),00H 36 00
Store 00H at Register Pair HL, 5A14H: the mode of the stand in area is closed.
5B88
LD (5B2CH),HL 22 2C 5B
Store Register Pair HL, 5A14H, at 5B2CH, the table entry of file 0.
5B8B
RET C9
Return to the ROM at 1AEFH, which calls 1B5DH.
5B8CH - After a Line Is Stored: Put the File Back
The DOS exit 41B8H, called from 1AF2H after 1B5DH: the file in use (from 40F3H) and the area of file 0 (5B4CH) are put back.
5B8C
LD HL,(40F3H) 2A F3 40
Load Register Pair HL with the word at 40F3H, the file in use kept by 5B80H.
5B8F
LD (5B2AH),HL 22 2A 5B
Store Register Pair HL at 5B2AH: the same file is in use again.
5B92
LD HL,(5B4CH) 2A 4C 5B
Load Register Pair HL with the word at 5B4CH, the area of file 0.
5B95
LD (5B2CH),HL 22 2C 5B
Store Register Pair HL at 5B2CH, the table entry of file 0, in place of 5A14H.
5B98
RET C9
Return to the ROM at 1AF5H, which takes the next line.
5B99H - After PRINT's Carriage Return
The DOS exit 41D0H, called from 2103H: nothing is done.
5B99
RET C9
Return to the ROM at once from the exit 41D0H (the same in TRSDOS 2.1).
5B9AH - A Number to a File
The DOS exit 41CDH, called from 20C6H after PRINT has made a number ASCII. With a file in use the ROM's test of the room left on the line (20C9H-20E6H) is passed over and the text is sent at once (20E9H).
5B9A
LD HL,(5B2AH) 2A 2A 5B
Load Register Pair HL with the word at 5B2AH, the area of the file in use, 0000H when there is none.
5B9D
LD A,H 7C
Load Register A with Register H, the high byte of the word at 5B2AH.
5B9E
OR L B5
OR Register L into Register A: the Z FLAG is set when no file is in use.
5B9F
RET Z C8
If the Z FLAG is set (no file in use), return to the ROM at 20C9H, which tests the room on the line.
5BA0
POP HL E1
Remove the return address 20C9H into Register Pair HL: the ROM's test is passed over.
5BA1
Jump to 20E9H in the ROM, which sends the number's text to the file through 28AAH.
5BA4H - The BREAK Key in BASIC
The target of the JP at 4312H of SYS0/SYS while BASIC runs (5C2CH-5C2FH): the dispatcher of RST 28H (4BA2H) jumps there for a request code with bit 7 clear. The ROM's keyboard driver does LD A,01H then RST 28H at 0456H when BREAK is pressed; the DOS's own target 4BA0H clears Register A, so the key is lost. Here code 01H returns at once with Register A still 01H, so BASIC sees BREAK; any other code goes to the old target, whose address 5C29H stores at 5BA8H.
5BA4
CP 01H FE 01
Compare Register A, the request code, with 01H, the code of the BREAK key from the ROM's 0456H.
5BA6
RET Z C8
If the Z FLAG is set (the BREAK key), return with Register A still 01H, the key.
5BA7
Jump to the old target of the JP at 4312H (0000H in the file); the operand 5BA8H is stored by 5C29H (4BA0H) and read by 5B53H and 544AH.
5BAA-5BAC
DEFB 3AH,00H,2CH 3A 00 2C
Three bytes after the jump at 5BA7H that no instruction reads or runs (3AH, 00H, 2CH).
5BADH - The Start-up: BASIC F, M, Command and the asterisk form of BASIC
The transfer address of BASIC/CMD, entered from SYS1/SYS's @RUN (4433H) with Register Pair HL past the name BASIC on the command line. The numbers after BASIC are F (below 256: the highest file number, 0-15; 16 or more goes back to the DOS) and M (256 or more: the memory size, the top being M less 1), in either order, separated by commas; the first item that is not a number is a command for BASIC (5D02H). the asterisk form of BASIC keeps the program in memory (5BBAH). The bytes of the start-up are DBLDOS's: TRSDOS 2.1's start-up at 5BA4H is other code.
5BAD
XOR A AF
Clear Register A to 00H for the overlay request code.
5BAE
LD (430EH),A 32 0E 43
Store Register A, 00H, at 430EH, the overlay request code of SYS0/SYS: no overlay is taken as being in memory.
5BB1
DEC HL 2B
Decrement Register Pair HL so that the RST 10H at 5BB2H takes the character that ended the name BASIC again.
5BB2
RST 10H D7
RST 10H: Register A is the next character after Register Pair HL, spaces passed over; the C FLAG is set for a digit.
5BB3
If the C FLAG is set (a digit), jump to 5BFEH, which takes the numbers F and M.
5BB6
CP 2AH FE 2A
Compare Register A with 2AH, the asterisk after BASIC that keeps the program.
5BB8
If the NZ FLAG is set (no asterisk), jump to 5C23H with Register Pair HL the command, or the 0DH at the end of the line.
5BBA
PUSH HL E5
Save Register Pair HL, the text pointer at the asterisk, on the stack.
5BBB
LD HL,(40B1H) 2A B1 40
Load Register Pair HL with the word at 40B1H, the top of memory BASIC had.
5BBE
LD (5C87H),HL 22 87 5C
Store Register Pair HL at 5C87H, the operand of the LD HL at 5C86H: the same top of memory is kept.
5BC1
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the word at 40A4H, the start of the program text BASIC had.
5BC4
PUSH HL E5
Save Register Pair HL, the start of the program text, on the stack.
5BC5
LD E,(HL) 5E
Load Register E with the low byte of the link of the first line at Register Pair HL.
5BC6
INC HL 23
Increment Register Pair HL to the high byte of the link of the first line.
5BC7
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE is the address of the second line.
5BC8
LD (5CD7H),DE ED 53 D7 5C
Store Register Pair DE at 5CD7H, the operand of the LD BC at 5CD6H, which puts the link back after NEW.
5BCC
OR A B7
OR Register A with itself, 2AH, to clear the C FLAG for the SBC.
5BCD
SBC HL,DE ED 52
Subtract Register Pair DE, the link, from Register Pair HL: the NC FLAG is set when the link is not above the program's start.
5BCF
If the NC FLAG is set (no program, or a bad link), jump to 5BF8H, back to the DOS.
5BD1
LD HL,(40F9H) 2A F9 40
Load Register Pair HL with the word at 40F9H, the end of the program, where the variables start.
5BD4
LD (5CE0H),HL 22 E0 5C
Store Register Pair HL at 5CE0H, the operand of the LD HL at 5CDFH, for 1B5AH after NEW.
5BD7
DEC HL 2B
Decrement Register Pair HL to the last byte of the program, the high byte of the last link.
5BD8
LD A,(HL) 7E
Load Register A with that byte at Register Pair HL.
5BD9
DEC HL 2B
Decrement Register Pair HL to the low byte of the last link.
5BDA
OR (HL) B6
OR the byte at Register Pair HL into Register A: the Z FLAG is set when the program ends with the link 0000H.
5BDB
If the NZ FLAG is set (the program does not end with 0000H), jump to 5BF8H, back to the DOS.
5BDD
SBC HL,DE ED 52
Subtract Register Pair DE, the second line, from Register Pair HL, the program's end (the C FLAG is clear).
5BDF
If the C FLAG is set (the second line is past the end), jump to 5BF8H, back to the DOS.
5BE1
POP HL E1
Restore Register Pair HL with the start of the program text, saved at 5BC4H.
5BE2
DEC HL 2B
Decrement Register Pair HL to the byte 00H before the program text that the start-up stores (5C80H).
5BE3
LD DE,6431H 11 31 64
Load Register Pair DE with 6431H, the start of the file areas after BASIC/CMD.
5BE6
OR FFH F6 FF
OR Register A with FFH: Register A is FFH, one less than the first count, and the C FLAG is cleared.
5BE8
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL: the bytes of the file areas BASIC had.
5BEA
LD DE,0122H 11 22 01
Load Register Pair DE with 0122H, the size of one file area, 290 bytes.
5BED
INC A 3C
Increment Register Pair AF by one in Register A, the number of files counted so far.
5BEE
OR A B7
OR Register A with itself to clear the C FLAG for the SBC.
5BEF
SBC HL,DE ED 52
Subtract Register Pair DE, one area, from Register Pair HL, the bytes of the areas left.
5BF1
If the Z FLAG is set (all areas counted), jump to 5C1FH with Register A the highest file number BASIC had.
5BF4
CP 0FH FE 0F
Compare Register A with 0FH, the highest file number, 15.
5BF6
If the C FLAG is set (below 15), jump back to 5BEDH for the next area.
5BF8
Jump to 402DH, the DOS's normal exit, without a message: BASIC is not entered.
5BFB
RST 10H D7
RST 10H: Register A is the next character after the comma at Register Pair HL; the C FLAG is set for a digit.
5BFC
If the NC FLAG is set (not a digit), jump to 5C23H: the command for BASIC starts at Register Pair HL.
5BFE
Call 1E5AH in the ROM, which reads the decimal number at Register Pair HL into Register Pair DE.
5C01
LD A,D 7A
Load Register A with Register D, the high byte of the number.
5C02
OR A B7
OR Register A with itself: the Z FLAG is set when the number is below 256, the number of files.
5C03
If the NZ FLAG is set (256 or more), jump to 5C18H: the number is the memory size M.
5C05
LD A,E 7B
Load Register A with Register E, the highest file number F.
5C06
CP 10H FE 10
Compare Register A with 10H, one more than the highest file number allowed, 15.
5C08
If the NC FLAG is set (16 or more), jump to 5BF8H, back to the DOS.
5C0A
LD (5C5CH),A 32 5C 5C
Store Register A at 5C5CH, the operand of the LD A at 5C5BH, the highest file number.
5C0D
LD A,(HL) 7E
Load Register A with the character at Register Pair HL after the number.
5C0E
CP 2CH FE 2C
Compare Register A with 2CH, the comma before the next item.
5C10
If the Z FLAG is set (a comma), jump back to 5BFBH for the next item.
5C12
CP 0DH FE 0D
Compare Register A with 0DH, the end of the command line.
5C14
If the NZ FLAG is set (anything else after the number), jump to 5BF8H, back to the DOS.
5C16
Jump to 5C23H with Register Pair HL at the 0DH: no command for BASIC.
5C18
DEC DE 1B
Decrement Register Pair DE, the memory size M, to the highest address BASIC may use.
5C19
LD (5C87H),DE ED 53 87 5C
Store Register Pair DE at 5C87H, the operand of the LD HL at 5C86H, the top of memory.
5C1D
Jump back to 5C0DH, which looks at the character after the number.
5C1F
LD (5C5CH),A 32 5C 5C
Store Register A at 5C5CH, the operand of the LD A at 5C5BH: the asterisk form keeps the number of files.
5C22
POP HL E1
Restore Register Pair HL with the text pointer at the asterisk, saved at 5BBAH.
5C23
LD (5CCFH),HL 22 CF 5C
Store Register Pair HL at 5CCFH, the operand of the LD HL at 5CCEH: the command, the asterisk or the 0DH.
5C26
LD HL,(4313H) 2A 13 43
Load Register Pair HL with the word at 4313H, the target of the JP at 4312H of SYS0/SYS (4BA0H).
5C29
LD (5BA8H),HL 22 A8 5B
Store Register Pair HL at 5BA8H, the operand of the JP at 5BA7H, for 5BA4H and for 5B53H at the end.
5C2C
LD HL,5BA4H 21 A4 5B
Load Register Pair HL with 5BA4H, the BREAK key code of BASIC.
5C2F
LD (4313H),HL 22 13 43
Store Register Pair HL at 4313H: RST 28H with a code with bit 7 clear now goes to 5BA4H.
5C32
XOR A AF
Clear Register A to 00H, the value of the BREAK flag 4315H while BASIC runs.
5C33
LD (4315H),A 32 15 43
Store Register A, 00H, at 4315H, the BREAK flag of SYS0/SYS: BREAK is not sent to the vector at 4316H.
5C36
LD DE,4080H 11 80 40
Load Register Pair DE with 4080H, the start of the ROM's work space in memory.
5C39
LD HL,18F7H 21 F7 18
Load Register Pair HL with 18F7H, the ROM's table of the first values of that work space.
5C3C
LD BC,0027H 01 27 00
Load Register Pair BC with 0027H, the 39 bytes of the table.
5C3F
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL, 18F7H, to Register Pair DE, 4080H, as the ROM does at power on.
5C41
LD SP,5C41H 31 41 5C
Load the Stack Pointer with 5C41H: the stack grows down over the start-up code, which has run.
5C44
LD HL,4D00H 21 00 4D
Load Register Pair HL with 4D00H, the table of the Disk BASIC vectors in the file.
5C47
LD DE,4152H 11 52 41
Load Register Pair DE with 4152H, the first of the Disk BASIC vectors of the ROM.
5C4A
LD BC,0093H 01 93 00
Load Register Pair BC with 0093H, the 147 bytes of forty-nine vectors.
5C4D
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL, 4D00H, to Register Pair DE, 4152H: the vectors are set.
5C4F
LD HL,FFFEH 21 FE FF
Load Register Pair HL with FFFEH, the line number that marks the start-up for the ROM's error code (1A0CH).
5C52
LD (40A2H),HL 22 A2 40
Store Register Pair HL, FFFEH, at 40A2H, the number of the current line.
5C55
LD HL,5BADH 21 AD 5B
Load Register Pair HL with 5BADH, the start-up code, which is to be the input buffer.
5C58
LD (40A7H),HL 22 A7 40
Store Register Pair HL, 5BADH, at 40A7H, the address of the ROM's input buffer.
5C5B
LD A,03H 3E 03
Load Register A with 03H, the highest file number when none is given; the operand 5C5CH is stored by 5C0AH or 5C1FH.
5C5D
LD (5B50H),A 32 50 5B
Store Register A at 5B50H, the highest file number that may be used.
5C60
INC A 3C
Increment Register A: the number of file areas, file 0 and files 1 to F.
5C61
LD HL,6431H 21 31 64
Load Register Pair HL with 6431H, the first byte after BASIC/CMD, the area of file 0.
5C64
LD DE,5B2CH 11 2C 5B
Load Register Pair DE with 5B2CH, the table of the file areas.
5C67
LD (5B4CH),HL 22 4C 5B
Store Register Pair HL, 6431H, at 5B4CH, the area of file 0.
5C6A
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL is the table, Register Pair DE the area.
5C6B
LD (HL),E 73
Store Register E, the low byte of the area, at Register Pair HL in the table.
5C6C
INC HL 23
Increment Register Pair HL to the high byte of the table entry.
5C6D
LD (HL),D 72
Store Register D, the high byte of the area, at Register Pair HL in the table.
5C6E
INC HL 23
Increment Register Pair HL to the next table entry.
5C6F
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL is the area, Register Pair DE the table.
5C70
LD BC,0122H 01 22 01
Load Register Pair BC with 0122H, the 290 bytes of a file area.
5C73
EX AF,AF' 08
Exchange Register Pair AF with the alternate Register Pair AF: the count of the areas is kept.
5C74
LD (HL),00H 36 00
Store 00H at Register Pair HL, the next byte of the file area.
5C76
INC HL 23
Increment Register Pair HL to the next byte of the file area.
5C77
DEC BC 0B
Decrement Register Pair BC, the bytes of the area left.
5C78
LD A,B 78
Load Register A with Register B, the high byte of the count in Register Pair BC.
5C79
OR C B1
OR Register C into Register A: the Z FLAG is set when the count in Register Pair BC is 0000H.
5C7A
If the NZ FLAG is set (bytes are left), jump back to 5C74H.
5C7C
EX AF,AF' 08
Exchange Register Pair AF with the alternate Register Pair AF: Register A is the count of the areas again.
5C7D
DEC A 3D
Decrement Register A, the areas still to set up.
5C7E
If the NZ FLAG is set (areas are left), jump back to 5C6AH for the next one.
5C80
LD (HL),00H 36 00
Store 00H at Register Pair HL, the byte before the program text.
5C82
INC HL 23
Increment Register Pair HL to the start of the program text.
5C83
LD (40A4H),HL 22 A4 40
Store Register Pair HL at 40A4H, the start of the program text.
5C86
LD HL,0000H 21 00 00
Load Register Pair HL with the top of memory given (M less 1, or the old 40B1H for the asterisk); the operand 5C87H is 0000H when none.
5C89
LD A,H 7C
Load Register A with Register H, the high byte of the top of memory given.
5C8A
OR L B5
OR Register L into Register A: the Z FLAG is set when no top of memory was given.
5C8B
If the NZ FLAG is set (a top of memory was given), jump to 5CA0H to test it.
5C8D
LD HL,(4049H) 2A 49 40
Load Register Pair HL with the word at 4049H, the top of memory found by SYS0/SYS.
5C90
Jump to 5CA0H, which tests the byte at Register Pair HL.
5C92-5C9F
DEFB B5H,28H,08H,7EH,47H,2FH,77H,BEH,70H,28H,F3H,2BH,18H,08H B5 28 08 7E 47 2F 77 BE 70 28 F3 2B 18 08
Fourteen bytes that no instruction reads or runs; as instructions they would look for the top of memory, a byte at a time.
5CA0H - The Start-up: Memory and the Banner
The top of memory must hold a byte written to it (else back to the DOS, 5CEDH), and must leave 300 bytes after the start of the program (else Out of memory). 50 bytes are kept for strings. The banner is shown, the program cleared (1B4DH), and for the asterisk form of BASIC the old program is linked again (5CD6H-5CE2H).
5CA0
LD A,D9H 3E D9
Load Register A with D9H, the byte written to the top of memory to test it.
5CA2
LD B,(HL) 46
Load Register B with the byte at Register Pair HL, the top of memory, to put it back.
5CA3
LD (HL),A 77
Store Register A, D9H, at Register Pair HL, the top of memory to be tested.
5CA4
CP (HL) BE
Compare Register A with the byte at Register Pair HL: the Z FLAG is set when the byte was kept (memory).
5CA5
LD (HL),B 70
Store Register B, the old byte, at Register Pair HL again.
5CA6
If the NZ FLAG is set (no memory there), jump to 5CEDH, back to the DOS.
5CA8
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE is the top of memory.
5CA9
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the word at 40A4H, the start of the program text.
5CAC
LD BC,012CH 01 2C 01
Load Register Pair BC with 012CH, 300 bytes, the least room for the program (5CFCH stores 00H at 5CACH later).
5CAF
ADD HL,BC 09
Add Register Pair BC to Register Pair HL: the start of the program plus 300 bytes.
5CB0
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL is the top of memory.
5CB1
RST 18H DF
RST 18H: compare Register Pair HL, the top, with Register Pair DE; the C FLAG is set when the room is less than 300 bytes.
5CB2
If the C FLAG is set (too little memory), jump to 197AH in the ROM, Out of memory.
5CB5
LD DE,FFCEH 11 CE FF
Load Register Pair DE with FFCEH, minus 50, the string space BASIC starts with.
5CB8
LD (40B1H),HL 22 B1 40
Store Register Pair HL, the top of memory, at 40B1H.
5CBB
ADD HL,DE 19
Add Register Pair DE to Register Pair HL: 50 bytes below the top of memory.
5CBC
LD (40A0H),HL 22 A0 40
Store Register Pair HL at 40A0H, the start of the string space.
5CBF
LD HL,4D93H 21 93 4D
Load Register Pair HL with 4D93H, the first part of the banner, RADIO SHACK DISK BASIC VERSION 1.1.
5CC2
Call 4467H of SYS0/SYS, which shows the text at Register Pair HL to 0DH.
5CC5
LD HL,5D25H 21 25 5D
Load Register Pair HL with 5D25H, the second part of the banner, DBLDOS ADAPTATIONS COPYRIGHT 1980 BY PERCOM.
5CC8
Call 4467H of SYS0/SYS, which shows the text at Register Pair HL to 0DH.
5CCB
Call 1B4DH in the ROM, NEW: the program text is cleared and the variables with it.
5CCE
LD HL,0000H 21 00 00
Load Register Pair HL with the command after BASIC (0000H in the file); the operand 5CCFH is stored by 5C23H.
5CD1
LD A,(HL) 7E
Load Register A with the first character of the command at Register Pair HL.
5CD2
CP 2AH FE 2A
Compare Register A with 2AH, the asterisk after BASIC that keeps the program.
5CD4
If the NZ FLAG is set (no asterisk), jump to 5CF1H, which looks for a command.
5CD6
LD BC,0000H 01 00 00
Load Register Pair BC with the link of the old first line (0000H in the file); the operand 5CD7H is stored by 5BC8H.
5CD9
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the word at 40A4H, the start of the program text.
5CDC
LD (HL),C 71
Store Register C, the low byte of the link, at Register Pair HL, where NEW stored 00H.
5CDD
INC HL 23
Increment Register Pair HL to the high byte of the link.
5CDE
LD (HL),B 70
Store Register B, the high byte of the link, at Register Pair HL: the old program is linked again.
5CDF
LD HL,0000H 21 00 00
Load Register Pair HL with the old end of the program (0000H in the file); the operand 5CE0H is stored by 5BD4H.
5CE2
Call 1B5AH in the ROM, which stores Register Pair HL at 40F9H, the end of the program, and clears the variables.
5CE5
LD HL,5D59H 21 59 5D
Load Register Pair HL with 5D59H, a byte 00H, as the command after the asterisk form: an empty line, with no 0DH after it (a bug: the Bugs part of the introduction).
5CE8
LD (5CCFH),HL 22 CF 5C
Store Register Pair HL, 5D59H, at 5CCFH, the command that 5D02H copies.
5CEB
Jump to 5CF5H, which has 5D02H give the command at the first READY.
5CED
XOR A AF
Clear Register A to 00H and the C FLAG: 5B52H goes to 402DH.
5CEE
Jump to 5B52H, which puts the DOS's vectors back and returns to DOS READY without a message.
5CF1
CP 0DH FE 0D
Compare Register A, the first character of the command, with 0DH, the end of the line.
5CF3
If the Z FLAG is set (no command), jump to 5CFBH.
5CF5
LD HL,5D02H 21 02 5D
Load Register Pair HL with 5D02H, the routine that gives the command at the first READY.
5CF8
LD (524AH),HL 22 4A 52
Store Register Pair HL, 5D02H, at 524AH, the operand of the CALL 0033H at 5249H.
5CFB
XOR A AF
Clear Register A to 00H, the byte stored at 5CACH next.
5CFC
LD (5CACH),A 32 AC 5C
Store Register A, 00H, at 5CACH, the first byte of the LD BC,012CH at 5CACH, which has run; nothing runs it again.
5CFF
Jump to 1A19H in the ROM, READY, the first command line of BASIC.
5D02H - The Command after BASIC
Called once, by the CALL at 5249H when the operand 524AH has been made 5D02H (5CF8H), when the first command line after READY is to be taken. The CALL is made 0033H again; 1DH, 1BH and 1FH are shown (5D54H); the command is copied from (5CCFH) into the input buffer up to and with its 0DH; and the line input ends at 0379H as if the line had been typed. For the asterisk form of BASIC the command is at 5D59H, a byte 00H: an empty line; the copy, which stops only at a 0DH, takes 294 bytes, to 5E7EH, into 5BADH-5CD2H, the start-up code, which has run.
5D02
POP HL E1
Remove the return address 524CH into Register Pair HL: the wait for a key at 524CH is passed over.
5D03
PUSH BC C5
Save Register Pair BC on the stack, as ROM 036BH does, for the POP BC at 037FH.
5D04
LD HL,0033H 21 33 00
Load Register Pair HL with 0033H, the ROM's display of a character.
5D07
LD (524AH),HL 22 4A 52
Store Register Pair HL, 0033H, at 524AH: the CALL at 5249H shows the cursor again from now on.
5D0A
LD HL,5D54H 21 54 5D
Load Register Pair HL with 5D54H, the codes 1DH, 1BH and 1FH and the end 03H.
5D0D
Call 4467H of SYS0/SYS, which shows the text at Register Pair HL to 03H.
5D10
LD DE,(5CCFH) ED 5B CF 5C
Load Register Pair DE with the word at 5CCFH, the command after BASIC.
5D14
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the word at 40A7H, the address of the ROM's input buffer.
5D17
LD A,(DE) 1A
Load Register A with the next character of the command at Register Pair DE.
5D18
LD (HL),A 77
Store Register A at Register Pair HL in the input buffer.
5D19
INC DE 13
Increment Register Pair DE to the next character of the command.
5D1A
INC HL 23
Increment Register Pair HL to the next place in the input buffer.
5D1B
CP 0DH FE 0D
Compare Register A with 0DH, the end of the command.
5D1D
If the NZ FLAG is set (not the end), jump back to 5D17H.
5D1F
DEC HL 2B
Decrement Register Pair HL to the 0DH, which 0379H replaces with 00H.
5D20
XOR A AF
Clear Register A to 00H and the C FLAG: no BREAK.
5D21
PUSH AF F5
Save Register Pair AF, the clear C FLAG, on the stack for the POP AF at 037EH.
5D22
Jump to 0379H in the ROM, the end of the line input, which returns the line to 1A7EH.
5D25H - The Texts of the Start-up
The second part of the banner, the codes shown by 5D02H, and the texts of the never run abbreviations of 5307H at 5D58H-5D69H.
5D25-5D50
DEFM "DBLDOS ADAPTATIONS COPYRIGHT 1980 BY PERCOM." 44 42 4C 44 4F 53 20 41 44 41 50 54 41 54 49 4F 4E 53 20 43 4F 50 59 52 49 47 48 54 20 31 39 38 30 20 42 59 20 50 45 52 43 4F 4D 2E
The second part of the banner at 5D25H, DBLDOS ADAPTATIONS COPYRIGHT 1980 BY PERCOM., shown by 5CC8H.
5D51-5D53
DEFB 20H,0AH,0DH 20 0A 0D
A space, a line feed and the carriage return at 5D51H-5D53H that ends the banner for 4467H.
5D54-5D57
DEFB 1DH,1BH,1FH,03H 1D 1B 1F 03
The codes shown by 5D0DH: 1DH the cursor to the start of the line, 1BH up one line, 1FH clear to the end of the screen, 03H the end.
5D58
DEFB 04H 04
The length of the text for the letter L of the never run 5307H (5321H reads it); its characters at 5D59H-5D5DH are 00H.
5D59-5D69
DEFB 00H x 17 00 x 17
Seventeen bytes 00H at 5D59H-5D69H: the characters of the text for L, and the texts for E (5D5EH) and D (5D63H) of the never run 5307H, each of length 00H; 5D59H is also the empty command that 5CE5H gives the asterisk form of BASIC.
5D6AH - FIELD: A Record Filled to Its Last Byte
DBLDOS's code, called from 60D6H when the length of a field takes the total past 255 bytes, and entered from 60E2H after every field. TRSDOS 2.1 has JP C,63F8H at 60D6H (FIELD overflow for any total above 255) and JP 60B9H at 60E2H, so the 256th byte of a record could not be in a field. Here a total of exactly 256 (Register A 00H, the Z FLAG and C FLAG set by the ADD at 60D5H) is allowed when it is the last field of the statement.
5D6A
RET Z C8
If the Z FLAG is set (the total is exactly 256 bytes), return to 60D9H, which sets up the field.
5D6B
Jump to 63F8H, which gives FIELD overflow: the total is above 256, or another field follows the 256th byte.
5D6E
If the NC FLAG is set (the total is below 256), jump to 60B9H for the next field, as TRSDOS 2.1 does.
5D71
LD A,(HL) 7E
Load Register A with the character at Register Pair HL after the field, the record being full.
5D72
CP 2CH FE 2C
Compare Register A with 2CH, the comma before another field of the statement.
5D74
RET NZ C0
If the NZ FLAG is set (the end of FIELD), return to the ROM with the record full to its 256th byte.
5D75
Jump back to 5D6BH, which gives FIELD overflow: no field may follow the 256th byte.
5D77H - Capitals Helpers (Never Run)
Used only by the never run code of 5307H and 5404H: 5D77H makes a small letter a capital, 5D80H makes a command line capitals outside its quotation marks, 5D9CH copies Register B characters as capitals.
5D77
CP 61H FE 61
Compare Register A with 61H, the small letter a (never run: only the never run 5D82H and 5D9EH call 5D77H).
5D79
RET C D8
If the C FLAG is set (below a), return with Register A as it is (never run).
5D7A
CP 7BH FE 7B
Compare Register A with 7BH, one more than the small letter z (never run).
5D7C
RET NC D0
If the NC FLAG is set (above z), return with Register A as it is (never run).
5D7D
SUB 20H D6 20
Subtract 20H from Register A: the small letter becomes a capital (never run).
5D7F
RET C9
Return with Register A the capital letter (never run: no instruction reaches 5D77H).
5D80
PUSH HL E5
Save Register Pair HL, the start of the command line, on the stack (never run: called only from 5307H).
5D81
LD A,(HL) 7E
Load Register A with the next character of the line at Register Pair HL (never run).
5D82
Call 5D77H, which makes Register A a capital when it is a small letter (never run).
5D85
LD (HL),A 77
Store Register A at Register Pair HL in the line (never run: no instruction reaches 5D80H).
5D86
INC HL 23
Increment Register Pair HL to the next character of the line (never run).
5D87
CP 22H FE 22
Compare Register A with 22H, a quotation mark (never run).
5D89
If the NZ FLAG is set (not a quotation mark), jump to 5D94H (never run).
5D8B
LD A,(HL) 7E
Load Register A with the next character inside the quotation marks at Register Pair HL (never run).
5D8C
INC HL 23
Increment Register Pair HL to the next character of the line (never run).
5D8D
CP 22H FE 22
Compare Register A with 22H, the closing quotation mark (never run).
5D8F
If the Z FLAG is set (the closing quotation mark), jump to 5D94H (never run).
5D91
OR A B7
OR Register A with itself: the Z FLAG is set at the 00H that ends the line (never run).
5D92
If the NZ FLAG is set (not the end), jump back to 5D8BH, the characters in quotation marks unchanged (never run).
5D94
OR A B7
OR Register A with itself: the Z FLAG is set at the 00H that ends the line (never run).
5D95
If the NZ FLAG is set (not the end), jump back to 5D81H for the next character (never run).
5D97
POP HL E1
Restore Register Pair HL with the start of the command line (never run: no instruction reaches 5D80H).
5D98
LD A,(HL) 7E
Load Register A with the first character of the line at Register Pair HL (never run).
5D99
CP 52H FE 52
Compare Register A with 52H, the letter R, for the caller (never run: only 5307H calls 5D80H).
5D9B
RET C9
Return with the Z FLAG set when the line starts with R (never run).
5D9C
LD A,(HL) 7E
Load Register A with the next character at Register Pair HL (never run: called only from the never run 5404H).
5D9D
INC HL 23
Increment Register Pair HL to the next character (never run: no instruction reaches 5D9CH).
5D9E
Call 5D77H, which makes Register A a capital when it is a small letter (never run).
5DA1
LD (DE),A 12
Store Register A at Register Pair DE, the copy (never run: no instruction reaches 5D9CH).
5DA2
INC DE 13
Increment Register Pair DE to the next place of the copy (never run).
5DA3
Decrement Register B and jump back to 5D9CH while it is not zero (never run).
5DA5
RET C9
Return with Register B characters copied as capitals (never run: no instruction reaches 5D9CH).
5DA6H - The File Name Buffer
66 bytes 00H. 5DC8H-5DE7H take a file name made capitals by 62FFH (6315H, at most 23 characters and an end byte), for @FSPEC (6334H-6339H). TRSDOS 2.1 has at 5DA6H-5DC6H the end of its banner (DIO SHACK DISK BASIC VERSION 1.1 and 0DH), which DBLDOS has at 4D93H.
5DA6-5DC7
DEFB 00H x 34 00 x 34
Thirty-four bytes 00H at 5DA6H-5DC7H that nothing reads; TRSDOS 2.1 has the end of its banner text here.
5DC8-5DE7
DEFB 00H x 32 00 x 32
The buffer at 5DC8H-5DE7H of the file name in capitals, written by 6326H-632DH and given to 441CH by 6334H.
5DE8H - Choose the File after #
5DE8H for INPUT # and LINE INPUT # (mode 01H, input), 5DEAH with Register C the mode from PRINT # (02H). With Register A not the sign # nothing is done. The file number must be open in the mode of Register C (Bad file mode, 63E3H), and must be followed by a comma; its area goes to 5B2AH. TRSDOS 2.1's code.
5DE8
LD C,01H 0E 01
Load Register C with 01H, the mode the file must be open in for INPUT # and LINE INPUT #: input.
5DEA
CP 23H FE 23
Compare Register A, the character at Register Pair HL, with 23H, the sign #.
5DEC
RET NZ C0
If the NZ FLAG is set (no #), return: the screen or the keyboard is used.
5DED
PUSH BC C5
Save Register Pair BC, the mode in Register C, on the stack.
5DEE
Call 5E00H, which takes the file number at Register Pair HL: Register Pair BC is its area, Register A its mode.
5DF1
POP DE D1
Restore Register Pair DE with the mode wanted in Register E, saved at 5DEDH.
5DF2
CP E BB
Compare Register A, the mode of the file, with Register E, the mode wanted.
5DF3
If the NZ FLAG is set (another mode, or not open), jump to 63E3H, Bad file mode.
5DF6
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (5DF7H).
5DF7
DEFB 2CH 2C
The byte for the RST 08H at 5DF6H: 2CH, the comma after the file number.
5DF8
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE is the text pointer while 5B2AH is set.
5DF9
LD H,B 60
Load Register H with Register B, the high byte of the file's area.
5DFA
LD L,C 69
Load Register L with Register C: Register Pair HL is the file's area.
5DFB
LD (5B2AH),HL 22 2A 5B
Store Register Pair HL, the file's area, at 5B2AH: the file is in use.
5DFE
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL is the text pointer again.
5DFF
RET C9
Return with the file in use set at 5B2AH and Register Pair HL at the first item.
5E00H - A File Number and Its Area
Entered with Register Pair HL at the file number (5E00H, an optional # first), or at 5E0AH with the number's value in 4121H, or at 5E0DH with the number in Register A. A number above the highest (5B50H) is Bad file number (63E6H). Register Pair BC is the area from the table 5B2CH, Register A its first byte, the mode (00H closed, 01H input, 02H output, 03H random), with the Z FLAG set when it is closed. TRSDOS 2.1's code.
5E00
DEC HL 2B
Decrement Register Pair HL so that the RST 10H at 5E01H takes the character at Register Pair HL again.
5E01
RST 10H D7
RST 10H: Register A is the next character at Register Pair HL, spaces passed over.
5E02
CP 23H FE 23
Compare Register A with 23H, the sign # before the file number, which may be left out.
5E04
If the Z FLAG is set (a #), call 1D78H in the ROM, the code of RST 10H, which passes over it.
5E07
Call 2337H in the ROM, which evaluates the expression at Register Pair HL, the file number, into 4121H.
5E0A
Call 2B1FH in the ROM, which makes the value in 4121H a byte 0-255 in Register A.
5E0D
LD E,A 5F
Load Register E with Register A, the file number.
5E0E
LD A,(5B50H) 3A 50 5B
Load Register A with the byte at 5B50H, the highest file number that may be used.
5E11
CP E BB
Compare Register A with Register E, the file number: the C FLAG is set when the number is too high.
5E12
If the C FLAG is set (above the highest file number), jump to 63E6H, Bad file number.
5E15
LD D,00H 16 00
Load Register D with 00H, so that Register Pair DE is the file number.
5E17
PUSH HL E5
Save Register Pair HL, the text pointer, on the stack.
5E18
LD HL,5B2CH 21 2C 5B
Load Register Pair HL with 5B2CH, the table of the file areas.
5E1B
ADD HL,DE 19
Add Register Pair DE, the file number, to Register Pair HL.
5E1C
ADD HL,DE 19
Add Register Pair DE again: Register Pair HL is the table entry of the file, two bytes a file.
5E1D
LD C,(HL) 4E
Load Register C with the low byte of the file's area at Register Pair HL.
5E1E
INC HL 23
Increment Register Pair HL to the high byte of the table entry.
5E1F
LD B,(HL) 46
Load Register B with the high byte at Register Pair HL: Register Pair BC is the file's area.
5E20
LD A,(BC) 0A
Load Register A with the first byte of the area at Register Pair BC, the mode of the file.
5E21
OR A B7
OR Register A with itself: the Z FLAG is set when the file is not open (mode 00H).
5E22
POP HL E1
Restore Register Pair HL, the text pointer, from the stack.
5E23
RET C9
Return with Register Pair BC the area and Register A the mode.
5E24-5E2C
DEFB CDH,0EH,5EH,21H,22H,00H,09H,EBH,C9H CD 0E 5E 21 22 00 09 EB C9
Nine bytes that no instruction reaches: as instructions CALL 5E0EH, LD HL,0022H, ADD HL,BC, EX DE,HL and RET. TRSDOS 2.1 has the same bytes here.
5E2DH - MKI$, MKS$ and MKD$
The vectors 416AH (5E2DH, MKI$, Register A 02H), 416DH (5E30H, MKS$, 04H) and 4170H (5E33H, MKD$, 08H), entered inside the LD BC instructions. The value in 4121H is made of that type (2819H) and copied, 2, 4 or 8 bytes, into a new string of that length. TRSDOS 2.1's code.
5E2D
LD A,02H 3E 02
Load Register A with 02H, the type and length of an integer, for MKI$.
5E2F
LD BC,043EH 01 3E 04
Load Register Pair BC with 043EH, which passes over 5E30H-5E31H; entered at 5E30H for MKS$, 3EH 04H is LD A,04H.
5E32
LD BC,083EH 01 3E 08
Load Register Pair BC with 083EH, which passes over 5E33H-5E34H; entered at 5E33H for MKD$, 3EH 08H is LD A,08H.
5E35
PUSH AF F5
Save Register Pair AF, the type in Register A, on the stack.
5E36
Call 2819H in the ROM, which makes the value in 4121H of the type in Register A.
5E39
POP AF F1
Restore Register Pair AF, the type and length in Register A, from the stack.
5E3A
Call 2857H in the ROM, which makes room for a string of Register A characters, its descriptor at 40D3H.
5E3D
LD HL,(40D4H) 2A D4 40
Load Register Pair HL with the word at 40D4H, the address of the new string's characters.
5E40
Call 09FFH in the ROM, which copies the value in 4121H, of the length of its type, to Register Pair HL.
5E43
Jump to 2A2BH in the ROM, which makes the string of 40D3H the result.
5E46H - CVI, CVS and CVD
The vectors 4152H (5E46H, CVI, Register A 01H), 4158H (5E49H, CVS, 03H) and 415EH (5E4CH, CVD, 07H). The string must have more characters than Register A, one less than the length of the type (else Illegal function call); its first 2, 4 or 8 bytes are copied to 4121H as a number of that type. TRSDOS 2.1's code.
5E46
LD A,01H 3E 01
Load Register A with 01H, one less than the length of an integer, for CVI.
5E48
LD BC,033EH 01 3E 03
Load Register Pair BC with 033EH, which passes over 5E49H-5E4AH; entered at 5E49H for CVS, 3EH 03H is LD A,03H.
5E4B
LD BC,073EH 01 3E 07
Load Register Pair BC with 073EH, which passes over 5E4CH-5E4DH; entered at 5E4CH for CVD, 3EH 07H is LD A,07H.
5E4E
PUSH AF F5
Save Register Pair AF, one less than the length in Register A, on the stack.
5E4F
Call 29D7H in the ROM, which checks that the value is a string and frees it: Register Pair HL is its descriptor.
5E52
POP AF F1
Restore Register Pair AF, one less than the length in Register A, from the stack.
5E53
CP (HL) BE
Compare Register A with the length of the string at Register Pair HL: the NC FLAG is set when it is too short.
5E54
If the NC FLAG is set (the string is too short), jump to 1E4AH in the ROM, Illegal function call.
5E57
INC A 3C
Increment Register A: the type, 02H, 04H or 08H.
5E58
INC HL 23
Increment Register Pair HL to the address of the characters in the descriptor.
5E59
LD C,(HL) 4E
Load Register C with the low byte of the address of the characters at Register Pair HL.
5E5A
INC HL 23
Increment Register Pair HL to the high byte of the address of the characters.
5E5B
LD H,(HL) 66
Load Register H with the high byte of the address of the characters at Register Pair HL.
5E5C
LD L,C 69
Load Register L with Register C: Register Pair HL is the address of the characters of the string.
5E5D
LD (40AFH),A 32 AF 40
Store Register A, the type, at 40AFH, the type of the value in 4121H.
5E60
Jump to 09F7H in the ROM, which copies the bytes at Register Pair HL, of the length of the type, to 4121H.
5E63H - INPUT # and READ: A Value from the File
The hook 41DCH, called from 222DH for each variable of READ and INPUT. With no file in use the ROM goes on. For INPUT # the value is taken from the file: a number ends at a space, a comma or a carriage return; a string at a comma or a carriage return, or, when it starts with a quotation mark, at the next quotation mark. The value goes back to the ROM at 2243H. TRSDOS 2.1's code from here to 5F71H.
5E63
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE is kept while the word at 5B2AH is tested.
5E64
LD HL,(5B2AH) 2A 2A 5B
Load Register Pair HL with the word at 5B2AH, the area of the file in use, 0000H when there is none.
5E67
LD A,H 7C
Load Register A with Register H, the high byte of the word at 5B2AH.
5E68
OR L B5
OR Register L into Register A: the Z FLAG is set when no file is in use.
5E69
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL is the text pointer again.
5E6A
RET Z C8
If the Z FLAG is set (no file in use), return to the ROM's READ or INPUT.
5E6B
POP AF F1
Remove the return address of the call at 222DH into Register Pair AF: the ROM's own input is passed over.
5E6C
RST 20H E7
RST 20H: test the type of the variable (40AFH); the Z FLAG is set for a string.
5E6D
LD BC,2243H 01 43 22
Load Register Pair BC with 2243H, the ROM's code after a value has been read, the return address.
5E70
LD DE,2C20H 11 20 2C
Load Register Pair DE with 2C20H: Register D the comma, Register E the space, the characters that end a number.
5E73
If the NZ FLAG is set (a number), jump to 5E8EH.
5E76
LD E,D 5A
Load Register E with Register D, the comma: a string ends only at a comma or a carriage return.
5E77
Jump to 5E8EH, which reads the value with the end characters in Register Pair DE.
5E7AH - LINE INPUT #
Reached from LINE INPUT at 575AH. The file is chosen (5DE8H, mode input), the variable must be a string, and the characters up to the carriage return, spaces, commas and quotation marks included, are read by 5E8EH with Register D and Register E 00H and given to the variable by the ROM's LET (1F31H); 2169H ends the statement.
5E7A
Call 5DE8H, which chooses the file after the # at Register Pair HL; it must be open for input.
5E7D
Call 260DH in the ROM, which finds the variable named at Register Pair HL: Register Pair DE is its address.
5E80
Call 0AF4H in the ROM, which gives a Type mismatch error unless the variable just found (40AFH) is a string.
5E83
LD BC,2169H 01 69 21
Load Register Pair BC with 2169H, the ROM's end of an input statement.
5E86
PUSH BC C5
Save Register Pair BC, 2169H, on the stack as the last return address.
5E87
PUSH DE D5
Save Register Pair DE, the address of the variable, on the stack for 1F31H.
5E88
LD BC,1F31H 01 31 1F
Load Register Pair BC with 1F31H, the ROM's end of LET, the return address of the read.
5E8B
XOR A AF
Clear Register A to 00H, with the Z FLAG set: the value is a string.
5E8C
LD D,A 57
Load Register D with Register A, 00H: no character but the carriage return ends the line.
5E8D
LD E,A 5F
Load Register E with Register A, 00H: no character but the carriage return ends the line.
5E8E
PUSH AF F5
Save Register Pair AF, the Z FLAG of a string, on the stack.
5E8F
PUSH BC C5
Save Register Pair BC, the return address 2243H or 1F31H, on the stack.
5E90
PUSH HL E5
Save Register Pair HL, the text pointer, on the stack.
5E91
Call 62E5H, which reads the next byte of the file in use into Register A; the C FLAG is set at its end.
5E94
If the C FLAG is set (the end of the file), jump to 63ECH, Input past end.
5E97
CP 20H FE 20
Compare Register A, the byte from the file, with 20H, a space.
5E99
If the NZ FLAG is set (not a space), jump to 5EA1H.
5E9C
INC D 14
Increment Register D, the first end character, to test it.
5E9D
DEC D 15
Decrement Register D back: the Z FLAG is set when Register D is 00H (LINE INPUT #, which keeps the spaces).
5E9E
If the NZ FLAG is set (INPUT #), jump back to 5E91H: spaces before a value are passed over.
5EA1
CP 22H FE 22
Compare Register A with 22H, a quotation mark.
5EA3
If the NZ FLAG is set (not a quotation mark), jump to 5EB6H.
5EA6
LD B,A 47
Load Register B with Register A, the quotation mark.
5EA7
LD A,E 7B
Load Register A with Register E, the second end character.
5EA8
CP 2CH FE 2C
Compare Register A with 2CH: the Z FLAG is set for a string of INPUT #.
5EAA
LD A,B 78
Load Register A with Register B, the quotation mark again.
5EAB
If the NZ FLAG is set (a number, or LINE INPUT #), jump to 5EB6H: the quotation mark is a character.
5EAE
LD D,B 50
Load Register D with Register B, the quotation mark, the only end character inside quotation marks.
5EAF
LD E,B 58
Load Register E with Register B, the quotation mark.
5EB0
Call 62E5H, which reads the byte after the quotation mark into Register A; the C FLAG is set at the end of the file.
5EB3
If the C FLAG is set (the end of the file), jump to 5F04H, which ends the value.
5EB6
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the word at 40A7H, the ROM's input buffer, where the value is put.
5EB9
LD B,FFH 06 FF
Load Register B with FFH, the most characters a value may have, 255.
5EBB
LD C,A 4F
Load Register C with Register A, the character just read.
5EBC
LD A,D 7A
Load Register A with Register D, the first end character.
5EBD
CP 22H FE 22
Compare Register A with 22H: the Z FLAG is set inside quotation marks.
5EBF
LD A,C 79
Load Register A with Register C, the character just read.
5EC0
If the Z FLAG is set (inside quotation marks), jump to 5EEFH: a carriage return or line feed is a character.
5EC3
CP 0DH FE 0D
Compare Register A with 0DH, the carriage return.
5EC5
PUSH HL E5
Save Register Pair HL, the place in the buffer, on the stack for 5F4EH.
5EC6
If the Z FLAG is set (a carriage return), jump to 5F24H, the end of the value.
5EC9
POP HL E1
Restore Register Pair HL, the place in the buffer, from the stack.
5ECA
CP 0AH FE 0A
Compare Register A, the byte from the file, with 0AH, a line feed.
5ECC
If the NZ FLAG is set (another character), jump to 5EEFH.
5ECF
LD C,A 4F
Load Register C with Register A, the line feed.
5ED0
LD A,E 7B
Load Register A with Register E, the second end character.
5ED1
CP 2CH FE 2C
Compare Register A with 2CH: the Z FLAG is set for a string of INPUT #.
5ED3
LD A,C 79
Load Register A with Register C, the line feed again.
5ED4
If the NZ FLAG is set (a number or LINE INPUT #), call 5F68H, which puts the line feed in the buffer.
5ED7
Call 62E5H, which reads the byte after the line feed into Register A; the C FLAG is set at the end of the file.
5EDA
If the C FLAG is set (the end of the file), jump to 5F04H, which ends the value.
5EDD
CP 0DH FE 0D
Compare Register A with 0DH, a carriage return after the line feed.
5EDF
If the NZ FLAG is set (another character), jump to 5EEFH.
5EE2
LD A,E 7B
Load Register A with Register E, the second end character.
5EE3
CP 20H FE 20
Compare Register A with 20H: the Z FLAG is set for a number.
5EE5
If the Z FLAG is set (a number), jump to 5EFEH: the line feed and carriage return do not end it.
5EE8
CP 2CH FE 2C
Compare Register A with 2CH: the Z FLAG is set for a string of INPUT #.
5EEA
LD A,0DH 3E 0D
Load Register A with 0DH, the carriage return.
5EEC
If the Z FLAG is set (a string of INPUT #), jump to 5EFEH: the pair does not end it.
5EEF
OR A B7
OR Register A with itself: the Z FLAG is set for a byte 00H.
5EF0
If the Z FLAG is set (a byte 00H), jump to 5EFEH: it is left out.
5EF3
CP D BA
Compare Register A with Register D, the first end character.
5EF4
If the Z FLAG is set (an end character), jump to 5F04H, which ends the value.
5EF7
CP E BB
Compare Register A with Register E, the second end character.
5EF8
If the Z FLAG is set (an end character), jump to 5F04H, which ends the value.
5EFB
Call 5F68H, which puts the character of Register A in the buffer.
5EFE
Call 62E5H, which reads the next byte of the file into Register A; the C FLAG is set at its end.
5F01
If the NC FLAG is set (a byte was read), jump back to 5EBBH.
5F04
PUSH HL E5
Save Register Pair HL, the place in the buffer after the value, on the stack.
5F05
CP 22H FE 22
Compare Register A, the character that ended the value, with 22H, a quotation mark.
5F07
If the Z FLAG is set (the closing quotation mark), jump to 5F0FH, which passes over the spaces after it.
5F0A
CP 20H FE 20
Compare Register A, the byte that ended the value, with 20H, a space.
5F0C
If the NZ FLAG is set (a comma or the end of the file), jump to 5F4EH, the end.
5F0F
Call 62E5H, which reads the next byte of the file into Register A; the C FLAG is set at its end.
5F12
If the C FLAG is set (the end of the file), jump to 5F4EH, the end.
5F15
CP 20H FE 20
Compare Register A, the byte from the file, with 20H, a space.
5F17
If the Z FLAG is set (a space), jump back to 5F0FH.
5F1A
CP 2CH FE 2C
Compare Register A with 2CH, the comma before the next value.
5F1C
If the Z FLAG is set (a comma), jump to 5F4EH, the end.
5F1F
CP 0DH FE 0D
Compare Register A with 0DH, a carriage return.
5F21
If the NZ FLAG is set (another character, the start of the next value), jump to 5F2FH, which puts it back.
5F24
Call 62E5H, which reads the byte after the carriage return into Register A; the C FLAG is set at the end of the file.
5F27
If the C FLAG is set (the end of the file), jump to 5F4EH, the end.
5F2A
CP 0AH FE 0A
Compare Register A with 0AH, a line feed after the carriage return.
5F2C
If the Z FLAG is set (a line feed), jump to 5F4EH: it belongs to the end of the line.
5F2F
LD HL,(5B2AH) 2A 2A 5B
Load Register Pair HL with the word at 5B2AH, the area of the file in use.
5F32
LD BC,0007H 01 07 00
Load Register Pair BC with 0007H, the place of FCB+05H, the offset in the sector, in the area.
5F35
ADD HL,BC 09
Add Register Pair BC to Register Pair HL: Register Pair HL is FCB+05H of the file.
5F36
DEC (HL) 35
Decrement the offset at Register Pair HL: the byte just read is to be read again.
5F37
LD A,(HL) 7E
Load Register A with the offset at Register Pair HL.
5F38
CP FFH FE FF
Compare Register A with FFH: the Z FLAG is set when the offset was 00H, the byte was in the last sector.
5F3A
If the NZ FLAG is set (the byte is in this sector), jump to 5F4EH, the end.
5F3D
PUSH HL E5
Save Register Pair HL, FCB+05H, on the stack.
5F3E
PUSH DE D5
Save Register Pair DE, the end characters, on the stack.
5F3F
LD BC,FFFBH 01 FB FF
Load Register Pair BC with FFFBH, minus 5, from FCB+05H back to the FCB.
5F42
ADD HL,BC 09
Add Register Pair BC to Register Pair HL: Register Pair HL is the FCB of the file.
5F43
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE is the FCB.
5F44
Call 4445H, @BKSP of SYS0/SYS, which sets the file of the FCB at Register Pair DE back one record.
5F47
If the NZ FLAG is set (a disk error, its code in Register A), jump to 63FDH, which gives the error.
5F4A
POP DE D1
Restore Register Pair DE, the end characters, from the stack.
5F4B
POP HL E1
Restore Register Pair HL, FCB+05H, from the stack.
5F4C
LD (HL),FFH 36 FF
Store FFH at Register Pair HL, FCB+05H: the last byte of the sector before is read next.
5F4E
POP HL E1
Restore Register Pair HL with the place in the buffer after the value, saved at 5EC5H or 5F04H.
5F4F
LD (HL),00H 36 00
Store 00H at Register Pair HL, the end of the value in the buffer.
5F51
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the word at 40A7H, the ROM's input buffer.
5F54
DEC HL 2B
Decrement Register Pair HL to the byte before the buffer, as 2868H and 0E6CH take it.
5F55
LD A,E 7B
Load Register A with Register E, the second end character.
5F56
SUB 20H D6 20
Subtract 20H from Register A: the Z FLAG is set for a number.
5F58
If the Z FLAG is set (a number), jump to 5F62H.
5F5B
LD B,00H 06 00
Load Register B with 00H, the end byte for 2868H.
5F5D
Call 2868H in the ROM, which makes a temporary string of the characters after Register Pair HL up to the byte of Register B.
5F60
POP HL E1
Restore Register Pair HL, the text pointer, saved at 5E90H.
5F61
RET C9
Return to 2243H or 1F31H with the string, its descriptor in 4121H.
5F62
RST 10H D7
RST 10H: Register A is the first character of the number at Register Pair HL, spaces passed over.
5F63
Call 0E6CH in the ROM, which makes the number at Register Pair HL a value in 4121H.
5F66
POP HL E1
Restore Register Pair HL, the text pointer, saved at 5E90H.
5F67
RET C9
Return to 2243H in the ROM with the number in 4121H.
5F68
OR A B7
OR Register A with itself: the Z FLAG is set for a byte 00H.
5F69
RET Z C8
If the Z FLAG is set (a byte 00H), return without keeping it.
5F6A
LD (HL),A 77
Store Register A at Register Pair HL, the next place in the buffer.
5F6B
INC HL 23
Increment Register Pair HL to the next place in the buffer.
5F6C
DEC B 05
Decrement Register B, the count of the characters still allowed.
5F6D
RET NZ C0
If the NZ FLAG is set (room is left), return for the next character.
5F6E
POP BC C1
Remove the return address into Register Pair BC: the value has 255 characters.
5F6F
Jump to 5F4FH, which ends the value at Register Pair HL.
5F72H - Open File 0
5F72H for LOAD, RUN and MERGE (Register D 01H, input), 5F74H with the mode in Register D for SAVE (02H). Register A 00H, the file number; the open is done by OPEN's code at 6389H with Register Pair HL at the file name.
5F72
LD D,01H 16 01
Load Register D with 01H, the mode input, for LOAD, RUN and MERGE.
5F74
XOR A AF
Clear Register A to 00H, the file number 0, the file of LOAD and SAVE.
5F75
Jump to 6389H, OPEN's code, which opens file 0 with the name at Register Pair HL in the mode of Register D.
5F78H - RUN with a File Name and LOAD
5F78H is the DOS exit 41C7H from 1EA6H, RUN: with a line number (the C FLAG set) the ROM goes on; with a name the program is loaded and run (Register A AFH). 5F7BH is the vector 4188H, LOAD (Register A 00H, set to F1H by the option R). LOAD,R keeps the files open: the highest file number is made 0 while the program is cleared (1B4DH) and the variables reset. A program in memory form (the first byte FFH) is read at once (552BH, 57B2H); one in ASCII form is read a line at a time by the ROM's command input from file 0 (6030H, 5996H).
5F78
RET C D8
If the C FLAG is set (RUN with a line number), return to the ROM's RUN.
5F79
POP AF F1
Remove the return address of the call at 1EA6H into Register Pair AF: the ROM's RUN is passed over.
5F7A
OR AFH F6 AF
OR Register A with AFH: Register A is not 00H, the program is run; entered at 5F7BH by LOAD (the vector 4188H), the byte AFH is XOR A: Register A 00H, not run.
5F7C
PUSH AF F5
Save Register Pair AF, the run switch in Register A, on the stack.
5F7D
Call 5F72H, which opens file 0 with the name at Register Pair HL for input.
5F80
LD A,(5B50H) 3A 50 5B
Load Register A with the byte at 5B50H, the highest file number.
5F83
LD (5B4FH),A 32 4F 5B
Store Register A at 5B4FH, which keeps the highest file number during the load.
5F86
DEC HL 2B
Decrement Register Pair HL so that the RST 10H at 5F87H takes the character at Register Pair HL again.
5F87
RST 10H D7
RST 10H: Register A is the next character at Register Pair HL; the Z FLAG is set at the end of the statement.
5F88
If the Z FLAG is set (no option), jump to 5F98H with the run switch on the stack.
5F8B
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (5F8CH).
5F8C
DEFB 2CH 2C
The byte for the RST 08H at 5F8BH: 2CH, the comma before the option R.
5F8D
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (5F8EH).
5F8E
DEFB 52H 52
The byte for the RST 08H at 5F8DH: 52H, the letter R, the option that runs the program and keeps the files open.
5F8F
If the NZ FLAG is set (something follows the R), jump to 1997H in the ROM, Syntax error.
5F92
POP AF F1
Remove the run switch into Register Pair AF: the option R sets it.
5F93
XOR A AF
Clear Register A to 00H for the highest file number.
5F94
LD (5B50H),A 32 50 5B
Store Register A, 00H, at 5B50H while the program is cleared: no file but file 0 is closed.
5F97
OR F1H F6 F1
OR Register A with F1H: Register A is F1H, the program is run; entered at 5F98H without the option, the byte F1H is POP AF, the run switch from the stack.
5F99
LD (5B4EH),A 32 4E 5B
Store Register A at 5B4EH, the switch of running the program after it is loaded.
5F9C
LD HL,5A14H 21 14 5A
Load Register Pair HL with 5A14H, the byte that stands for a file area that is not open.
5F9F
LD (HL),00H 36 00
Store 00H at Register Pair HL, 5A14H, the mode closed.
5FA1
LD (5B2CH),HL 22 2C 5B
Store Register Pair HL, 5A14H, at 5B2CH, the table entry of file 0, so that NEW does not close file 0.
5FA4
Call 1B4DH in the ROM, NEW: the program is cleared, the variables reset and the files closed (60A1H).
5FA7
LD A,(5B4FH) 3A 4F 5B
Load Register A with the byte at 5B4FH, the highest file number kept at 5F83H.
5FAA
LD (5B50H),A 32 50 5B
Store Register A at 5B50H, the highest file number, as before.
5FAD
LD HL,(5B4CH) 2A 4C 5B
Load Register Pair HL with the word at 5B4CH, the area of file 0.
5FB0
LD (5B2CH),HL 22 2C 5B
Store Register Pair HL at 5B2CH, the table entry of file 0, as before.
5FB3
LD (5B2AH),HL 22 2A 5B
Store Register Pair HL at 5B2AH: file 0 is the file in use.
5FB6
INC HL 23
Increment Register Pair HL past the mode byte of the area (DBLDOS's code from here to 5FD7H).
5FB7
INC HL 23
Increment Register Pair HL past the position byte: Register Pair HL is the FCB of file 0.
5FB8
PUSH HL E5
Save Register Pair HL, the FCB, on the stack.
5FB9
POP IX DD E1
Restore Index Register IX with the FCB of file 0.
5FBB
Call 57D5H, which reads the first sector of the file: Register Pair DE is the buffer.
5FBE
LD A,(DE) 1A
Load Register A with the first byte of the file at Register Pair DE.
5FBF
INC A 3C
Increment Register A: the Z FLAG is set when the byte is FFH, a program in memory form.
5FC0
If the Z FLAG is set (memory form), jump to 5FCEH, which reads the program at once.
5FC2
PUSH IX DD E5
Save Index Register IX, the FCB, on the stack.
5FC4
POP DE D1
Restore Register Pair DE with the FCB, the register 443FH takes it in.
5FC5
Call 443FH, @REW of SYS0/SYS, which sets the file of the FCB at Register Pair DE back to its first sector.
5FC8
If the NZ FLAG is set (a disk error, its code in Register A), jump to 63FDH, which gives the error.
5FCB
Jump to 6030H, which takes the program's lines from the file through the ROM's command input (1A33H).
5FCE
LD HL,(40A0H) 2A A0 40
Load Register Pair HL with the word at 40A0H, the start of the string space.
5FD1
LD DE,FFAAH 11 AA FF
Load Register Pair DE with FFAAH, minus 56H, the room kept below the string space.
5FD4
ADD HL,DE 19
Add Register Pair DE to Register Pair HL: the top for the program; the C FLAG is set (taken by 552FH).
5FD5
Call 552BH, which tests the size of the file against the room and reads the program to 40A4H (57B2H).
5FD8
Call 1AF8H in the ROM, which sets the links of the lines: Register Pair HL is at the last byte of the end link.
5FDB
INC HL 23
Increment Register Pair HL past the end link: the end of the program.
5FDC
NOP 00
No operation; TRSDOS 2.1 has a second INC HL here (its own load had read the program a byte further).
5FDD
LD (40F9H),HL 22 F9 40
Store Register Pair HL at 40F9H, the end of the program, where the variables start.
5FE0
LD HL,5B50H 21 50 5B
Load Register Pair HL with 5B50H, the highest file number.
5FE3
LD A,(HL) 7E
Load Register A with the highest file number at Register Pair HL.
5FE4
LD (5B4FH),A 32 4F 5B
Store Register A at 5B4FH, which keeps the highest file number during 1B5DH.
5FE7
LD (HL),00H 36 00
Store 00H at Register Pair HL, 5B50H, while the variables are reset: no file is closed.
5FE9
Call 1B5DH in the ROM, which resets the variables as RUN does.
5FEC
LD A,(5B4FH) 3A 4F 5B
Load Register A with the byte at 5B4FH, the highest file number kept at 5FE5H.
5FEF
LD (5B50H),A 32 50 5B
Store Register A at 5B50H, the highest file number, as before.
5FF2
LD A,(5B4EH) 3A 4E 5B
Load Register A with the byte at 5B4EH, the switch of running the program.
5FF5
OR A B7
OR Register A with itself: the Z FLAG is set when the program is not run.
5FF6
If the Z FLAG is set (LOAD without R), jump to 1A19H in the ROM, READY.
5FF9
Jump to 1D1EH in the ROM, NEWSTT, which runs the program from its start.
5FFCH - The READY Exit: Close File 0
The DOS link 41ACH, called from 1A1CH before READY is shown, and called at the end of SAVE (5827H), of a LOAD in ASCII form (59EEH) and of a bad MERGE (6014H). Output goes back to the screen (2169H, which clears 5B2AH through 41BEH), file 0 is closed (6210H with Register A 00H), and Register Pair HL is the text pointer kept at 40DFH (1BAFH).
5FFC
Call 2169H in the ROM, which sends output to the screen again; it returns with Register A 00H.
5FFF
Call 6210H, which closes the file of Register A, file 0, the file of LOAD, SAVE and MERGE.
6002
Jump to 1BAFH in the ROM, which loads Register Pair HL with the word at 40DFH and returns.
6005H - LOAD: Out of Memory
Reached from 57B3H and 57B8H when the program in the file does not fit: the program in memory, partly overwritten or not, is cleared (NEW) before the error.
6005
Call 1B4DH in the ROM, NEW, which clears the program text and the variables.
6008
Jump to 197AH in the ROM, Out of memory, with the program cleared.
600BH - MERGE
The vector 418BH. File 0 is opened for input; nothing may follow the name (else file 0 is closed and Syntax error). A program in memory form (first byte FFH) is Bad file mode. The first byte is put back (FCB+05H less one), and the ROM's command input takes the lines from the file (1A33H, 5996H): each line with a number goes into the program, a line without one is Direct statement in file (6033H). TRSDOS 2.1's code.
600B
POP BC C1
Remove the return address of the vector call into Register Pair BC: MERGE ends at READY.
600C
Call 5F72H, which opens file 0 with the name at Register Pair HL for input.
600F
DEC HL 2B
Decrement Register Pair HL so that the RST 10H at 6010H takes the character at Register Pair HL again.
6010
RST 10H D7
RST 10H: Register A is the next character at Register Pair HL; the Z FLAG is set at the end of the statement.
6011
If the Z FLAG is set (nothing after the name), jump to 601AH.
6014
Call 5FFCH, which closes file 0 again before the error.
6017
Jump to 1997H in the ROM, Syntax error: something follows the file name.
601A
XOR A AF
Clear Register A to 00H: the program is not run at the end of the file.
601B
LD (5B4EH),A 32 4E 5B
Store Register A, 00H, at 5B4EH, the switch of running the program after it is loaded.
601E
Call 62E5H, which reads the first byte of file 0 into Register A; the C FLAG is set at the end of the file.
6021
If the C FLAG is set (an empty file), jump to 1A33H in the ROM, the command input.
6024
INC A 3C
Increment Register A: the Z FLAG is set when the first byte is FFH, a program in memory form.
6025
If the Z FLAG is set (memory form), jump to 63E3H, Bad file mode.
6028
LD HL,(5B2AH) 2A 2A 5B
Load Register Pair HL with the word at 5B2AH, the area of file 0, the file in use.
602B
LD BC,0007H 01 07 00
Load Register Pair BC with 0007H, the place of FCB+05H, the offset in the sector, in the area.
602E
ADD HL,BC 09
Add Register Pair BC to Register Pair HL: Register Pair HL is FCB+05H of file 0.
602F
DEC (HL) 35
Decrement the offset at Register Pair HL: the first byte is read again.
6030
Jump to 1A33H in the ROM, the command input, which now takes its lines from the file (5996H).
6033H - A Line Tokenized: Direct Statement in File
The DOS exit 41B2H, called from 1AA1H after a line has been tokenized, with the C FLAG set when it has a line number. A line without a number is run by the ROM (1D5AH), but not while the lines come from a file (LOAD in ASCII form, MERGE): then Direct statement in file.
6033
RET C D8
If the C FLAG is set (the line has a number), return to the ROM at 1AA4H, which puts it in the program.
6034
POP AF F1
Remove the return address 1AA4H into Register Pair AF.
6035
PUSH HL E5
Save Register Pair HL, the text pointer of the line, on the stack.
6036
LD HL,(5B2AH) 2A 2A 5B
Load Register Pair HL with the word at 5B2AH, the area of the file in use, 0000H when there is none.
6039
LD A,H 7C
Load Register A with Register H, the high byte of the word at 5B2AH.
603A
OR L B5
OR Register L into Register A: the Z FLAG is set when no file is in use.
603B
LD E,84H 1E 84
Load Register E with 84H, the code of Direct statement in file (error 67).
603D
If the NZ FLAG is set (the line came from a file), jump to 19A2H in the ROM, which gives the error of Register E.
6040
POP HL E1
Restore Register Pair HL, the text pointer of the line, from the stack.
6041
Jump to 1D5AH in the ROM, which runs the line typed.
6044H - SAVE
The vector 41A0H. File 0 is opened for output (Register D 02H). SAVE "name",A writes the program in ASCII form, as LIST does (2B2EH, the lines going to the file through 41C1H); without A the program is written in memory form by 57E5H. DBLDOS's 6055H-606EH: TRSDOS 2.1 wrote FFH and then the program a byte at a time through 624FH.
6044
LD D,02H 16 02
Load Register D with 02H, the mode output, in which 5F74H opens file 0.
6046
Call 5F74H, which opens file 0 with the name at Register Pair HL in the mode of Register D.
6049
DEC HL 2B
Decrement Register Pair HL so that the RST 10H at 604AH takes the character at Register Pair HL again.
604A
RST 10H D7
RST 10H: Register A is the next character at Register Pair HL; the Z FLAG is set at the end of the statement.
604B
If the Z FLAG is set (no option), jump to 6055H, which saves in memory form.
604E
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (604FH).
604F
DEFB 2CH 2C
The byte for the RST 08H at 604EH: 2CH, the comma before the option A.
6050
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (6051H).
6051
DEFB 41H 41
The byte for the RST 08H at 6050H: 41H, the letter A, the option of a program in ASCII form.
6052
Jump to 2B2EH in the ROM, LIST, whose lines go to file 0, the file in use.
6055
LD IX,(5B2CH) DD 2A 2C 5B
Load Index Register IX with the word at 5B2CH, the area of file 0 (DBLDOS's code to 606EH).
6059
INC IX DD 23
Increment Index Register IX past the mode byte of the area.
605B
INC IX DD 23
Increment Index Register IX past the position byte: Index Register IX is the FCB of file 0.
605D
LD HL,(40F9H) 2A F9 40
Load Register Pair HL with the word at 40F9H, the end of the program text.
6060
LD DE,(40A4H) ED 5B A4 40
Load Register Pair DE with the word at 40A4H, the start of the program text.
6064
OR A B7
OR Register A with itself to clear the C FLAG for the SBC.
6065
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL: the length of the program.
6067
INC HL 23
Increment Register Pair HL: one byte more for the FFH in front of the program.
6068
LD B,H 44
Load Register B with Register H, the high byte of the count.
6069
LD C,L 4D
Load Register C with Register L: Register Pair BC is the number of bytes to write.
606A
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL is the start of the program text.
606B
LD A,C 79
Load Register A with Register C, the low byte of the count, for 57E5H.
606C
Jump to 57E5H, which writes FFH and the program to file 0 and checks it by reading it back.
606FH - CLOSE
The vector 4185H, and from 60A4H (NEW, END) with Register A 00H and the Z FLAG set. CLOSE alone closes every file from the highest number down to file 0 (6210H for each, 6081H); CLOSE n, m, ... closes each file named, a # before the number allowed (6090H, 6089H). TRSDOS 2.1's code.
606F
LD BC,6210H 01 10 62
Load Register Pair BC with 6210H, the routine that closes one file.
6072
LD A,(5B50H) 3A 50 5B
Load Register A with the byte at 5B50H, the highest file number.
6075
If the NZ FLAG is set (numbers follow CLOSE), jump to 6090H.
6078
PUSH HL E5
Save Register Pair HL, the text pointer, on the stack.
6079
PUSH BC C5
Save Register Pair BC, 6210H, on the stack for 6082H.
607A
PUSH AF F5
Save Register Pair AF, the file number in Register A, on the stack.
607B
LD DE,6081H 11 81 60
Load Register Pair DE with 6081H, the return address after the file is closed.
607E
PUSH DE D5
Save Register Pair DE, 6081H, on the stack as the return address.
607F
PUSH BC C5
Save Register Pair BC, 6210H, on the stack as the address to go to.
6080
RET C9
Return to 6210H, which closes the file of Register A and returns to 6081H.
6081
POP AF F1
Restore Register Pair AF with the file number in Register A, saved at 607AH.
6082
POP BC C1
Restore Register Pair BC with 6210H, saved at 6079H.
6083
DEC A 3D
Decrement Register A to the next lower file number.
6084
If the P FLAG is set (the number is 0 or more), jump back to 6079H to close that file.
6087
POP HL E1
Restore Register Pair HL, the text pointer, saved at 6078H.
6088
RET C9
Return to the ROM with every file closed, file 0 the last.
6089
POP BC C1
Restore Register Pair BC with 6210H, saved at 609BH (the return of 60A0H).
608A
POP HL E1
Restore Register Pair HL, the text pointer after the file number, saved at 609AH.
608B
LD A,(HL) 7E
Load Register A with the character at Register Pair HL after the file number.
608C
CP 2CH FE 2C
Compare Register A with 2CH, the comma before another file number.
608E
RET NZ C0
If the NZ FLAG is set (no comma), return to the ROM: CLOSE is done.
608F
RST 10H D7
RST 10H: Register A is the character after the comma at Register Pair HL.
6090
PUSH BC C5
Save Register Pair BC, 6210H, on the stack for 609AH.
6091
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
6092
CP 23H FE 23
Compare Register A with 23H, the sign # before the file number, which may be left out.
6094
If the Z FLAG is set (a #), call 1D78H in the ROM, the code of RST 10H, which passes over it.
6097
Call 2B1CH in the ROM, which evaluates the expression at Register Pair HL as a byte in Register A, the file number.
609A
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: the text pointer is saved, Register Pair HL is 6210H.
609B
PUSH HL E5
Save Register Pair HL, 6210H, on the stack again for 6089H.
609C
LD DE,6089H 11 89 60
Load Register Pair DE with 6089H, the return address after the file is closed.
609F
PUSH DE D5
Save Register Pair DE, 6089H, on the stack as the return address.
60A0
JP (HL) E9
Jump to Register Pair HL, 6210H, which closes the file of Register A and returns to 6089H.
60A1H - NEW and END: Close the Files
The DOS exit 41BBH, called from 1B8CH (NEW, RUN, CLEAR) and 1DB0H (END): every file is closed through CLOSE (606FH) with the Z FLAG set. TRSDOS 2.1's code.
60A1
PUSH DE D5
Save Register Pair DE on the stack while the files are closed.
60A2
PUSH BC C5
Save Register Pair BC on the stack while the files are closed.
60A3
XOR A AF
Clear Register A to 00H and set the Z FLAG: CLOSE closes every file.
60A4
Call 606FH, CLOSE, which closes the files from the highest number (5B50H) down to 0.
60A7
POP BC C1
Restore Register Pair BC from the stack, saved at 60A2H.
60A8
POP DE D1
Restore Register Pair DE from the stack, saved at 60A1H.
60A9
XOR A AF
Clear Register A to 00H for the ROM's NEW or END, which goes on.
60AA
RET C9
Return to the ROM at 1B8FH or 1DB3H with the files closed.
60ABH - FIELD
The vector 417CH. FIELD n, w AS v$, ...: the file must be open in mode 03H, random (else Bad file mode; closed, Bad file number). Each string variable is pointed at w bytes of the record buffer, the area from +22H on, one field after the other. The total may be 256 bytes, the last field ending at the record's last byte (DBLDOS's 5D6AH; TRSDOS 2.1 allows 255).
60AB
Call 5E00H, which takes the file number at Register Pair HL: Register Pair BC is its area, Register A its mode.
60AE
If the Z FLAG is set (the file is not open), jump to 63E6H, Bad file number.
60B1
SUB 03H D6 03
Subtract 03H, the mode random, from Register A: Register A is 00H for a random file.
60B3
If the NZ FLAG is set (another mode), jump to 63E3H, Bad file mode.
60B6
LD DE,0022H 11 22 00
Load Register Pair DE with 0022H, the place of the record buffer in the file's area.
60B9
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL is the offset of the next field.
60BA
ADD HL,BC 09
Add Register Pair BC to Register Pair HL: the area plus 22H, or the last field plus its width.
60BB
LD B,A 47
Load Register B with Register A, the number of bytes of the record used so far.
60BC
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE is the next field, Register Pair HL the text.
60BD
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
60BE
CP 2CH FE 2C
Compare Register A with 2CH, the comma before the next field.
60C0
RET NZ C0
If the NZ FLAG is set (no comma), return to the ROM: FIELD is done.
60C1
PUSH DE D5
Save Register Pair DE, the address of the next field, on the stack.
60C2
PUSH BC C5
Save Register Pair BC, the bytes used in Register B, on the stack.
60C3
Call 2B1BH in the ROM, which passes over the comma and evaluates the width as a byte in Register A.
60C6
PUSH AF F5
Save Register Pair AF, the width in Register A, on the stack.
60C7
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (60C8H).
60C8
DEFB 41H 41
The byte for the RST 08H at 60C7H: 41H, the letter A of AS.
60C9
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (60CAH).
60CA
DEFB 53H 53
The byte for the RST 08H at 60C9H: 53H, the letter S of AS.
60CB
Call 260DH in the ROM, which finds the variable named at Register Pair HL: Register Pair DE is its address.
60CE
Call 0AF4H in the ROM, which gives a Type mismatch error unless the variable just found (40AFH) is a string.
60D1
POP AF F1
Restore Register Pair AF with the width in Register A, saved at 60C6H.
60D2
POP BC C1
Restore Register Pair BC with the bytes used in Register B, saved at 60C2H.
60D3
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: the text is saved, Register Pair HL is the field's address.
60D4
LD C,A 4F
Load Register C with Register A, the width of the field.
60D5
ADD A,B 80
Add Register B, the bytes used, to Register A: the C FLAG is set when the total passes 255.
60D6
If the C FLAG is set (past 255), call 5D6AH, which allows exactly 256 and else gives FIELD overflow; TRSDOS 2.1 has JP C,63F8H.
60D9
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL is the variable, Register Pair DE the field.
60DA
LD (HL),C 71
Store Register C, the width, at Register Pair HL, the length in the variable's descriptor.
60DB
INC HL 23
Increment Register Pair HL to the address in the descriptor.
60DC
LD (HL),E 73
Store Register E, the low byte of the field's address, at Register Pair HL.
60DD
INC HL 23
Increment Register Pair HL to the high byte of the address in the descriptor.
60DE
LD (HL),D 72
Store Register D, the high byte of the field's address, at Register Pair HL: the variable is the field.
60DF
LD B,00H 06 00
Load Register B with 00H, so that Register Pair BC is the width for the ADD at 60BAH.
60E1
POP HL E1
Restore Register Pair HL, the text pointer, saved at 60D3H.
60E2
Jump to 5D6EH, which goes on at 60B9H or ends a full record; TRSDOS 2.1 has JP 60B9H.
60E5H - LSET and RSET
The vectors 419AH (60E5H, RSET: OR 37H, the C FLAG clear) and 4197H (60E6H, LSET: 37H is SCF, the C FLAG set). The string is put into the variable's own characters, a field of a file's buffer: LSET from the left, spaces after it, RSET from the right, spaces before it; a longer string is cut to the field's length. A variable whose characters are still in the program text is first given new room in the string space (6118H). TRSDOS 2.1's code.
60E5
OR 37H F6 37
OR Register A with 37H for RSET: the C FLAG is clear; entered at 60E6H for LSET, the byte 37H is SCF, the C FLAG set.
60E7
PUSH AF F5
Save Register Pair AF, the C FLAG of LSET or RSET, on the stack.
60E8
Call 260DH in the ROM, which finds the variable named at Register Pair HL: Register Pair DE is its address.
60EB
Call 0AF4H in the ROM, which gives a Type mismatch error unless the variable just found (40AFH) is a string.
60EE
PUSH DE D5
Save Register Pair DE, the address of the variable, on the stack.
60EF
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (60F0H).
60F0
DEFB D5H D5
The byte for the RST 08H at 60EFH: D5H, the token of the equals sign.
60F1
Call 2337H in the ROM, which evaluates the expression at Register Pair HL, the string to put in, into 4121H.
60F4
POP BC C1
Restore Register Pair BC with the address of the variable, saved at 60EEH.
60F5
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: the text is saved, Register Pair HL is the flags of 60E7H.
60F6
PUSH HL E5
Save Register Pair HL, the flags of LSET or RSET, on the stack again.
60F7
PUSH BC C5
Save Register Pair BC, the address of the variable, on the stack.
60F8
Call 29D7H in the ROM, which checks that the value is a string and frees it: Register Pair HL is its descriptor.
60FB
LD B,(HL) 46
Load Register B with the length of the string at Register Pair HL.
60FC
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: the descriptor is saved, Register Pair HL is the variable.
60FD
LD A,(HL) 7E
Load Register A with the length of the variable's string at Register Pair HL, the length of the field.
60FE
LD C,A 4F
Load Register C with Register A, the length of the field.
60FF
PUSH BC C5
Save Register Pair BC on the stack: Register B the string's length, Register C the field's.
6100
PUSH HL E5
Save Register Pair HL, the address of the variable, on the stack.
6101
PUSH AF F5
Save Register Pair AF, the length of the field in Register A and the flags left by 29D7H, on the stack.
6102
INC HL 23
Increment Register Pair HL to the address of the characters in the variable's descriptor.
6103
LD E,(HL) 5E
Load Register E with the low byte of the address of the variable's characters at Register Pair HL.
6104
INC HL 23
Increment Register Pair HL to the high byte of the address of the characters.
6105
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE is the variable's characters.
6106
OR A B7
OR Register A with itself, the length of the field: the Z FLAG is set when it is 0.
6107
If the Z FLAG is set (a field of no characters), jump to 616AH: nothing is done.
610A
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the word at 40A4H, the start of the program text.
610D
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE, the characters; the NC FLAG is set when they are below the program.
610E
If the NC FLAG is set (the characters are below the program, in a file's buffer), jump to 6140H.
6111
LD HL,(40F9H) 2A F9 40
Load Register Pair HL with the word at 40F9H, the end of the program text.
6114
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE, the characters; the C FLAG is set when they are after the program.
6115
If the C FLAG is set (the characters are in the variables or the string space), jump to 6140H.
6118
LD E,C 59
Load Register E with Register C, the length of the field.
6119
LD D,00H 16 00
Load Register D with 00H, so that Register Pair DE is the length of the field.
611B
LD HL,(40A0H) 2A A0 40
Load Register Pair HL with the word at 40A0H, the start of the string space.
611E
ADD HL,DE 19
Add Register Pair DE, the length, to Register Pair HL.
611F
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE is the start of the string space plus the length.
6120
LD HL,(40D6H) 2A D6 40
Load Register Pair HL with the word at 40D6H, the next free byte of the string space.
6123
Call 1C90H in the ROM, the compare of RST 18H: the C FLAG is set when Register Pair HL is below Register Pair DE.
6126
If the C FLAG is set (the string space is short), jump to 617EH.
6129
POP AF F1
Restore Register Pair AF with the length of the field in Register A, saved at 6101H or 6192H.
612A
LD A,C 79
Load Register A with Register C, the length of the field.
612B
Call 28BFH in the ROM, which takes room for Register A characters in the string space: Register Pair DE is its address.
612E
POP HL E1
Restore Register Pair HL with the address of the variable, saved at 6100H.
612F
POP BC C1
Restore Register Pair BC with the two lengths, saved at 60FFH.
6130
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: the variable is saved, Register Pair HL is the string's descriptor.
6131
PUSH DE D5
Save Register Pair DE, the new room, on the stack.
6132
PUSH BC C5
Save Register Pair BC, the two lengths, on the stack.
6133
Call 29D7H in the ROM, which frees the string's descriptor at Register Pair HL again: Register Pair HL is its descriptor.
6136
POP BC C1
Restore Register Pair BC with the two lengths, saved at 6132H.
6137
POP DE D1
Restore Register Pair DE with the new room, saved at 6131H.
6138
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: the descriptor is saved, Register Pair HL is the variable.
6139
PUSH BC C5
Save Register Pair BC, the two lengths, on the stack for 6146H.
613A
PUSH HL E5
Save Register Pair HL, the address of the variable, on the stack for 6141H.
613B
INC HL 23
Increment Register Pair HL to the address of the characters in the variable's descriptor.
613C
LD (HL),E 73
Store Register E, the low byte of the new room, at Register Pair HL.
613D
INC HL 23
Increment Register Pair HL to the high byte of the address of the characters.
613E
LD (HL),D 72
Store Register D, the high byte of the new room, at Register Pair HL: the variable's characters are in the string space.
613F
PUSH AF F5
Save Register Pair AF on the stack, a word for the POP AF at 6140H.
6140
POP AF F1
Remove the word saved at 6101H or 613FH into Register Pair AF.
6141
POP HL E1
Restore Register Pair HL with the address of the variable, saved at 6100H or 613AH.
6142
INC HL 23
Increment Register Pair HL to the address of the characters in the variable's descriptor.
6143
LD E,(HL) 5E
Load Register E with the low byte of the address of the variable's characters at Register Pair HL.
6144
INC HL 23
Increment Register Pair HL to the high byte of the address of the characters.
6145
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE is the field.
6146
POP BC C1
Restore Register Pair BC: Register B the string's length, Register C the field's.
6147
POP HL E1
Restore Register Pair HL with the string's descriptor, saved at 60FCH or 6138H.
6148
PUSH DE D5
Save Register Pair DE, the field, on the stack.
6149
INC HL 23
Increment Register Pair HL to the address of the characters in the string's descriptor.
614A
LD E,(HL) 5E
Load Register E with the low byte of the address of the string's characters at Register Pair HL.
614B
INC HL 23
Increment Register Pair HL to the high byte of the address of the characters.
614C
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE is the string's characters.
614D
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL is the string's characters.
614E
POP DE D1
Restore Register Pair DE with the field, saved at 6148H.
614F
LD A,C 79
Load Register A with Register C, the length of the field.
6150
SUB B 90
Subtract Register B, the string's length, from Register A: the C FLAG is set when the string is longer.
6151
LD A,B 78
Load Register A with Register B, the string's length, the number of characters to copy.
6152
If the NC FLAG is set (the string fits), jump to 6156H.
6155
LD A,C 79
Load Register A with Register C, the field's length: the string is cut to it.
6156
LD B,A 47
Load Register B with Register A, the number of characters to copy.
6157
LD A,C 79
Load Register A with Register C, the length of the field.
6158
SUB B 90
Subtract Register B, the characters copied, from Register A: the spaces needed.
6159
LD C,A 4F
Load Register C with Register A, the number of spaces.
615A
POP AF F1
Restore Register Pair AF with the C FLAG of LSET (set) or RSET (clear), saved at 60E7H.
615B
If the NC FLAG is set (RSET), call 6174H, which puts the spaces before the string.
615E
INC B 04
Increment Register B, so that the DEC at 615FH tests it.
615F
DEC B 05
Decrement Register B, the characters left to copy: the Z FLAG is set when none is left.
6160
If the Z FLAG is set (all copied), jump to 616FH.
6163
LD A,(HL) 7E
Load Register A with the next character of the string at Register Pair HL.
6164
LD (DE),A 12
Store Register A at Register Pair DE, the next place of the field.
6165
INC HL 23
Increment Register Pair HL to the next character of the string.
6166
INC DE 13
Increment Register Pair DE to the next place of the field.
6167
Jump back to 615FH for the next character of the string into the field.
616A
POP BC C1
Remove the word saved at 6101H into Register Pair BC.
616B
POP BC C1
Remove the word saved at 6100H into Register Pair BC.
616C
POP BC C1
Remove the word saved at 60FFH into Register Pair BC.
616D
POP BC C1
Remove the word saved at 60FCH into Register Pair BC.
616E
POP BC C1
Remove the word saved at 60F6H into Register Pair BC; the C FLAG is clear from 6106H.
616F
If the C FLAG is set (LSET), call 6174H, which puts the spaces after the string.
6172
POP HL E1
Restore Register Pair HL, the text pointer, saved at 60F5H.
6173
RET C9
Return to the ROM with the field set by LSET or RSET.
6174
LD A,20H 3E 20
Load Register A with 20H, a space, the character that fills the rest of the field.
6176
INC C 0C
Increment Register C, so that the DEC at 6177H tests it.
6177
DEC C 0D
Decrement Register C, the spaces left: the Z FLAG is set when none is left.
6178
RET Z C8
If the Z FLAG is set (no space left), return with Register Pair DE after the spaces.
6179
LD (DE),A 12
Store Register A, a space, at Register Pair DE in the field.
617A
INC DE 13
Increment Register Pair DE to the next place of the field.
617B
Jump back to 6177H for the next space with Register C the count.
617E
POP AF F1
Restore Register Pair AF with the flags of 29D7H at 60F8H, saved at 6101H.
617F
POP HL E1
Restore Register Pair HL with the address of the variable, saved at 6100H.
6180
POP BC C1
Restore Register Pair BC with the two lengths, saved at 60FFH.
6181
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: the variable is saved, Register Pair HL is the string's descriptor.
6182
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE is the string's descriptor.
6183
If the NZ FLAG is set (as 29D7H left it), jump to 618FH.
6186
PUSH BC C5
Save Register Pair BC, the two lengths, on the stack.
6187
LD A,B 78
Load Register A with Register B, the string's length.
6188
Call 2857H in the ROM, which takes room for a string of Register A characters, its descriptor at 40D3H.
618B
Call 2884H in the ROM, which makes the string of 40D3H a temporary string.
618E
POP BC C1
Restore Register Pair BC with the two lengths, saved at 6186H.
618F
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: Register Pair HL is the variable.
6190
PUSH BC C5
Save Register Pair BC, the two lengths, on the stack.
6191
PUSH HL E5
Save Register Pair HL, the address of the variable, on the stack.
6192
PUSH AF F5
Save Register Pair AF on the stack, for the POP AF at 6129H.
6193
Jump to 6129H, which takes the new room for the variable.
6196-61EA
DEFB D7H,CFH,24H,CFH,28H,CDH,1CH,2BH,D5H,7EH,FEH,2CH,C2H,B2H,61H,D7H,CDH,00H,5EH,FEH,01H,C2H,E3H,63H,CDH,F8H,5DH,AFH,F5H,CFH,29H,F1H,E3H,F5H,7DH,B7H,CAH,4AH,1EH,E5H,CDH,57H,28H,EBH,C1H,F1H,F5H,CAH,E2H,61H,CDH,84H,03H,FEH,01H,CAH,DDH,61H,77H,23H,0DH,C2H,C3H,61H,F1H,CDH,69H,21H,C3H,84H,28H,F1H,E1H,C3H,AAH,1DH,CDH,E5H,62H,DAH,ECH,63H,C3H,D0H,61H D7 CF 24 CF 28 CD 1C 2B D5 7E FE 2C C2 B2 61 D7 CD 00 5E FE 01 C2 E3 63 CD F8 5D AF F5 CF 29 F1 E3 F5 7D B7 CA 4A 1E E5 CD 57 28 EB C1 F1 F5 CA E2 61 CD 84 03 FE 01 CA DD 61 77 23 0D C2 C3 61 F1 CD 69 21 C3 84 28 F1 E1 C3 AA 1D CD E5 62 DA EC 63 C3 D0 61
Eighty-five bytes that no vector or instruction reaches: as instructions an INPUT$(n [,f]) function, n characters from the keyboard (0384H, BREAK ending the program at 1DAAH) or from the file f open for input (62E5H). TRSDOS 2.1 has the same bytes here.
61EBH - EOF
The vector 4161H. EOF(f) is -1 when the next byte of the file is past its end: the next sector (FCB+0AH-+0BH) is the end of file sector (FCB+0CH-+0DH) and the offset (FCB+05H) is the end of file offset (FCB+08H); else 0. A file open for output is Bad file mode. DBLDOS has SUB (HL) at 61FBH and 6200H, TRSDOS 2.1 CP (HL): with CP, Register A at 620AH was the byte of the end sector, not the difference, so EOF was -1 at another sector when that byte was 00H.
61EB
Call 5E0AH, which takes the file number from 4121H: Register Pair BC is its area, Register A its mode.
61EE
CP 02H FE 02
Compare Register A with 02H, the mode output.
61F0
If the Z FLAG is set (a file open for output), jump to 63E3H, Bad file mode.
61F3
LD HL,000FH 21 0F 00
Load Register Pair HL with 000FH, the place of FCB+0DH in the area.
61F6
ADD HL,BC 09
Add Register Pair BC to Register Pair HL: Register Pair HL is FCB+0DH, the high byte of the end of file sector.
61F7
LD A,(HL) 7E
Load Register A with the high byte of the end of file sector at Register Pair HL.
61F8
DEC HL 2B
Decrement Register Pair HL to FCB+0CH, the low byte of the end of file sector.
61F9
LD E,(HL) 5E
Load Register E with the low byte of the end of file sector at Register Pair HL.
61FA
DEC HL 2B
Decrement Register Pair HL to FCB+0BH, the high byte of the next sector.
61FB
SUB (HL) 96
Subtract the high byte of the next sector at Register Pair HL from Register A; TRSDOS 2.1 has CP (HL).
61FC
If the NZ FLAG is set (the sectors differ), jump to 620AH with Register A not 00H: not the end.
61FE
DEC HL 2B
Decrement Register Pair HL to FCB+0AH, the low byte of the next sector.
61FF
LD A,E 7B
Load Register A with Register E, the low byte of the end of file sector.
6200
SUB (HL) 96
Subtract the low byte of the next sector at Register Pair HL from Register A; TRSDOS 2.1 has CP (HL).
6201
If the NZ FLAG is set (the sectors differ), jump to 620AH with Register A not 00H: not the end.
6203
DEC HL 2B
Decrement Register Pair HL to FCB+09H, the record length, passed over.
6204
DEC HL 2B
Decrement Register Pair HL to FCB+08H, the end of file offset.
6205
LD A,(HL) 7E
Load Register A with the end of file offset at Register Pair HL.
6206
DEC HL 2B
Decrement Register Pair HL to FCB+07H, the directory record, passed over.
6207
DEC HL 2B
Decrement Register Pair HL to FCB+06H, the drive, passed over.
6208
DEC HL 2B
Decrement Register Pair HL to FCB+05H, the offset of the next byte in the sector.
6209
SUB (HL) 96
Subtract the offset at Register Pair HL from Register A: 00H at the end of the file.
620A
SUB 01H D6 01
Subtract 01H from Register A: the C FLAG is set only when Register A was 00H, the end.
620C
SBC A,A 9F
Subtract Register A and the C FLAG from Register A: FFH at the end, else 00H.
620D
Jump to 098DH in the ROM, which makes Register A, FFH or 00H, the integer -1 or 0 in 4121H.
6210H - Close a File
Called by CLOSE (6080H, 60A0H) and 5FFFH with Register A the file number. A file that is not open is passed over; one open for input is only cleared; others are closed by @CLOSE (4428H). The 34 bytes of the area before the buffer (mode, position and the FCB) are then cleared. TRSDOS 2.1's code.
6210
Call 5E0DH, which takes the file number in Register A: Register Pair BC is its area, Register A its mode.
6213
RET Z C8
If the Z FLAG is set (the file is not open), return.
6214
CP 01H FE 01
Compare Register A, the mode, with 01H, input.
6216
If the Z FLAG is set (a file open for input), jump to 6227H, which only clears the area.
6219
PUSH BC C5
Save Register Pair BC, the file's area, on the stack.
621A
XOR A AF
Clear Register A to 00H, the mode closed, stored before @CLOSE.
621B
LD (BC),A 02
Store Register A, 00H, at Register Pair BC, the mode of the area.
621C
INC BC 03
Increment Register Pair BC past the mode byte.
621D
INC BC 03
Increment Register Pair BC past the position byte: Register Pair BC is the FCB.
621E
LD D,B 50
Load Register D with Register B, the high byte of the FCB.
621F
LD E,C 59
Load Register E with Register C: Register Pair DE is the FCB.
6220
Call 4428H, @CLOSE of SYS0/SYS (SYS3/SYS), which closes the file of the FCB at Register Pair DE.
6223
If the NZ FLAG is set (a disk error, its code in Register A), jump to 63FDH, which gives the error.
6226
POP BC C1
Restore Register Pair BC, the file's area, from the stack.
6227
LD D,22H 16 22
Load Register D with 22H, the 34 bytes of the mode, the position and the FCB.
6229
XOR A AF
Clear Register A to 00H, the byte the area is cleared with.
622A
LD (BC),A 02
Store Register A, 00H, at Register Pair BC in the area.
622B
INC BC 03
Increment Register Pair BC to the next byte of the area.
622C
DEC D 15
Decrement Register D, the bytes of the area left to clear.
622D
If the NZ FLAG is set (bytes are left), jump back to 622AH.
6230
RET C9
Return with the file closed and its area cleared.
6231H - LOC and LOF
The vectors 4164H (6231H, LOC) and 4167H (6242H, LOF). LOC(f) is the number of the next sector of the file (FCB+0AH-+0BH), LOF(f) its end of file sector (FCB+0CH-+0DH), each as an integer; a file that is not open is Bad file number. DBLDOS's 6232H-6233H: TRSDOS 2.1 has CALL 63E3H at 6231H, so its LOC always gave Bad file mode.
6231
Call 5E0AH, which takes the file number from 4121H: Register Pair BC is its area; TRSDOS 2.1 has CALL 63E3H.
6234
If the Z FLAG is set (the file is not open), jump to 63E6H, Bad file number.
6237
LD HL,000CH 21 0C 00
Load Register Pair HL with 000CH, the place of FCB+0AH, the next sector, in the area.
623A
ADD HL,BC 09
Add Register Pair BC to Register Pair HL: Register Pair HL is the word of the FCB.
623B
LD E,(HL) 5E
Load Register E with the low byte of the word at Register Pair HL.
623C
INC HL 23
Increment Register Pair HL to the high byte of the word.
623D
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE is the sector number.
623E
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL is the sector number.
623F
Jump to 0A9AH in the ROM, which stores Register Pair HL at 4121H as an integer.
6242
Call 5E0AH, which takes the file number from 4121H: Register Pair BC is its area, for LOF.
6245
If the Z FLAG is set (the file is not open), jump to 63E6H, Bad file number.
6248
LD HL,000EH 21 0E 00
Load Register Pair HL with 000EH, the place of FCB+0CH, the end of file sector, in the area.
624B
Jump to 623AH, which gives the word of the FCB as the result.
624E
DEFB E1H E1
A byte that no instruction reaches (E1H, as an instruction POP HL); TRSDOS 2.1 has the same byte here.
624FH - A Byte to the File
Entered from 59CAH with Register A the character for the file in use (5B2AH). For a file open for input nothing is written (1DFDH). The position in the line (the area's second byte) is set to 0 by a carriage return and counted up by each character from 20H on; the byte goes to the file through the ROM's 001BH with Register Pair DE the FCB, a disk error going to 63FDH. TRSDOS 2.1's code.
624F
PUSH HL E5
Save Register Pair HL on the stack while the byte is written.
6250
PUSH AF F5
Save Register Pair AF, the character in Register A, on the stack.
6251
LD HL,(5B2AH) 2A 2A 5B
Load Register Pair HL with the word at 5B2AH, the area of the file in use.
6254
LD A,(HL) 7E
Load Register A with the mode of the file at Register Pair HL.
6255
CP 01H FE 01
Compare Register A, the mode of the file, with 01H, input.
6257
If the Z FLAG is set (a file open for input), jump to 1DFDH in the ROM, which restores Register Pair AF and Register Pair HL and returns.
625A
POP AF F1
Restore Register Pair AF, the character in Register A, from the stack.
625B
PUSH DE D5
Save Register Pair DE on the stack while the byte is written.
625C
PUSH BC C5
Save Register Pair BC on the stack while the byte is written.
625D
INC HL 23
Increment Register Pair HL to the position in the line, the second byte of the area.
625E
LD B,00H 06 00
Load Register B with 00H, the new position and the zero for the ADC.
6260
PUSH AF F5
Save Register Pair AF, the character in Register A, on the stack.
6261
LD D,(HL) 56
Load Register D with the position in the line at Register Pair HL.
6262
CP 0DH FE 0D
Compare Register A, the character, with 0DH, the carriage return.
6264
LD (HL),B 70
Store Register B, 00H, at Register Pair HL: the position for a carriage return.
6265
If the Z FLAG is set (a carriage return), jump to 626CH with the position 0.
6267
ADD A,E0H C6 E0
Add E0H to Register A: the C FLAG is set for a character from 20H on, one that takes a place on the line.
6269
LD A,D 7A
Load Register A with Register D, the old position in the line.
626A
ADC A,B 88
Add Register B, 00H, and the C FLAG to Register A: the position plus one for a printed character.
626B
LD (HL),A 77
Store Register A, the new position, at Register Pair HL.
626C
INC HL 23
Increment Register Pair HL to the FCB of the file.
626D
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE is the FCB.
626E
POP AF F1
Restore Register Pair AF, the character in Register A.
626F
PUSH AF F5
Save Register Pair AF, the character, on the stack again.
6270
Call 001BH in the ROM, which sends the character of Register A to the device or file of Register Pair DE.
6273
If the NZ FLAG is set (a disk error, its code in Register A), jump to 63FDH, which gives the error.
6276
POP AF F1
Restore Register Pair AF, the character in Register A.
6277
POP BC C1
Restore Register Pair BC from the stack, saved at 625CH.
6278
POP DE D1
Restore Register Pair DE from the stack, saved at 625BH.
6279
POP HL E1
Restore Register Pair HL from the stack, saved at 624FH.
627A
RET C9
Return with the character written to the file.
627BH - GET and PUT
The vectors 417FH (627CH, GET: XOR A) and 4182H (627BH, PUT: OR AFH, the byte AFH being the XOR A of GET). GET f [,r] and PUT f [,r] on a file open in mode 03H, random: the record r (the next one when not given; 0 is Bad record number) is set by @POSN (4442H). GET reads it into the buffer (4436H); a record past the end gives a buffer of 00H. PUT writes the buffer and reads it back (@VERF, 443CH; TRSDOS 2.1 has @WRITE, 4439H, at 62BFH).
627B
OR AFH F6 AF
OR Register A with AFH for PUT: Register A is not 00H; entered at 627CH for GET, the byte AFH is XOR A: Register A 00H.
627D
LD (5B28H),A 32 28 5B
Store Register A at 5B28H, the switch of GET (00H) or PUT.
6280
Call 5E00H, which takes the file number at Register Pair HL: Register Pair BC is its area, Register A its mode.
6283
CP 03H FE 03
Compare Register A, the mode, with 03H, random.
6285
If the NZ FLAG is set (not a random file), jump to 63E3H, Bad file mode.
6288
PUSH BC C5
Save Register Pair BC, the file's area, on the stack.
6289
PUSH HL E5
Save Register Pair HL, the text pointer, on the stack.
628A
LD HL,000CH 21 0C 00
Load Register Pair HL with 000CH, the place of FCB+0AH, the next sector, in the area.
628D
ADD HL,BC 09
Add Register Pair BC to Register Pair HL: Register Pair HL is FCB+0AH.
628E
LD E,(HL) 5E
Load Register E with the low byte of the next sector at Register Pair HL.
628F
INC HL 23
Increment Register Pair HL to the high byte of the next sector.
6290
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE is the next sector.
6291
INC DE 13
Increment Register Pair DE: the record number counted from 1, the record when none is given.
6292
POP HL E1
Restore Register Pair HL, the text pointer, from the stack.
6293
LD A,(HL) 7E
Load Register A with the character at Register Pair HL after the file number.
6294
CP 2CH FE 2C
Compare Register A with 2CH, the comma before a record number.
6296
If the Z FLAG is set (a record number), call 1E45H in the ROM, which evaluates it into Register Pair DE.
6299
DEC HL 2B
Decrement Register Pair HL so that the RST 10H at 629AH takes the character at Register Pair HL again.
629A
RST 10H D7
RST 10H: Register A is the next character at Register Pair HL; the Z FLAG is set at the end of the statement.
629B
If the NZ FLAG is set (more after the statement), jump to 1997H in the ROM, Syntax error.
629E
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: the text is saved, Register Pair HL is the area.
629F
PUSH HL E5
Save Register Pair HL, the file's area, on the stack.
62A0
LD A,E 7B
Load Register A with Register E, the low byte of the record number.
62A1
OR D B2
OR Register D into Register A: the Z FLAG is set when the record number is 0.
62A2
If the Z FLAG is set (record 0), jump to 63F5H, Bad record number.
62A5
DEC DE 1B
Decrement Register Pair DE: the record counted from 0, as @POSN takes it.
62A6
LD B,D 42
Load Register B with Register D, the high byte of the record.
62A7
LD C,E 4B
Load Register C with Register E: Register Pair BC is the record.
62A8
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE is the file's area.
62A9
INC DE 13
Increment Register Pair DE past the mode byte.
62AA
INC DE 13
Increment Register Pair DE past the position byte: Register Pair DE is the FCB.
62AB
Call 4442H, @POSN of SYS0/SYS, which sets the file of the FCB at Register Pair DE to record Register Pair BC.
62AE
If the Z FLAG is set (the record is in the file), jump to 62C8H.
62B0
CP 1CH FE 1C
Compare Register A, the error code, with 1CH, END OF FILE ENCOUNTERED.
62B2
If the Z FLAG is set (error 1CH), jump to 62B9H: the record is past the end.
62B4
CP 1DH FE 1D
Compare Register A, the error code, with 1DH, RECORD NUMBER OUT OF RANGE.
62B6
If the NZ FLAG is set (another error), jump to 63FDH, which gives it.
62B9
LD A,(5B28H) 3A 28 5B
Load Register A with the byte at 5B28H, the switch of GET or PUT.
62BC
OR A B7
OR Register A with itself: the Z FLAG is set for GET.
62BD
If the Z FLAG is set (GET past the end), jump to 62D7H, which clears the buffer.
62BF
Call 443CH, @VERF of SYS0/SYS, which writes the record and reads it back; TRSDOS 2.1 has CALL 4439H, @WRITE.
62C2
If the NZ FLAG is set (a disk error, its code in Register A), jump to 63FDH, which gives the error.
62C5
POP AF F1
Remove the file's area, saved at 629FH, into Register Pair AF.
62C6
POP HL E1
Restore Register Pair HL, the text pointer, saved at 629EH.
62C7
RET C9
Return to the ROM after PUT with the record written.
62C8
LD A,(5B28H) 3A 28 5B
Load Register A with the byte at 5B28H, the switch of GET or PUT.
62CB
OR A B7
OR Register A with itself: the Z FLAG is set for GET.
62CC
If the NZ FLAG is set (PUT), jump back to 62BFH, which writes the record.
62CE
Call 4436H, @READ of SYS0/SYS, which reads the record of the FCB at Register Pair DE into the buffer.
62D1
If the NZ FLAG is set (a disk error, its code in Register A), jump to 63FDH, which gives the error.
62D4
POP BC C1
Remove the file's area, saved at 629FH, into Register Pair BC.
62D5
POP HL E1
Restore Register Pair HL, the text pointer, saved at 629EH.
62D6
RET C9
Return to the ROM after GET with the record in the buffer.
62D7
POP HL E1
Restore Register Pair HL with the file's area, saved at 629FH.
62D8
LD DE,0022H 11 22 00
Load Register Pair DE with 0022H, the place of the record buffer in the area.
62DB
ADD HL,DE 19
Add Register Pair DE to Register Pair HL: Register Pair HL is the record buffer.
62DC
LD B,00H 06 00
Load Register B with 00H, the count of 256 bytes.
62DE
XOR A AF
Clear Register A to 00H, the byte the buffer is cleared with.
62DF
LD (HL),A 77
Store Register A, 00H, at Register Pair HL in the record buffer.
62E0
INC HL 23
Increment Register Pair HL to the next byte of the buffer.
62E1
Decrement Register B and jump back to 62DFH while it is not zero: 256 bytes.
62E3
POP HL E1
Restore Register Pair HL, the text pointer, saved at 629EH.
62E4
RET C9
Return to the ROM after GET with an empty record.
62E5H - A Byte from the File
Called with a file in use (5B2AH): the next byte of the file is read through the ROM's 0013H with Register Pair DE the FCB. At the end of the file (error 1CH) the C FLAG is set; any other error goes to 63FDH. TRSDOS 2.1's code.
62E5
PUSH BC C5
Save Register Pair BC on the stack while the byte is read.
62E6
PUSH HL E5
Save Register Pair HL on the stack while the byte is read.
62E7
LD HL,(5B2AH) 2A 2A 5B
Load Register Pair HL with the word at 5B2AH, the area of the file in use.
62EA
PUSH DE D5
Save Register Pair DE on the stack while the byte is read.
62EB
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE is the file's area.
62EC
INC DE 13
Increment Register Pair DE past the mode byte.
62ED
INC DE 13
Increment Register Pair DE past the position byte: Register Pair DE is the FCB.
62EE
Call 0013H in the ROM, which reads a byte from the device or file of Register Pair DE into Register A.
62F1
If the Z FLAG is set (a byte was read), jump to 62FAH, which clears the C FLAG.
62F3
CP 1CH FE 1C
Compare Register A, the error code, with 1CH, END OF FILE ENCOUNTERED.
62F5
If the NZ FLAG is set (another error), jump to 63FDH, which gives it.
62F8
SCF 37
Set the C FLAG: the end of the file has been reached.
62F9
LD B,B7H 06 B7
Load Register B with B7H, which passes over 62FAH; entered at 62FAH, B7H is OR A, which clears the C FLAG.
62FB
POP DE D1
Restore Register Pair DE from the stack, saved at 62EAH.
62FC
POP HL E1
Restore Register Pair HL from the stack, saved at 62E6H.
62FD
POP BC C1
Restore Register Pair BC from the stack, saved at 62E5H.
62FE
RET C9
Return with the byte in Register A, or the C FLAG set at the end of the file.
62FFH - The File Name into the FCB
Called by OPEN (6391H) and KILL (63C4H) with Register Pair BC the file's area. The name string, 1 to 23 characters (24 or more, or none, is Bad file name), is copied to 5DC8H in capitals with an end byte 00H and given to @FSPEC (441CH), which fills the FCB. DBLDOS's 630DH is CP 18H, TRSDOS 2.1's CP 17H, which allowed 22 characters.
62FF
PUSH BC C5
Save Register Pair BC, the file's area, on the stack.
6300
Call 2337H in the ROM, which evaluates the expression at Register Pair HL, the file name, into 4121H.
6303
PUSH HL E5
Save Register Pair HL, the text pointer after the name, on the stack.
6304
Call 29D7H in the ROM, which checks that the value is a string and frees it: Register Pair HL is its descriptor.
6307
LD A,(HL) 7E
Load Register A with the length of the name at Register Pair HL.
6308
OR A B7
OR Register A with itself: the Z FLAG is set for an empty name.
6309
If the Z FLAG is set (an empty name), jump to 63F2H, Bad file name.
630C
CP 18H FE 18
Compare Register A, the length, with 18H, 24; TRSDOS 2.1 has 17H here.
630E
If the NC FLAG is set (24 characters or more), jump to 63F2H, Bad file name.
6311
INC HL 23
Increment Register Pair HL to the address of the characters in the descriptor.
6312
LD C,(HL) 4E
Load Register C with the low byte of the address of the characters at Register Pair HL.
6313
INC HL 23
Increment Register Pair HL to the high byte of the address of the characters.
6314
LD B,(HL) 46
Load Register B with the high byte at Register Pair HL: Register Pair BC is the name.
6315
LD HL,5DC8H 21 C8 5D
Load Register Pair HL with 5DC8H, the buffer of the name in capitals.
6318
LD E,A 5F
Load Register E with Register A, the length of the name.
6319
LD A,(BC) 0A
Load Register A with the next character of the name at Register Pair BC.
631A
CP 61H FE 61
Compare Register A with 61H, the small letter a.
631C
If the C FLAG is set (below a), jump to 6326H.
631F
CP 7BH FE 7B
Compare Register A with 7BH, one more than the small letter z.
6321
If the NC FLAG is set (above z), jump to 6326H.
6324
XOR 20H EE 20
XOR Register A with 20H: the small letter becomes a capital.
6326
LD (HL),A 77
Store Register A at Register Pair HL in the buffer.
6327
INC HL 23
Increment Register Pair HL to the next place of the buffer.
6328
INC BC 03
Increment Register Pair BC to the next character of the name.
6329
DEC E 1D
Decrement Register E, the characters of the name left to copy.
632A
If the NZ FLAG is set (characters are left), jump back to 6319H.
632D
LD (HL),E 73
Store Register E, 00H, at Register Pair HL: the end of the name.
632E
POP HL E1
Restore Register Pair HL, the text pointer after the name, saved at 6303H.
632F
POP DE D1
Restore Register Pair DE with the file's area, saved at 62FFH.
6330
LD B,D 42
Load Register B with Register D, the high byte of the area.
6331
LD C,E 4B
Load Register C with Register E: Register Pair BC is the area again.
6332
PUSH BC C5
Save Register Pair BC, the file's area, on the stack.
6333
PUSH HL E5
Save Register Pair HL, the text pointer, on the stack.
6334
LD HL,5DC8H 21 C8 5D
Load Register Pair HL with 5DC8H, the name in capitals.
6337
INC DE 13
Increment Register Pair DE past the mode byte.
6338
INC DE 13
Increment Register Pair DE past the position byte: Register Pair DE is the FCB.
6339
Call 441CH of SYS0/SYS (SYS1/SYS), which parses the file specification at Register Pair HL into the FCB at Register Pair DE.
633C
If the NZ FLAG is set (a bad specification), jump to 63F2H, Bad file name.
633F
OR A B7
OR Register A with itself: the Z FLAG is set when 441CH returned 00H.
6340
If the NZ FLAG is set (Register A not 00H), jump to 63F2H, Bad file name.
6343
POP HL E1
Restore Register Pair HL, the text pointer, saved at 6333H.
6344
POP BC C1
Restore Register Pair BC, the file's area, saved at 6332H.
6345
RET C9
Return with the FCB holding the file specification.
6346H - NAME
The vector 418EH: the NAME statement is not supported.
6346
Jump to 1E4AH in the ROM, Illegal function call (the same in TRSDOS 2.1).
6349H - OPEN
The vector 4179H. OPEN "m", f, "name": the mode is the first letter of the string, O (02H, output), I (01H, input), R (03H, random) or, new in DBLDOS (5216H), E (output at the end of the file); file numbers 1 to the highest; a file already open is File already open. The name is put in the FCB (62FFH); I opens a file that must exist (@OPEN, 4424H), the others open or make it (@INIT, 4420H), with the buffer in the area at +22H and records of 256 bytes. DBLDOS's 6372H-6374H and 63B6H-63B8H lead to 5216H and 521FH. 6389H is also entered from 5F75H for file 0.
6349
LD BC,2169H 01 69 21
Load Register Pair BC with 2169H, the ROM's end of an input or output statement.
634C
PUSH BC C5
Save Register Pair BC, 2169H, on the stack as the return address at the end.
634D
Call 2337H in the ROM, which evaluates the expression at Register Pair HL, the mode string, into 4121H.
6350
PUSH HL E5
Save Register Pair HL, the text pointer after the mode, on the stack.
6351
Call 29D7H in the ROM, which checks that the value is a string and frees it: Register Pair HL is its descriptor.
6354
LD A,(HL) 7E
Load Register A with the length of the mode string at Register Pair HL.
6355
OR A B7
OR Register A with itself: the Z FLAG is set for an empty string.
6356
If the Z FLAG is set (no mode), jump to 63E3H, Bad file mode.
6359
INC HL 23
Increment Register Pair HL to the address of the characters in the descriptor.
635A
LD C,(HL) 4E
Load Register C with the low byte of the address of the characters at Register Pair HL.
635B
INC HL 23
Increment Register Pair HL to the high byte of the address of the characters.
635C
LD B,(HL) 46
Load Register B with the high byte at Register Pair HL: Register Pair BC is the mode string.
635D
LD A,(BC) 0A
Load Register A with the first character of the mode string at Register Pair BC.
635E
AND DFH E6 DF
AND Register A with DFH: a small letter becomes a capital.
6360
LD D,02H 16 02
Load Register D with 02H, the mode output, for O.
6362
CP 4FH FE 4F
Compare Register A, the mode letter, with 4FH, the letter O.
6364
If the Z FLAG is set (O), jump to 6375H with Register D 02H.
6367
LD D,01H 16 01
Load Register D with 01H, the mode input, for I.
6369
CP 49H FE 49
Compare Register A, the mode letter, with 49H, the letter I.
636B
If the Z FLAG is set (I), jump to 6375H with Register D 01H.
636E
LD D,03H 16 03
Load Register D with 03H, the mode random, for R.
6370
CP 52H FE 52
Compare Register A, the mode letter, with 52H, the letter R.
6372
Call 5216H, which keeps R or makes Register D 04H for E, else Bad file mode; TRSDOS 2.1 has JP NZ,63E3H here.
6375
POP HL E1
Restore Register Pair HL, the text pointer after the mode, saved at 6350H.
6376
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (6377H).
6377
DEFB 2CH 2C
The byte for the RST 08H at 6376H: 2CH, the comma after the mode.
6378
PUSH DE D5
Save Register Pair DE, the mode in Register D, on the stack.
6379
CP 23H FE 23
Compare Register A, the character after the comma, with 23H, the sign #, which may be given.
637B
If the Z FLAG is set (a #), call 1D78H in the ROM, the code of RST 10H, which passes over it.
637E
Call 2B1CH in the ROM, which evaluates the expression at Register Pair HL as a byte in Register E and Register A, the file number.
6381
RST 08H CF
RST 08H: the ROM's syntax check of the byte at Register Pair HL against the byte that follows (6382H).
6382
DEFB 2CH 2C
The byte for the RST 08H at 6381H: 2CH, the comma before the file name.
6383
LD A,E 7B
Load Register A with Register E, the file number.
6384
OR A B7
OR Register A with itself: the Z FLAG is set for file 0, which OPEN may not use.
6385
If the Z FLAG is set (file 0), jump to 63E6H, Bad file number.
6388
CP D5H FE D5
Compare Register A with D5H, an instruction whose result nothing tests; entered at 6389H from 5F75H, the byte D5H is PUSH DE, the mode.
638A
Call 5E0DH, which takes the file number in Register A: Register Pair BC is its area; the NZ FLAG is set when it is open.
638D
If the NZ FLAG is set (the file is open), jump to 63EFH, File already open.
6390
PUSH BC C5
Save Register Pair BC, the file's area, on the stack.
6391
Call 62FFH, which puts the file name at Register Pair HL into the FCB of the area at Register Pair BC.
6394
LD (40DFH),HL 22 DF 40
Store Register Pair HL, the text pointer after the name, at 40DFH until 63BCH.
6397
POP HL E1
Restore Register Pair HL with the file's area, saved at 6390H.
6398
POP AF F1
Restore Register Pair AF with the mode in Register A, the Register D saved at 6378H or 6389H.
6399
PUSH AF F5
Save Register Pair AF, the mode, on the stack again for 5220H.
639A
PUSH HL E5
Save Register Pair HL, the file's area, on the stack for 521FH.
639B
LD (5B2AH),HL 22 2A 5B
Store Register Pair HL, the file's area, at 5B2AH: the file is the one in use.
639E
LD B,00H 06 00
Load Register B with 00H, the record length of 256 bytes for the open.
63A0
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE is the file's area.
63A1
INC DE 13
Increment Register Pair DE past the mode byte.
63A2
INC DE 13
Increment Register Pair DE past the position byte: Register Pair DE is the FCB.
63A3
LD HL,0020H 21 20 00
Load Register Pair HL with 0020H, from the FCB to the record buffer.
63A6
ADD HL,DE 19
Add Register Pair DE to Register Pair HL: Register Pair HL is the buffer, the area plus 22H.
63A7
CP 01H FE 01
Compare Register A, the mode, with 01H, input.
63A9
If the Z FLAG is set (input), jump to 63B0H, which opens a file that must exist.
63AB
Call 4420H, @INIT of SYS0/SYS (SYS2/SYS), which opens the file of the FCB at Register Pair DE or makes it.
63AE
Jump to 63B3H, which tests the result of the open in the NZ FLAG.
63B0
Call 4424H, @OPEN of SYS0/SYS (SYS2/SYS), which opens the file of the FCB at Register Pair DE.
63B3
If the NZ FLAG is set (a disk error, its code in Register A), jump to 63FDH, which gives the error.
63B6
Jump to 521FH, which positions a file of the mode E at its end and stores the mode; TRSDOS 2.1 has POP HL, POP AF, LD (HL),A here.
63B9
INC HL 23
Increment Register Pair HL to the position byte of the area (entered from 5235H with the mode stored).
63BA
LD (HL),00H 36 00
Store 00H at Register Pair HL: the position in the line is 0.
63BC
LD HL,(40DFH) 2A DF 40
Load Register Pair HL with the word at 40DFH, the text pointer after the name, kept at 6394H.
63BF
RET C9
Return to 2169H, the end of OPEN, with the file open and in use.
63C0H - KILL
The vector 4191H. The name is put in the FCB of file 0 (62FFH), the file is opened (@OPEN, it must exist) and killed (@KILL, 442CH), and file 0 is marked closed. TRSDOS 2.1's code.
63C0
XOR A AF
Clear Register A to 00H, the file number 0, whose FCB KILL uses.
63C1
Call 5E0DH, which takes the file number in Register A: Register Pair BC is the area of file 0.
63C4
Call 62FFH, which puts the file name at Register Pair HL into the FCB of file 0's area at Register Pair BC.
63C7
PUSH HL E5
Save Register Pair HL, the text pointer after the name, on the stack.
63C8
LD HL,(5B2CH) 2A 2C 5B
Load Register Pair HL with the word at 5B2CH, the area of file 0.
63CB
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE is the area of file 0.
63CC
INC DE 13
Increment Register Pair DE past the mode byte.
63CD
INC DE 13
Increment Register Pair DE past the position byte: Register Pair DE is the FCB.
63CE
LD B,00H 06 00
Load Register B with 00H, the record length of 256 bytes.
63D0
Call 4424H, @OPEN of SYS0/SYS (SYS2/SYS), which opens the file of the FCB at Register Pair DE.
63D3
If the NZ FLAG is set (a disk error, its code in Register A), jump to 63FDH, which gives the error.
63D6
Call 442CH, @KILL of SYS0/SYS (SYS3/SYS), which kills the file of the FCB at Register Pair DE.
63D9
If the NZ FLAG is set (a disk error, its code in Register A), jump to 63FDH, which gives the error.
63DC
LD HL,(5B2CH) 2A 2C 5B
Load Register Pair HL with the word at 5B2CH, the area of file 0.
63DF
LD (HL),00H 36 00
Store 00H at Register Pair HL, the mode of file 0: closed.
63E1
POP HL E1
Restore Register Pair HL, the text pointer after the name, saved at 63C7H.
63E2
RET C9
Return to the ROM after KILL with the file gone from the disk.
63E3H - The Errors of Disk BASIC
Each entry loads Register E with the code of an error, 2 x (number - 1), and the others pass over it inside LD BC instructions; 19A2H gives the error, whose long message SYS7/SYS shows. 63FDH turns a DOS error code in Register A into one of these through the table 640BH, and keeps the DOS code at 5B29H for CMD"E". TRSDOS 2.1's code.
63E3
LD E,6CH 1E 6C
Load Register E with 6CH, the code of Bad file mode (error 55).
63E5
LD BC,681EH 01 1E 68
Load Register Pair BC with 681EH, which passes over 63E6H-63E7H; entered at 63E6H, 1EH 68H is LD E,68H, Bad file number (error 53).
63E8
LD BC,661EH 01 1E 66
Load Register Pair BC with 661EH, which passes over 63E9H-63EAH; entered at 63E9H, 1EH 66H is LD E,66H, Internal error (error 52).
63EB
LD BC,7C1EH 01 1E 7C
Load Register Pair BC with 7C1EH, which passes over 63ECH-63EDH; entered at 63ECH, 1EH 7CH is LD E,7CH, Input past end (error 63).
63EE
LD BC,6E1EH 01 1E 6E
Load Register Pair BC with 6E1EH, which passes over 63EFH-63F0H; entered at 63EFH, 1EH 6EH is LD E,6EH, File already open (error 56).
63F1
LD BC,801EH 01 1E 80
Load Register Pair BC with 801EH, which passes over 63F2H-63F3H; entered at 63F2H, 1EH 80H is LD E,80H, Bad file name (error 65).
63F4
LD BC,7E1EH 01 1E 7E
Load Register Pair BC with 7E1EH, which passes over 63F5H-63F6H; entered at 63F5H, 1EH 7EH is LD E,7EH, Bad record number (error 64).
63F7
LD BC,641EH 01 1E 64
Load Register Pair BC with 641EH, which passes over 63F8H-63F9H; entered at 63F8H, 1EH 64H is LD E,64H, FIELD overflow (error 51).
63FA
Jump to 19A2H in the ROM, which gives the error of Register E.
63FD
LD B,00H 06 00
Load Register B with 00H, so that Register Pair BC is the DOS error code when Register C is loaded.
63FF
LD HL,640AH 21 0A 64
Load Register Pair HL with 640AH, the byte before the table of 640BH, which starts with the code 01H.
6402
LD C,A 4F
Load Register C with Register A, the DOS error code.
6403
ADD HL,BC 09
Add Register Pair BC to Register Pair HL: Register Pair HL is the table byte of the DOS error code.
6404
LD E,(HL) 5E
Load Register E with the BASIC error code at Register Pair HL.
6405
LD (5B29H),A 32 29 5B
Store Register A, the DOS error code, at 5B29H for CMD"E".
6408
Jump to 19A2H in the ROM, which gives the error of Register E.
640BH - The DOS Error Codes as BASIC Errors
One byte for each DOS error code 01H-27H (its SYS4/SYS message): 72H Disk I/O error (58), 80H Bad file name (65), 88H Disk write protected (69), 66H Internal error (52), 6AH File not found (54), 8AH File access denied (70), 86H Too many files (68), 7AH Disk full (62). The last byte, at 6431H, is also the first byte of file 0's area (5C61H, 5C74H), which the start-up clears: it is for code 27H, which no DOS file gives. TRSDOS 2.1's table.
640B-6411
DEFB 72H,72H,72H,72H,72H,72H,72H 72 72 72 72 72 72 72
The codes 01H-07H, the read errors (PARITY ERROR DURING HEADER READ to ATTEMPTED TO READ SYSTEM DATA RECORD): 72H, Disk I/O error.
6412
DEFB 80H 80
The code 08H, DEVICE NOT AVAILABLE: 80H, Bad file name.
6413-6418
DEFB 72H,72H,72H,72H,72H,72H 72 72 72 72 72 72
The codes 09H-0EH, the write errors (PARITY ERROR DURING HEADER WRITE to WRITE FAULT ON DISK DRIVE): 72H, Disk I/O error.
6419
DEFB 88H 88
The code 0FH, WRITE PROTECTED DISKETTE: 88H, Disk write protected.
641A
DEFB 66H 66
The code 10H, ILLEGAL LOGICAL FILE NUMBER: 66H, Internal error.
641B-641C
DEFB 72H,72H 72 72
The codes 11H and 12H, DIRECTORY READ ERROR and DIRECTORY WRITE ERROR: 72H, Disk I/O error.
641D
DEFB 80H 80
The code 13H, ILLEGAL FILE NAME: 80H, Bad file name.
641E-6421
DEFB 72H,72H,72H,72H 72 72 72 72
The codes 14H-17H, GAT READ ERROR to HIT WRITE ERROR: 72H, Disk I/O error.
6422
DEFB 6AH 6A
The code 18H, FILE NOT IN DIRECTORY: 6AH, File not found.
6423
DEFB 8AH 8A
The code 19H, FILE ACCESS DENIED: 8AH, File access denied.
6424
DEFB 86H 86
The code 1AH, DIRECTORY SPACE FULL: 86H, Too many files.
6425
DEFB 7AH 7A
The code 1BH, DISK SPACE FULL: 7AH, Disk full.
6426-6427
DEFB 66H,66H 66 66
The codes 1CH and 1DH, END OF FILE ENCOUNTERED and RECORD NUMBER OUT OF RANGE: 66H, Internal error.
6428
DEFB 7AH 7A
The code 1EH, DIRECTORY FULL - CAN'T EXTEND FILE: 7AH, Disk full.
6429
DEFB 66H 66
The code 1FH, PROGRAM NOT FOUND: 66H, Internal error.
642A
DEFB 80H 80
The code 20H, ILLEGAL DRIVE NUMBER: 80H, Bad file name.
642B-642E
DEFB 66H,66H,66H,66H 66 66 66 66
The codes 21H-24H, NO DEVICE SPACE AVAILABLE to ATTEMPTED TO LOAD READ ONLY MEMORY: 66H, Internal error.
642F
DEFB 8AH 8A
The code 25H, ILLEGAL ACCESS ATTEMPTED TO PROTECTED FILE: 8AH, File access denied.
6430
DEFB 66H 66
The code 26H, FILE NOT OPEN: 66H, Internal error.
6431
DEFB DEH DE
The code 27H: DEH, which SYS7/SYS shows as Unprintable error; the start-up clears this byte, the first of file 0's area at 6431H.