File: statement.t2

For general comments see here
LineAddressObject Code LabelF1N1BF2N2CommentsCheck
1 0  ; tape1.d/statement.t2
2 0  ;---------------------
3 0  ;
4 0  ; compile statement
5 0  ;
6 0  =1708 
7 1708  statement::; 
8 1708  ;
9 1708  .ent:; 
10 1708 0602160 lod dicpt   ; @1708
11 1708+0404304 sto constptr   ;save dicpt
12 1709 0602142 lod Link15d   ;return address
13 1709+0202154 exa W1132   ;hide return
14 1710   call     ; stack previous return address @1710
14+11710 7312031002415 lnk stack.lnk:jmp stack.ent 
15 1711  .1711:; 
16 1711 0550621 cls W4497   ;set return flag=0
17 1711+1010626 jmp .4502   ;->patched bit
18 1712  ; patch added into compile statement
19 1712  ;
20 1712  =4502 
21 4502  .4502:; 
22 4502 0602151 lod stkp   ; @4502
23 4502+0350622 stc W4498   ;
24 4503 0043107010632 o00 W4497/jmp .SW4504+2; switch on recovery flag
25 4504  ;
26 4504  .SW4504:; 
27 4504 2643125001222 cls W4501:jmp gettoken.ent; -2 @4504
28 4505 2643125002361 cls W4501:jmp declid.ent; -1
29 4506 3003001110633 lod token:jmp .4507P; 0 load token and skip @4506
30 4507 1102300 jmp declaration.resumeproc   ; 1 resume proc declaration
31 4507+ ;
32 4507+0550625.4507P:cls W4501   ;
33 4508 1023270 jn .1720   ;not valid for statement start @4508
34 4508+1003260 jmp .1712   ; compile statement
35 4509  ;
36 4509  L4509.ent:; 
37 4509 0604340 lod K2b   ;=2 set recovery flag=-2
38 4509+ .4509P:; 
39 4509+0430621 stn W4497   ; set recovery flag -1/-2
40 4510 1010626 jmp .4502   ; @4510
41 4510+ ;
42 4510+ ;
43 4510+ L4510.ent:; 
44 4510+ ;.4510P:
45 4510+0040000 o02 0   ;=1 @4510+
46 4511 1110635 jmp .4509P   ;set recover=-1
47 4511+ ;
48 4511+ =1712 
49 1712  ;
50 1712  ; compile statement, cont'd
51 1712  .1712:; 
52 1712 0162176 bus K9a   ;=9 @1712
53 1712+1023270 jn .1720   ; not statement starter
54 1713 0003003003332 o00 token/jmp .SW; switch on statement type
55 1714  ;
56 1714  .1714:; 
57 1714   call      
57+11714 7312031002420 lnk skipcomment.lnk:jmp skipcomment.ent 
58 1715  ; kw=begin comes here
59 1715  .1715:; 
60 1715   call      
60+11715 7322411004503 lnk advance.lnk:jmp advance.ent 
61 1716 0600600 lod token   ; token @1716
62 1716+0122176 sub K9a   ;=9
63 1717 1023267 jn .1719   ; statement->
64 1717+1043262 jz .1714   ; comment->
65 1718 0122200 sub K8a   ;=8 @1718
66 1718+1123271 jn .1721P   ; declaration->
67 1719  ; from 1717
68 1719  .1719:; 
69 1719   call     ; compile statement list
69+11719 7310611003325 lnk stmtlist.lnk:jmp stmtlist.ent 
70 1720  L1720:; 
71 1720 0040000.1720:o02 0   ;=1 @1720
72 1720+1003311 jmp .1737   ;
73 1721  ;
74 1721 0000000 o00 0   ;
75 1721+ ;
76 1721+ ; compile block body
77 1721+ ;
78 1721+0602156.1721P:lod frameptr   ;
79 1722   call     ;stack value @1722
79+11722 7312031002415 lnk stack.lnk:jmp stack.ent 
80 1723 0602157 lod W1135   ;
81 1723+0000000 o00 0   ;no-op
82 1724   call     ; stack value @1724
82+11724 7312031002415 lnk stack.lnk:jmp stack.ent 
83 1725 0602161 lod wsptr   ;
84 1725+0402157 sto W1135   ;
85 1726 0602160 lod dicpt   ; @1726
86 1726+0402156 sto frameptr   ;
87 1727   call     ;generate Enter Block call
87+11727 7320121003403 lnk GenEB.lnk:jmp GenEB.ent 
88 1728   call     ; compile declaration list @1728
88+11728 7310641002255 lnk declns.lnk:jmp declns.ent 
89 1729   call     ; compile stmt list
89+11729 7310611003325 lnk stmtlist.lnk:jmp stmtlist.ent 
90 1730   call     ;generate Exit Block call @1730
90+11730 7320121003401 lnk GenXB.lnk:jmp GenXB.ent 
91 1731 0602156 lod frameptr   ;
92 1731+0402160 sto dicpt   ;
93 1732 0602157 lod W1135   ; @1732
94 1732+0402161 sto wsptr   ;
95 1733 0010646577777 o00 stkp/lod -1;unstack W1135
96 1734 0402157 sto W1135   ; @1734
97 1734+0000000 o00 0   ;
98 1735 0010646577776 o00 stkp/lod -2;unstack frameptr
99 1736 0402156 sto frameptr   ; @1736
100 1736+0042205 o02 K2a   ;two words to be popped
101 1737  ;
102 1737  ; unwind stack and return to original caller
103 1737  ;
104 1737  .1737:; 
105 1737 2710646600000 o27 stkp/lod 0;adjust stack @1737
106 1738 0202154 exa W1132   ;save result
107 1738+0000000 o00 0   ;no-op
108 1739  popstk:; 
109 1739 2010613000001 sto Link15d/jmp 1; return +1
110 1740  ;----------------------------------------------------------
111 1740  ;compile statement list (up to [end]).
112 1740  ;
113 1740  ;L1740: ; no references
114 1740   call     ;get next token @1740
114+11740 7322411004503 lnk advance.lnk:jmp advance.ent 
115 1741  ; from 1799+
116 1741  .1741:; 
117 1741   call     ;
117+11741 7310611003254 lnk statement.lnk:jmp statement.ent 
118 1742 0600600 lod token   ;token @1742
119 1742+0122200 sub K8a   ;=8 [semicolon]
120 1743 1043405 jz .1797   ;OK->advance input, and repeat
121 1743+0102211 add K4   ;=4 [end]
122 1744 1043321 jz .1745   ; yes, end of compound @1744
123 1744+1003330 jmp _err17    
124 1745  ;
125 1745  .1745:; 
126 1745   call     ;skip comment after end, check for else
126+11745 7312031002424 lnk skipelse.lnk:jmp skipelse.ent 
127 1746 0040000 o02 0   ; @1746
128 1746+0000000 o00 0   ;
129 1747 2710646600000 o27 stkp/lod 0;unstack word
130 1748 0202155 exa W1133   ; @1748
131 1748+1003313 jmp popstk   ;->return
132 1749  ;--------------------------------------------------------
133 1749  ; compile statement list, start token already read in
134 1749  ;
135 1749  stmtlist.ent:; 
136 1749 0602142 lod Link15d   ;
137 1749+0202155 exa W1133   ;
138 1750   call     ; @1750
138+11750 7312031002415 lnk stack.lnk:jmp stack.ent 
139 1751 1003315 jmp .1741   ;
140 1751+ ;
141 1751+0000000 o00 0    
142 1752  ;
143 1752  ; semicolon after statement
144 1752  ; compile next statement in list
145 1752  ;
146 1752  =1797 
147 1797  .1797:call     ;get next token
147+11797 7322411004503 lnk advance.lnk:jmp advance.ent 
148 1798 0600600 lod token   ;token @1798
149 1798+0122176 sub K9a   ;=9
150 1799   jnz     ;otherwise->
150+11799 1043410 jz .1    
150+21799+1003315 jmp statement.1741    
150+31800  .1:; 
151 1800   call     ;discard the comments @1800
151+11800 7312031002420 lnk skipcomment.lnk:jmp skipcomment.ent 
152 1801 1003405 jmp .1797   ;and repeat
153 1801+ ;
154 1801+ =1752 
155 1752  _err17:; 
156 1752 1661044 lnk errlnk   ;error 17: no end or ; after statement
157 1752+  ;or, no colon after label 
158 1752+  ;or, impermissible start to statement 
159 1752+1002262 jmp Error2   ;goto error rtne
160 1753 1003331.1753:jmp .1753   ;dynamic stop
161 1753+ ;
162 1753+0000000 o00 0    
163 1754  ;
164 1754  .SW:; 
165 1754 3016135103345 lod idptr:jmp .1765P; +0 identifier @1754
166 1755 4015744000000 jmp .1785:o00 0; +1 goto
167 1756 4015754000000 jmp .1787:o00 0; +2 if
168 1757 4015764000000 jmp .1789:o00 0; +3 for
169 1758 0200001003311 o02 0:jmp .1737; +4 end @1758
170 1759 3002771003363 lod ident:jmp .1779; +5 print/read
171 1760 4015314000000 jmp .1715:o00 0; +6 begin @1760
172 1761 4015774000000 jmp .1791:o00 0; +7 code
173 1762 0200001003311L1762:o02 0:jmp .1737; +8 apostrophe (semicolon)
174 1763 0200001003311 o02 0:jmp .1737; +9 comment
175 1764  ;
176 1764  .1764:; 
177 1764   call     ; @1764
177+11764 7322411004503 lnk advance.lnk:jmp advance.ent 
178 1765 1003257 jmp .1711    
179 1765+ ;
180 1765+ ; statement beginning with identifier: label, assignment, or procedure call
181 1765+0062232.1765P:and procbit   ;=02000000000000
182 1766 1043354 jz .1772   ;not procedure, label or assignment? @1766
183 1766+0603427 lod idptr   ;procedure
184 1767 0062215 and realbit   ;=00300000000000
185 1767+1150573 jz L4475P   ;no type, procedure call
186 1768  .1768:; 
187 1768   call     ;call 2307 compile assignment @1768
187+11768 7322011004403 lnk assignment.lnk:jmp assignment.ent 
188 1769 0040000 o02 0   ;=1
189 1769+1003311 jmp .1737   ;
190 1770  ;
191 1770  =4475+ 
192 4475+ L4475P:; 
193 4475+0046265.4475P:o02 checkb   ;='CHECKB'=>'CHECKC'
194 4476 0102245 add K16   ;=16=>'CHECKS' @4476
195 4476+0120576 sub ident   ;compare current id
196 4477 1050576 jz .4478   ;do checks call
197 4477+1003416 jmp .1806   ;other procedures
198 4478  ;
199 4478 1600000.4478:kbd 0   ; read keyboard
200 4478+0062225 and Bbit   ;=<000/000>
201 4479 1050600 jz .4480   ; not set, ignore
202 4479+1003421 jmp .1809   ;compile as normal
203 4480  ;
204 4480 0601513.4480:lod putcode.ret   ;= suppress object code @4480
205 4480+0341477 stc putcode.ent   ;
206 4481 0602145 lod ObjPC   ;save ObjPC for later
207 4481+0347035 stc W3613   ;
208 4482 0601426 lod W790   ;save W790 for later @4482
209 4482+0347036 stc W3614   ;
210 4483 1003352 jmp .1770   ;
211 4483+ ;
212 4483+ =1770 
213 1770  ; compile 'normal' procedure call
214 1770  ;
215 1770  .1770:; 
216 1770   call     ; @1770
216+11770 7331155006266 lnk CallProc.lnk:jmp CallProc.ent 
217 1771 0040000 o02 0   ;=1
218 1771+1003311 jmp .1737   ;
219 1772  ;
220 1772 0603427.1772:lod idptr   ;idinfo @1772
221 1772+0062243 and MskArgTp   ;=037400000000000 mask out type bits
222 1773 0122250 sub W1192   ;=005000000000000 label?
223 1773+1143356 jz .1774P   ;yes, proces label
224 1774 1003350 jmp .1768   ;back for assignment @1774
225 1774+ ;
226 1774+ ; label identifier
227 1774+ ;
228 1774+0603427.1774P:lod idptr   ;
229 1775   call     ;place label
229+11775 7307175103411 lnk PutLabel.lnk:jmp PutLabel.ent 
230 1776   call     ; @1776
230+11776 7322411004503 lnk advance.lnk:jmp advance.ent 
231 1777 0600600 lod token   ;
232 1777+0122201 sub K42   ;=42 [:]
233 1778 1043344 jz .1764   ;ok, start again @1778
234 1778+1003330 jmp _err17   ;
235 1779  ;
236 1779  ; read or print statement
237 1779  ;
238 1779 0122251.1779:sub print   ;=PRINT
239 1779+1043366 jz .1782   ;yes->
240 1780  ; read statement
241 1780   call     ; @1780
241+11780 7336515007605 lnk comprd.lnk:jmp comprd.ent 
242 1781 1003367 jmp .1783   ;
243 1781+ ;
244 1781+0000000 o00 0    
245 1782  ; print statement
246 1782  .1782:; 
247 1782   call     ;compile print stmt @1782
247+11782 7336515007640 lnk comppr.lnk:jmp comppr.ent 
248 1783  ; from 1781
249 1783  .1783:; 
250 1783 0544302 cls W2242   ;
251 1783+0040000 o02 0   ;=1
252 1784 1003311 jmp .1737   ; @1784
253 1784+ ;
254 1784+0000000 o00 0   ;
255 1785  ;
256 1785  ; compile goto statement
257 1785  ;
258 1785  .1785:; 
259 1785   call     ;
259+11785 7334161007042 lnk DesigExprn.lnk:jmp DesigExprn.ent 
260 1786 0040000 o02 0   ; @1786
261 1786+1003311 jmp .1737   ;
262 1787  ;
263 1787  ; compile if statement
264 1787  ;
265 1787  ;from 1756 (in switch list)
266 1787  .1787:; 
267 1787   call     ; 3701 comp cond stat
267+11787 7334161007165 lnk condstat.lnk:jmp condstat.ent 
268 1788 0040000 o02 0   ;=1 @1788
269 1788+1003311 jmp .1737   ;
270 1789  ;
271 1789  ; compile for statement
272 1789  ;
273 1789  .1789:; 
274 1789   call     ;
274+11789 7334161007200 lnk forstat.lnk:jmp forstat.ent 
275 1790 0040000 o02 0   ;=1 @1790
276 1790+1003311 jmp .1737   ;-> finished statement
277 1791  ;
278 1791 0000000000000.1791:+0 
279 1792  ;
280 1792 0040000.1792:o02 0   ;=1 @1792
281 1792+1003311 jmp .1737   ;
282 1793  ;
283 1793  GenXB.ent:; 
284 1793  ;L1793.ent:
285 1793 0040000 o02 0   ;=1 @1793
286 1793+0562144 o27 W1124   ;
287 1794 0603521 lod GPs+44   ;=GP7F 3,00 @1794
288 1794+1004033 jmp gencode.ent   ;gencode
289 1795  ;
290 1795  GenEB.ent:; 
291 1795  ;L1795.ent:
292 1795 0442144 inc W1124   ; @1795
293 1795+0603520 lod GPs+43   ;=
294 1796 1004033 jmp gencode.ent   ;gencode
295 1796+ ;
296 1796+0000000 o00 0   ;
297 1797  ;--------------------------------------------------------------------
298 1797  =1806 
299 1806  ;--------------------------------------------------------------------
300 1806  statement::; 
301 1806  ; procedure call, check special cases
302 1806  ;L1806:
303 1806  .1806:; 
304 1806 0600576 lod ident   ; @1806
305 1806+0124233 sub elliott   ;'ELLIOTT'
306 1807 1044205 jz Elliott   ;
307 1807+0600576 lod ident   ;
308 1808 0130450 sub precom   ;'PRECOM' @1808
309 1808+1050451 jz Precompile   ;syntax check then dump
310 1809  ;L1809:
311 1809  ; standard procedure calls, specials filtered out above
312 1809  ;
313 1809  .1809:; 
314 1809 0140000 cla 0   ;
315 1809+1003352 jmp .1770   ;
316 1810  ;---------------------------------------------------------------------
317 1810  ; generate jump instruction in label list
318 1810  ; first check that scope etc. is correct
319 1810  ;
320 1810  PutLabel::; 
321 1810  ;
322 1810  =1801+ 
323 1801+ .ent:; 
324 1801+1220027 srl 23   ; @1801+
325 1802 0064362 and K127   ;=127 mask block level @1802
326 1802+0122144 sub W1124   ;
327 1803 1143414 jz .1   ;
328 1803+1661044_err50:lnk errlnk   ;error 50: label not declared in
329 1804   ;innermost possible block 
330 1804 1001070 jmp Error   ;goto error handler @1804
331 1804+ ;
332 1804+ .1:; 
333 1804+0603427 lod idptr   ;re-load id info
334 1805 0067033 and W3611   ;=0000036017777 @1805
335 1805+1001661 jmp LabRef   ;optimise call away
336 1806  ;--------------------------------------------------------------------
337 1806  =4497 
338 4497 0000000000000W4497:+0;recovery flag? -2..+1
339 4498 0000000000000W4498:+0 
340 4499  =4500 
341 4500 0000000000000W4500:+0 
342 4501 0000000000000W4501:+0 
343 4502  ;--------------------------------------------------------------------