5202
LD A,0EH 3E 0E
Load Register A with 0EH, the display code that turns the cursor on.
5204
Self-Modifying Code
GOSUB to the routine whose address is the operand 5205H: ROM 0033H, which displays the character in Register A, in the file. BASIC/CMD stores 6562H there at its 655CH for the first command line after a start with a command (its startup hook takes the line from there and puts 0033H back).
5207
LD A,(4289H) 3A 89 42
Load Register A with the byte at 4289H, SYS0/SYS's system flags.
520A
BIT 5,A CB 6F
Test bit 5 of Register A (4289H): set while a chain file supplies the keys.
520C
If the Z FLAG is set (no chain file), JUMP to 521AH to wait for the first key.
520E
PUSH BC C5
Chain file: save Register Pair BC (5202H) on the stack, where the ROM's INLIN keeps its caller's Register Pair BC (as its 036BH does).
520F
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the 16-bit value at 40A7H, the ROM's pointer to the input buffer.
5212
LD B,F0H 06 F0
Load Register B with F0H (240), the most characters in a line.
5214
GOSUB to ROM 05D9H, the line input, which reads up to Register B characters into the buffer at Register Pair HL (here from the chain file, through the keyboard driver) and returns the CARRY FLAG for BREAK and Register B = the characters typed.
5217
JUMP to 53C5H to check the line for SYS18/SYS's commands.
521A
GOSUB to ROM 0049H, which waits for a key and returns it in Register A.
521D
PUSH AF F5
Save Register Pair AF (Register A = the first key) on the stack.
521E
LD A,(63FAH) 3A FA 63
Load Register A with the byte at 63FAH, the operand of BASIC/CMD's OR nn at 63F9H: 00H normally, not 00H with option AB (RUN-ONLY) or as SYS19/SYS stores it at its 524EH.
5221
OR A B7
OR Register A (the byte from 63FAH) with itself to set the flags: the Z FLAG is set if it is 00H.
5222
If the NZ FLAG is set (no direct command may be typed), JUMP to ROM 2831H for ILLEGAL DIRECT.
5225
POP AF F1
Restore Register Pair AF from the stack: Register A = the first key.
5226
LD L,00H 2E 00
Self-Modifying Code
Load Register L with the first key of the line before, the operand 5227H (00H in the file; stored at 522FH).
5228
CP 60H FE 60
Compare Register A (the first key) against 60H, the code of the shifted @ key.
522A
If the NZ FLAG is set (Register A is not 60H), JUMP to 522EH.
522C
LD A,40H 3E 40
Load Register A with 40H: the shifted @ counts as @.
522E
PUSH AF F5
Save Register Pair AF (Register A = the first key) on the stack, above 1A7EH.
522F
LD (5227H),A 32 27 52
Self-Modifying Code
Store Register A (the first key) at 5227H, the operand of LD L,nn at 5226H: the key of the line before, for the next line.
5232
CP 3AH FE 3A
Compare Register A (the first key) against 3AH, a colon.
5234
If the Z FLAG is set (a colon), JUMP to 5271H.
5236
CP 0AH FE 0A
Compare Register A (the first key) against 0AH, the code of the down arrow.
5238
If the Z FLAG is set (the down arrow), JUMP to 527CH to start from the current line.
523A
CP 5BH FE 5B
Compare Register A (the first key) against 5BH, the code of the up arrow.
523C
If the Z FLAG is set (the up arrow), JUMP to 527CH to start from the current line.
523E
CP 2EH FE 2E
Compare Register A (the first key) against 2EH, a period.
5240
If the Z FLAG is set (a period), JUMP to 527CH to start from the current line.
5242
CP 2CH FE 2C
Compare Register A (the first key) against 2CH, a comma.
5244
If the Z FLAG is set (a comma), JUMP to 527CH to start from the current line.
5246
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the 16-bit value at 40A4H, the ROM's pointer to the first program line.
5249
CP 3BH FE 3B
Compare Register A (the first key) against 3BH, a semicolon.
524B
If the Z FLAG is set (a semicolon), JUMP to 524FH with the Z FLAG still set.
524D
CP 1BH FE 1B
Compare Register A (the first key) against 1BH, the code of shift-up arrow.
524F
If the Z FLAG is set (a semicolon or shift-up arrow), JUMP to 537AH to list the first line, at Register Pair HL.
5252
LD DE,FFFFH 11 FF FF
Load Register Pair DE with FFFFH (65535), a number above every line: the search stops at the last line.
5255
CP 1AH FE 1A
Compare Register A (the first key) against 1AH, the code of shift-down arrow.
5257
If the Z FLAG is set (shift-down arrow), JUMP to 5280H to find the last line.
5259
CP 2FH FE 2F
Compare Register A (the first key) against 2FH, a slash.
525B
If the Z FLAG is set (a slash), JUMP to 5280H to find the last line.
525D
CP 40H FE 40
Compare Register A (the first key) against 40H, the character @.
525F
If the Z FLAG is set (@), JUMP to 527CH to start from the current line.
5261
POP AF F1
Any other key: restore Register Pair AF from the stack, Register A = the key (the stack holds 1A7EH again).
5262
PUSH BC C5
Save Register Pair BC (5202H) on the stack, as the ROM's INLIN does with its caller's Register Pair BC at 036BH.
5263
LD HL,53C5H 21 C5 53
Load Register Pair HL with 53C5H, SYS18/SYS's check of the typed line.
5266
PUSH HL E5
Push Register Pair HL (53C5H) on the stack: the line input returns there, in place of INLIN's 0374H.
5267
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the 16-bit value at 40A7H, the ROM's pointer to the input buffer.
526A
LD B,F0H 06 F0
Load Register B with F0H (240), the most characters in a line.
526C
LD C,B 48
Load Register C with Register B (240), as the line input does at 05DFH: the buffer size.
526D
PUSH HL E5
Push Register Pair HL (the input buffer) on the stack, as the line input does at 05D9H.
526E
JUMP into ROM 05E3H, the line input just after its CALL 0049H at 05E0H, so that the key in Register A becomes the line's first character and the rest of the line is read.
5271
LD DE,0000H 11 00 00
Self-Modifying Code
A colon: load Register Pair DE with the number of the first line of the last colon or @ listing, the operand 5272H (0000H in the file; stored at 536EH).
5274
CP L BD
Compare Register A (the colon) with Register L, the first key of the line before.
5275
If the Z FLAG is set (a colon again), JUMP to 5280H to go back from that line.
5277
LD A,L 7D
Load Register A with Register L, the first key of the line before.
5278
CP 40H FE 40
Compare Register A (that key) against 40H, the character @.
527A
If the Z FLAG is set (after an @ listing), JUMP to 5280H to go back from its first line.
527C
LD DE,(40ECH) ED 5B EC 40
Load Register Pair DE with the 16-bit value at 40ECH, the ROM's current line for LIST and EDIT (its DOT).
5280
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the 16-bit value at 40A4H, the ROM's pointer to the first program line.
5283
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, the count of lines passed.
5286
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the low byte of the first line's link field.
5287
INC HL 23
Increment Register Pair HL to the high byte of the first line's link field.
5288
OR (HL) B6
OR Register A (the link's low byte) with the byte at Register Pair HL: the Z FLAG is set for 0000H, no program.
5289
DEC HL 2B
Decrement Register Pair HL back to the first line's start.
528A
If the Z FLAG is set (no program), JUMP to 537AH, which lists nothing from the end marker at Register Pair HL.
FIND THE LINE LOOP
Register Pair HL = the line being tested, Register Pair DE = the line number wanted, Register Pair BC = the lines passed.
528D
INC HL 23
Increment Register Pair HL, 1 of 3, from the line's start towards its number.
528E
INC HL 23
Increment Register Pair HL, 2 of 3, to the low byte of the line's number (52A7H loops back here with Register Pair HL one byte into the line).
528F
INC HL 23
Increment Register Pair HL, 3 of 3, to the high byte of the line's number.
5290
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the high byte of this line's number.
5291
CP D BA
Compare Register A (the high byte) with Register D, the high byte of the number wanted: the CARRY FLAG is set if this line's number is lower.
5292
DEC HL 2B
Decrement Register Pair HL to the low byte of the line's number (DEC HL does not change the flags).
5293
If the NZ FLAG is set (the high bytes differ), JUMP to 5297H with the flags of that compare.
5295
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the low byte of this line's number.
5296
CP E BB
Compare Register A (the low byte) with Register E, the low byte of the number wanted: the Z FLAG is set on an exact match, the CARRY FLAG if this line's number is lower.
5297
DEC HL 2B
Decrement Register Pair HL, 1 of 2, back towards the line's start.
5298
DEC HL 2B
Decrement Register Pair HL, 2 of 2: Register Pair HL = the line's start, its link field.
5299
If the NO CARRY FLAG is set (this line's number is not below the one wanted), JUMP to 52ADH: found.
529B
PUSH HL E5
Save Register Pair HL (this line's address) on the stack.
529C
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the low byte of this line's link.
529D
INC HL 23
Increment Register Pair HL to the high byte of this line's link.
529E
LD H,(HL) 66
Load Register H with the byte at Register Pair HL, the high byte of the link.
529F
LD L,A 6F
Load Register L with Register A, the low byte. Register Pair HL = the next line.
52A0
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the low byte of the next line's link field.
52A1
INC HL 23
Increment Register Pair HL to the high byte of the next line's link field.
52A2
OR (HL) B6
OR Register A (the low byte) with the byte at Register Pair HL: the Z FLAG is set if the next line is the end marker.
52A3
If the Z FLAG is set (this was the last line), JUMP to 52A9H.
52A5
INC BC 03
Increment Register Pair BC, the count of lines passed.
52A6
POP AF F1
Restore Register Pair AF from the stack, discarding the address saved at 529BH.
52A7
LOOP back to 528EH with Register Pair HL one byte into the next line.
52A9
POP HL E1
The last line: restore Register Pair HL from the stack, the last line's address saved at 529BH.
52AA
POP AF F1
Restore Register Pair AF from the stack: Register A = the first key, pushed at 522EH (the stack holds 1A7EH again).
52AB
JUMP to 52BFH with Register A = the key and Register Pair HL = the last line.
52AD
POP DE D1
Found: restore Register Pair DE from the stack: Register D = the first key, pushed with its flags at 522EH (the stack holds 1A7EH again). POP does not change the flags.
52AE
LD A,D 7A
Load Register A with Register D, the first key. LD does not change the flags (the Z FLAG is set if the line found has the number wanted).
52AF
If the NZ FLAG is set (the line found has a higher number: the current line does not exist), JUMP to 52B8H.
52B1
LD DE,0001H 11 01 00
Load Register Pair DE with 0001H: one line on.
52B4
CP 0AH FE 0A
Compare Register A (the first key) against 0AH, the down arrow.
52B6
If the Z FLAG is set (the down arrow), JUMP to 52CEH with Register Pair DE = +1.
52B8
LD DE,FFFFH 11 FF FF
Load Register Pair DE with FFFFH: one line back (minus 1).
52BB
CP 5BH FE 5B
Compare Register A (the first key) against 5BH, the up arrow.
52BD
If the Z FLAG is set (the up arrow), JUMP to 52CEH with Register Pair DE = minus 1.
52BF
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H: no step, the listing starts at the line found.
52C2
CP 40H FE 40
Compare Register A (the first key) against 40H, the character @.
52C4
If the Z FLAG is set (@), JUMP to 52CEH with Register Pair DE = 0.
52C6
LD DE,FFF3H 11 F3 FF
Load Register Pair DE with FFF3H: 13 lines back (minus 13).
52C9
CP 3AH FE 3A
Compare Register A (the first key) against 3AH, a colon.
52CB
If the NZ FLAG is set (a period, a comma, a slash, shift-down arrow, or the down arrow at a line that does not exist), JUMP to 5379H to list or edit the line at Register Pair HL.
52CE
PUSH AF F5
Save Register Pair AF (Register A = the first key) on the stack.
52CF
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the step (+1, minus 1, 0 or minus 13), Register Pair DE = the line found.
52D0
ADD HL,BC 09
Add Register Pair BC (the number of lines before the line found) to Register Pair HL: Register Pair HL = the index of the target line from the first line.
52D1
LD A,H 7C
Load Register A with Register H, the high byte of the target index.
52D2
CP FFH FE FF
Compare Register A (the high byte) against FFH: the Z FLAG is set if the index is below 0 (before the first line).
52D4
If the NZ FLAG is set (the index is 0 or more), JUMP to 52D9H.
52D6
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H: start at the first line instead.
52D9
PUSH BC C5
Save Register Pair BC (the index of the line found) on the stack.
52DA
LD B,H 44
Load Register B with Register H, the high byte of the target index.
52DB
LD C,L 4D
Load Register C with Register L, the low byte. Register Pair BC = the target index.
52DC
POP HL E1
Restore Register Pair HL from the stack: the index of the line found.
52DD
OR A B7
OR Register A with itself to clear the CARRY FLAG for the SBC HL,BC at 52DEH.
52DE
SBC HL,BC ED 42
Subtract Register Pair BC (the target index) from Register Pair HL (the index of the line found): the number of lines from the target to the line found.
52E0
PUSH HL E5
Save Register Pair HL (that number of lines) on the stack.
52E1
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the 16-bit value at 40A4H, the first program line.
STEP TO THE TARGET LINE
Register Pair BC counts down the lines to pass; Register Pair HL = the current line, Register Pair DE = the next.
52E4
LD E,(HL) 5E
Load Register E with the byte at Register Pair HL, the low byte of this line's link field.
52E5
INC HL 23
Increment Register Pair HL to the high byte of this line's link field.
52E6
LD D,(HL) 56
Load Register D with the byte at Register Pair HL, the high byte. Register Pair DE = the next line.
52E7
DEC HL 2B
Decrement Register Pair HL back to this line's start.
52E8
LD A,B 78
Load Register A with Register B, the high byte of the lines left to pass.
52E9
OR C B1
OR Register A with Register C, the low byte: the Z FLAG is set when none are left.
52EA
DEC BC 0B
Decrement Register Pair BC, the lines left to pass (DEC BC does not change the flags).
52EB
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the next line, Register Pair DE = this line.
52EC
If the NZ FLAG is set (lines were left), LOOP back to 52E4H.
52EE
POP BC C1
Restore Register Pair BC from the stack: the number of lines from the target to the line found.
52EF
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the target line.
52F0
INC BC 03
Increment Register Pair BC: the number of lines to list, up to and including the line found.
52F1
POP AF F1
Restore Register Pair AF from the stack: Register A = the first key (the stack holds 1A7EH again).
52F2
CP 3AH FE 3A
Compare Register A (the first key) against 3AH, a colon.
52F4
LD B,A 47
Load Register B with Register A, the first key. LD does not change the flags.
52F5
If the Z FLAG is set (a colon; Register C = the lines to list), JUMP to 52FCH.
52F7
CP 40H FE 40
Compare Register A (the first key) against 40H, the character @.
52F9
If the NZ FLAG is set (an arrow), JUMP to 5379H to list the target line at Register Pair HL.
52FB
LD C,A 4F
Load Register C with Register A (40H): @ lists up to 64 lines, as many as fit.
52FC
POP AF F1
Restore Register Pair AF from the stack, discarding 1A7EH, the return into the ROM's command loop: the listing ends through LIST4 at READY.
52FD
LD A,1CH 3E 1C
Load Register A with 1CH, the display code that moves the cursor to the top left of the screen.
52FF
GOSUB to BASIC 5D3FH, which displays the character in Register A (1CH).
5302
LD A,1FH 3E 1F
Load Register A with 1FH, the display code that erases from the cursor to the end of the screen.
5304
GOSUB to BASIC 5D3FH to display it: the screen is cleared.
COUNT THE ROWS
Each line is expanded (ROM 2B7EH) and its screen rows counted; lines are added while the total stays below 15 rows. Register D = the rows so far, Register E = the lines counted, Register C = the most lines wanted, Register B = the first key.
5307
PUSH HL E5
Save Register Pair HL (the first line to list) on the stack (5352H loops back here with a later first line).
5308
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H: Register D = the screen rows used, Register E = the lines counted.
530B
PUSH HL E5
Save Register Pair HL (the line being counted) on the stack.
530C
PUSH DE D5
Save Register Pair DE (the rows and lines counted) on the stack.
530D
PUSH BC C5
Save Register Pair BC (Register B = the first key, Register C = the line limit) on the stack.
530E
INC HL 23
Increment Register Pair HL, 1 of 2, towards the line's number.
530F
INC HL 23
Increment Register Pair HL, 2 of 2, to the low byte of the line's number.
5310
LD E,(HL) 5E
Load Register E with the byte at Register Pair HL, the low byte of the line's number.
5311
INC HL 23
Increment Register Pair HL to the high byte of the line's number.
5312
LD D,(HL) 56
Load Register D with the byte at Register Pair HL, the high byte. Register Pair DE = the line's number.
5313
PUSH DE D5
Save Register Pair DE (the line's number) on the stack.
5314
INC HL 23
Increment Register Pair HL to the line's text.
5315
GOSUB to ROM 2B7EH (BUFLIN), which expands the tokenized text at Register Pair HL into readable text in the input buffer (40A7H) through Register Pair BC, returned after the last character.
5318
POP DE D1
Restore Register Pair DE from the stack: the line's number.
5319
PUSH DE D5
Save Register Pair DE (the line's number) on the stack again, for 533DH.
531A
GOSUB to BASIC 5D0BH, which converts Register Pair DE to five digits at 5D2AH and returns Register E = the number of digits without leading zeros.
531D
XOR A AF
Load Register A with 00H (XOR A with itself).
531E
LD D,01H 16 01
Load Register D with 01H: the line takes at least one row.
5320
INC E 1C
Increment Register E, the number of digits: the column after the number and the space LIST puts after it.
5321
LD (BC),A 02
Store Register A (00H) at Register Pair BC, ending the expanded text in the input buffer.
5322
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the 16-bit value at 40A7H, the input buffer holding the expanded text.
5325
JUMP to 5337H to start counting at the first character at Register Pair HL.
5327
CP 0DH FE 0D
Compare Register A (the character) against 0DH, a carriage return.
5329
If the Z FLAG is set (a carriage return: a new row), JUMP to 5334H.
532B
CP 0AH FE 0A
Compare Register A (the character) against 0AH, a line feed.
532D
If the Z FLAG is set (a line feed: a new row), JUMP to 5334H.
532F
INC E 1C
Increment Register E, the column in the current screen row.
5330
BIT 6,E CB 73
Test bit 6 of Register E: set when the column reaches 64, the end of a row.
5332
If the Z FLAG is set (still inside the row), JUMP to 5337H.
5334
INC D 14
Increment Register D, the rows this line takes.
5335
LD E,00H 1E 00
Load Register E with 00H, column 0 of the new row.
5337
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, a character of the expanded text.
5338
OR A B7
OR Register A (the character) with itself to set the flags: the Z FLAG is set at the 00H end.
5339
INC HL 23
Increment Register Pair HL to the next character (INC HL does not change the flags).
533A
If the NZ FLAG is set (not the end), LOOP back to 5327H.
533C
LD A,D 7A
Load Register A with Register D, the rows this line takes.
533D
POP HL E1
Restore Register Pair HL from the stack: this line's number.
533E
POP BC C1
Restore Register Pair BC from the stack: Register B = the first key, Register C = the line limit.
533F
POP DE D1
Restore Register Pair DE from the stack: Register D = the rows so far, Register E = the lines counted.
5340
ADD A,D 82
Add Register D (the rows so far) to Register A (this line's rows).
5341
LD D,A 57
Load Register D with Register A, the rows including this line.
5342
CP 0FH FE 0F
Compare Register A (the rows) against 0FH (15): the CARRY FLAG is set if fewer than 15 rows are used.
5344
If the CARRY FLAG is set (the line fits), JUMP to 5354H.
5346
POP HL E1
Too many rows: restore Register Pair HL from the stack, discarding the line pushed at 530BH.
5347
LD A,B 78
Load Register A with Register B, the first key (a colon or @).
5348
CP 40H FE 40
Compare Register A (the first key) against 40H, the character @.
534A
If the Z FLAG is set (@), JUMP to 5367H to list the lines that fit.
534C
POP HL E1
A colon: restore Register Pair HL from the stack, the first line of the listing.
534D
DEC C 0D
Decrement Register C, the lines to list: the listing starts one line later and ends at the same line.
534E
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the low byte of the first line's link field.
534F
INC HL 23
Increment Register Pair HL to the high byte of the first line's link field.
5350
LD H,(HL) 66
Load Register H with the byte at Register Pair HL, the high byte of the link.
5351
LD L,A 6F
Load Register L with Register A, the low byte. Register Pair HL = the next line, the new first line.
5352
JUMP to 5307H to count the rows again from there.
5354
LD (5373H),HL 22 73 53
Self-Modifying Code
Store Register Pair HL (this line's number) at 5373H, the operand of LD HL,nnnn at 5372H: the last line to list so far.
5357
POP HL E1
Restore Register Pair HL from the stack: this line's address.
5358
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the low byte of this line's link field.
5359
INC HL 23
Increment Register Pair HL to the high byte of this line's link field.
535A
LD H,(HL) 66
Load Register H with the byte at Register Pair HL, the high byte of the link.
535B
LD L,A 6F
Load Register L with Register A, the low byte. Register Pair HL = the next line.
535C
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the low byte of the next line's link field.
535D
INC HL 23
Increment Register Pair HL to the high byte of the next line's link field.
535E
OR (HL) B6
OR Register A (the low byte) with the byte at Register Pair HL: the Z FLAG is set at the end marker.
535F
DEC HL 2B
Decrement Register Pair HL back to the next line's start (DEC HL does not change the flags).
5360
If the Z FLAG is set (no more lines), JUMP to 5367H to list what was counted.
5362
INC E 1C
Increment Register E, the number of lines counted.
5363
LD A,E 7B
Load Register A with Register E, the lines counted.
5364
CP C B9
Compare Register A (the lines counted) with Register C, the most lines wanted: the CARRY FLAG is set if more may follow.
5365
If the CARRY FLAG is set, LOOP back to 530BH for the next line at Register Pair HL.
5367
POP HL E1
Restore Register Pair HL from the stack: the first line of the listing.
5368
PUSH HL E5
Save Register Pair HL (the first line of the listing) on the stack again.
5369
INC HL 23
Increment Register Pair HL, 1 of 2, towards the line's number.
536A
INC HL 23
Increment Register Pair HL, 2 of 2, to the low byte of the first line's number.
536B
LD E,(HL) 5E
Load Register E with the byte at Register Pair HL, the low byte of the first line's number.
536C
INC HL 23
Increment Register Pair HL to the high byte of the first line's number.
536D
LD D,(HL) 56
Load Register D with the byte at Register Pair HL, the high byte. Register Pair DE = the first line's number.
536E
LD (5272H),DE ED 53 72 52
Self-Modifying Code
Store Register Pair DE (the first listed line's number) at 5272H, the operand of LD DE,nnnn at 5271H: a colon typed next goes back from here.
5372
LD HL,0000H 21 00 00
Self-Modifying Code
Load Register Pair HL with the number of the last line to list, the operand 5373H (0000H in the file; stored at 5354H).
5375
EX (SP),HL E3
Exchange Register Pair HL with the word at the top of the stack (at the Stack Pointer SP): the last line's number goes there and Register Pair HL = the first line's address.
5376
PUSH HL E5
Push Register Pair HL (the first line's address) on the stack: LIST4 takes it with POP HL and the last number with POP DE.
5377
JUMP to 53B8H, which jumps to LIST4 with the range on the stack.
5379
PUSH AF F5
One line: save Register Pair AF (Register A = the first key) on the stack.
537A
LD A,1DH 3E 1D
Load Register A with 1DH, the display code that moves the cursor to the start of its row (524FH and 528AH enter here with the key pushed at 522EH on the stack).
537C
GOSUB to ROM 0033H, which displays the character in Register A (1DH).
537F
POP AF F1
Restore Register Pair AF from the stack: Register A = the first key (pushed at 5379H, or at 522EH on the paths from 524FH and 528AH).
5380
POP BC C1
Restore Register Pair BC from the stack, discarding 1A7EH, the return into the ROM's command loop: LIST4 and EDIT end at READY by themselves.
5381
LD B,H 44
Load Register B with Register H, the high byte of the line's address.
5382
LD C,L 4D
Load Register C with Register L, the low byte. Register Pair BC = the line's address.
5383
INC HL 23
Increment Register Pair HL, 1 of 2, towards the line's number.
5384
INC HL 23
Increment Register Pair HL, 2 of 2, to the low byte of the line's number.
5385
LD E,(HL) 5E
Load Register E with the byte at Register Pair HL, the low byte of the line's number.
5386
INC HL 23
Increment Register Pair HL to the high byte of the line's number.
5387
LD D,(HL) 56
Load Register D with the byte at Register Pair HL, the high byte. Register Pair DE = the line's number.
5388
CP 2CH FE 2C
Compare Register A (the first key) against 2CH, a comma.
538A
If the Z FLAG is set (a comma), JUMP to ROM 2E65H inside EDIT, which stores Register Pair DE (the line's number) at 40ECH and edits the line at Register Pair BC.
538D
PUSH DE D5
Push Register Pair DE (the line's number) on the stack: the last line to list.
538E
PUSH BC C5
Push Register Pair BC (the line's address) on the stack: the first line to list.
538F
LD A,0FH 3E 0F
Load Register A with 0FH, the display code that turns the cursor off.
5391
GOSUB to ROM 0033H to display the character in Register A (0FH): the cursor is off while the line is listed.
5394
LD HL,(4020H) 2A 20 40
Load Register Pair HL with the 16-bit value at 4020H, the ROM's cursor address in the video memory.
5397
LD DE,FFC0H 11 C0 FF
Load Register Pair DE with FFC0H, minus 64 (one screen row).
539A
ADD HL,DE 19
Add Register Pair DE (minus 64) to Register Pair HL: Register Pair HL = the same column in the row above.
539B
LD A,H 7C
Load Register A with Register H, the high byte of that address.
539C
CP 3CH FE 3C
Compare Register A (the high byte) against 3CH: the CARRY FLAG is set if the address lies before the video memory (3C00H).
539E
If the CARRY FLAG is set (no row above), JUMP to 53B3H.
53A0
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the address in the row above.
53A1
LD B,0AH 06 0A
Load Register B with 0AH (10), the number of characters to compare.
53A3
LD HL,53BBH 21 BB 53
Load Register Pair HL with 53BBH, the text READY and five spaces as they stand on the screen.
IS THE ROW ABOVE THE READY LINE?
Register Pair DE = the screen, Register Pair HL = the text at 53BBH, Register B = the characters left.
53A6
LD A,(DE) 1A
Load Register A with the byte at Register Pair DE, a character on the screen.
53A7
INC DE 13
Increment Register Pair DE to the next screen position.
53A8
CP (HL) BE
Compare Register A (the screen character) with the byte at Register Pair HL, the character expected.
53A9
INC HL 23
Increment Register Pair HL to the next expected character (INC HL does not change the flags).
53AA
If the NZ FLAG is set (they differ), JUMP to 53B3H.
53AC
Decrement Register B, the characters left, and LOOP back to 53A6H until all 10 match.
53AE
LD A,1BH 3E 1B
The row above shows READY: load Register A with 1BH, the display code that moves the cursor up one row.
53B0
GOSUB to ROM 0033H to display it (1BH): the listing is written over the READY line.
53B3
LD A,1EH 3E 1E
Load Register A with 1EH, the display code that erases to the end of the row.
53B5
GOSUB to ROM 0033H to display the character in Register A (1EH): the rest of the row is erased before the listing.
53B8
JUMP to ROM 2B33H (LIST4, inside LIST), which takes the first line's address (POP HL) and the last line's number (POP DE), lists them and goes to READY.