File: gencode.t2

For general comments see here
LineAddressObject Code LabelF1N1BF2N2CommentsCheck
1 0  ; tape1.d/gencode.t2
2 0  ;-------------------
3 0  ;
4 0  ; processing of gen-patterns
5 0  ; type processing
6 0  ; 0 modify to type 6, then call geninst
7 0  ; 1 call GenSubr with word
8 0  ; 2 get address from N1 part of word, adding 004/000,
9 0  ; modify type to 6, then call geninst
10 0  ; 3 skip if current type (W2246) matches F1 second digit,
11 0  ; number of items skipped=N1
12 0  ; 4 as for type 3, but type is determined by id rather than acc
13 0  ; 5 ensure both operands are FP, do swap in 4 if needed,
14 0  ; following two words specify fwd and rev instn.
15 0  ; 6 extract GP.n where n is N1 part of word and call gencode1
16 0  ; recursively.
17 0  ; 7 generate call to run-time support, offset=N1, F2 gets
18 0  ; '40' added to form jump instn
19 0  ; 8 GenAdr=GenPtr+1, call GenInst with F2 part of word+type 6
20 0  ; 9 modify type to 1, then call GenInst (short branch?)
21 0  ; 10 modify type to 2, then call GenInst
22 0  ; 11 modify type to 3, then call GenInst
23 0  ; 12 call putcode6 (patch branch destination)
24 0  ; 13 call GenSubr with current type (W2246)
25 0  ;
26 0  =2069 
27 2069 0000000004027GenPtr:+GenDmy; @2069
28 2070 4000031000002GenWord:+04000031000002; 40 6 : 40 2 @2070
29 2071 4000031000002GenDmy:+04000031000002; 40 6 : 40 2 @2071
30 2072  =2073 
31 2073 0000000000000IdInfo:+0; @2073
32 2074  ;--------------------------------------------------------------------
33 2074  ; gencode1: special entry Acc contains index into list of gen patterns
34 2074  ; load up selected one and fall through into gencode.
35 2074  ;
36 2074  gencode1.ent:; 
37 2074 2000022603445 sto 4/lod GPs;load specified pattern @2074
38 2075  ;
39 2075  ; generate code
40 2075  ; parameter may have two forms:
41 2075  ; positive values are pointers to values,
42 2075  ; negative values are direct
43 2075  ;
44 2075  gencode::; 
45 2075  .ent:; 
46 2075 1024043 jn .single   ;negative value, set up dummy list and re-enter
47 2075+  nop     ;
47+12075+1004034 jmp .1    
47+22076  .1:; 
48 2076  ; acc contains pointer to list of words
49 2076  .1:; 
50 2076 2020126600000 sto GenPtr/lod 0;get info from table @2076
51 2077 1004041 jmp .4   ;
52 2077+  pad     ;
52+12077+0000000 00 0    
53 2078  ;
54 2078  ; return here for next item in arg list
55 2078  .gennxt:; 
56 2078 0020126600000 o00 GenPtr/lod 0;re-load previous item @2078
57 2079  .2:; 
58 2079 0020123020001 o00 .lnk/jn 1;return if <, end of list
59 2080  ;
60 2080  .3:; 
61 2080 2220126600000 inc GenPtr/lod 0;bump ptr and fetch next item @2080
62 2081  ; next item now in acc
63 2081  .4:; 
64 2081 0404026 sto GenWord   ;save item
65 2081+0061450 and N2bits   ;=017777
66 2082 2000023004132 sto 4/jmp .SW;switch @2082
67 2083  =2138 
68 2138  ;
69 2138  ; switch called from 2082, moved from further down
70 2138  .SW:; 
71 2138 3020131104044 lod GenWord:jmp .gen0;+0
72 2139 3020145004052 lod IdInfo:jmp .gen1;+1
73 2140 3020131104046 lod GenWord:jmp .gen2;+2 @2140
74 2141 3020131104062 lod GenWord:jmp .gen3;+3
75 2142 3020131104067 lod GenWord:jmp .gen4;+4
76 2143 3021431004160 lod W2246:jmp .gen5;+5
77 2144 3020125004100 lod GenPtr:jmp .gen6;+6 @2144
78 2145 3020131004150 lod GenWord:jmp .gen7;+7
79 2146 0220125004073 o02 GenPtr:jmp .gen8;+8
80 2147 3020131004202 lod GenWord:jmp .gen9;+9
81 2148 3020131004202 lod GenWord:jmp .gen9;+10 @2148
82 2149 3020131004202 lod GenWord:jmp .gen9;+11
83 2150 4021014000000 jmp .gen12:o00 0;+12
84 2151 0211145004061 o02 K11:jmp .gen13;+13 load 12, jump
85 2152  =2083 
86 2083  ;
87 2083  ; negative values come here
88 2083  ; set up dummy arg list, then branch back to treat as list
89 2083  ;
90 2083  .single:; 
91 2083 0404027 sto GenDmy   ; save argument
92 2083+0604116 lod GenDmyP   ;=GenDmy, address of argument
93 2084 1004034 jmp .1   ;->join main code @2084
94 2084+ ;--------------------------------------------------------------------
95 2084+ ; type 0 entries, GenWord in Acc
96 2084+ ;
97 2084+ .gen0:; 
98 2084+0101443 add K5a   ;=5 convert to type 6
99 2085  .gen0a:; 
100 2085   call     ;and output instruction
100+12085 7307175001640 lnk GenInst.lnk:jmp GenInst.ent 
101 2086 1004036 jmp .gennxt   ;->back for more @2086
102 2086+ ;--------------------------------------------------------------------
103 2086+ ; type 2 entries, get address exprn from N1 part of Acc (GenWord)
104 2086+ ; convert to type 6 and output instruction
105 2086+ ;
106 2086+ .gen2:; 
107 2086+1220024 srl 20   ; >> 20
108 2087 0061450 and N2bits   ;=017777
109 2087+0104117 add W2127   ;=0022000000
110 2088 0401422 sto GenAdr   ; @2088
111 2088+0044026 o02 GenWord   ;item+1
112 2089 0101452 add K3   ;=+3 convert to type 6
113 2089+1004045 jmp .gen0a   ;->and generate instruction
114 2090  ;
115 2090  ; type 1 entries, call subroutine to do output
116 2090  ;
117 2090  .gen1:; 
118 2090   call     ;output item to ocode @2090
118+12090 7320141004054 lnk GenSubr.lnk:jmp GenSubr.ent 
119 2091 1004036 jmp .gennxt   ; back for more
120 2091+  pad     ;
120+12091+0000000 00 0    
121 2092  =2097 
122 2097  ;
123 2097  ; type 13 entry, Acc=12
124 2097  ;
125 2097 0564026.gen13:o27 GenWord   ;convert to type 1 item
126 2097+0604306 lod W2246   ;
127 2098 1004052 jmp .gen1   ;join type 1 code @2098
128 2098+ ;
129 2098+ ; type 3 entries, skip if current type matches, type from F1 second digit
130 2098+ ; number of items skipped = N1, GenWord in Acc.
131 2098+ ;
132 2098+0064121.gen3:and W2129   ;=0300000000000 @2098+
133 2099 0124306 sub W2246   ;current type match?
134 2099+  jnz     ;no, on to next item
134+12099+1144064 jz .1    
134+22100 1004040 jmp gencode.3    
134+32100+ .1:; 
135 2100+ .gen3a:; 
136 2100+0604026 lod GenWord   ;reload current word
137 2101 1024037 jn .2   ;finished if negative (only happens with type 4)
138 2101+1220024 srl 20   ; >> 20 get number of entries...
139 2102 0061450 and N2bits   ;=017777 ...to be skipped @2102
140 2102+0504025 ads GenPtr   ;add to pointer
141 2103 1004040 jmp .3   ;and continue with next item
142 2103+ ;
143 2103+ ; type 4 entries, skip if id type matches, as for type 3, but type
144 2103+ ; is that associated with id, rather than Acc
145 2103+ ;
146 2103+0064121.gen4:and W2129   ;=00300000000000
147 2104 0400004 sto 4   ;save type bits @2104
148 2104+0064031 and IdInfo   ;mask with current setting
149 2105 0120004 sub 4   ;compare
150 2105+1144064 jz .gen3a   ;match, perform skip
151 2106 1004040 jmp .3   ;otherwise do next item @2106
152 2106+  pad     ;
152+12106+0000000 00 0    
153 2107  ;
154 2107  ; type 8 entries
155 2107  ; acc = GenPtr+1
156 2107  ;
157 2107 0401422.gen8:sto GenAdr   ; @2107
158 2107+0604026 lod GenWord   ; item
159 2108 0061465 and F2mask   ;=<:77 0>
160 2108+0104122 add K6a   ;=6 make type 6 entry
161 2109   call     ;and generate it @2109
161+12109 7307175001640 lnk GenInst.lnk:jmp GenInst.ent 
162 2110 2220126577777 inc GenPtr/lod -1;
163 2111 1024037 jn .2   ;finished, check end of list @2111
164 2111+1004040 jmp .3   ;
165 2112  ;
166 2112  ; type 6 entries
167 2112  ; enter with GenPtr (pointer to generate list) in Acc
168 2112  ; extract pattern number from word and recursively call generate1
169 2112  ;
170 2112  .gen6:call     ;save generate list pointer @2112
170+12112 7323731005012 lnk push.lnk:jmp push.ent 
171 2113 0604024 lod gencode.lnk   ;
172 2113+  nop     ;
172+12113+1004102 jmp .1    
172+22114  .1:; 
173 2114   call     ;and return address @2114
173+12114 7323731005012 lnk push.lnk:jmp push.ent 
174 2115 0604026 lod GenWord   ; item
175 2115+1220024 srl 20   ;
176 2116 0061450 and N2bits   ;extract item number @2116
177 2116+  nop     ;
177+12116+1004105 jmp .1    
177+22117  .1:; 
178 2117   call     ;generate it
178+12117 7320121004032 lnk gencode1.lnk:jmp gencode1.ent 
179 2118 0010646577777 o00 stkp/lod -1;restore link @2118
180 2119 0404024 sto gencode.lnk   ;
181 2119+0041461 o02 K1   ;=1+1=>2
182 2120 2710646600000 o27 stkp/lod 0;undo stack @2120
183 2121 0404025 sto GenPtr   ;restore generate pointer
184 2121+1004036 jmp .gennxt   ;and resume
185 2122  ;
186 2122  =2152 
187 2152  ;
188 2152  ; type 7 entries
189 2152  ; generate call to run-time support
190 2152  ;
191 2152 1220024.gen7:srl 20   ; >> 20 @2152
192 2152+0061450 and N2bits   ;=017777 shift instruction down
193 2153 0404030 sto Link19   ;save instruction
194 2153+0044117 o02 W2127   ;=<00 4/00 0>
195 2154 0401422 sto GenAdr   ;address info for linkage @2154
196 2154+0604123 lod W2131   ;=<:73 6>
197 2155   call     ;output linkage to RTS
197+12155 7307175001665 lnk GenSkpInst.lnk:jmp GenSkpInst.ent 
198 2156 0604030 lod Link19   ;load supplied instruction @2156
199 2156+0104117 add W2127   ;=0000022000000 add RTS markers
200 2157 0401422 sto GenAdr   ;store for PutInst
201 2157+0604026 lod GenWord   ;load original param word
202 2158 0064124 and W2132   ;=00000000160000 @2158
203 2158+0104120 add W2128   ;=00000001000000
204 2159 0104122 add K6a   ;=6 type 6 flag for PutInst
205 2159+1004045 jmp .gen0a   ;->
206 2160  ;
207 2160  ; type 5 entries, make sure both operands are float, do swap in loc 4
208 2160  ; if neccesary, then generate appropriate version. Entry always
209 2160  ; followed by forward and reverse instructions (may be same thing).
210 2160  ;
211 2160 0124121.gen5:sub W2129   ;=00300000000000 (mask type) @2160
212 2160+1044163 jz .gen5a   ;
213 2161 0604125 lod W2133   ;=<00 4096 : 65 5>
214 2161+  nop     ;
214+12161+1004162 jmp .1    
214+22162  .1:; 
215 2162   call     ;convert to float @2162
215+12162 7307175001640 lnk GenInst.lnk:jmp GenInst.ent 
216 2163  .gen5a:; 
217 2163 0604031 lod IdInfo   ;
218 2163+0064121 and W2129   ;=00300000000000 (mask type)
219 2164 0124121 sub W2129   ;=00300000000000 real ? @2164
220 2164+1044200 jz .gen5b   ;yes, ->
221 2165 0604126 lod W2134   ;=<00 4/00 1> (use location 4)
222 2165+0401422 sto GenAdr   ;store address info
223 2166 0604127 lod W2135   ;<00 0:20 0> @2166
224 2166+0104122 add K6a   ;=6
225 2167   call     ;code to store value
225+12167 7307175001640 lnk GenInst.lnk:jmp GenInst.ent 
226 2168 0044130 o02 W2136   ;=<00 0:30 0>=><00 0:30 1> @2168
227 2168+0404026 sto GenWord   ;store item
228 2169   nop     ;
228+12169 1104171 jmp .1    
228+22169+ .1:; 
229 2169+0604031 lod IdInfo   ;
230 2170   call     ;generate load @2170
230+12170 7320141004054 lnk GenSubr.lnk:jmp GenSubr.ent 
231 2171 0604125 lod W2133   ;<00 4096 : 65 5>
232 2171+  nop     ;
232+12171+1004174 jmp .1    
232+22172  .1:; 
233 2172   call     ;generate float @2172
233+12172 7307175001640 lnk GenInst.lnk:jmp GenInst.ent 
234 2173 0604126 lod W2134   ;=<00 4/00 1>
235 2173+0404031 sto IdInfo   ;set address
236 2174 0020126600002 o00 GenPtr/lod 2;back to do reverse op @2174
237 2175 1004041 jmp .4   ;
238 2175+  nop     ;
238+12175+1004200 jmp .1    
238+22176  .1:; 
239 2176  .gen5b:; 
240 2176 0020126600001 o00 GenPtr/lod 1;back to do forward op @2176
241 2177 1004041 jmp .4   ;
242 2177+  pad     ;
242+12177+0000000 00 0    
243 2178  ;
244 2178  ; types 9, 10, 11
245 2178  ; convert to 1, 2, 3 and re-process
246 2178  ;
247 2178  .gen9:; 
248 2178 0124131 sub W2137   ;=8 treat as 1, 2, 3 @2178
249 2178+1004045 jmp .gen0a   ;
250 2179  ;
251 2179  ; type 12
252 2179  .gen12:; 
253 2179   call     ; @2179
253+12179 7306371101531 lnk putcode6.lnk:jmp putcode6.ent 
254 2180 1004036 jmp .gennxt   ; @2180
255 2180+  pad     ;
255+12180+0000000 00 0    
256 2181  ;
257 2181  =2126 
258 2126 0000000004027GenDmyP:+GenDmy; @2126
259 2127 0000022000000W2127:+00000022000000;=<00 4/00 0> @2127
260 2128 0000001000000W2128:+00000001000000; 00 0 : 40 0 @2128
261 2129 0300000000000W2129:+00300000000000; 03 0 : 00 0 @2129
262 2130 0000000000006K6a:+6; @2130
263 2131 0000001660006W2131:+00000001660006; 00 0 : 73 6 @2131
264 2132 0000000160000W2132:+00000000160000; @2132
265 2133 0040001520005W2133:+00040001520005;<00 4096 : 65 5> @2133
266 2134 0000022000001W2134:+00000022000001;<00 4/00 1> @2134
267 2135 0000000400000W2135:+00000000400000;<00 0:20 0> @2135
268 2136 0000000600000W2136:+00000000600000;<00 0:30 0> @2136
269 2137 0000000000010W2137:+8; @2137
270 2138  ;--------------------------------------------------------------------
271 2138  =2092 
272 2092  ;
273 2092  GenSubr::; 
274 2092  .ent:; 
275 2092 0401422 sto GenAdr   ;save it @2092
276 2092+0061462 and B1920   ;= mask out bits
277 2093 0121462 sub B1920   ;= are both set?
278 2093+1044112 jz .2   ; yes, ->
279 2094 0601443 lod K5a   ;=5 convert word to type 6 @2094
280 2094+ .1:; 
281 2094+0104026 add GenWord   ;+item
282 2095   call     ;
282+12095 7307175001640 lnk GenInst.lnk:jmp GenInst.ent 
283 2096   ret     ; @2096
283+12096 0020143000001 o00 GenSubr.lnk/jmp 1 
284 2097  =2122 
285 2122 0604120.2:lod W2128   ;=<00 0:40 0> (jmp) @2122
286 2122+0561422 o27 GenAdr   ;remove bit from word
287 2123 0041443 o02 K5a   ;=5+1->6 make type 6
288 2123+0101456 add B20   ;=<000/000> add in B-bit
289 2124   call     ;and output instruction @2124
289+12124 7307175001640 lnk GenInst.lnk:jmp GenInst.ent 
290 2125 0602211 lod K4   ;=4 convert word to type 5
291 2125+1104056 jmp .1   ;back to main stream of code
292 2126  ;--------------------------------------------------------------------