-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmdLIST.inc
More file actions
54 lines (41 loc) · 2.27 KB
/
Copy pathcmdLIST.inc
File metadata and controls
54 lines (41 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
.proc LIST
;-----------------------------------------------------------------------------
PromptLIST:
;-----------------------------------------------------------------------------
MOV program_ @p ; Assume list to start from the beginning
MOV CONST_MAXINT @lastLineNo ; Assume list to end of the program
CALL GetParsedToken ; Get the line number to start listing from
JMP0 tokenValue @loop1 ; If not given, list all lines
MOV tokenValue @lastLineNo ; If we have a start lineNo then assume it's also the last
PUSH tokenValue ; Find the line number
CALL FindLine
MOV pFound @p ; And start from there
JMP0 tokenPeek @loop1 ; If the last line number is not given, list all lines
CALL GetParsedToken ; Get the last line number to list
JMPL0 tokenValue @loop1 ; If not given, list all lines
MOV tokenValue @lastLineNo
@loop1:
INDEXEDRD @p @lineNo ; Get Linenumber of current line as a binary value
INC @p
JMP0 @lineNo @done ; Reached the end of the code?
CMPGE @lineNo @lastLineNo @done ; Is this line number greater than the last line number?
PUSH @lineNo ; Print the line number and a space
CALL PrintInteger
OUT ASCII_SPACE
INC @p ; Skip the offset to the next line
@loop2:
INDEXEDRD @p @ch ; Get Linenumber of current line as a binary value
INC @p
JMP0 @ch @eol ; Reached the end of the line?
OUT @ch ; Print the character
JMP @loop2
@eol:
PRINTCRLF ; Print a CRLF and go print the next line
JMP @loop1
@done:
JMP Restart
@p: .data 0 ; Pointer to current location in the program
@lineNo: .data 0 ; Line number;
@lastLineNo: .data 0 ; Last line number to list
@ch: .data 0 ; Tempporary storage for the character
.endp