Mercurial > hg > index.cgi
annotate src/progctrl.s @ 136:e49bd0493baf
Checkpoint updates to immediate mode program editing and some memory handling
author | William Astle <lost@l-w.ca> |
---|---|
date | Fri, 12 Jul 2024 23:29:45 -0600 |
parents | 917b4893bb3d |
children |
rev | line source |
---|---|
74
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1 *pragmapush list |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
2 *pragma list |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
4 ; The END command. |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
5 cmd_end bne SNERROR ; error out if there is an argument |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
6 ;jsr closeall ; close all files for END |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
7 clra ; flag END (clear carry) |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
8 bra cmd_stop0 ; go do the stop/end |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
9 cmd_stop bne SNERROR ; raise error if there was an argument |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
10 coma ; flag STOP - set carry |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
11 cmd_stop0 ror endflag ; set stop/end flag |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
12 cmd_stop1 clr filenum ; reset I/O to console |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
13 ldx curline ; in immediate mode? |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
14 beq cmd_stop2 ; brif so - don't save the continue pointers |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
15 stx contline ; save pointer to current line for CONT |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
16 ldx curstmt ; get current statement address |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
17 stx contstmt ; save it for CONT |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
18 cmd_stop2 rol endflag ; get STOP/END to C (1=STOP) |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
19 bcc cmd_stop3 ; brif END - don't do message |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
20 ldx #breakmsg ; do "BREAK IN" |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
21 jmp ERROR2 ; the bottom half of the error handler can deal with the details |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
22 cmd_stop3 puls x,pc ; lose return address and return to caller of interpretation loop |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
23 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
24 ; The NEW command. |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
25 ; |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
26 ; This also includes several useful entry points: |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
27 ; |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
28 ; cmd_newraw: does the whole NEW but without any syntax checks |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
29 ; cmd_newinptr: skips clearing the program text |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
30 ; cmd_newvars: clears variables and resets the stack and other misc state |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
31 ; cmd_newstack: just reset the stack and other misc state |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
32 cmd_new bne cmd_new0 ; brif there was an argument - don't wipe things out on syntax error |
132
917b4893bb3d
Checkpoint before redoing a bunch of code for clarity
William Astle <lost@l-w.ca>
parents:
128
diff
changeset
|
33 cmd_newraw ldx prog_linetab ; get start of program line table |
917b4893bb3d
Checkpoint before redoing a bunch of code for clarity
William Astle <lost@l-w.ca>
parents:
128
diff
changeset
|
34 stx prog_linetabp ; clear out all line entries |
917b4893bb3d
Checkpoint before redoing a bunch of code for clarity
William Astle <lost@l-w.ca>
parents:
128
diff
changeset
|
35 leax linetabent_size*(linetab_stride+1),x ; make room for default program line entries and one extra |
917b4893bb3d
Checkpoint before redoing a bunch of code for clarity
William Astle <lost@l-w.ca>
parents:
128
diff
changeset
|
36 stx [prog_linetabp] ; set the pointer for the dummy ending entry |
917b4893bb3d
Checkpoint before redoing a bunch of code for clarity
William Astle <lost@l-w.ca>
parents:
128
diff
changeset
|
37 stx prog_text ; set end of program line table |
74
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
38 stx vartab ; set start of variables after that |
132
917b4893bb3d
Checkpoint before redoing a bunch of code for clarity
William Astle <lost@l-w.ca>
parents:
128
diff
changeset
|
39 cmd_newinptr ldx zero ; blank out current line pointer - we'll fall back to immediate mode |
917b4893bb3d
Checkpoint before redoing a bunch of code for clarity
William Astle <lost@l-w.ca>
parents:
128
diff
changeset
|
40 stx curline |
917b4893bb3d
Checkpoint before redoing a bunch of code for clarity
William Astle <lost@l-w.ca>
parents:
128
diff
changeset
|
41 ldx #zero ; point to a zero input byte - will read as end of line |
917b4893bb3d
Checkpoint before redoing a bunch of code for clarity
William Astle <lost@l-w.ca>
parents:
128
diff
changeset
|
42 stx inputptr |
74
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
43 cmd_newvars ldx memsize ; get top of memory |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
44 stx stringtab ; clear out string space |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
45 ldx vartab ; get start of variables |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
46 stx objecttab ; set start of large objects (arrays) there too (clear vars) |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
47 stx freestart ; set start of free memory (end of large objects) (clear arrays) |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
48 cmd_newstack ldx #stringstackend ; reset string stack (string stack counts down) |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
49 stx stringstackptr |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
50 ldx ,s ; get return address |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
51 lds freetop ; reset stack to top of memory |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
52 clr ,-s ; put a flag to stop stack searches (NEXT, RETURN) |
119
a6a53e5c04bd
Make a call stack implementation that is more complete and maybe cleaner.
William Astle <lost@l-w.ca>
parents:
74
diff
changeset
|
53 sts cstackptr ; reset pointer for call stack |
74
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
54 clr contstmt ; clear "CONT" destination |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
55 clr contstmt+1 |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
56 jmp ,x ; return to caller |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
57 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
58 ; REM and ' commands; also ELSE comes here since it needs to skip the rest of the line in that case. |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
59 cmd_else |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
60 cmd_apos |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
61 cmd_rem clra ; clear carry |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
62 ldx curline ; get start of current line |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
63 beq cmd_stop3 ; brif immediate mode - fall back to caller |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
64 ldx ,x ; get address of next line |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
65 leax -1,x ; move back one |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
66 stx inputptr ; put input pointer there |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
67 cmd_new0 rts |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
68 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
69 ; DATA command |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
70 ; |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
71 ; need to skip to the end of the current statement, which is either the end of the line OR a colon not included inside |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
72 ; a quoted string |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
73 cmd_data ldx inputptr ; get input pointer |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
74 cmd_data0 lda ,x+ ; get character at pointer |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
75 beq cmd_data1 ; brif end of line |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
76 cmpa #': ; end of statement? |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
77 bne cmd_data2 ; brif not |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
78 cmd_data1 leax -1,x ; move back to the NUL or colon |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
79 stx inputptr ; reset input pointer for interpreter |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
80 rts |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
81 cmd_data2 cmpa #'" ; start of constant string? |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
82 bne cmd_data0 ; brif not - process more characters |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
83 cmd_data3 lda ,x+ ; get next string character |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
84 beq cmd_data1 ; brif end of line |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
85 cmpa #'" ; string delimiter? |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
86 bne cmd_data3 ; brif not - keep going |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
87 bra cmd_data0 ; process stuff outside string |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
88 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
89 ; RUN command |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
90 cmd_run ;jsr closeall ; close all files |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
91 jsr curchar ; what do we have as an argument? |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
92 bcs cmd_goto ; brif a digit - it's a line number (RUN ###); do GOTO |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
93 lbne SNERROR ; brif anything else on the line - not legit command |
136
e49bd0493baf
Checkpoint updates to immediate mode program editing and some memory handling
William Astle <lost@l-w.ca>
parents:
132
diff
changeset
|
94 ldx prog_text ; point to start of program |
74
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
95 bra cmd_goto0 ; go transfer control to the start of the program |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
96 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
97 ; GOTO command |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
98 cmd_goto jsr parse_lineno ; parse the line number |
136
e49bd0493baf
Checkpoint updates to immediate mode program editing and some memory handling
William Astle <lost@l-w.ca>
parents:
132
diff
changeset
|
99 cmd_gosub0 jsr prog_findline ; go look up line number |
74
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
100 bcc cmd_goto0 ; brif line found |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
101 ULERROR ldb #err_ul ; raise undefined line error |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
102 jmp ERROR |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
103 cmd_goto0 stx curline ; make sure we aren't flagging immediate mode |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
104 leax -1,x ; move input pointer to NUL before destination line |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
105 stx inputptr ; put input pointer there |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
106 rts ; resume interpretation at the new location |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
107 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
108 ; GOSUB command |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
109 cmd_gosub jsr parse_lineno ; parse the destination line so return location is after the line number |
128
9d57279c900e
Remove old style keyword lists and jump tables
William Astle <lost@l-w.ca>
parents:
119
diff
changeset
|
110 ldd #token_gosub*256+4 ; stack frame details |
119
a6a53e5c04bd
Make a call stack implementation that is more complete and maybe cleaner.
William Astle <lost@l-w.ca>
parents:
74
diff
changeset
|
111 jsr cstack_alloc ; make a stack frame |
74
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
112 ldx curline ; save current line pointer |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
113 stx ,u |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
114 ldx inputptr ; save current input pointer |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
115 stx 2,u |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
116 bra cmd_gosub0 ; go finish up as a GOTO |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
117 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
118 ; RETURN command |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
119 ; POP command |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
120 ; |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
121 ; RETURN will search the call stack for the first GOSUB frame and remove all other placeholders it finds. A frame type |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
122 ; of 0 will cause it to stop. |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
123 cmd_pop skip1lda ; set nonzero for POP |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
124 cmd_return clra ; set zero for RETURN |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
125 pshs a ; save operation type |
119
a6a53e5c04bd
Make a call stack implementation that is more complete and maybe cleaner.
William Astle <lost@l-w.ca>
parents:
74
diff
changeset
|
126 jsr cstack_first ; get first entry on call stack |
74
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
127 bne cmd_return1 ; brif there's a frame - don't error |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
128 RG_ERROR ldb #err_rg ; raise RETURN without GOSUB |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
129 jmp ERROR |
119
a6a53e5c04bd
Make a call stack implementation that is more complete and maybe cleaner.
William Astle <lost@l-w.ca>
parents:
74
diff
changeset
|
130 cmd_return0 jsr cstack_next ; move to next entry |
74
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
131 beq RG_ERROR ; brif end of stack - raise error |
128
9d57279c900e
Remove old style keyword lists and jump tables
William Astle <lost@l-w.ca>
parents:
119
diff
changeset
|
132 cmd_return1 cmpb #token_gosub ; do we have a GOSUB frame? |
74
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
133 bne cmd_return0 ; brif not - try again |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
134 lda ,s+ ; is it "POP"? |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
135 bne cmd_return2 ; brif so - don't change flow control but clear stack frame |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
136 ldx ,u ; get back saved line pointer |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
137 stx curline |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
138 ldx 2,u ; get back saved input pointer |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
139 stx inputptr |
119
a6a53e5c04bd
Make a call stack implementation that is more complete and maybe cleaner.
William Astle <lost@l-w.ca>
parents:
74
diff
changeset
|
140 cmd_return2 jsr cstack_popto ; clean up call stack |
74
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
141 bra cmd_data ; move to end of statement (move past any "ON GOSUB" entries |
e74d00ac6b79
Split some code into separate files for easier management (2)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
142 *pragmapop list |