[Index] [Previous] [Next]

1.7 LIST Handler

List

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.
038E CD9D04 List CALL LineNumberFromStr
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.
0393 CD7D02 CALL FindProgramLine
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
0398 F7 RST PushNextWord
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
039C CAF901 JZ Main
Allow user a chance to stop the program listing.
039F CD7304 CALL TestBreakKey
03A2 C5 PUSH B
03A3 CD8A05 CALL NewLine
Get current program line number into HL, and push current program line ptr onto the stack.
03A6 F7 RST PushNextWord
03A7 E3 XTHL
Print the line number and prepare to print a space..
03A8 CD370B CALL PrintInt
03AB 3E20 MVI A,' '
Restore current line ptr to HL, print current character, advance current line ptr and
03AD E1 POP H
03AE DF ListChar RST OutChar
03AF 7E MOV A,M
03B0 B7 ORA A
03B1 23 INX H
03B2 CA9703 JZ ListNextLine
03B5 F2AE03 JP ListChar
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
03BC 115700 LXI D,KEYWORDS
03BF D5 PUSH D
Find the start of the next keyword.
03C0 1A ToNextKeyword LDAX D
03C1 13 INX D
03C2 B7 ORA A
03C3 F2C003 JP ToNextKeyword
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
03C8 C2BF03 JNZ ToNextKeyword-1
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
03CD FAAD03 JM ListChar-1
03D0 DF RST OutChar
03D1 23 INX H
03D2 C3CB03 JMP PrintKeyword

 


[Index] [Previous] [Next]