Lists the program. As the stored program is in tokenised form (ie keywords are represented with single byte numeric IDs) LIST is more complex than a simple memory dump. When it meets a keyword ID it looks it up in the keywords table and prints it.
Get the line number argument into DE and error back if a non-numeric argument was given.
0391
C0
RNZ
0392
C1
POP B
?why get return address?
From the line number in DE, get the address of the starting program line onto the stack.
0396
C5
PUSH B
Pop the current program line address into HL, and get the address of the *next* program line into BC..
0397
E1
ListNextLine
POP H
0399
C1
POP B
If we've reached the null line at the end of the program, then exit.
039A
78
MOV A,B
039B
B1
ORA C
Allow user a chance to stop the program listing.
03A2
C5
PUSH B
Get current program line number into HL, and push current program line ptr onto the stack.
03A7
E3
XTHL
Print the line number and prepare to print a space..
03AB
3E20
MVI A,' '
Restore current line ptr to HL, print current character, advance current line ptr and
03AD
E1
POP H
03AF
7E
MOV A,M
03B0
B7
ORA A
03B1
23
INX H
Bit 7 of A is set, indicating a keyword ID. So we need to look the keyword up in the table and print it.
03B8
D67F
SUI 7F
A is now keyword index + 1.
03BA
4F
MOV C,A
03BB
E5
PUSH H
03BF
D5
PUSH D
Find the start of the next keyword.
03C0
1A
ToNextKeyword
LDAX D
03C1
13
INX D
03C2
B7
ORA A
Decrement keyword index and restore start of previous keyword to HL. If this is not yet the keyword we want, then loop back.
03C6
0D
DCR C
03C7
E1
POP H
Print the keyword. Note that printing of the last character is deferred to ListChar in the main loop.
03CB
7E
PrintKeyword
MOV A,M
03CC
B7
ORA A
03D1
23
INX H
[Index] [Previous] [Next]