Pristine Ack-5.5
[Ack-5.5.git] / mach / pdp / cg / table
1 "$Id: table,v 2.33 1994/06/24 13:11:49 ceriel Exp $"
2 /********************************************************
3  * Back end tables for pdp 11                           *
4  * Authors : Ceriel J.H. Jacobs,Hans van Staveren       *
5  *                                                      *
6  * wordsize = 2 bytes, pointersize = 2 bytes.           *
7  *                                                      *
8  * Register r5 is used for the LB, the stack pointer    *
9  * is used for SP. Also some global variables are used: *
10  * - reghp~     : the heap pointer                      *
11  * - trpim~     : trap ignore mask                      *
12  * - trppc~     : address of user defined trap handler  *
13  * - retar      : function return area for size>4       *
14  *                                                      *
15  * Timing is based on the timing information available  *
16  * for the 11/45. Hardware floating point processor is  *
17  * assumed.                                             *
18  ********************************************************/
19
20 /*
21  * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
22  *
23  *          This product is part of the Amsterdam Compiler Kit.
24  *
25  * Permission to use, sell, duplicate or disclose this software must be
26  * obtained in writing. Requests for such permissions may be sent to
27  *
28  *      Dr. Andrew S. Tanenbaum
29  *      Wiskundig Seminarium
30  *      Vrije Universiteit
31  *      Postbox 7161
32  *      1007 MC Amsterdam
33  *      The Netherlands
34  *
35  */
36
37 /* #define REGPATCH             \* save all registers in link block */
38 /* #define UNTESTED             \* include untested rules */
39
40 #ifdef REGPATCH
41 #define SL 8
42 #define SSL "010"
43 #else /* REGPATCH */
44 #define SL 4
45 #define SSL "4"
46 #endif /* REGPATCH */
47
48 #define NC nocoercions:
49
50 /* options */
51 /* #define DORCK        \* rck is expanded instead of thrown away */
52 #define REGVARS         /* use register variables */
53
54 EM_WSIZE=2
55 EM_PSIZE=2
56 EM_BSIZE=SL
57
58 TIMEFACTOR= 1/30
59
60 REGISTERS:
61 r0      = ("r0", 2), REG.
62 r1      = ("r1", 2), REG, ODD_REG.
63 #ifdef REGVARS
64 r2      = ("r2", 2) regvar, RREG.
65 #else
66 /* r2      = ("r2", 2), REG. */
67 #endif
68 r3      = ("r3", 2), REG, ODD_REG.
69 #ifdef REGVARS
70 r4      = ("r4", 2) regvar, RREG.
71 #else
72 /* r4      = ("r4", 2), REG. */
73 #endif
74 lb      = ("r5", 2), localbase.
75 r01     = ("r0", 4, r0, r1), REG_PAIR.
76 #ifndef REGVARS
77 /* r23     = ("r2", 4, r2, r3), REG_PAIR. */
78 #endif
79 fr0     = ("fr0", 4), FLT_REG.
80 fr1     = ("fr1", 4), FLT_REG.
81 fr2     = ("fr2", 4), FLT_REG.
82 fr3     = ("fr3", 4), FLT_REG.
83 fr01    = ("fr0", 8, fr0, fr1), FLT_REG_PAIR.
84 fr23    = ("fr2", 8, fr2, fr3), FLT_REG_PAIR.
85 dr0     = ("fr0", 8, fr0), DBL_REG.
86 dr1     = ("fr1", 8, fr1), DBL_REG.
87 dr2     = ("fr2", 8, fr2), DBL_REG.
88 dr3     = ("fr3", 8, fr3), DBL_REG.
89 dr01    = ("fr0", 16, dr0, dr1), DBL_REG_PAIR.
90 dr23    = ("fr2", 16, dr2, dr3), DBL_REG_PAIR.
91
92 TOKENS:
93
94 /********************************
95  * Types on the EM-machine      *
96  ********************************/
97
98 CONST2          = {INT num;}    2 cost=(2,30) "$%[num]"
99 LOCAL2          = {INT ind,size;}       2 cost=(2,60) "%[ind](r5)"
100 LOCAL4          = {INT ind,size;}       4 cost=(2,120) "%[ind](r5)"
101 ADDR_LOCAL      = {INT ind;}    2
102 ADDR_EXTERNAL   = {STRING ind;} 2 cost=(2,30)  "$%[ind]"
103
104 /********************************************************
105  * Now mostly addressing modes of target machine        *
106  ********************************************************/
107
108 regdef2 =       {REGISTER reg;} 2 cost=(0,30) "(%[reg])"
109 regind2 =       {REGISTER reg; STRING ind;} 2 cost=(2,60) "%[ind](%[reg])"
110 reginddef2 =    {REGISTER reg; STRING ind;} 2 cost=(2,105) "*%[ind](%[reg])"
111 regconst2 =     {REGISTER reg; STRING ind;} 2
112 /********************************************************
113  * This means : add "reg" and "ind" to get address.     *
114  * Not really addressable on the PDP 11                 *
115  ********************************************************/
116 relative2 =     {STRING ind;} 2 cost=(2,60) "%[ind]"
117 reldef2 =       {STRING ind;} 2 cost=(2,105) "*%[ind]"
118 regdef1 =       {REGISTER reg;} 2 cost=(0,30) "(%[reg])"
119 regind1 =       {REGISTER reg; STRING ind;} 2 cost=(2,60) "%[ind](%[reg])"
120 reginddef1 =    {REGISTER reg; STRING ind;} 2 cost=(2,105) "*%[ind](%[reg])"
121 relative1 =     {STRING ind;} 2 cost=(2,60) "%[ind]"
122 reldef1 =       {STRING ind;} 2 cost=(2,105) "*%[ind]"
123
124 /************************************************************************
125  * fto* are floats converted to *, conversion is delayed to be combined *
126  * with store.                                                          *
127  ************************************************************************/
128
129 ftoint =        {REGISTER reg;} 2
130 ftolong =       {REGISTER reg;} 4
131
132 /************************************************************************
133  * ...4 and ...8 are only addressable by the floating point processor.    *
134  ************************************************************************/
135
136 regind4 =       {REGISTER reg; STRING ind; } 4 cost=(2,363) "%[ind](%[reg])"
137 relative4 =     {STRING ind; } 4 cost=(2,363) "%[ind]"
138 regdef4 =       {REGISTER reg;} 4 cost=(2,324) "(%[reg])"
139 regdef8 =       {REGISTER reg;} 8 cost=(2,522) "(%[reg])"
140 relative8 =     {STRING ind; } 8 cost=(2,561) "%[ind]"
141 regind8 =       {REGISTER reg; STRING ind;} 8 cost=(2,561) "%[ind](%[reg])"
142
143 TOKENEXPRESSIONS:
144 SCR_REG =       REG * SCRATCH
145 SCR_FLT_REG =   FLT_REG * SCRATCH
146 SCR_DBL_REG =   DBL_REG * SCRATCH
147 SCR_ODD_REG =   ODD_REG * SCRATCH
148 SCR_REG_PAIR =  REG_PAIR * SCRATCH
149 all=            ALL 
150 source2 =       RREG + REG + regdef2 + regind2 + reginddef2 + localbase + 
151                 relative2 + reldef2 + ADDR_EXTERNAL + CONST2 + LOCAL2 
152 xsource2 =      source2 + ftoint
153 source1 =       regdef1 + regind1 + reginddef1 + relative1 +
154                 reldef1
155 source1or2 =    source1 + source2
156 long4 =         relative4 + regdef4 + LOCAL4 + regind4 + REG_PAIR
157 longf4 =        long4 + FLT_REG - REG_PAIR
158 double8 =       relative8 + regdef8 + regind8 + DBL_REG
159 indexed2 =      regind2 + reginddef2
160 indexed4 =      regind4
161 indexed8 =      regind8
162 indexed  =      indexed2 + indexed4 + indexed8
163 regdeferred =   regdef2 + regdef4 + regdef8
164 indordef =      indexed + regdeferred
165 locals =        LOCAL2 + LOCAL4 
166 variable2 =     relative2 + reldef2
167 variable4 =     relative4
168 variable8 =     relative8
169 variable  =     variable2 + variable4 + variable8
170 dadres2 =       relative2 + RREG + REG + regind2
171 regs =          RREG + REG + REG_PAIR + FLT_REG + FLT_REG_PAIR +
172                 DBL_REG + DBL_REG_PAIR
173 noconst2 =      source2 - CONST2 - ADDR_EXTERNAL
174 allexeptcon =   all - regs - CONST2 - ADDR_LOCAL - ADDR_EXTERNAL
175 externals =     relative1 + relative2 + relative4 + relative8
176 posextern =     variable + regdeferred + indexed + externals
177 diradr2 =       regconst2 + ADDR_EXTERNAL
178
179 #ifdef REGVARS
180 register =      RREG + REG
181 #define INDSTORE remove(allexeptcon-locals) remove(locals, inreg(%[ind])==0)
182 #else
183 register =      REG
184 #define INDSTORE remove(allexeptcon)
185 #endif
186
187 CODE:
188
189 /********************************************************
190  * Group 1 : load instructions.                         *
191  *                                                      *
192  * For most load instructions no code is generated.     *
193  * Action : put something on the fake-stack.            *
194  ********************************************************/
195
196 loc             | |             | {CONST2, $1}                          | |
197 ldc             | |             | {CONST2, loww(1)}  {CONST2, highw(1)} | |
198 #ifdef REGVARS
199 lol inreg($1)==2| |             | regvar($1)                    | |
200 #endif
201 lol             | |             | {LOCAL2, $1,2}                        | |
202 loe             | |             | {relative2, $1}                       | |
203 #ifdef REGVARS
204 lil inreg($1)==2| |             | {regdef2, regvar($1)}         | |
205 #endif
206 lil             | |             | {reginddef2, lb, tostring($1)}    | |
207 lof             | register         | | {regind2,%[1],tostring($1)}       | |
208 ...             | NC regconst2 |
209                  | {regind2,%[1.reg],tostring($1)+"+"+%[1.ind]}        | |
210 ...             | NC ADDR_EXTERNAL |
211                  | {relative2,tostring($1)+"+"+%[1.ind]}                | |
212 ...             | NC ADDR_LOCAL |  | {LOCAL2, %[1.ind] + $1,2}          | |
213 #ifdef REGVARS
214 lol lof inreg($1)!=2 | |
215                         allocate(REG={LOCAL2, $1,2})
216                                 | {regind2,%[a],tostring($2)}   | |
217 #endif
218 lal             | |             | {ADDR_LOCAL, $1}                      | |
219 lae             | |             | {ADDR_EXTERNAL, $1}                   | |
220 lpb             | |             |                       | adp SL          |
221 lxl $1==0       | |             | lb                            | |
222 lxl $1==1       | |             | {LOCAL2 ,SL,2}                        | |
223 lxl $1==2       | |     allocate(REG={LOCAL2, SL, 2})
224                                 | {regind2,%[a], SSL}                   | |
225 lxl $1==3       | |     allocate(REG={LOCAL2, SL, 2})
226                         move({regind2,%[a], SSL},%[a])
227                                 | {regind2,%[a], SSL}                   | |
228 lxl $1>3        | |     allocate(REG={LOCAL2, SL, 2}, REG={CONST2,$1-1})
229                         "1:"
230                         move({regind2,%[a], SSL},%[a])
231                         "sob %[b],1b"
232                         setcc(%[a]) erase(%[a]) erase(%[b])
233                                 | %[a]                                  | |
234 lxa $1==0       | |             | {ADDR_LOCAL, SL}                      | |
235 lxa $1==1       | |     allocate(REG={LOCAL2, SL, 2 })
236                                 | {regconst2, %[a], SSL }               | |
237 lxa $1==2       | |     allocate(REG={LOCAL2, SL, 2 })
238                         move({regind2, %[a], SSL }, %[a])
239                                 | {regconst2, %[a], SSL }               | |
240 lxa $1==3       | |     allocate(REG={LOCAL2, SL, 2 })
241                         move({regind2, %[a], SSL }, %[a])
242                         move({regind2, %[a], SSL }, %[a])
243                                 | {regconst2, %[a], SSL }               | |
244 lxa $1 > 3      | |     allocate(REG={LOCAL2, SL, 2}, REG={CONST2,$1-1})
245                         "1:"
246                         move({regind2,%[a], SSL},%[a])
247                         "sob %[b],1b"
248                         setcc(%[a]) erase(%[a]) erase(%[b])
249                                 | {regconst2, %[a], SSL }               | |
250 dch             | |             |                              | loi 2    |
251 loi $1==2       | register |            | {regdef2, %[1]}                    | |
252 ...             | NC regconst2 |   | {regind2, %[1.reg], %[1.ind]}      | |
253 ...             | NC relative2 |   | {reldef2, %[1.ind]}                | |
254 ...             | NC regind2 |     | {reginddef2, %[1.reg], %[1.ind]}   | |
255 ...             | NC regdef2 |     | {reginddef2, %[1.reg], "0"}| |
256 ...             | NC ADDR_LOCAL |  | {LOCAL2, %[1.ind],2}               | |
257 ...             | NC ADDR_EXTERNAL | | {relative2, %[1.ind]}            | |
258 ...             | NC LOCAL2 |
259                                |{reginddef2, lb, tostring(%[1.ind])}| |
260 loi $1==1       | register |         | {regdef1, %[1]}                       | |
261 ...             | NC regconst2 |   | {regind1, %[1.reg], %[1.ind]}      | |
262 ...             | NC ADDR_EXTERNAL | | {relative1, %[1.ind]}            | |
263 ...             | NC ADDR_LOCAL| |{regind1, lb, tostring(%[1.ind])} | |
264 ...             | NC relative2 |   | {reldef1, %[1.ind]}                | |
265 ...             | NC regind2 |     | {reginddef1, %[1.reg], %[1.ind]}   | |
266 ...             | NC regdef2 |     | {reginddef1, %[1.reg], "0"}| |
267 ...             | NC LOCAL2 | |{reginddef1, lb, tostring(%[1.ind])} | |
268 loi $1==4       | register |         | {regdef4, %[1]}                       | |
269 ...             | NC regconst2 |   | {regind4, %[1.reg], %[1.ind]}      | |
270 ...             | NC ADDR_LOCAL |  | {LOCAL4,%[1.ind],4}                | |
271 ...             | NC ADDR_EXTERNAL | | {relative4, %[1.ind]}            | |
272 loi $1==8       | register |         | {regdef8, %[1]}                       | |
273 ...             | NC regconst2 |   | {regind8, %[1.reg], %[1.ind]}      | |
274 ...             | NC ADDR_LOCAL |
275                  | {regind8, lb , tostring(%[1.ind])}           | |
276 ...             | NC ADDR_EXTERNAL | | {relative8, %[1.ind]}            | |
277 loi             | NC ADDR_LOCAL |
278                         remove(all)
279                         allocate(REG={CONST2,$1/2},REG)
280                         move(lb,%[b])
281                         "add $$%(%[1.ind]+$1%),%[b]"
282                         "1:\tmov -(%[b]),-(sp)"
283                         "sob %[a],1b"
284                         erase(%[a]) erase(%[b])         |               | |
285 ...             | NC ADDR_EXTERNAL |
286                         remove(all)
287                         allocate(REG={CONST2,$1/2},REG)
288                         "mov $$%[1.ind]+$1,%[b]"
289                         "1:\tmov -(%[b]),-(sp)"
290                         "sob %[a],1b"
291                         erase(%[a]) erase(%[b])         |               | |
292 ...             | SCR_REG |
293                         remove(all)
294                         allocate(REG={CONST2,$1})
295                         "add %[a],%[1]"
296                         "asr %[a]"
297                         "1:\tmov -(%[1]),-(sp)"
298                         "sob %[a],1b"
299                         erase(%[1]) erase(%[a])         |               | |
300 los $1==2       | |
301                         remove(all)
302                         "mov (sp)+,r0"
303                         "mov (sp)+,r1"
304                         "jsr pc,los2~"                  |               | |
305 #ifdef UNTESTED
306 los !defined($1)| source2 |
307                         remove(all)
308                         "cmp %[1],$$2"
309                         "beq 1f;jmp unknown~;1:"
310                         "mov (sp)+,r0"
311                         "mov (sp)+,r1"
312                         "jsr pc,los2~"                  |               | |
313 #endif
314
315 ldl             | |             | {LOCAL4, $1,4}                        | |
316 lde             | |             | {relative4, $1}                       | |
317 ldf             | regconst2 |
318                  | {regind4,%[1.reg], tostring($1)+"+"+%[1.ind]}       | |
319 ...             | NC ADDR_EXTERNAL |
320                  | {relative4, tostring($1)+"+"+%[1.ind]}               | |
321 ...             | NC ADDR_LOCAL |  | {LOCAL4, %[1.ind]+$1,4}            | |
322 lpi             | |             | {ADDR_EXTERNAL, $1}                   | |
323
324 /****************************************************************
325  * Group 2 : Store instructions.                                *
326  *                                                              *
327  * These instructions are likely to ruin the fake-stack.        *
328  * We don't expect many items on the fake-stack anyway          *
329  * because we seem to have evaluated an expression just now.    *
330  ****************************************************************/
331
332 #ifdef REGVARS
333 stl inreg($1)==2| xsource2 |
334                         remove(regvar($1))
335                         move(%[1],regvar($1))              |       | |
336 #endif
337 stl             | xsource2 |
338                         remove(indordef)
339                         remove(locals, %[ind] <= $1 && %[ind]+%[size] > $1)
340                         move(%[1],{LOCAL2,$1,2})              |       | |
341 ste             | xsource2 |
342                         remove(posextern)
343                         move(%[1], {relative2, $1 })            |       | |
344 #ifdef REGVARS
345 sil inreg($1)==2| xsource2 |
346                         INDSTORE
347                         move(%[1], {regdef2,regvar($1)})          |       | |
348 #endif
349 sil             | xsource2 |
350                         INDSTORE
351                         move(%[1], {reginddef2,lb,tostring($1)})          |       | |
352 stf             | regconst2 xsource2 |
353                         INDSTORE
354                         move(%[2],{regind2,%[1.reg],tostring($1)+"+"+%[1.ind]}) |     | |
355 ...             | ADDR_EXTERNAL xsource2 |
356                         INDSTORE
357                         move(%[2],{relative2,tostring($1)+"+"+%[1.ind]})|   | |
358 #ifdef REGVARS
359 lol stf inreg($1)!=2 | xsource2 |
360                         INDSTORE
361                         allocate(REG={LOCAL2, $1,2})
362                         move(%[1],{regind2,%[a],tostring($2)})  |    | |
363 lae lol ads sti $3==2 && inreg($2)==2 | | 
364                                         | {regconst2, regvar($2), $1} | sti $4 |
365 lae lol ads loi $3==2 && inreg($2)==2 | | 
366                                         | {regconst2, regvar($2), $1} | loi $4 |
367 #endif
368 sti $1==2       | register xsource2 |
369                         INDSTORE
370                         move(%[2],{regdef2,%[1]})               |       | |
371 ...             | regconst2 xsource2 |
372                         INDSTORE
373                         move(%[2],{regind2,%[1.reg],%[1.ind]})  |       | |
374 ...             | ADDR_EXTERNAL xsource2 |
375                         INDSTORE
376                         move(%[2],{relative2,%[1.ind]})         |       | |
377 ...             | ADDR_LOCAL xsource2 |
378                         INDSTORE
379                         move(%[2],{LOCAL2, %[1.ind], 2})        |       | |
380 ...             | relative2 xsource2 |
381                         INDSTORE
382                         move(%[2],{reldef2,%[1.ind]})           |       | |
383 ...             | regind2 xsource2 |
384                         INDSTORE
385                         move(%[2],{reginddef2,%[1.reg],%[1.ind]}) |     | |
386 sti $1==1       | register source1or2 |
387                         INDSTORE
388                         move(%[2],{regdef1,%[1]})               |       | |
389 ...             | regconst2 source1or2 |
390                         INDSTORE
391                         move(%[2],{regind1,%[1.reg],%[1.ind]})  |       | |
392 ...             | ADDR_EXTERNAL source1or2 |
393                         INDSTORE
394                         move(%[2],{relative1,%[1.ind]})         |       | |
395 ...             | ADDR_LOCAL source1or2 |
396                         INDSTORE
397                         move(%[2],{regind1, lb, tostring(%[1.ind])}) | | |
398 ...             | relative2 source1or2 |
399                         INDSTORE
400                         move(%[2],{reldef1,%[1.ind]})           |       | |
401 ...             | regind2 source1or2 |
402                         INDSTORE
403                         move(%[2],{reginddef1,%[1.reg],%[1.ind]}) |     | |
404 sti $1==4       | NC dadres2 FLT_REG |
405                         INDSTORE
406                         "movfo %[2],*%[1]"
407                         samecc                                  |       | |
408 ...             | NC dadres2 ftolong |
409                         INDSTORE
410                         "setl\nmovfi %[2.reg],*%[1]\nseti"
411                         samecc                                  |       | |
412 ...             | NC regconst2 FLT_REG |
413                         INDSTORE
414                         "movfo %[2],%[1.ind](%[1.reg])"
415                         samecc                                  |       | |
416 ...             | NC regconst2 ftolong |
417                         INDSTORE
418                         "setl\nmovfi %[2.reg],%[1.ind](%[1.reg])\nseti"
419                         samecc                                  |       | |
420 ...             | NC ADDR_LOCAL FLT_REG |
421                         INDSTORE
422                         "movfo %[2],%[1.ind](r5)"
423                         samecc                                  |       | |
424 ...             | NC ADDR_LOCAL ftolong |
425                         INDSTORE
426                         "setl\nmovfi %[2.reg],%[1.ind](r5)\nseti"
427                         samecc                                  |       | |
428 ...             | NC ADDR_EXTERNAL FLT_REG |
429                         INDSTORE
430                         "movfo %[2],%[1.ind]"
431                         samecc                                  |       | |
432 ...             | NC ADDR_EXTERNAL ftolong |
433                         INDSTORE
434                         "setl\nmovfi %[2.reg],%[1.ind]\nseti"
435                         samecc                                  |       | |
436 ...             | register source2 source2 |
437                         INDSTORE
438                         move(%[2],{regdef2,%[1]})
439                         move(%[3],{regind2,%[1],"2"})             |       | |
440 ...             | SCR_REG STACK |
441                         "mov (sp)+,(%[1])+"
442                         "mov (sp)+,(%[1])"
443                         erase(%[1])                             |       | | (4,204)
444 sti $1==8       | NC dadres2 DBL_REG |
445                         INDSTORE
446                         "movf %[2],*%[1]"
447                         samecc                                  |       | |
448 ...             | NC regconst2 DBL_REG |
449                         INDSTORE
450                         "movf %[2],%[1.ind](%[1.reg])"
451                         samecc                                  |       | |
452 ...             | NC ADDR_LOCAL DBL_REG |
453                         INDSTORE
454                         "movf %[2],%[1.ind](r5)"
455                         samecc                                  |       | |
456 ...             | NC ADDR_EXTERNAL DBL_REG |
457                         INDSTORE
458                         "movf %[2],%[1.ind]"
459                         samecc                                  |       | |
460 ...             | SCR_REG regdef8 |
461                         INDSTORE
462                         "mov (%[2.reg]),(%[1])+"
463                         "mov 2(%[2.reg]),(%[1])+"
464                         "mov 4(%[2.reg]),(%[1])+"
465                         "mov 6(%[2.reg]),(%[1])"
466                         erase(%[1])                             |       | |
467 ...             | SCR_REG regind8 |
468                         INDSTORE
469                         "mov %[2.ind](%[2.reg]),(%[1])+"
470                         "mov 2+%[2.ind](%[2.reg]),(%[1])+"
471                         "mov 4+%[2.ind](%[2.reg]),(%[1])+"
472                         "mov 6+%[2.ind](%[2.reg]),(%[1])"
473                         erase(%[1])                             |       | |
474 ...             | SCR_REG relative8 |
475                         INDSTORE
476                         allocate(REG={ADDR_EXTERNAL,%[2.ind]})
477                         "mov (%[a])+,(%[1])+"
478                         "mov (%[a])+,(%[1])+"
479                         "mov (%[a])+,(%[1])+"
480                         "mov (%[a]),(%[1])"
481                         erase(%[1]) erase(%[a])                 |       | |
482 ...             | SCR_REG |
483                         remove(all)
484                         "mov (sp)+,(%[1])+"
485                         "mov (sp)+,(%[1])+"
486                         "mov (sp)+,(%[1])+"
487                         "mov (sp)+,(%[1])"
488                         erase(%[1])                             |       | | (8,408)
489 sti             | SCR_REG |
490                         remove(all)
491                         allocate(REG={CONST2,$1/2})
492                         "1:\tmov (sp)+,(%[1])+"
493                         "sob %[a],1b"
494                         erase(%[1]) erase(%[a]) |       | | (8,150+$1*82)
495 lal sti $2>2 && $2<=8   | NC xsource2 | | %[1] | stl $1 lal $1+2 sti $2-2 |
496 ...                     |                       | | {ADDR_LOCAL,$1} | sti $2 |
497 sts $1==2       | |
498                         remove(all)
499                         "mov (sp)+,r0"
500                         "mov (sp)+,r1"
501                         "jsr pc,sto2~"
502                         erase(r01)                              |       | |
503 sdl             | NC FLT_REG |
504                         remove(indordef)
505                         remove(locals, %[ind] <= $1+2 && %[ind]+%[size] > $1)
506                         move(%[1],{LOCAL4,$1,4})              |       | |
507 ...             | NC ftolong |
508                         remove(indordef)
509                         remove(locals, %[ind] <= $1+2 && %[ind]+%[size] > $1)
510                         "setl\nmovfi %[1.reg],$1(r5)\nseti"
511                         samecc                                  |       | |
512 ...             | source2 source2 |
513                         remove(indordef)
514                         remove(locals, %[ind] <= $1+2 && %[ind]+%[size] > $1)
515                         move(%[1],{LOCAL2,$1,2})
516                         move(%[2],{LOCAL2,$1+2,2})              |       | |
517 sde             | NC FLT_REG |
518                         remove(posextern)
519                         move(%[1],{relative4,$1})               |       | |
520 ...             | NC ftolong |
521                         remove(posextern)
522                         "setl\nmovfi %[1.reg],$1\nseti"
523                         samecc                                  |       | |
524 ...             | source2 source2 |
525                         remove(posextern)
526                         move(%[1], {relative2, $1 })
527                         move(%[2], {relative2, $1+"+2" })            |       | |
528 sdf             | NC regconst2 FLT_REG |
529                         INDSTORE
530                         move(%[2],{regind4,%[1.reg],tostring($1)+"+"+%[1.ind]}) |     | |
531 ...             | NC regconst2 ftolong |
532                         INDSTORE
533                         "setl\nmovfi %[2.reg],$1+%[1.ind](%[1.reg])\nseti"
534                         samecc                                  |     | |
535 ...             | NC ADDR_EXTERNAL FLT_REG |
536                         INDSTORE
537                         move(%[2],{relative4,tostring($1)+"+"+%[1.ind]})|   | |
538 ...             | NC ADDR_EXTERNAL ftolong |
539                         INDSTORE
540                         "setl\nmovfi %[2.reg],$1+%[1.ind]\nseti"
541                         samecc                                  |   | |
542 ...             | regconst2 source2 source2 |
543                         INDSTORE
544                         move(%[2],{regind2,%[1.reg],tostring($1)+"+"+%[1.ind]})
545                         move(%[3],{regind2,%[1.reg],tostring($1+2)+"+"+%[1.ind]}) |     | |
546 ...             | ADDR_EXTERNAL source2 source2 |
547                         INDSTORE
548                         move(%[2],{relative2,tostring($1)+"+"+%[1.ind]})
549                         move(%[3],{relative2,tostring($1+2)+"+"+%[1.ind]}) |     | |
550
551 /****************************************************************
552  * Group 3 : Integer arithmetic.                                *
553  *                                                              *
554  * Implemented (sometimes with the use of subroutines) :        *
555  * all 2 and 4 byte arithmetic.                         *
556  ****************************************************************/
557
558 adi $1==2       | NC SCR_REG CONST2 | | {regconst2,%[1],tostring(%[2.num])} | |
559 ...             | NC SCR_REG ADDR_EXTERNAL | | {regconst2,%[1],%[2.ind]} | |
560 ...             | NC SCR_REG ADDR_LOCAL |
561                         "add r5,%[1]" erase(%[1])       |
562                                            {regconst2,%[1],tostring(%[2.ind])} | | (2,45)
563 ...             | NC register ADDR_LOCAL |
564                         allocate(REG)
565                         "mov r5,%[a]"
566                         "add %[1],%[a]"
567                         erase(%[a])     | {regconst2,%[a],tostring(%[2.ind])} | | (4,90)
568 ...             | NC SCR_REG regconst2 |
569                         "add %[2.reg],%[1]" erase(%[1]) |
570                                            {regconst2,%[1],%[2.ind]} | | (2,45)
571 ...             | NC CONST2+ADDR_EXTERNAL+ADDR_LOCAL+regconst2 SCR_REG |
572                                                 | %[1] %[2]     | adi 2 |
573 ...             | NC source2-register CONST2+ADDR_EXTERNAL+ADDR_LOCAL |
574                         allocate(%[1],REG=%[1]) | %[2] %[a] | adi 2 |
575 ...             | NC source1 CONST2+ADDR_EXTERNAL+ADDR_LOCAL |
576                         allocate(REG={CONST2, 0})
577                         "bisb %[1],%[a]"
578                         erase(%[a])             | %[2] %[a] | adi 2 |
579 ...             | NC regconst2 CONST2 | |
580                                            {regconst2,%[1.reg],
581                                               tostring(%[2.num])+"+"+%[1.ind]} | |
582 ...             | NC regconst2 ADDR_EXTERNAL | |
583                                            {regconst2,%[1.reg],
584                                               %[2.ind]+"+"+%[1.ind]} | |
585 ...             | NC regconst2 ADDR_LOCAL | 
586                         "add r5,%[1.reg]" erase(%[1.reg]) |
587                                            {regconst2,%[1.reg],
588                                               tostring(%[2.ind])+"+"+%[1.ind]} | | (2,45)
589 ...             | NC regconst2 regconst2 |
590                         "add %[2.reg],%[1.reg]" erase(%[1.reg]) |
591                                            {regconst2,%[1.reg],%[2.ind]+"+"+%[1.ind]} | | (2,45)
592 ...             | NC regconst2 noconst2 |
593                         "add %[2],%[1.reg]" erase(%[1.reg]) | %[1] | | (2,45)+%[2]
594 ...             | NC SCR_REG noconst2 |
595                         "add %[2],%[1]"
596                         setcc(%[1])     erase(%[1])     | %[1]  | | (2,45)+%[2]
597 ...             | NC source2 regconst2 |
598                         "add %[1],%[2.reg]"
599                         erase(%[2.reg])                 | %[2]  | | (2,45)+%[1]
600 ...             | NC regconst2 source2 |
601                         "add %[2],%[1.reg]"
602                         erase(%[1.reg])                 | %[1]  | | (2,45)+%[2]
603 ...             | source2 SCR_REG |
604                         "add %[1],%[2]"
605                         setcc(%[2])     erase(%[2])     | %[2]  | | (2,45)+%[1]
606
607 ldc adi $2==4 && highw(1)==0 | SCR_REG SCR_REG |
608                         "add $$%(loww(1)%),%[2]"
609                         "adc %[1]"
610                         erase(%[1]) erase(%[2])         | %[2] %[1] | |
611 ldc adi $2==4 | SCR_REG SCR_REG |
612                         "add $$%(loww(1)%),%[2]"
613                         "adc %[1]"
614                         "add $$%(highw(1)%),%[1]"
615                         erase(%[1]) erase(%[2])         | %[2] %[1] | |
616 adi $1==4       | SCR_REG SCR_REG source2 source2 |
617                         "add %[4],%[2]"
618                         "adc %[1]"
619                         "add %[3],%[1]"
620                         setcc(%[1]) erase(%[1]) erase(%[2])
621                                 | %[2] %[1]              | | (6,120)+%[4]+%[3]
622 ...             | SCR_REG SCR_REG source2 STACK |
623                         "add (sp)+,%[2]"
624                         "adc %[1]"
625                         "add %[3],%[1]"
626                         setcc(%[1]) erase(%[1]) erase(%[2])
627                                 | %[2] %[1]              | | (6,190)+%[3]
628 ...             | SCR_REG SCR_REG STACK |
629                         "add (sp)+,%[1]"
630                         "add (sp)+,%[2]"
631                         "adc %[1]"
632                         setcc(%[1]) erase(%[1]) erase(%[2])
633                                 | %[2] %[1]             | | (6,280)
634 ...             | source2 source2 SCR_REG SCR_REG |
635                         "add %[2],%[4]"
636                         "adc %[3]"
637                         "add %[1],%[3]"
638                         setcc(%[3]) erase(%[3]) erase(%[4])
639                                 | %[4] %[3]              | | (6,120)+%[1]+%[2]
640 #ifdef UNTESTED
641 adi !defined($1)| source2 |
642                         remove(all)
643                         move(%[1],r0)
644                         "jsr pc,adi~"                   |       | |
645 #endif
646 loc sbi $2==2   | |                                     | | loc 0-$1 adi 2 |
647 sbi $1==2       | source2 SCR_REG |
648                         "sub %[1],%[2]"
649                         setcc(%[2])     erase(%[2])     | %[2]  | | (2,45)+%[1]
650 ...             | NC SCR_REG source2-register |
651                         "sub %[2],%[1]"
652                         "neg %[1]"
653                         setcc(%[1])     erase(%[1])     | %[1]  | | (4,75)+%[2]
654 ldc sbi $2==4 && highw(1)==0 | SCR_REG SCR_REG |
655                         "sub $$%(loww(1)%),%[2]"
656                         "sbc %[1]"
657                         erase(%[1]) erase(%[2])         | %[2] %[1] | |
658 ldc sbi $2==4 | SCR_REG SCR_REG |
659                         "sub $$%(loww(1)%),%[2]"
660                         "sbc %[1]"
661                         "sub $$%(highw(1)%),%[1]"
662                         erase(%[1]) erase(%[2])         | %[2] %[1] | |
663 sbi $1==4       | source2-register source2-register SCR_REG SCR_REG |
664                         "sub %[2],%[4]"
665                         "sbc %[3]"
666                         "sub %[1],%[3]"
667                         setcc(%[3]) erase(%[3]) erase(%[4])
668                                 | %[4] %[3]             | | (6,120)+%[1]+%[2]
669 ...             | source2 source2 STACK |
670                         "sub %[2],2(sp)"
671                         "sbc (sp)"
672                         "sub %[1],(sp)"               | | | (10,280)+%[1]+%[2]
673 #ifdef UNTESTED
674 sbi !defined($1)| source2 |
675                         remove(all)
676                         move(%[1],r0)
677                         "jsr pc,sbi~"                   |       | |
678 #endif
679 mli $1==2       | SCR_ODD_REG source2 |
680                         "mul %[2],%[1]"
681                         setcc(%[1])     erase(%[1])     | %[1]  | |(2,330)+%[2]
682 ...             | source2 SCR_ODD_REG |
683                         "mul %[1],%[2]"
684                         setcc(%[2])     erase(%[2])     | %[2]  | |(2,330)+%[1]
685 mli $1==4       | |     remove(all)
686                         "jsr pc,mli4~"
687                                 | r1 r0                                 | |
688 #ifdef UNTESTED
689 mli !defined($1)| source2 |
690                         remove(all)
691                         move(%[1],r0)
692                         "jsr pc,mli~"                   |       | |
693 #endif
694 dvi $1==2       | source2 source2 |
695                         allocate(%[2],REG_PAIR)
696                         "mov %[2],%[a.2]"
697                         "sxt %[a.1]"
698                         "div %[1],%[a.1]"               | %[a.1] | |
699 ...             | source2 source2 |
700                         INDSTORE
701                         "mov %[1],-(sp)"
702                         "mov %[2],r1"
703                         "sxt r0"
704                         "div (sp)+,r0"                  | r0     | |(100,1000)
705 dvi $1==4       | |     remove(all)
706                         "jsr pc,dvi4~"                  | r1 r0 | |
707 #ifdef UNTESTED
708 dvi !defined($1)| source2 |
709                         remove(all)
710                         move(%[1],r0)
711                         "jsr pc,dvi~"                   |       | |
712 #endif
713 rmi $1==2       | source2 source2 |
714                         allocate(%[2],REG_PAIR)
715                         "mov %[2],%[a.2]"
716                         "sxt %[a.1]"
717                         "div %[1],%[a.1]"               | %[a.2] | |
718 ...             | source2 source2 |
719                         INDSTORE
720                         "mov %[1],-(sp)"
721                         "mov %[2],r1"
722                         "sxt r0"
723                         "div (sp)+,r0"                  | r1     | |(100,1000)
724 rmi $1==4       | |     remove(all)
725                         "jsr pc,rmi4~"                  | r1 r0 | |
726 #ifdef UNTESTED
727 rmi !defined($1)| source2 |
728                         remove(all)
729                         move(%[1],r0)
730                         "jsr pc,rmi~"                   |       | |
731 #endif
732 ngi $1==2       | SCR_REG |
733                         "neg %[1]"
734                         setcc(%[1])     erase(%[1])     | %[1]  | | (2,75)
735 ngi $1==4       | SCR_REG SCR_REG |
736                         "neg %[1]"
737                         "neg %[2]"
738                         "sbc %[1]"
739                         setcc(%[1]) erase(%[1]) erase(%[2])
740                                 | %[2] %[1]                     | | (6,180)
741 #ifdef UNTESTED
742 ngi !defined($1)| source2 |
743                         remove(all)
744                         move(%[1],r0)
745                         "jsr pc,ngi~"                   |       | |
746 #endif
747 loc sli $1==1 && $2==2 | SCR_REG |
748                         "asl %[1]"
749                         setcc(%[1])     erase(%[1])             | %[1]| |
750 sli $1==2       | source2 SCR_REG |
751                         "ash %[1],%[2]"
752                         setcc(%[2])     erase(%[2])             | %[2]  | |
753 sli $1==4       | source2 SCR_REG_PAIR |
754                         "ashc %[1],%[2]"
755                         setcc(%[2])     erase(%[2])             | %[2]  | |
756 #ifdef UNTESTED
757 sli !defined($1)| source2 |
758                         remove(all)
759                         move(%[1],r0)
760                         "jsr pc,sli~"                   |       | |
761 #endif
762 loc sri $1==1 && $2==2  | SCR_REG |
763                         "asr %[1]"
764                         setcc(%[1])     erase(%[1])             | %[1]| |
765 loc sri $2==2   | SCR_REG |
766                         "ash $$%(0-$1%),%[1]"
767                         setcc(%[1])     erase(%[1])             | %[1]| |
768 sri $1==2       | SCR_REG SCR_REG |
769                         "neg %[1]"
770                         "ash %[1], %[2]"
771                         setcc(%[2])     erase(%[1]) erase(%[2]) | %[2]  | |
772 loc sri $2==4       | SCR_REG_PAIR |
773                         "ashc $$%(0-$1%),%[1]"
774                         setcc(%[1])     erase(%[1])             | %[1]  | |
775 sri $1==4       | SCR_REG SCR_REG_PAIR |
776                         "neg %[1]"
777                         "ashc %[1],%[2]"
778                         setcc(%[2])     erase(%[1]) erase(%[2]) | %[2]  | |
779 #ifdef UNTESTED
780 sri !defined($1)| source2 |
781                         remove(all)
782                         move(%[1],r0)
783                         "jsr pc,sri~"                   |       | |
784 #endif
785
786 /************************************************
787  * Group 4 : unsigned arithmetic                *
788  *                                              *
789  * adu = adi                                    *
790  * sbu = sbi                                    *
791  * slu = sli                                    *
792  *                                              *
793  * Supported : 2- and 4 byte arithmetic.        *
794  ************************************************/
795
796 adu             | |     |                                       | adi $1 |
797 sbu             | |     |                                       | sbi $1 |
798 mlu $1==2       | |     |                                       | mli $1 |
799 mlu $1==4       | |     remove(all)
800                         "jsr pc,mlu4~"                  | r1 r0 | |
801 #ifdef UNTESTED
802 mlu !defined($1)| source2 |
803                         remove(all)
804                         move(%[1],r0)
805                         "jsr pc,mlu~"                   |       | |
806 #endif
807 loc dvu $1>0 && $1<=32767 && $2==2       | source2 |
808                         allocate(%[1],REG_PAIR)
809                         move(%[1],%[a.2])
810                         "clr %[a.1]"
811                         "div $$$1,%[a.1]"               | %[a.1] | |
812 dvu $1==2       | |     remove(all)
813                         "jsr pc,dvu2~"                  | r0    | |
814 dvu $1==4       | |     remove(all)
815                         "jsr pc,dvu4~"                  | r1 r0 | |
816 #ifdef UNTESTED
817 dvu !defined($1)| source2 |
818                         remove(all)
819                         move(%[1],r0)
820                         "jsr pc,dvu~"                   |       | |
821 #endif
822 loc rmu $1>0 && $1<=32767 && $2==2       | source2 |
823                         allocate(%[1],REG_PAIR)
824                         move(%[1],%[a.2])
825                         "clr %[a.1]"
826                         "div $$$1,%[a.1]"               | %[a.2] | |
827 rmu $1==2       | |     remove(all)
828                         "jsr pc,rmu2~"                  | r1    | |
829 rmu $1==4       | |     remove(all)
830                         "jsr pc,rmu4~"                  | r1 r0 | |
831 #ifdef UNTESTED
832 rmu !defined($1)| source2 |
833                         remove(all)
834                         move(%[1],r0)
835                         "jsr pc,rmu~"                   |       | |
836 #endif
837 slu             | |     |                               | sli $1 |
838 loc slu         | |     |                               | loc $1 sli $2 |
839 sru $1==2       | source2 xsource2 |
840                         allocate(%[1],%[2],REG=%[1],REG_PAIR)
841                         move(%[2],%[b.2])
842                         move({CONST2,0},%[b.1])
843                         "neg %[a]"
844                         "ashc %[a],%[b]"
845                         erase(%[b])                     | %[b.2]  | |
846 loc sru $2==2       | xsource2 |
847                         allocate(%[1],REG_PAIR)
848                         move(%[1],%[a.2])
849                         move({CONST2,0},%[a.1])
850                         "ashc $$%(0-$1%),%[a]"
851                         erase(%[a])                     | %[a.2]  | |
852 sru $1==4       | |     remove(all)
853                         move({CONST2,$1},r0)
854                         "jsr pc,sru~"
855                         erase(r0)                               |       | |
856 #ifdef UNTESTED
857 sru !defined($1)| source2 |
858                         remove(all)
859                         move(%[1],r0)
860                         "jsr pc,sru~"                   |       | |
861 #endif
862
863 /************************************************
864  * Group 5 : Floating point arithmetic          *
865  *                                              *
866  * Supported : 4- and 8 byte arithmetic.        *
867  ************************************************/
868
869 adf $1==4       | FLT_REG SCR_FLT_REG |
870                         "addf %[1],%[2]"
871                         samecc erase(%[2])              | %[2] | | (2,500)+%[1]
872 ...             | SCR_FLT_REG FLT_REG |
873                         "addf %[2],%[1]"
874                         samecc erase(%[1])              | %[1] | | (2,500)+%[2]
875 adf $1==8       | double8 SCR_DBL_REG |
876                         "addf %[1],%[2]"
877                         samecc erase(%[2])              | %[2] | | (2,600)+%[1]
878 ...             | SCR_DBL_REG double8 |
879                         "addf %[2],%[1]"
880                         samecc erase(%[1])              | %[1] | | (2,600)+%[2]
881 #ifdef UNTESTED
882 adf !defined($1)| source2 |
883                         remove(ALL)
884                         move(%[1],r0)
885                         "jsr pc,adf~"                   |       | |
886 #endif
887 sbf $1==4       | FLT_REG SCR_FLT_REG |
888                         "subf %[1],%[2]"
889                         samecc erase(%[2])              | %[2] | | (2,500)+%[1]
890 sbf $1==8       | double8 SCR_DBL_REG |
891                         "subf %[1],%[2]"
892                         samecc erase(%[2])              | %[2] | | (2,600)+%[1]
893 #ifdef UNTESTED
894 sbf !defined($1)| source2 |
895                         remove(ALL)
896                         move(%[1],r0)
897                         "jsr pc,sbf~"                   |       | |
898 #endif
899 mlf $1==4       | FLT_REG SCR_FLT_REG |
900                         "mulf %[1],%[2]"
901                         samecc erase(%[2])              | %[2] | | (2,700)+%[1]
902 ...             | SCR_FLT_REG FLT_REG |
903                         "mulf %[2],%[1]"
904                         samecc erase(%[1])              | %[1] | | (2,700)+%[2]
905 mlf $1==8       | double8 SCR_DBL_REG |
906                         "mulf %[1],%[2]"
907                         samecc erase(%[2])              | %[2] | | (2,1000)+%[1]
908 ...             | SCR_DBL_REG double8 |
909                         "mulf %[2],%[1]"
910                         samecc erase(%[1])              | %[1] | | (2,1000)+%[2]
911 #ifdef UNTESTED
912 mlf !defined($1)| source2 |
913                         remove(ALL)
914                         move(%[1],r0)
915                         "jsr pc,mlf~"                   |       | |
916 #endif
917 dvf $1==4       | FLT_REG SCR_FLT_REG |
918                         "divf %[1],%[2]"
919                         samecc erase(%[2])              | %[2] | | (2,800)+%[1]
920 dvf $1==8       | double8 SCR_DBL_REG |
921                         "divf %[1],%[2]"
922                         samecc erase(%[2])              | %[2] | | (2,1200)+%[1]
923 #ifdef UNTESTED
924 dvf !defined($1)| source2 |
925                         remove(ALL)
926                         move(%[1],r0)
927                         "jsr pc,dvf~"                   |       | |
928 #endif
929 ngf $1==4       | SCR_FLT_REG |
930                         "negf %[1]"
931                         samecc erase(%[1])              | %[1] | |(2,270)
932 ngf $1==8       | SCR_DBL_REG |
933                         "negf %[1]"
934                         samecc erase(%[1])              | %[1] | |(2,270)
935 #ifdef UNTESTED
936 ngf !defined($1)| source2 |
937                         remove(ALL)
938                         move(%[1],r0)
939                         "jsr pc,ngf~"                   |       | |
940 #endif
941 fif $1==4       | longf4 FLT_REG |
942                         allocate(FLT_REG_PAIR)
943                         move(%[1],%[a.1])
944                         "modf %[2],%[a]"
945                         samecc erase(%[a.1])    | %[a.1] %[a.2] | | (2,750)+%[2]
946 fif $1==8       | double8 double8 |
947                         allocate(DBL_REG_PAIR)
948                         move(%[1],%[a.1])
949                         "modf %[2],%[a]"
950                         samecc erase(%[a.1])    | %[a.1] %[a.2] | | (2,1500)+%[2]
951 #ifdef UNTESTED
952 fif !defined($1)| source2 |
953                         remove(ALL)
954                         move(%[1],r0)
955                         "jsr pc,fif~"                   |       | |
956 #endif
957 fef $1==4       | FLT_REG |
958                         allocate(REG)
959                         "movei %[1],%[a]"
960                         "movie $$0,%[1]"
961                         samecc
962                         erase(%[1])             |%[1] %[a] | | (4,500)
963 fef $1==8       | DBL_REG |
964                         allocate(REG)
965                         "movei %[1],%[a]"
966                         "movie $$0,%[1]"
967                         samecc
968                         erase(%[1])             |%[1] %[a] | | (4,500)
969 #ifdef UNTESTED
970 fef !defined($1)| source2 |
971                         remove(ALL)
972                         move(%[1],r0)
973                         "jsr pc,fef~"                   |       | |
974 #endif
975
976 /****************************************
977  * Group 6 : pointer arithmetic.        *
978  *                                      *
979  * Pointers have size 2 bytes.          *
980  ****************************************/
981
982 adp             | SCR_REG |  | {regconst2, %[1], tostring($1)} | |
983 ...             | NC regconst2 |   | {regconst2, %[1.reg], tostring($1)+"+"+%[1.ind]}    | |
984 ...             | NC ADDR_EXTERNAL | | {ADDR_EXTERNAL, tostring($1)+"+"+%[1.ind]} | |
985 ...             | NC ADDR_LOCAL |  | {ADDR_LOCAL,%[1.ind]+$1}              | |
986 ads $1==2       | |             |                       | adi $1 |
987 sbs $1==2       | |             |                       | sbi $1 |
988
989 /****************************************
990  * Group 7 : increment/decrement/zero   *
991  ****************************************/
992
993 inc             | SCR_REG |
994                         "inc %[1]"
995                         setcc(%[1])     erase(%[1])     | %[1] | |
996 #ifdef REGVARS
997 inl inreg($1)==2| |     remove(regvar($1))
998                         "inc %(regvar($1)%)"
999                         erase(regvar($1))          |       | |
1000 #endif
1001 inl             | |     remove(indordef)
1002                         remove(locals, %[ind] <= $1 && %[ind]+%[size] > $1)
1003                         "inc $1(r5)"
1004                         setcc({LOCAL2,$1,2})          |       | |
1005 ldl ldc adi sdl $1==$4 && $3==4 && highw(2)==0 | |
1006                         remove(indordef)
1007                         remove(locals, %[ind] <= $1 && %[ind]+%[size] > $1)
1008                         "add $$%(loww(2)%),2+$1(r5)"
1009                         "adc $1(r5)"                     |      | |
1010 ldl ldc adi sdl $1==$4 && $3==4 | |
1011                         remove(indordef)
1012                         remove(locals, %[ind] <= $1 && %[ind]+%[size] > $1)
1013                         "add $$%(loww(2)%),2+$1(r5)"
1014                         "adc $1(r5)"
1015                         "add $$%(highw(2)%),$1(r5)"     |       | |
1016 ine             | |     remove(posextern)
1017                         "inc $1"
1018                         setcc({relative2,$1})           |       | |
1019 lde ldc adi sde $1==$4 && $3==4 && highw(2)==0 | |
1020                         remove(posextern)
1021                         "add $$%(loww(2)%),2+$1"
1022                         "adc $1"                        |       | |
1023 lde ldc adi sde $1==$4 && $3==4 | |
1024                         remove(posextern)
1025                         "add $$%(loww(2)%),2+$1"
1026                         "adc $1"
1027                         "add $$%(highw(2)%),$1"         |       | |
1028 dec             | SCR_REG |
1029                         "dec %[1]"
1030                         setcc(%[1])     erase(%[1])     | %[1]  | |
1031 #ifdef REGVARS
1032 del inreg($1)==2| |     remove(regvar($1))
1033                         "dec %(regvar($1)%)"
1034                         erase(regvar($1))          |       | |
1035 #endif
1036 del             | |     remove(indordef)
1037                         remove(locals, %[ind] <= $1 && %[ind]+%[size] > $1)
1038                         "dec $1(r5)"
1039                         setcc({LOCAL2,$1,2})          |       | |
1040 dee             | |     remove(posextern)
1041                         "dec $1"
1042                         setcc({relative2,$1})           |       | | (4,90)
1043
1044 #ifdef REGVARS
1045 lol loc sbi stl $1==$4 && $3==2 && inreg($1)==2 | | 
1046                         remove(regvar($1))
1047                         "sub $$$2,%(regvar($1)%)"
1048                         erase(regvar($1))               |       | |
1049 lol ngi stl $1==$3 && $2==2 && inreg($1)==2 | |
1050                         remove(regvar($1))
1051                         "neg %(regvar($1)%)"
1052                         erase(regvar($1))               |       | |
1053 lil ngi sil $1==$3 && $2==2 && inreg($1)==2 | |
1054                         INDSTORE
1055                         "neg *%(regvar($1)%)"           |       | |
1056 lil inc sil $1==$3 && inreg($1)==2 | | INDSTORE
1057                         "inc *%(regvar($1)%)"
1058                         setcc({regdef2, regvar($1)})    |       | |
1059 lil dec sil $1==$3 && inreg($1)==2 | | INDSTORE
1060                         "dec *%(regvar($1)%)"
1061                         setcc({regdef2, regvar($1)})    |       | |
1062 lol adi stl $2==2 && $1==$3 && inreg($1)==2 | source2 |
1063                         remove(regvar($1))
1064                         "add %[1],%(regvar($1)%)"
1065                         erase(regvar($1))               |       | |
1066 lol dup adp stl loi $1==$4 && $2==2 && inreg($1)==2 && $3==1 && $5==1 | |
1067                         allocate(REG={CONST2, 0})
1068                         remove(regvar($1))
1069                         "bisb (%(regvar($1)%))+,%[a]"
1070                         erase(%[a])                     | %[a]  | |
1071 lol dup adp stl loi loc loc cii $1==$4 && $2==2 && inreg($1)==2 && $3==1 && $5==1 && $6==1 && $7==2 | |
1072                         allocate(REG)
1073                         remove(regvar($1))
1074                         "movb (%(regvar($1)%))+,%[a]"
1075                         erase(%[a])                     | %[a]  | |
1076 lol dup adp stl loi $1==$4 && $2==2 && inreg($1)==2 && $3==2 && $5==2 | |
1077                         allocate(REG)
1078                         remove(regvar($1))
1079                         "mov (%(regvar($1)%))+,%[a]"    | %[a]  | |
1080 lol sti lol adp stl $1==$3 && $3==$5 && inreg($1)==2 && $2==1 && $4==1 | source1or2|
1081                         remove(regvar($1))
1082                         "movb %[1],(%(regvar($1)%))+"   |       | |
1083 sil lol adp stl $1==$2 && $2==$4 && inreg($1)==2 && $3==2 | source2 |
1084                         remove(regvar($1))
1085                         "mov %[1],(%(regvar($1)%))+"    |       | |
1086 lol dup adp stl $1==$4 && $2==2 && inreg($1)==2 | |
1087                         allocate(REG=regvar($1))        | %[a] 
1088                                                         | lol $1 adp $3 stl $1 |
1089 lol dup adp stl $1==$4 && $2==2 | |
1090                         allocate(REG={LOCAL2, $1, 2})   | %[a] 
1091                                                         | lol $1 adp $3 stl $1 |
1092 lol inl $1==$2 && inreg($1)==2 | |
1093                         allocate(REG=regvar($1))        | %[a] 
1094                                                         | inl $2 |
1095 lol inl $1==$2 | |
1096                         allocate(REG={LOCAL2, $1, 2})   | %[a] 
1097                                                         | inl $2 |
1098 lol del $1==$2 && inreg($1)==2 | |
1099                         allocate(REG=regvar($1))        | %[a] 
1100                                                         | del $2 |
1101 lol del $1==$2 | |
1102                         allocate(REG={LOCAL2, $1, 2})   | %[a] 
1103                                                         | del $2 |
1104 lol adp stl $1==$3 && $2==1 && inreg($1)==2 | |
1105                         remove(regvar($1))
1106                         "inc %(regvar($1)%)"
1107                         erase(regvar($1))               |       | |
1108 lol adp stl $1==$3 && $2==0-1 && inreg($1)==2 | |
1109                         remove(regvar($1))
1110                         "dec %(regvar($1)%)"
1111                         erase(regvar($1))               |       | |
1112 lol adp stl $1==$3 && inreg($1)==2 | |
1113                         remove(regvar($1))
1114                         "add $$$2,%(regvar($1)%)"
1115                         erase(regvar($1))               |       | |
1116 lil lil adp sil $2==$4 && inreg($1)==2 | |
1117                         allocate(REG={regdef2, regvar($1)}) 
1118                                                 | %[a] | lil $2 adp $3 sil $2 |
1119 lil adp sil $1==$3 && $2==1 && inreg($1)==2 | |
1120                         INDSTORE
1121                         "inc *%(regvar($1)%)"           |       | |
1122 lil adp sil $1==$3 && $2==0-1 && inreg($1)==2 | |
1123                         INDSTORE
1124                         "dec *%(regvar($1)%)"           |       | |
1125 lil adp sil $1==$3 && inreg($1)==2 | |
1126                         INDSTORE
1127                         "add $$$2,*%(regvar($1)%)"      |       | |
1128 lol lof inc lol stf $1==$4 && $2==$5 && inreg($1)==2 | |
1129                         INDSTORE
1130                         "inc $2(%(regvar($1)%))"
1131                         setcc({regind2, regvar($1), tostring($2)}) | | |
1132 lol lof dec lol stf $1==$4 && $2==$5 && inreg($1)==2 | |
1133                         INDSTORE
1134                         "dec $2(%(regvar($1)%))"
1135                         setcc({regind2, regvar($1), tostring($2)}) | | |
1136 lol lof adp lol stf $1==$4 && $2==$5 && inreg($1)==2 && $3==1 | |
1137                         INDSTORE
1138                         "inc $2(%(regvar($1)%))"
1139                         setcc({regind2, regvar($1), tostring($2)}) | | |
1140 lol lof adp lol stf $1==$4 && $2==$5 && inreg($1)==2 && $3==0-1 | |
1141                         INDSTORE
1142                         "dec $2(%(regvar($1)%))"
1143                         setcc({regind2, regvar($1), tostring($2)}) | | |
1144 lol lof adp lol stf $1==$4 && $2==$5 && inreg($1)==2 | |
1145                         INDSTORE
1146                         "add $3,$2(%(regvar($1)%))"
1147                         setcc({regind2, regvar($1), tostring($2)}) | | |
1148 #endif
1149 lol loc sbi stl $1==$4 && $3==2 | | 
1150                         remove(indordef)
1151                         remove(locals, %[ind] <= $1 && %[ind]+%[size] > $1)
1152                         "sub $$$2,$1(r5)"
1153                         setcc({LOCAL2,$1,2})            |       | |
1154 lol ngi stl $1==$3 && $2==2 | |
1155                         remove(indordef)
1156                         remove(locals, %[ind] <= $1 && %[ind]+%[size] > $1)
1157                         "neg $1(r5)"
1158                         setcc({LOCAL2,$1,2})            |       | |
1159 lil ngi sil $1==$3 && $2==2 | | INDSTORE
1160                         "neg *$1(r5)"                   |       | |
1161 lil inc sil $1==$3 | | INDSTORE
1162                         "inc *$1(r5)"
1163                         setcc({reginddef2, lb, tostring($1)})   |       | |
1164 lil dec sil $1==$3 | | INDSTORE
1165                         "dec *$1(r5)"
1166                         setcc({reginddef2, lb, tostring($1)})   |       | |
1167 lol adi stl $2==2 && $1==$3 | source2 |
1168                         remove(indordef)
1169                         remove(locals, %[ind] <= $1 && %[ind]+%[size] > $1)
1170                         "add %[1],$1(r5)"
1171                         setcc({LOCAL2,$1,2})            |       | |
1172 lol adp stl $1==$3 && $2==1 | |
1173                         remove(indordef)
1174                         remove(locals, %[ind] <= $1 && %[ind]+%[size] > $1)
1175                         "inc $1(r5)"
1176                         setcc({LOCAL2,$1,2})            |       | |
1177 lol adp stl $1==$3 && $2==0-1 | |
1178                         remove(indordef)
1179                         remove(locals, %[ind] <= $1 && %[ind]+%[size] > $1)
1180                         "dec $1(r5)"
1181                         setcc({LOCAL2,$1,2})            |       | |
1182 lol adp stl $1==$3 | |
1183                         remove(indordef)
1184                         remove(locals, %[ind] <= $1 && %[ind]+%[size] > $1)
1185                         "add $$$2,$1(r5)"
1186                         setcc({LOCAL2,$1,2})            |       | |
1187 lil lil adp sil $2==$4 | |
1188                         allocate(REG={reginddef2, lb, tostring($1)}) 
1189                                                 | %[a] | lil $2 adp $3 sil $2 |
1190 lil adp sil $1==$3 && $2==1 | |
1191                         INDSTORE
1192                         "inc *$1(r5)"
1193                         setcc({LOCAL2,$1,2})            |       | |
1194 lil adp sil $1==$3 && $2==0-1 | |
1195                         INDSTORE
1196                         "dec *$1(r5)"
1197                         setcc({LOCAL2,$1,2})            |       | |
1198 lil adp sil $1==$3 | |
1199                         INDSTORE
1200                         "add $$$2,*$1(r5)"
1201                         setcc({LOCAL2,$1,2})            |       | |
1202 loe adi ste $2==2 && $1==$3 | source2 |
1203                         remove(posextern)
1204                         "add %[1],$1"
1205                         setcc({relative2,$1})           |       | |
1206 loe adp ste $1==$3 && $2==1 | |
1207                         remove(posextern)
1208                         "inc $1"
1209                         setcc({relative2,$1})           |       | |
1210 loe adp ste $1==$3 && $2==0-1 | |
1211                         remove(posextern)
1212                         "dec $1"
1213                         setcc({relative2,$1})           |       | |
1214 loe adp ste $1==$3 | |
1215                         remove(posextern)
1216                         "add $$$2,$1"
1217                         setcc({relative2,$1})           |       | |
1218 loe loi loe loi adp loe sti $3==$6 && $2==2 && $4==2 && $7==2 | |
1219                         allocate(REG={reldef2, $1})
1220                                 | %[a] | loe $3 loi $4 adp $5 loe $6 sti $7 |
1221 loe loi adp loe sti $1==$4 && $2==2 && $5==2 && $3==1 | |
1222                         INDSTORE
1223                         "inc *$1"
1224                         setcc({reldef2,$1})             |       | |
1225 loe loi adp loe sti $1==$4 && $2==2 && $5==2 && $3==0-1 | |
1226                         INDSTORE
1227                         "dec *$1"
1228                         setcc({reldef2,$1})             |       | |
1229 loe loi adp loe sti $1==$4 && $2==2 && $5==2 | |
1230                         INDSTORE
1231                         "add $$$3,*$1"
1232                         setcc({reldef2,$1})             |       | |
1233 lol lof inc lol stf $1==$4 && $2==$5 | |
1234                         INDSTORE
1235                         allocate(REG={LOCAL2, $1, 2})
1236                         "inc $2(%[a])"
1237                         setcc({regind2, %[a], tostring($2)}) | | |
1238 lol lof dec lol stf $1==$4 && $2==$5 | |
1239                         INDSTORE
1240                         allocate(REG={LOCAL2, $1, 2})
1241                         "dec $2(%[a])"
1242                         setcc({regind2, %[a], tostring($2)}) | | |
1243 lol lof adp lol stf $1==$4 && $2==$5 && $3==1 | |
1244                         INDSTORE
1245                         allocate(REG={LOCAL2, $1, 2})
1246                         "inc $2(%[a])"
1247                         setcc({regind2, %[a], tostring($2)}) | | |
1248 lol lof adp lol stf $1==$4 && $2==$5 && $3==0-1 | |
1249                         INDSTORE
1250                         allocate(REG={LOCAL2, $1, 2})
1251                         "dec $2(%[a])"
1252                         setcc({regind2, %[a], tostring($2)}) | | |
1253 lol lof adp lol stf $1==$4 && $2==$5 | |
1254                         INDSTORE
1255                         allocate(REG={LOCAL2, $1, 2})
1256                         "add $3,$2(%[a])"
1257                         setcc({regind2, %[a], tostring($2)}) | | |
1258 loe lof inc loe stf $1==$4 && $2==$5 | |
1259                         INDSTORE
1260                         allocate(REG={relative2, $1})
1261                         "inc $2(%[a])"
1262                         setcc({regind2, %[a], tostring($2)}) | | |
1263 loe lof dec loe stf $1==$4 && $2==$5 | |
1264                         INDSTORE
1265                         allocate(REG={relative2, $1})
1266                         "dec $2(%[a])"
1267                         setcc({regind2, %[a], tostring($2)}) | | |
1268 loe lof adp loe stf $1==$4 && $2==$5 && $3==1 | |
1269                         INDSTORE
1270                         allocate(REG={relative2, $1})
1271                         "inc $2(%[a])"
1272                         setcc({regind2, %[a], tostring($2)}) | | |
1273 loe lof adp loe stf $1==$4 && $2==$5 && $3==0-1 | |
1274                         INDSTORE
1275                         allocate(REG={relative2, $1})
1276                         "dec $2(%[a])"
1277                         setcc({regind2, %[a], tostring($2)}) | | |
1278 loe lof adp loe stf $1==$4 && $2==$5 | |
1279                         INDSTORE
1280                         allocate(REG={relative2, $1})
1281                         "add $3,$2(%[a])"
1282                         setcc({regind2, %[a], tostring($2)}) | | |
1283 loe ine $1==$2 | |
1284                         allocate(REG={relative2, $1})   | %[a] 
1285                                                         | ine $2 |
1286 loe dee $1==$2 | |
1287                         allocate(REG={relative2, $1})   | %[a] 
1288                                                         | dee $2 |
1289 loe dup adp ste $1==$4 && $2==2 | |
1290                         allocate(REG={relative2, $1})   | %[a] 
1291                                                         | loe $1 adp $3 ste $1 |
1292 #ifdef REGVARS
1293 lol ior stl $2==2 && $1==$3 && inreg($1)==2 | source2 |
1294                         remove(regvar($1))
1295                         "bis %[1],%(regvar($1)%)"
1296                         erase(regvar($1))               |       | |
1297 #endif
1298 lol ior stl $2==2 && $1==$3 | source2 |
1299                         remove(indordef)
1300                         remove(locals, %[ind] <= $1 && %[ind]+%[size] > $1)
1301                         "bis %[1],$1(r5)"
1302                         setcc({LOCAL2,$1,2})            |       | |
1303 loe ior ste $2==2 && $1==$3 | source2 |
1304                         remove(posextern)
1305                         "bis %[1],$1"
1306                         setcc({relative2,$1})           |       | |
1307 #ifdef REGVARS
1308 lol and stl $2==2 && $1==$3 && inreg($1)==2 | SCR_REG |
1309                         remove(regvar($1))
1310                         "com %[1]"
1311                         "bic %[1],%(regvar($1)%)"
1312                         erase(%[1])
1313                         erase(regvar($1))               |       | |
1314 #endif
1315 lol and stl $2==2 && $1==$3 | SCR_REG |
1316                         remove(indordef)
1317                         remove(locals, %[ind] <= $1 && %[ind]+%[size] > $1)
1318                         "com %[1]"
1319                         "bic %[1],$1(r5)"
1320                         erase(%[1])
1321                         setcc({LOCAL2,$1,2})            |       | |
1322 loe and ste $2==2 && $1==$3 | SCR_REG |
1323                         remove(posextern)
1324                         "com %[1]"
1325                         "bic %[1],$1"
1326                         erase(%[1])
1327                         setcc({relative2,$1})           |       | |
1328 #ifdef REGVARS
1329 loc lol and stl $3==2 && $2==$4 && inreg($2)==2 | |
1330                         remove(regvar($2))
1331                         "bic $$%(~$1%),%(regvar($2)%)"
1332                         erase(regvar($2))               |       | |
1333 #endif
1334 loc lol and stl $3==2 && $2==$4 | |
1335                         remove(indordef)
1336                         remove(locals, %[ind] <= $2 && %[ind]+%[size] > $2)
1337                         "bic $$%(~$1%),$2(r5)"
1338                         setcc({LOCAL2,$2,2})            |       | |
1339 loc loe and ste $3==2 && $2==$4 | |
1340                         remove(posextern)
1341                         "bic $$%(~$1%),$2"
1342                         setcc({relative2,$2})           |       | |
1343 #ifdef REGVARS
1344 zrl inreg($1)==2| |     remove(regvar($1))
1345                         "clr %(regvar($1)%)"
1346                         erase(regvar($1))          |       | | (4,90)
1347 #endif
1348 zrl             | |     remove(indordef)
1349                         remove(locals, %[ind] <= $1 && %[ind]+%[size] > $1)
1350                         "clr $1(r5)"
1351                         setcc({LOCAL2,$1,2})          |       | | (4,90)
1352 zre             | |     remove(posextern)
1353                         "clr $1"
1354                         setcc({relative2,$1})           |       | | (4,90)
1355 zrf $1==4       | |     allocate(FLT_REG)
1356                         "clrf %[a]"             | %[a]  | | (2,220)
1357 zrf $1==8       | |     allocate(DBL_REG)
1358                         "clrf %[a]"             | %[a]  | | (2,240)
1359 zrf !defined($1)| |             |                       | zer |
1360 zrf defined($1) | |             |                       | zer $1 |
1361 zer $1==2       | |             | {CONST2, 0}                   | |
1362 zer $1==4       | |             | {CONST2,0}     {CONST2,0}     | |
1363 zer $1==6       | |             | {CONST2,0} {CONST2,0}
1364                                   {CONST2,0}                    | |
1365 zer $1==8       | |             | {CONST2,0} {CONST2,0}
1366                                   {CONST2, 0} {CONST2,0}        | |
1367 zer defined($1) | |     remove(all)
1368                         move({CONST2,$1/2},r0)
1369                         "1:\tclr -(sp)"
1370                         "sob r0,1b"
1371                         erase(r0)                       |       | |(8,150+$1*37)
1372 zer !defined($1)| SCR_REG |
1373                         remove(all)
1374                         "asr %[1]"
1375                         "1:\tclr -(sp)"
1376                         "sob %[1],1b"
1377                         erase(%[1])                             |       | |
1378
1379 /****************************************
1380  * Group 8 : Convert instructions       *
1381  ****************************************/
1382
1383 #ifdef UNTESTED
1384 cii             | |     remove(all)
1385                         "jsr pc,cii~"                  |       | |
1386 cfi             | |             |                       | cfu   |
1387 cfu             | |     remove(ALL)
1388                         "jsr pc,cfi~"                   |       | |
1389 cif             | |     remove(ALL)
1390                         "jsr pc,cif~"                   |       | |
1391 cuf             | |     remove(ALL)
1392                         "jsr pc,cuf~"                   |       | |
1393 cff             | |     remove(ALL)
1394                         "jsr pc,cff~"                   |       | |
1395 ciu             | |             |                       | cuu   |
1396 cui             | |             |                       | cuu   |
1397 cuu             | |     remove(all)
1398                         "jsr pc,cuu~"                   |       | |
1399 #endif
1400
1401 loc loc cii $1==1 && $2==2      | source1or2 |
1402                          allocate(%[1],REG)
1403                          "movb %[1],%[a]"
1404                          /* movb does sign extend if dest is register */
1405                                                                 | %[a]  | |
1406 loc loc cii $1==1 && $2==4      | source1or2 |
1407                         allocate(%[1],REG,REG)
1408                         "movb %[1],%[a]"
1409                         "sxt %[b]"
1410                                                                 | %[a] %[b] | |
1411 loc loc cii $1==2 && $2==4      | source2 |
1412                         allocate(%[1],REG,REG)
1413                         move(%[1],%[a])
1414                         test(%[a])
1415                         "sxt %[b]"
1416                                                                 | %[a] %[b] | |
1417 loc loc loc cii $1>=0 && $2==2 && $3==4 | | | | loc $1 loc 0 |
1418 loc loc loc cii $1< 0 && $2==2 && $3==4 | | | | loc $1 loc 0-1 |
1419 loc loc cii $1==4 && $2==2      | source2 source2 |             | %[2]  | |
1420 loc loc ciu     | |             |               | loc $1 loc $2 cuu     |
1421 loc loc cui     | |             |               | loc $1 loc $2 cuu     |
1422 loc loc cuu $1==2 && $2==4      | | | {CONST2,0} | |
1423 loc loc cuu $1==4 && $2==2      | source2 |             |   | |
1424 loc loc cuu $1==$2 | |          |               | |
1425 loc loc cfu $1==4               | FLT_REG |     | {ftolong,%[1]} | loc 4 loc $2 cuu |
1426 loc loc cfu $1==8               | DBL_REG |     | {ftolong,%[1]} | loc 4 loc $2 cuu |
1427 loc loc cfi $1==4 && $2==2      | FLT_REG |     | {ftoint,%[1]} | |
1428 loc loc cfi $1==4 && $2==4      | FLT_REG |     | {ftolong,%[1]} | |
1429 loc loc cfi $1==8 && $2==2      | DBL_REG |     | {ftoint,%[1]} | |
1430 loc loc cfi $1==8 && $2==4      | DBL_REG |     | {ftolong,%[1]} | |
1431 loc loc cif $1==2 && $2==4      | source2 |
1432                         allocate(FLT_REG)
1433                         "movif %[1],%[a]"
1434                         samecc
1435                                                                 | %[a]  | |
1436 loc loc cif $1==2 && $2==8      | source2 |
1437                         allocate(DBL_REG)
1438                         "movif %[1],%[a]"
1439                         samecc
1440                                                                 | %[a]  | |
1441 loc loc cif $1==4 && $2==4      | NC long4-REG_PAIR |
1442                         allocate(FLT_REG)
1443                         "setl"
1444                         "movif %[1],%[a]"
1445                         "seti"
1446                         samecc
1447                                                                 | %[a]  | |
1448 ...     | |             remove(all)
1449                         allocate(FLT_REG)
1450                         "setl"
1451                         "movif (sp)+,%[a]"
1452                         "seti"
1453                         samecc
1454                                                                 | %[a]  | |
1455 loc loc cif $1==4 && $2==8      | NC long4-REG_PAIR |
1456                         allocate(DBL_REG)
1457                         "setl"
1458                         "movif %[1],%[a]"
1459                         "seti"
1460                         samecc
1461                                                                 | %[a]  | |
1462 ...     | |             remove(all)
1463                         allocate(DBL_REG)
1464                         "setl"
1465                         "movif (sp)+,%[a]"
1466                         "seti"
1467                         samecc
1468                                                                 | %[a]  | |
1469 loc loc cuf $1==2 && $2==4      | |
1470                         remove(all)
1471                         allocate(FLT_REG)
1472                         "clr -(sp)"
1473                         "setl"
1474                         "movif (sp)+,%[a]"
1475                         "seti"
1476                                                                 | %[a]  | |
1477 loc loc cuf $1==2 && $2==8      | |
1478                         remove(all)
1479                         allocate(DBL_REG)
1480                         "clr -(sp)"
1481                         "setl"
1482                         "movif (sp)+,%[a]"
1483                         "seti"
1484                                                                 | %[a]  | |
1485 loc loc cuf $1==4 && ($2==8 || $2==4) | |       | | loc $1 loc $2 cif |
1486 loc loc cff $1==4 && $2==8      | longf4 - FLT_REG |
1487                         allocate(DBL_REG)
1488                         "movof %[1],%[a]"
1489                         samecc
1490                                                                 | %[a]  | |
1491 ...                             | FLT_REG |
1492                         allocate(DBL_REG)
1493                         move(%[1],%[a.1])
1494                         samecc                                  | %[a] | |
1495 loc loc cff $1==8 && $2==4      | DBL_REG |                     | %[1.1] | |
1496
1497 /****************************************
1498  * Group 9 : Logical instructions       *
1499  ****************************************/
1500
1501 and $1==2       | CONST2 SCR_REG |
1502                         "bic $$%(~%[1.num]%),%[2]"
1503                         setcc(%[2])
1504                         erase(%[2])             | %[2]  | | (4,75)
1505 ...             | SCR_REG CONST2 |
1506                         "bic $$%(~%[2.num]%),%[1]"
1507                         setcc(%[1])
1508                         erase(%[1])             | %[1]  | | (4,75)
1509 ...             | SCR_REG SCR_REG |
1510                         "com %[1]"
1511                         "bic %[1],%[2]"
1512                         setcc(%[2])
1513                         erase(%[1]) erase(%[2]) | %[2]  | | (4,60)
1514 ldc and $2==4 && highw(1)==0    | source2 SCR_REG |
1515                         "bic $$%(~loww(1)%),%[2]"
1516                         erase(%[2])             | %[2] {CONST2, 0} | |
1517 ldc and $2==4 && highw(1)==0-1  | source2 SCR_REG |
1518                         "bic $$%(~loww(1)%),%[2]"
1519                         erase(%[2])             | %[2] %[1] | |
1520 ldc and $2==4   | SCR_REG SCR_REG |
1521                         "bic $$%(~highw(1)%),%[1]"
1522                         "bic $$%(~loww(1)%),%[2]"
1523                         erase(%[1]) erase(%[2]) | %[2] %[1] | |
1524 and defined($1) | |     remove(all)
1525                         move({CONST2,$1}, r0)
1526                         "jsr pc,and~"
1527                         erase(r0)                               |       | |
1528 and !defined($1)| source2 |
1529                         remove(all)
1530                         move(%[1],r0)
1531                         "jsr pc,and~"
1532                         erase(r0)                               |       | |
1533 ior $1==2       | SCR_REG source2 |
1534                         "bis %[2],%[1]"
1535                         setcc(%[1])
1536                         erase(%[1])                     | %[1]  | | (2,45)+%[2]
1537 ...             | source2 SCR_REG |
1538                         "bis %[1],%[2]"
1539                         setcc(%[2])
1540                         erase(%[2])                     | %[2]  | | (2,45)+%[1]
1541 ldc ior $2==4 && highw(1)==0    | source2 SCR_REG |
1542                         "bis $$%(loww(1)%),%[2]"
1543                         erase(%[2])             | %[2] %[1] | |
1544 ldc ior $2==4 && highw(1)==0-1  | source2 SCR_REG |
1545                         "bis $$%(loww(1)%),%[2]"
1546                         erase(%[2])             | {CONST2, 0-1} %[1] | |
1547 ldc ior $2==4   | SCR_REG SCR_REG |
1548                         "bis $$%(highw(1)%),%[1]"
1549                         "bis $$%(loww(1)%),%[2]"
1550                         erase(%[1]) erase(%[2]) | %[2] %[1] | |
1551 ior $1==8       | NC source2 source2 source2 source2 |
1552                         remove(all)
1553                         "bis %[1],(sp)"
1554                         "bis %[2],2(sp)"
1555                         "bis %[3],4(sp)"
1556                         "bis %[4],6(sp)"                |       | |
1557 ...             | |     remove(all)
1558                         allocate(REG={CONST2,$1})
1559                         "add sp,%[a]"
1560                         "bis (sp)+,(%[a])+"
1561                         "bis (sp)+,(%[a])+"
1562                         "bis (sp)+,(%[a])+"
1563                         "bis (sp)+,(%[a])+"
1564                         erase(%[a])                     |       | |
1565 ior defined($1) | |     remove(all)
1566                         allocate(REG={CONST2,$1},REG={CONST2,$1/2})
1567                         "add sp,%[a]"
1568                         "1:\tbis (sp)+,(%[a])+"
1569                         "sob %[b],1b"
1570                         erase(%[a]) erase(%[b])         |       | | (12,210+$1*97)
1571 ior !defined($1)| SCR_REG |
1572                         remove(all)
1573                         allocate(REG=%[1])
1574                         "asr %[1]"
1575                         "add sp,%[a]"
1576                         "1:\tbis (sp)+,(%[a])+"
1577                         "sob %[1],1b"
1578                         erase(%[1]) erase(%[a])         |       | |
1579 xor $1==2       | register SCR_REG |
1580                         "xor %[1],%[2]"
1581                         setcc(%[2])
1582                         erase(%[2])                     | %[2]  | | (2,30)
1583 ...             | SCR_REG register |
1584                         "xor %[2],%[1]"
1585                         setcc(%[1])
1586                         erase(%[1])                     | %[1]  | | (2,30)
1587 xor defined($1) | |     remove(all)
1588                         move({CONST2,$1},r0)
1589                         "jsr pc,xor~"
1590                         erase(r0)                               |       | |
1591 xor !defined($1)| source2 |
1592                         remove(all)
1593                         move(%[1],r0)
1594                         "jsr pc,xor~"
1595                         erase(r0)                               |       | |
1596 com $1==2       | SCR_REG |
1597                         "com %[1]"
1598                         setcc(%[1])
1599                         erase(%[1])                     | %[1]  | | (2,30)
1600 com defined($1) | |     remove(all)
1601                         allocate(REG={CONST2,$1/2},REG)
1602                         "mov sp,%[b]"
1603                         "1:\tcom (%[b])+"
1604                         "sob %[a],1b"
1605                         erase(%[a])                     |       | | (10,180+$1*82)
1606 com !defined($1)| SCR_REG |
1607                         remove(all)
1608                         allocate(REG)
1609                         "asr %[1]"
1610                         "mov sp,%[a]"
1611                         "1:\tcom (%[a])+"
1612                         "sob %[1],1b"
1613                         erase(%[1])                             |       | |
1614 rol $1==2       | CONST2 SCR_ODD_REG |
1615                         "ashc $$%(%[1.num]-16%),%[2]"
1616                         setcc(%[2])
1617                         erase(%[2])                     | %[2] | |
1618 ...             | SCR_REG SCR_ODD_REG |
1619                         "sub $$%(16%),%[1]"
1620                         "ashc %[1],%[2]"
1621                         setcc(%[2])
1622                         erase(%[1]) erase(%[2])         | %[2]  | |
1623 rol defined($1) | |     remove(all)
1624                         move({CONST2,$1},r0)
1625                         "jsr pc,rol~"
1626                         erase(r0)                               |       | |
1627 #ifdef UNTESTED
1628 rol !defined($1)| source2 |
1629                         remove(all)
1630                         move(%[1],r0)
1631                         "jsr pc,rol~"
1632                         erase(r0)                               |       | |
1633 #endif
1634 ror $1==2       | CONST2 SCR_ODD_REG |
1635                         "ashc $$%(0-%[1.num]%),%[2]"
1636                         setcc(%[2])
1637                         erase(%[2])                     | %[2]  | |
1638 ...             | SCR_REG SCR_ODD_REG |
1639                         "neg %[1]"
1640                         "ashc %[1],%[2]"
1641                         setcc(%[2]) erase(%[1]) erase(%[2])     | %[2]  | |
1642 ror defined($1) | |     remove(all)
1643                         move({CONST2,$1},r0)
1644                         "jsr pc,ror~"
1645                         erase(r0)                               |       | |
1646 #ifdef UNTESTED
1647 ror !defined($1)| source2 |
1648                         remove(all)
1649                         move(%[1],r0)
1650                         "jsr pc,ror~"
1651                         erase(r0)                               |       | |
1652 #endif
1653 com and $1==2 && $2==2  | source2 SCR_REG |
1654                           "bic %[1],%[2]"
1655                           setcc(%[2])
1656                           erase(%[2])                   | %[2]  | | (2,45)+%[1]
1657 com and $1==$2  | |     remove(all)
1658                         allocate(REG={CONST2,$1},REG)
1659                         "mov sp,%[b]"
1660                         "add %[a],%[b]"
1661                         "asr %[a]"
1662                         "1:\tbic (sp)+,(%[b])+"
1663                         "sob %[a],1b"
1664                         erase(%[a])                     |       | | (12,210+$1*97)
1665
1666 /********************************
1667  * Group 10 : Set instructions  *
1668  ********************************/
1669
1670 inn $1==2       | SCR_REG SCR_REG |
1671                         "neg %[1]"
1672                         "ash %[1],%[2]"
1673                         "bic $$0177776,%[2]"
1674                         erase(%[1]) erase(%[2])                 | %[2]  | |
1675 loc inn $2==2 && $1==0 | SCR_REG |
1676                         "bic $$0177776,%[1]"
1677                         erase(%[1])                             | %[1]  | |
1678 loc inn $2==2 && $1==1 | SCR_REG |
1679                         "asr %[1]"
1680                         "bic $$0177776,%[1]"
1681                         erase(%[1])                             | %[1]  | |
1682 loc inn $2==2   | SCR_REG |
1683                         "ash $$%(0-$1%),%[1]"
1684                         "bic $$0177776,%[1]"
1685                         erase(%[1])                             | %[1]  | |
1686
1687 loc inn zeq $2==2 | |   | {CONST2, 1<<$1} | and 2 zeq $3 |
1688 inn zeq $1==2   | source2 |
1689                         allocate(REG={CONST2,1})
1690                         "ash %[1],%[a]"                 | %[a] | and 2 zeq $2 |
1691 loc inn zne $2==2 | |   | {CONST2, 1<<$1} | and 2 zne $3 |
1692 inn zne $1==2   | source2 |
1693                         allocate(REG={CONST2,1})
1694                         "ash %[1],%[a]"                 | %[a] | and 2 zne $2 |
1695 inn defined($1) | source2 |
1696                         remove(all)
1697                         move(%[1],r1)
1698                         move({CONST2,$1},r0)
1699                         "jsr pc,inn~"
1700                         erase(r01)                              | r0    | |
1701 #ifdef UNTESTED
1702 inn !defined($1)| source2 |
1703                         remove(all)
1704                         move(%[1],r0)
1705                         "mov (sp)+,r1"
1706                         "jsr pc,inn~"
1707                         erase(r01)                              | r0    | |
1708 #endif
1709 set $1==2       | register |
1710                         allocate(REG={CONST2,1})
1711                         "ash %[1],%[a]"
1712                         erase(%[a])                             | %[a]  | |
1713 set defined($1) | source2 |
1714                         remove(all)
1715                         move(%[1],r1)
1716                         move({CONST2,$1},r0)
1717                         "jsr pc,set~"
1718                         erase(r01)                              |       | |
1719 set !defined($1)| source2 |
1720                         remove(all)
1721                         move(%[1],r0)
1722                         "mov (sp)+,r1"
1723                         "jsr pc,set~"
1724                         erase(r01)                              |       | |
1725
1726 /****************************************
1727  * Group 11 : Array instructions        *
1728  ****************************************/
1729
1730 lae aar $2==2 && rom(1,3)==1 && rom(1,1)==0 | | | | adi 2 |
1731 lae aar $2==2 && rom(1,3)==1 && rom(1,1)!=0 | | | | adi 2 adp 0-rom(1,1) |
1732
1733 lae aar $2==2 && rom(1,3)==2 && rom(1,1)==0 | SCR_REG |
1734                         "asl %[1]"
1735                         erase(%[1])        | %[1] | adi 2 |
1736 lae aar $2==2 && rom(1,3)==2 && rom(1,1)!=0 | SCR_REG |
1737                         "asl %[1]"
1738                         erase(%[1])                             |
1739                                         {regconst2,%[1],tostring((0-2)*rom(1,1))}  | 
1740                                         adi 2 |
1741 lae aar $2==2 && rom(1,3)==4 && rom(1,1)==0 | SCR_REG |
1742                         "ash $$2,%[1]"
1743                         erase(%[1])                             | 
1744                                         %[1]  |
1745                                         adi 2 |
1746 lae aar $2==2 && rom(1,3)==4 && rom(1,1)!=0 | SCR_REG |
1747                         "ash $$2,%[1]"
1748                         erase(%[1])                             | 
1749                                         {regconst2,%[1],tostring((0-4)*rom(1,1))}  |
1750                                         adi 2 |
1751 lae aar $2==2 && rom(1,3)==8 && rom(1,1)==0 | SCR_REG |
1752                         "ash $$3,%[1]"
1753                         erase(%[1])                             | 
1754                                         %[1]  |
1755                                         adi 2 |
1756 lae aar $2==2 && rom(1,3)==8 && rom(1,1)!=0 | SCR_REG |
1757                         "ash $$3,%[1]"
1758                         erase(%[1])                             | 
1759                                         {regconst2,%[1],tostring((0-8)*rom(1,1))}  |
1760                                         adi 2 |
1761 lae aar $2==2 && rom(1,1)==0 && defined(rom(1,3)) | SCR_ODD_REG |
1762                         "mul $$%(rom(1,3)%),%[1]"
1763                         erase(%[1])                             | 
1764                                         %[1]  |
1765                                         adi 2 |
1766 lae aar $2==2 && defined(rom(1,3)) | SCR_ODD_REG |
1767                         "mul $$%(rom(1,3)%),%[1]"
1768                         erase(%[1])                             | 
1769                                         {regconst2,%[1],tostring((0-rom(1,3))*rom(1,1))}  |
1770                                         adi 2 |
1771 aar $1==2       | |
1772                         remove(all)
1773                         "mov (sp)+,r0"
1774                         "mov (sp)+,r1"
1775                         "jsr pc,aar~"
1776                         erase(r01)                              |       | |
1777 #ifdef UNTESTED
1778 aar !defined($1) | |    remove(all)
1779                         "jsr pc,iaar~"                  |       | |
1780 #endif
1781 lae sar defined(rom(1,3)) | |   |       | lae $1 aar $2 sti rom(1,3) |
1782 lae lar defined(rom(1,3)) | |   |       | lae $1 aar $2 loi rom(1,3) |
1783 sar $1==2       | |
1784                         remove(all)
1785                         "mov (sp)+,r0"
1786                         "mov (sp)+,r1"
1787                         "jsr pc,sar~"
1788                         erase(r01)                              |       | |
1789 #ifdef UNTESTED
1790 sar !defined($1) | |    remove(all)
1791                         "jsr pc,isar~"                  |       | |
1792 #endif
1793 lar $1==2       | |
1794                         remove(all)
1795                         "mov (sp)+,r0"
1796                         "mov (sp)+,r1"
1797                         "jsr pc,lar~"
1798                         erase(r01)                              |       | |
1799 #ifdef UNTESTED
1800 lar !defined($1) | |    remove(all)
1801                         "jsr pc,ilar~"                  |       | |
1802 #endif
1803
1804 /****************************************
1805  * group 12 : Compare instructions      *
1806  ****************************************/
1807
1808 cmi $1==2       | source2 source2 |
1809                         allocate(REG = {CONST2,0})
1810                         "cmp %[1],%[2]"
1811                         "beq 2f"
1812                         "bgt 1f"
1813                         "inc %[a]"
1814                         "br 2f"
1815                         "1:\tdec %[a]\n2:"
1816                         setcc(%[a])
1817                         erase(%[a])                             | %[a]  | |
1818 ldc cmi zlt highw(1)==0 && loww(1)==0 && $2==4 | source2 source2 |
1819                                         | %[1] | zlt $3 |
1820 ldc cmi zge highw(1)==0 && loww(1)==0 && $2==4 | source2 source2 |
1821                                         | %[1] | zge $3 |
1822 cmi $1==4       | |     remove(all)
1823                         "jsr pc,cmi4~"                  | r0    | |
1824 #ifdef UNTESTED
1825 cmi !defined($1) | source2 |
1826                         remove(all)
1827                         move(%[1],r0)
1828                         "jsr pc,cmi~"
1829                         erase(r0)                               | r0    | |
1830 #endif
1831 cmf defined($1) | |     remove(ALL)
1832                         move({CONST2,$1},r0)
1833                         "jsr pc,cmf~"
1834                         erase(r0)                               | r0    | |
1835 #ifdef UNTESTED
1836 cmf !defined($1)| source2 |
1837                         remove(ALL)
1838                         move(%[1],r0)
1839                         "jsr pc,cmf~"
1840                         erase(r0)                               | r0    | |
1841 #endif
1842 cmu $1==2       | |             |                       | cmp |
1843 cmu $1==4       | |     remove(all)
1844                         "jsr pc,cmu4~"                  | r0    | |
1845 cmu defined($1) | |     remove(all)
1846                         move({CONST2,$1},r0)
1847                         "jsr pc,cmu~"                   | r0    | |
1848 #ifdef UNTESTED
1849 cmu !defined($1)| source2 |
1850                         remove(all)
1851                         move(%[1],r0)
1852                         "jsr pc,cmu~"
1853                         erase(r0)                               | r0    | |
1854 #endif
1855 cms $1==2       | |             |                       | cmi $1 |
1856 ldc cms zeq $2==4 && loww(1)==0 && highw(1)==0 | source2 SCR_REG |
1857                         remove(all)
1858                         "bis %[1],%[2]"
1859                         "jeq $3"                        |               | |
1860 ldc cms zne $2==4 && loww(1)==0 && highw(1)==0 | source2 SCR_REG |
1861                         remove(all)
1862                         "bis %[1],%[2]"
1863                         "jne $3"                        |               | |
1864 ldc cms zeq $2==4       | source2 source2 |
1865                         remove(all)
1866                         "cmp $$%(loww(1)%),%[2]"
1867                         "bne 1f"
1868                         "cmp $$%(highw(1)%),%[1]"
1869                         "jeq $3"
1870                         "1:"                            |               | |
1871 ldc cms zne $2==4       | source2 source2 |
1872                         remove(all)
1873                         "cmp $$%(loww(1)%),%[2]"
1874                         "jne $3"
1875                         "cmp $$%(highw(1)%),%[1]"
1876                         "jne $3"                        |               | |
1877 cms defined($1) | |     remove(all)
1878                         move({CONST2,$1},r0)
1879                         "jsr pc,cms~"
1880                         erase(r0)                               | r0    | |
1881 #ifdef UNTESTED
1882 cms !defined($1)| source2 |
1883                         remove(all)
1884                         move(%[1],r0)
1885                         "jsr pc,cms~"
1886                         erase(r0)                              | r0    | |
1887 #endif
1888 cmp             | source2 source2 |
1889                         allocate(REG = {CONST2,0})
1890                         "cmp %[1],%[2]"
1891                         "beq 2f"
1892                         "bhi 1f"
1893                         "inc %[a]"
1894                         "br 2f"
1895                         "1:\tdec %[a]\n2:"
1896                         setcc(%[a])
1897                         erase(%[a])                             | %[a]  | |
1898 tlt and $2==2   | source2 SCR_REG |
1899                         test(%[1])
1900                         "blt 1f"
1901                         "clr %[2]\n1:"
1902                         erase(%[2])                             | %[2] | |
1903 tlt ior $2==2   | source2 SCR_REG |
1904                         test(%[1])
1905                         "bge 1f"
1906                         "bis $$1,%[2]\n1:"
1907                         erase(%[2])                             | %[2] | |
1908 tlt             | source2 |
1909                         allocate(REG={CONST2,0})
1910                         test(%[1])
1911                         "bge 1f"
1912                         "inc %[a]\n1:"
1913                         erase(%[a])                             | %[a]  | |
1914 tle and $2==2   | source2 SCR_REG |
1915                         test(%[1])
1916                         "ble 1f"
1917                         "clr %[2]\n1:"
1918                         erase(%[2])                             | %[2] | |
1919 tle ior $2==2   | source2 SCR_REG |
1920                         test(%[1])
1921                         "bgt 1f"
1922                         "bis $$1,%[2]\n1:"
1923                         erase(%[2])                             | %[2] | |
1924 tle             | source2 |
1925                         allocate(REG={CONST2,0})
1926                         test(%[1])
1927                         "bgt 1f"
1928                         "inc %[a]\n1:"
1929                         erase(%[a])                             | %[a]  | |
1930 teq and $2==2   | source1or2 SCR_REG |
1931                         test(%[1])
1932                         "beq 1f"
1933                         "clr %[2]\n1:"
1934                         erase(%[2])                             | %[2] | |
1935 teq ior $2==2   | source1or2 SCR_REG |
1936                         test(%[1])
1937                         "bne 1f"
1938                         "bis $$1,%[2]\n1:"
1939                         erase(%[2])                             | %[2] | |
1940 teq             | source1or2 |
1941                         allocate(REG={CONST2,0})
1942                         test(%[1])
1943                         "bne 1f"
1944                         "inc %[a]\n1:"
1945                         erase(%[a])                             | %[a]  | |
1946 tne and $2==2   | source1or2 SCR_REG |
1947                         test(%[1])
1948                         "bne 1f"
1949                         "clr %[2]\n1:"
1950                         erase(%[2])                             | %[2] | |
1951 tne ior $2==2   | source1or2 SCR_REG |
1952                         test(%[1])
1953                         "beq 1f"
1954                         "bis $$1,%[2]\n1:"
1955                         erase(%[2])                             | %[2] | |
1956 tne             | source1or2 |
1957                         allocate(REG={CONST2,0})
1958                         test(%[1])
1959                         "beq 1f"
1960                         "inc %[a]\n1:"
1961                         erase(%[a])                             | %[a]  | |
1962 tgt and $2==2   | source2 SCR_REG |
1963                         test(%[1])
1964                         "bgt 1f"
1965                         "clr %[2]\n1:"
1966                         erase(%[2])                             | %[2] | |
1967 tgt ior $2==2   | source2 SCR_REG |
1968                         test(%[1])
1969                         "ble 1f"
1970                         "bis $$1,%[2]\n1:"
1971                         erase(%[2])                             | %[2] | |
1972 tgt             | source2 |
1973                         allocate(REG={CONST2,0})
1974                         test(%[1])
1975                         "ble 1f"
1976                         "inc %[a]\n1:"
1977                         erase(%[a])                             | %[a]  | |
1978 tge and $2==2   | source2 SCR_REG |
1979                         test(%[1])
1980                         "bge 1f"
1981                         "clr %[2]\n1:"
1982                         erase(%[2])                             | %[2] | |
1983 tge ior $2==2   | source2 SCR_REG |
1984                         test(%[1])
1985                         "blt 1f"
1986                         "bis $$1,%[2]\n1:"
1987                         erase(%[2])                             | %[2] | |
1988 tge             | source2 |
1989                         allocate(REG={CONST2,0})
1990                         test(%[1])
1991                         "blt 1f"
1992                         "inc %[a]\n1:"
1993                         erase(%[a])                             | %[a]  | |
1994 and tne $1==2       | source2 source2 |
1995                         allocate(REG={CONST2,0})
1996                         "bit %[1],%[2]"
1997                         "beq 1f"
1998                         "inc %[a]\n1:"
1999                         erase(%[a])                             | %[a]  | |
2000 and teq $1==2       | source2 source2 |
2001                         allocate(REG={CONST2,0})
2002                         "bit %[1],%[2]"
2003                         "bne 1f"
2004                         "inc %[a]\n1:"
2005                         erase(%[a])                             | %[a]  | |
2006
2007 cmi tlt and $1==2 && $3==2 | source2 source2 SCR_REG |
2008                         "cmp %[2],%[1]"
2009                         "blt 1f"
2010                         "clr %[3]\n1:"
2011                         erase(%[3])                             | %[3] | |
2012 cmi tlt ior $1==2 && $3==2 | source2 source2 SCR_REG |
2013                         "cmp %[2],%[1]"
2014                         "bge 1f"
2015                         "bis $$1,%[3]\n1:"
2016                         erase(%[3])                             | %[3] | |
2017 cmi tlt $1==2   | source2 source2 |
2018                         allocate(REG={CONST2,0})
2019                         "cmp %[2],%[1]"
2020                         "bge 1f"
2021                         "inc %[a]\n1:"
2022                         erase(%[a])                             | %[a]  | |
2023 cmi tle and $1==2 && $3==2 | source2 source2 SCR_REG |
2024                         "cmp %[2],%[1]"
2025                         "ble 1f"
2026                         "clr %[3]\n1:"
2027                         erase(%[3])                             | %[3] | |
2028 cmi tle ior $1==2 && $3==2 | source2 source2 SCR_REG |
2029                         "cmp %[2],%[1]"
2030                         "bgt 1f"
2031                         "bis $$1,%[3]\n1:"
2032                         erase(%[3])                             | %[3] | |
2033 cmi tle $1==2   | source2 source2 |
2034                         allocate(REG={CONST2,0})
2035                         "cmp %[2],%[1]"
2036                         "bgt 1f"
2037                         "inc %[a]\n1:"
2038                         erase(%[a])                             | %[a]  | |
2039 cmi teq and $1==2 && $3==2 | source2 source2 SCR_REG |
2040                         "cmp %[2],%[1]"
2041                         "beq 1f"
2042                         "clr %[3]\n1:"
2043                         erase(%[3])                             | %[3] | |
2044 cmi teq ior $1==2 && $3==2 | source2 source2 SCR_REG |
2045                         "cmp %[2],%[1]"
2046                         "bne 1f"
2047                         "bis $$1,%[3]\n1:"
2048                         erase(%[3])                             | %[3] | |
2049 cmi teq $1==2   | source2 source2 |
2050                         allocate(REG={CONST2,0})
2051                         "cmp %[2],%[1]"
2052                         "bne 1f"
2053                         "inc %[a]\n1:"
2054                         erase(%[a])                             | %[a]  | |
2055 loc cmi teq and $1>=0 && $1<=127 && $2==2 && $4==2 | NC source1 SCR_REG |
2056                         "cmpb %[1],$$$1"
2057                         "beq 1f"
2058                         "clr %[2]\n1:"
2059                         erase(%[2])                             | %[2] | |
2060 ...     | |             | {CONST2, $1}  | cmi 2 teq and 2 |
2061 loc cmi teq ior $1>=0 && $1<=127 && $2==2 && $4==2 | NC source1 SCR_REG |
2062                         "cmpb %[1],$$$1"
2063                         "bne 1f"
2064                         "bis $$1,%[2]\n1:"
2065                         erase(%[2])                             | %[2] | |
2066 ...     | |             | {CONST2, $1}  | cmi 2 teq ior 2 |
2067 loc cmi teq $1>=0 && $1<=127 && $2==2   | NC source1 |
2068                         allocate(REG={CONST2,0})
2069                         "cmpb %[1],$$$1"
2070                         "bne 1f"
2071                         "inc %[a]\n1:"
2072                         erase(%[a])                             | %[a]  | |
2073 ...     | |             | {CONST2, $1}  | cmi 2 teq  |
2074 cmi tne and $1==2 && $3==2 | source2 source2 SCR_REG |
2075                         "cmp %[2],%[1]"
2076                         "bne 1f"
2077                         "clr %[3]\n1:"
2078                         erase(%[3])                             | %[3] | |
2079 cmi tne ior $1==2 && $3==2 | source2 source2 SCR_REG |
2080                         "cmp %[2],%[1]"
2081                         "beq 1f"
2082                         "bis $$1,%[3]\n1:"
2083                         erase(%[3])                             | %[3] | |
2084 cmi tne $1==2   | source2 source2 |
2085                         allocate(REG={CONST2,0})
2086                         "cmp %[2],%[1]"
2087                         "beq 1f"
2088                         "inc %[a]\n1:"
2089                         erase(%[a])                             | %[a]  | |
2090 loc cmi tne and $1>=0 && $1<=127 && $2==2 && $4==2 | NC source1 SCR_REG |
2091                         "cmpb %[1],$$$1"
2092                         "bne 1f"
2093                         "clr %[2]\n1:"
2094                         erase(%[2])                             | %[2] | |
2095 ...     | |             | {CONST2, $1}  | cmi 2 tne and 2 |
2096 loc cmi tne ior $1>=0 && $1<=127 && $2==2 && $4==2 | NC source1 SCR_REG |
2097                         "cmpb %[1],$$$1"
2098                         "beq 1f"
2099                         "bis $$1,%[2]\n1:"
2100                         erase(%[2])                             | %[2] | |
2101 ...     | |             | {CONST2, $1}  | cmi 2 tne ior 2 |
2102 loc cmi tne $1>=0 && $1<=127 && $2==2   | NC source1 |
2103                         allocate(REG={CONST2,0})
2104                         "cmpb %[1],$$$1"
2105                         "beq 1f"
2106                         "inc %[a]\n1:"
2107                         erase(%[a])                             | %[a]  | |
2108 ...     | |             | {CONST2, $1}  | cmi 2 tne  |
2109 cmi tge and $1==2 && $3==2 | source2 source2 SCR_REG |
2110                         "cmp %[2],%[1]"
2111                         "bge 1f"
2112                         "clr %[3]\n1:"
2113                         erase(%[3])                             | %[3] | |
2114 cmi tge ior $1==2 && $3==2 | source2 source2 SCR_REG |
2115                         "cmp %[2],%[1]"
2116                         "blt 1f"
2117                         "bis $$1,%[3]\n1:"
2118                         erase(%[3])                             | %[3] | |
2119 cmi tge $1==2   | source2 source2 |
2120                         allocate(REG={CONST2,0})
2121                         "cmp %[2],%[1]"
2122                         "blt 1f"
2123                         "inc %[a]\n1:"
2124                         erase(%[a])                             | %[a]  | |
2125 cmi tgt and $1==2 && $3==2 | source2 source2 SCR_REG |
2126                         "cmp %[2],%[1]"
2127                         "bgt 1f"
2128                         "clr %[3]\n1:"
2129                         erase(%[3])                             | %[3] | |
2130 cmi tgt ior $1==2 && $3==2 | source2 source2 SCR_REG |
2131                         "cmp %[2],%[1]"
2132                         "ble 1f"
2133                         "bis $$1,%[3]\n1:"
2134                         erase(%[3])                             | %[3] | |
2135 cmi tgt $1==2   | source2 source2 |
2136                         allocate(REG={CONST2,0})
2137                         "cmp %[2],%[1]"
2138                         "ble 1f"
2139                         "inc %[a]\n1:"
2140                         erase(%[a])                             | %[a]  | |
2141 cmp tlt | source2 source2 |
2142                         allocate(REG={CONST2,0})
2143                         "cmp %[2],%[1]"
2144                         "bhis 1f"
2145                         "inc %[a]\n1:"
2146                         erase(%[a])                             | %[a]  | |
2147 cmp tle | source2 source2 |
2148                         allocate(REG={CONST2,0})
2149                         "cmp %[2],%[1]"
2150                         "bhi 1f"
2151                         "inc %[a]\n1:"
2152                         erase(%[a])                             | %[a]  | |
2153 cmp teq | source2 source2 |
2154                         allocate(REG={CONST2,0})
2155                         "cmp %[2],%[1]"
2156                         "bne 1f"
2157                         "inc %[a]\n1:"
2158                         erase(%[a])                             | %[a]  | |
2159 cmp tne | source2 source2 |
2160                         allocate(REG={CONST2,0})
2161                         "cmp %[2],%[1]"
2162                         "beq 1f"
2163                         "inc %[a]\n1:"
2164                         erase(%[a])                             | %[a]  | |
2165 cmp tge | source2 source2 |
2166                         allocate(REG={CONST2,0})
2167                         "cmp %[2],%[1]"
2168                         "blo 1f"
2169                         "inc %[a]\n1:"
2170                         erase(%[a])                             | %[a]  | |
2171 cmp tgt | source2 source2 |
2172                         allocate(REG={CONST2,0})
2173                         "cmp %[2],%[1]"
2174                         "blos 1f"
2175                         "inc %[a]\n1:"
2176                         erase(%[a])                             | %[a]  | |
2177 cmf tlt $1==4   | FLT_REG FLT_REG |
2178                         allocate(REG={CONST2,0})
2179                         "cmpf %[2],%[1]\ncfcc"
2180                         "bge 1f"
2181                         "inc %[a]\n1:"
2182                         erase(%[a])                             | %[a] | |
2183 cmf tle $1==4   | FLT_REG FLT_REG |
2184                         allocate(REG={CONST2,0})
2185                         "cmpf %[2],%[1]\ncfcc"
2186                         "bgt 1f"
2187                         "inc %[a]\n1:"
2188                         erase(%[a])                             | %[a] | |
2189 cmf teq $1==4   | FLT_REG FLT_REG |
2190                         allocate(REG={CONST2,0})
2191                         "cmpf %[2],%[1]\ncfcc"
2192                         "bne 1f"
2193                         "inc %[a]\n1:"
2194                         erase(%[a])                             | %[a] | |
2195 cmf tne $1==4   | FLT_REG FLT_REG |
2196                         allocate(REG={CONST2,0})
2197                         "cmpf %[2],%[1]\ncfcc"
2198                         "beq 1f"
2199                         "inc %[a]\n1:"
2200                         erase(%[a])                             | %[a] | |
2201 cmf tgt $1==4   | FLT_REG FLT_REG |
2202                         allocate(REG={CONST2,0})
2203                         "cmpf %[2],%[1]\ncfcc"
2204                         "ble 1f"
2205                         "inc %[a]\n1:"
2206                         erase(%[a])                             | %[a] | |
2207 cmf tge $1==4   | FLT_REG FLT_REG |
2208                         allocate(REG={CONST2,0})
2209                         "cmpf %[2],%[1]\ncfcc"
2210                         "blt 1f"
2211                         "inc %[a]\n1:"
2212                         erase(%[a])                             | %[a] | |
2213 cmf tlt $1==8   | DBL_REG double8 |
2214                         allocate(REG={CONST2,0})
2215                         "cmpf %[2],%[1]\ncfcc"
2216                         "bge 1f"
2217                         "inc %[a]\n1:"
2218                         erase(%[a])                             | %[a] | |
2219 ...             | double8 DBL_REG |
2220                         allocate(REG={CONST2,0})
2221                         "cmpf %[1],%[2]\ncfcc"
2222                         "ble 1f"
2223                         "inc %[a]\n1:"
2224                         erase(%[a])                             | %[a] | |
2225 cmf tle $1==8   | DBL_REG double8 |
2226                         allocate(REG={CONST2,0})
2227                         "cmpf %[2],%[1]\ncfcc"
2228                         "bgt 1f"
2229                         "inc %[a]\n1:"
2230                         erase(%[a])                             | %[a] | |
2231 ...             | double8 DBL_REG |
2232                         allocate(REG={CONST2,0})
2233                         "cmpf %[1],%[2]\ncfcc"
2234                         "blt 1f"
2235                         "inc %[a]\n1:"
2236                         erase(%[a])                             | %[a] | |
2237 cmf teq $1==8   | DBL_REG double8 |
2238                         allocate(REG={CONST2,0})
2239                         "cmpf %[2],%[1]\ncfcc"
2240                         "bne 1f"
2241                         "inc %[a]\n1:"
2242                         erase(%[a])                             | %[a] | |
2243 ...             | double8 DBL_REG |
2244                         allocate(REG={CONST2,0})
2245                         "cmpf %[1],%[2]\ncfcc"
2246                         "bne 1f"
2247                         "inc %[a]\n1:"
2248                         erase(%[a])                             | %[a] | |
2249 cmf tne $1==8   | DBL_REG double8 |
2250                         allocate(REG={CONST2,0})
2251                         "cmpf %[2],%[1]\ncfcc"
2252                         "beq 1f"
2253                         "inc %[a]\n1:"
2254                         erase(%[a])                             | %[a] | |
2255 ...             | double8 DBL_REG |
2256                         allocate(REG={CONST2,0})
2257                         "cmpf %[1],%[2]\ncfcc"
2258                         "beq 1f"
2259                         "inc %[a]\n1:"
2260                         erase(%[a])                             | %[a] | |
2261 cmf tgt $1==8   | DBL_REG double8 |
2262                         allocate(REG={CONST2,0})
2263                         "cmpf %[2],%[1]\ncfcc"
2264                         "ble 1f"
2265                         "inc %[a]\n1:"
2266                         erase(%[a])                             | %[a] | |
2267 ...             | double8 DBL_REG |
2268                         allocate(REG={CONST2,0})
2269                         "cmpf %[1],%[2]\ncfcc"
2270                         "bge 1f"
2271                         "inc %[a]\n1:"
2272                         erase(%[a])                             | %[a] | |
2273 cmf tge $1==8   | DBL_REG double8 |
2274                         allocate(REG={CONST2,0})
2275                         "cmpf %[2],%[1]\ncfcc"
2276                         "blt 1f"
2277                         "inc %[a]\n1:"
2278                         erase(%[a])                             | %[a] | |
2279 ...             | double8 DBL_REG |
2280                         allocate(REG={CONST2,0})
2281                         "cmpf %[1],%[2]\ncfcc"
2282                         "bgt 1f"
2283                         "inc %[a]\n1:"
2284                         erase(%[a])                             | %[a] | |
2285
2286 /****************************************
2287  * Group 13 : Branch instructions       *
2288  ****************************************/
2289
2290 bra             | |     remove(all)
2291                         "jbr $1"
2292                         samecc                                  |       | |
2293 blt             | source2 source2 |
2294                         remove(all)
2295                         "cmp %[2],%[1]"
2296                         "jlt $1"                                |       | |
2297 ble             | source2 source2 |
2298                         remove(all)
2299                         "cmp %[2],%[1]"
2300                         "jle $1"                                |       | |
2301 beq             | NC source1 source1 |
2302                         remove(all)
2303                         "cmpb %[2],%[1]"
2304                         "jeq $1"                                |       | |
2305 ...             | source2 source2 |
2306                         remove(all)
2307                         "cmp %[2],%[1]"
2308                         "jeq $1"                                |       | |
2309 bne             | NC source1 source1 |
2310                         remove(all)
2311                         "cmpb %[2],%[1]"
2312                         "jne $1"                                |       | |
2313 ...             | source2 source2 |
2314                         remove(all)
2315                         "cmp %[2],%[1]"
2316                         "jne $1"                                |       | |
2317 bge             | source2 source2 |
2318                         remove(all)
2319                         "cmp %[2],%[1]"
2320                         "jge $1"                                |       | |
2321 bgt             | source2 source2 |
2322                         remove(all)
2323                         "cmp %[2],%[1]"
2324                         "jgt $1"                                |       | |
2325 loc beq $1>=0 && $1<=127 | NC source1 |
2326                         remove(all)
2327                         "cmpb %[1],$$$1"
2328                         "jeq $2"                                |       | |
2329 ...             | |                     | {CONST2, $1}          | beq $2 |
2330 loc bne $1>=0 && $1<=127 | NC source1 |
2331                         remove(all)
2332                         "cmpb %[1],$$$1"
2333                         "jne $2"                                |       | |
2334 ...             | |                     | {CONST2, $1}          | bne $2 |
2335 zlt             | source2 |
2336                         remove(all)
2337                         test(%[1])
2338                         "jlt $1"
2339                         samecc                                  |       | |
2340 zle             | source2 |
2341                         remove(all)
2342                         test(%[1])
2343                         "jle $1"
2344                         samecc                                  |       | |
2345 zeq             | source1or2 |
2346                         remove(all)
2347                         test(%[1])
2348                         "jeq $1"
2349                         samecc                                  |       | |
2350 zne             | source1or2 |
2351                         remove(all)
2352                         test(%[1])
2353                         "jne $1"
2354                         samecc                                  |       | |
2355 zge             | source2 |
2356                         remove(all)
2357                         test(%[1])
2358                         "jge $1"
2359                         samecc                                  |       | |
2360 zgt             | source2 |
2361                         remove(all)
2362                         test(%[1])
2363                         "jgt $1"
2364                         samecc                                  |       | |
2365 cmp zlt         | source2 source2 |
2366                         remove(all)
2367                         "cmp %[2],%[1]"
2368                         "jlo $2"                                | | |
2369 cmp zle         | source2 source2 |
2370                         remove(all)
2371                         "cmp %[2],%[1]"
2372                         "jlos $2"                               | | |
2373 cmp zeq         | source2 source2 |
2374                         remove(all)
2375                         "cmp %[2],%[1]"
2376                         "jeq $2"                                | | |
2377 cmp zne         | source2 source2 |
2378                         remove(all)
2379                         "cmp %[2],%[1]"
2380                         "jne $2"                                | | |
2381 cmp zgt         | source2 source2 |
2382                         remove(all)
2383                         "cmp %[2],%[1]"
2384                         "jhi $2"                                | | |
2385 cmp zge         | source2 source2 |
2386                         remove(all)
2387                         "cmp %[2],%[1]"
2388                         "jhis $2"                               | | |
2389 cmf zlt $1==4   | FLT_REG FLT_REG |
2390                         remove(all)
2391                         "cmpf %[2],%[1]\ncfcc"
2392                         "jlt $2"                                | | |
2393 cmf zle $1==4   | FLT_REG FLT_REG |
2394                         remove(all)
2395                         "cmpf %[2],%[1]\ncfcc"
2396                         "jle $2"                                | | |
2397 cmf zeq $1==4   | FLT_REG FLT_REG |
2398                         remove(all)
2399                         "cmpf %[2],%[1]\ncfcc"
2400                         "jeq $2"                                | | |
2401 cmf zne $1==4   | FLT_REG FLT_REG |
2402                         remove(all)
2403                         "cmpf %[2],%[1]\ncfcc"
2404                         "jne $2"                                | | |
2405 cmf zgt $1==4   | FLT_REG FLT_REG |
2406                         remove(all)
2407                         "cmpf %[2],%[1]\ncfcc"
2408                         "jgt $2"                                | | |
2409 cmf zge $1==4   | FLT_REG FLT_REG |
2410                         remove(all)
2411                         "cmpf %[2],%[1]\ncfcc"
2412                         "jge $2"                                | | |
2413 cmf zlt $1==8   | DBL_REG double8 |
2414                         remove(all)
2415                         "cmpf %[2],%[1]\ncfcc"
2416                         "jlt $2"                                | | |
2417 ...             | double8 DBL_REG |
2418                         remove(all)
2419                         "cmpf %[1],%[2]\ncfcc"
2420                         "jgt $2"                                | | |
2421 cmf zle $1==8   | DBL_REG double8 |
2422                         remove(all)
2423                         "cmpf %[2],%[1]\ncfcc"
2424                         "jle $2"                                | | |
2425 ...             | double8 DBL_REG |
2426                         remove(all)
2427                         "cmpf %[1],%[2]\ncfcc"
2428                         "jge $2"                                | | |
2429 cmf zeq $1==8   | DBL_REG double8 |
2430                         remove(all)
2431                         "cmpf %[2],%[1]\ncfcc"
2432                         "jeq $2"                                | | |
2433 ...             | double8 DBL_REG |
2434                         remove(all)
2435                         "cmpf %[1],%[2]\ncfcc"
2436                         "jeq $2"                                | | |
2437 cmf zne $1==8   | DBL_REG double8 |
2438                         remove(all)
2439                         "cmpf %[2],%[1]\ncfcc"
2440                         "jne $2"                                | | |
2441 ...             | double8 DBL_REG |
2442                         remove(all)
2443                         "cmpf %[1],%[2]\ncfcc"
2444                         "jne $2"                                | | |
2445 cmf zgt $1==8   | DBL_REG double8 |
2446                         remove(all)
2447                         "cmpf %[2],%[1]\ncfcc"
2448                         "jgt $2"                                | | |
2449 ...             | double8 DBL_REG |
2450                         remove(all)
2451                         "cmpf %[1],%[2]\ncfcc"
2452                         "jlt $2"                                | | |
2453 cmf zge $1==8   | DBL_REG double8 |
2454                         remove(all)
2455                         "cmpf %[2],%[1]\ncfcc"
2456                         "jge $2"                                | | |
2457 ...             | double8 DBL_REG |
2458                         remove(all)
2459                         "cmpf %[1],%[2]\ncfcc"
2460                         "jle $2"                                | | |
2461
2462 and zeq $1==2   | source1 source1or2 |
2463                         remove(all)
2464                         "bitb %[1],%[2]"
2465                         "jeq $2"                                | | |
2466 ...             | source1or2 source1 |
2467                         remove(all)
2468                         "bitb %[1],%[2]"
2469                         "jeq $2"                                | | |
2470 ...             | source2 source2 |
2471                         remove(all)
2472                         "bit %[1],%[2]"
2473                         "jeq $2"                                | | |
2474 and zne $1==2   | source1 source1or2 |
2475                         remove(all)
2476                         "bitb %[1],%[2]"
2477                         "jne $2"                                | | |
2478 ...             | source1or2 source1 |
2479                         remove(all)
2480                         "bitb %[1],%[2]"
2481                         "jne $2"                                | | |
2482 ...             | source2 source2 |
2483                         remove(all)
2484                         "bit %[1],%[2]"
2485                         "jne $2"                                | | |
2486
2487 /************************************************
2488  * group 14 : Procedure call instructions       *
2489  ************************************************/
2490
2491 cal             | |     remove(ALL)
2492                         "jsr pc,$1"                     |       | |
2493 cai             | register | remove(ALL)
2494                         "jsr pc,(%[1])"                 |       | |
2495 lfr $1==2       | |                                             | r0    | |
2496 lfr $1==4       | |                                             | r1 r0 | |
2497 lfr $1==8       | |                             | {relative8,"retar"} | |
2498 lfr             | |     remove(all)
2499                         move({CONST2,$1},r0)
2500                         "jsr pc,lfr~"
2501                         erase(r0)                              |       | |
2502
2503 lfr ret $1==$2  | |                                            | | ret 0 |
2504
2505 #ifndef REGVARS
2506 asp lfr ret $2==$3 | |                                         | | ret 0 |
2507 asp ret $2==0   | |                                            | | ret 0 |
2508 #endif
2509
2510 ret $1==0       | |     remove(all)
2511 #ifdef REGVARS
2512                         return                                 | | |
2513 #else
2514                         "mov r5,sp\nmov (sp)+,r5\nrts pc"      |       | |
2515 #endif
2516 ret $1==2       | source2 |
2517                         remove(all)
2518                         move(%[1],r0)
2519 #ifdef REGVARS
2520                         return                                 | | |
2521 #else
2522                         "mov r5,sp\nmov (sp)+,r5\nrts pc"      |       | |
2523 #endif
2524 ret $1==4       |  |
2525                         remove(all)
2526                         "mov (sp)+,r0"
2527                         "mov (sp)+,r1"
2528 #ifdef REGVARS
2529                         return                                 | | |
2530 #else
2531                         "mov r5,sp\nmov (sp)+,r5\nrts pc"      |       | |
2532 #endif
2533 ret $1==8       |       |       | {ADDR_EXTERNAL, "retar"} | sti 8 ret 0  |
2534 ret             | |     remove(all)
2535                         move({CONST2,$1},r0)
2536                         "jmp ret~"                              |       | |
2537
2538 /************************************************
2539  * Group 15 : Miscellaneous instructions        *
2540  ************************************************/
2541
2542 asp $1==2       | NC xsource2 |                                 |       | |
2543 ...             | |     remove(all)
2544                         "tst (sp)+"                             |       | |
2545 asp $1==4       | |     remove(all)
2546                         "cmp (sp)+,(sp)+"                       |       | |
2547 asp $1==0-2     | |     remove(all)
2548                         "tst -(sp)"                             |       | |
2549 asp             | |     remove(all)
2550                         "add $$$1,sp"                   |       | |
2551 ass $1==2       | |     remove(all)
2552                         "add (sp)+,sp"                          |       | |
2553 #ifdef UNTESTED
2554 ass !defined($1)| source2 |
2555                         remove(all)
2556                         "cmp %[1],$$2"
2557                         "beq 1f;jmp unknown~;1:"
2558                         "add (sp)+,sp"                          |       | |
2559 #endif
2560
2561 blm $1==4       | SCR_REG SCR_REG |
2562                         "mov (%[2])+,(%[1])+"
2563                         "mov (%[2]),(%[1])"
2564                         erase(%[1]) erase(%[2])                 |       | |
2565 blm $1==6       | SCR_REG SCR_REG |
2566                         "mov (%[2])+,(%[1])+"
2567                         "mov (%[2])+,(%[1])+"
2568                         "mov (%[2]),(%[1])"
2569                         erase(%[1]) erase(%[2])                 |       | |
2570 blm $1==8       | SCR_REG SCR_REG |
2571                         "mov (%[2])+,(%[1])+"
2572                         "mov (%[2])+,(%[1])+"
2573                         "mov (%[2])+,(%[1])+"
2574                         "mov (%[2]),(%[1])"
2575                         erase(%[1]) erase(%[2])                 |       | |
2576 blm             | SCR_REG SCR_REG |
2577                         allocate(REG={CONST2,$1/2})
2578                         "1:mov (%[2])+,(%[1])+\nsob %[a],1b"
2579                         erase(%[1]) erase (%[2]) erase(%[a])    |       | |
2580 bls $1==2       | SCR_REG SCR_REG SCR_REG |
2581                         "asr %[1]\nbeq 2f"
2582                         "1:mov (%[3])+,(%[2])+\nsob %[1],1b\n2:"
2583                         erase(%[1]) erase (%[2]) erase(%[3])    |       | |
2584 #ifdef UNTESTED
2585 bls !defined($1)| source2 SCR_REG SCR_REG SCR_REG |
2586                         remove(all)
2587                         "cmp %[1],$$2"
2588                         "beq 1f;jmp unknown~;1:"
2589                         "asr %[2]\nbeq 2f"
2590                         "1:mov (%[4])+,(%[3])+\nsob %[2],1b\n2:"
2591                         erase(%[2]) erase (%[3]) erase(%[4])    |       | |
2592 #endif
2593 lae csa $2==2 | source2 |
2594                         remove(all)
2595                         move(%[1],r1)
2596                         move({ADDR_EXTERNAL,$1},r0)
2597                         "jmp csa~"                              |       | |
2598 csa $1==2       | |
2599                         remove(all)
2600                         "mov (sp)+,r0"
2601                         "mov (sp)+,r1"
2602                         "jmp csa~"                              |       | |
2603 #ifdef UNTESTED
2604 csa !defined($1)| source2 |
2605                         remove(all)
2606                         "cmp %[1],$$2"
2607                         "beq 1f;jmp unknown~;1:"
2608                         "mov (sp)+,r0"
2609                         "mov (sp)+,r1"
2610                         "jmp csa~"                              |       | |
2611 #endif
2612 lae csb $2==2   | NC source2 |
2613                         remove(all)
2614                         move(%[1],r1)
2615                         move({ADDR_EXTERNAL,$1},r0)
2616                         "jmp csb~"                              |       | |
2617 ...             | |
2618                         remove(all)
2619                         move({ADDR_EXTERNAL,$1},r0)
2620                         "mov (sp)+,r1"
2621                         "jmp csb~"                              |       | |
2622
2623 csb $1==2       | |
2624                         remove(all)
2625                         "mov (sp)+,r0"
2626                         "mov (sp)+,r1"
2627                         "jmp csb~"                              |       | |
2628 #ifdef UNTESTED
2629 csb !defined($1)| source2 |
2630                         remove(all)
2631                         "cmp %[1],$$2"
2632                         "beq 1f;jmp unknown~;1:"
2633                         "mov (sp)+,r0"
2634                         "mov (sp)+,r1"
2635                         "jmp csb~"                              |       | |
2636 #endif
2637 dup $1==2       | register     |             | %[1] %[1]                     | |
2638 dup $1==4       | NC longf4 | | %[1] %[1]                               | |
2639 ...             | source2 source2 |     | %[2] %[1] %[2] %[1]           | |
2640 dup $1==8       | NC double8| | %[1] %[1]                               | |
2641 ...             | |     remove(all)
2642                         move({CONST2, $1}, r0)
2643                         "jsr pc,dup~"
2644                         erase(r01)                              |       | |
2645 dup             | |     remove(all)
2646                         move({CONST2, $1}, r0)
2647                         "jsr pc,dup~"
2648                         erase(r01)                              |       | |
2649 dus $1==2       | source2 |
2650                         remove(all)
2651                         move(%[1],r0)
2652                         "jsr pc,dup~"
2653                         erase(r01)                              |       | |
2654 #ifdef UNTESTED
2655 dus !defined($1)| source2 |
2656                         remove(all)
2657                         "cmp %[1],$$2"
2658                         "beq 1f;jmp unknown~;1:"
2659                         "mov (sp)+,r0"
2660                         "jsr pc,dup~"
2661                         erase(r01)                              |       | |
2662 #endif
2663 gto             | |     remove(all)
2664                         "mov $$$1,-(sp)"
2665                         "jmp gto~"                              |       | |
2666 fil             | |     "mov $$$1,hol0+4"                       |       | |
2667 lim             | |             | { relative2, "trpim~"}                | |
2668 lin             | |     "mov $$$1,hol0"                        |       | |
2669 lni             | |     "inc hol0"                              |       | |
2670 lor $1==0       | |                                             | lb    | |
2671 lor $1==1       | |     remove(all)
2672                         allocate(REG)
2673                         "mov sp,%[a]"                           | %[a]  | |
2674 lor $1==2       | |                             | {relative2,"reghp~"}  | |
2675 mon             | |     remove(all)
2676                         "jsr pc,mon~"                   |       | |
2677 nop             | |     remove(all)
2678 #ifdef DEBUG
2679                         "jsr pc,nop~"
2680 #endif
2681                                                         |       | |
2682 #ifdef DORCK
2683 rck $1==2       | source2 |
2684                         remove(all)
2685                         move(%[1],r0)
2686                         "jsr pc,rck~"                   |       | |
2687 #ifdef UNTESTED
2688 rck !defined($1)| source2 source2 |
2689                         remove(all)
2690                         "cmp %[1],$$2"
2691                         "beq 1f;jmp unknown~;1:"
2692                         move(%[2],r0)
2693                         "jsr pc,rck~"                       |       | |
2694 #endif
2695 #else
2696 rck $1==2       | source2 |                             |       | |
2697 rck !defined($1)| source2 source2 |                     |       | |
2698 #endif
2699 rtt             | |             |                       | ret 0 |
2700 sig             | source2 |
2701                         allocate(REG)
2702                         move({relative2,"trppc~"},%[a])
2703                         "mov %[1],trppc~"                       | %[a]  | |
2704 sim             | |     remove(all)
2705                         "jsr pc,sim~"                   |       | |
2706 str $1==0       | source2 |
2707                         "mov %[1],r5"                   |       | |
2708 str $1==1       | source2 |
2709                         remove(all)
2710                         "mov %[1],sp"                   |       | |
2711 str $1==2       | |     remove(all)
2712                         "jsr pc,strhp~"                 |       | |
2713 trp             | |     remove(all)
2714                         "jsr pc,trp~"                   |       | |
2715 exg $1==2       | source2 source2 |                     | %[1] %[2] | |
2716 exg defined($1) | |     remove(all)
2717                         move({CONST2,$1},r0)
2718                         "jsr pc,exg~"                   | | |
2719 exg             | source2 | remove(all)
2720                         move(%[1],r0)
2721                         "jsr pc,exg"                    | | |
2722
2723 lol lal sti $1==$2 && $3==1| | | | | /* throw away funny C-proc-prolog */
2724
2725 /********************************
2726  * Coercions                    *
2727  *                              *
2728  * From EM-tokens to PDP-tokens *
2729  ********************************/
2730
2731 | LOCAL2 |      | {regind2,lb,tostring(%[1.ind])} | |
2732 | LOCAL4 |      | {regind4,lb,tostring(%[1.ind])} | |
2733
2734 /********************************
2735  * From source to register      *
2736  ********************************/
2737
2738 | regconst2 |   allocate(%[1],REG=%[1.reg])
2739                 "add $$%[1.ind],%[a]"
2740                 setcc(%[a])                     | %[a]  | |(6,105)
2741 | ADDR_LOCAL |  allocate(REG)
2742                 "mov r5,%[a]"
2743                 "add $$%[1.ind],%[a]"
2744                 setcc(%[a])                     | %[a]  | |(6,105)
2745 | register |                         | {regconst2, %[1], "0"}  | | (2,60)
2746 | xsource2 |     allocate(%[1], REG=%[1])        | %[a]  | |
2747 | xsource2 |     allocate(%[1], REG=%[1])        | {regconst2, %[a], "0"}  | |
2748 | longf4 |      allocate(FLT_REG)
2749                 move( %[1],%[a])                | %[a]  | | (20,2000) + %[1]
2750 | double8 |     allocate(DBL_REG)
2751                 move(%[1],%[a])         | %[a]  | | (20,3000) + %[1]
2752
2753 /********************************
2754  * From source1 to source2      *
2755  ********************************/
2756
2757 | source1 |     allocate(REG={CONST2,0})
2758                 "bisb %[1],%[a]"
2759                 erase(%[a]) setcc(%[a])          | %[a]  | | (6,105)+%[1]
2760
2761 /********************************
2762  * From long4 to source2        *
2763  ********************************/
2764
2765 | REG_PAIR |    | %[1.2] %[1.1] | |
2766 | regind4 |     | {regind2,%[1.reg],"2+"+%[1.ind]} {regind2,%[1.reg],%[1.ind]} | |
2767 | relative4 |   | {relative2,"2+"+%[1.ind]} {relative2,%[1.ind]}        | |
2768 | regdef4 |     | {regind2,%[1.reg],"2"} {regdef2,%[1.reg]}               | |
2769 | LOCAL4 |      | {LOCAL2, %[1.ind]+2, 2} {LOCAL2, %[1.ind], 2}         | |
2770
2771 /********************************
2772  * from double8 to long4        *
2773  ********************************/
2774
2775 | regind8 |     | {regind4,%[1.reg],"4+"+%[1.ind]} {regind4,%[1.reg],%[1.ind]} | |
2776 | relative8 |   | {relative4,"4+"+%[1.ind]} {relative4,%[1.ind]}        | |
2777 | regdef8 |     | {regdef4,%[1.reg]} {regind4,%[1.reg],"4"}               | |
2778
2779
2780
2781 /************************
2782  * From STACK coercions *
2783  ************************/
2784
2785 | STACK |       allocate(REG)
2786                 "mov (sp)+,%[a]"
2787                 setcc(%[a])                     | %[a]  | | (2,75)
2788 | STACK |       allocate(REG)
2789                 "mov (sp)+,%[a]"
2790                 setcc(%[a])                     | {regconst2, %[a], "0"}  | | (2,75)
2791 | STACK |       allocate(FLT_REG)
2792                 "movof (sp)+,%[a]"
2793                 samecc                          | %[a]  | | (20,4740) /* /10  */
2794 | STACK |       allocate(DBL_REG)
2795                 "movf (sp)+,%[a]"
2796                 samecc                          | %[a]  | | (20,6920) /* /10 */
2797 | STACK |       allocate(REG_PAIR)
2798                 "mov (sp)+,%[a.1]"
2799                 "mov (sp)+,%[a.2]"
2800                 setcc(%[a.2])                   | %[a]  | | (4,150)
2801
2802 MOVES:
2803 (CONST2 %[num] == 0, source2, "clr %[2]" setcc(%[2]),(2,30))
2804 (source2, source2, "mov %[1],%[2]" setcc(%[2]),(2,30)+%[1]+%[2])
2805 (FLT_REG, longf4-FLT_REG,"movfo %[1],%[2]" samecc, (2,88) + %[2])
2806 (longf4-FLT_REG,FLT_REG, "movof %[1],%[2]" samecc, (2,150) + %[2])
2807 (FLT_REG, FLT_REG, "movf %[1],%[2]" samecc,(2,88))
2808 (DBL_REG,double8, "movf %[1],%[2]" samecc,(2,88) + %[2])
2809 (double8,DBL_REG, "movf %[1],%[2]" samecc,(2,170) + %[1])
2810 (CONST2 %[num] == 0,source1, "clrb %[2]" setcc(%[2]),(2,45)+%[2])
2811 (source1or2,source1, "movb %[1],%[2]" setcc(%[2]),(2,30)+%[1]+%[2])
2812 (ftoint,source2, "movfi %[1.reg],%[2]" samecc)
2813
2814 TESTS:
2815 (source2, "tst %[1]" ,(2,30) + %[1])
2816 (source1, "tstb %[1]",(2,40) + %[1])
2817 (FLT_REG+DBL_REG, "tstf %[1]\ncfcc" ,(4,260))
2818 /* (DBL_REG, "tstf %[1]\ncfcc" ,(4,260)) */
2819
2820 STACKS:
2821 ( CONST2 %[num]==0 ,, "clr -(sp)"                                             )
2822 ( source2 ,,     "mov %[1],-(sp)" setcc(%[1]),                    (2,90)+%[1])
2823 ( regconst2 ,,   "mov %[1.reg],-(sp)\nadd $$%[1.ind],(sp)" ,          (6,225))
2824 ( ADDR_LOCAL,,   "mov r5,-(sp)" "add $$%[1.ind],(sp)",               (6,225))
2825 ( DBL_REG ,,     "movf %[1],-(sp)" samecc             ,               (2,610))
2826 ( FLT_REG ,,     "movfo %[1],-(sp)" samecc                          , (2,412))
2827 ( REG_PAIR ,,    "mov %[1.2],-(sp)" "mov %[1.1],-(sp)"              , (4,180))
2828 ( regind4 ,,     "mov 2+%[1.ind](%[1.reg]),-(sp)"
2829                 "mov %[1.ind](%[1.reg]),-(sp)"  ,                     (8,300))
2830 ( relative4 ,,   "mov 2+%[1.ind],-(sp)"
2831                 "mov %[1.ind],-(sp)"            ,                     (8,300))
2832 ( regdef4 ,,     "mov 2(%[1.reg]),-(sp)"
2833                 "mov (%[1.reg]),-(sp)"          ,                     (6,270))
2834 ( regind8 ,REG, move(%[1.reg],%[a])
2835                 "add $$%(8%)+%[1.ind],%[a]"
2836                 "mov -(%[a]),-(sp)"
2837                 "mov -(%[a]),-(sp)"
2838                 "mov -(%[a]),-(sp)"
2839                 "mov -(%[a]),-(sp)"
2840                 erase(%[a])                     ,                    (14,600))
2841 ( regind8 ,,     "mov 6+%[1.ind](%[1.reg]),-(sp)"
2842                 "mov 4+%[1.ind](%[1.reg]),-(sp)"
2843                 "mov 2+%[1.ind](%[1.reg]),-(sp)"
2844                 "mov %[1.ind](%[1.reg]),-(sp)"  ,                    (16,600))
2845 ( relative8 ,REG,"mov $$%(8%)+%[1.ind],%[a]"
2846                 "mov -(%[a]),-(sp)"
2847                 "mov -(%[a]),-(sp)"
2848                 "mov -(%[a]),-(sp)"
2849                 "mov -(%[a]),-(sp)"             ,                    (12,500))
2850 ( relative8 ,,   "mov 6+%[1.ind],-(sp)"
2851                 "mov 4+%[1.ind],-(sp)"
2852                 "mov 2+%[1.ind],-(sp)"
2853                 "mov %[1.ind],-(sp)"            ,                    (16,600))
2854 ( regdef8 ,,     "mov 6(%[1.reg]),-(sp)"
2855                 "mov 4(%[1.reg]),-(sp)"
2856                 "mov 2(%[1.reg]),-(sp)"
2857                 "mov (%[1.reg]),-(sp)"          ,                    (14,570))
2858 ( LOCAL4 ,,      "mov 2+%[1.ind](r5),-(sp)"
2859                 "mov %[1.ind](r5),-(sp)"       ,                     (8,300))
2860 ( source1 ,,     "clr -(sp)"
2861                 "movb %[1],(sp)"                ,                (4,180)+%[1])
2862 ( ftoint ,,     "movfi %[1.reg],-(sp)"                                        )
2863 ( ftolong ,,    "setl\nmovfi %[1.reg],-(sp)\nseti"                            )