1 /* $Id: mach4.c,v 2.10 1994/06/24 13:02:53 ceriel Exp $ */
3 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4 * See the copyright notice in the ACK home directory, in the file "Copyright".
8 * Motorola 68000/68010 syntax rules
12 : { curr_instr = curr_token; }
18 { emit2($1 | $2 | $4<<9);}
19 | bcdx '-' '(' AREG ')' ',' '-' '(' AREG ')'
20 { emit2($1 | $4 | $9<<9 | 010);}
30 { $4.val -= (DOTVAL+2);
34 newrelo($4.typ, RELPC|RELO2|RELBR|RELWR);
40 | OP_EA_D sizedef ea ',' DREG
42 serror("illegal size");
44 emit2($1 | mrg_2 | $5<<9);
48 { emit2(040700 | mrg_2 | $4<<9);
52 { emit2(($1&0177700) | mrg_2);
53 ea_2($1&0300, $1&017);
63 | MOVEM sizedef regs ',' notimmreg
65 | MOVEM sizedef notimmreg ',' regs
70 emit2(007000 | $2 | mrg_2);
71 emit2(mrg_1 << 12 | 04000);
73 } else if (mrg_2 <= 017) {
74 emit2(007000 | $2 | mrg_1);
82 emit2(047172); emit2($2 | $4<<12);
86 emit2(047173); emit2($4 | $2<<12);
89 { if (($2 & 010) == 0)
97 (0140610|$2|($4&07)<<9)
102 | OP_EXT sizedef DREG
103 { checksize($2, 2|4); emit2(044000 | $2+0100 | $3);}
105 { emit2(044100 | $2);}
107 { emit2($1); ea_2(SIZE_W, 0);}
109 { emit2(047120 | $2); ea_2(SIZE_W, 0);}
111 { emit2(047130 | $2);}
113 { Xfit(fit4($3)); emit2(047100|low4($3));}
128 | SPEC { if ($1 != 075) badoperand(); $$ = 04000;}
143 for ($$ = 0; $1 <= $3; $1++)
164 { exp_2 = $1; ea707172($2);
165 RELOMOVE(rel_2, relonami);
167 | expr '(' reg sizenon ')'
168 { exp_2 = $1; ea5x73($3, $4);
169 RELOMOVE(rel_2, relonami);
171 | expr '(' AREG ',' reg sizedef ')'
172 { exp_2 = $1; ea6x($3, $5, $6);
173 RELOMOVE(rel_2, relonami);
176 { exp_2 = $1; ea72();
177 RELOMOVE(rel_2, relonami);
179 | expr '(' PC ',' reg sizedef ')'
180 { exp_2 = $1; ea73($5, $6);
181 RELOMOVE(rel_2, relonami);
185 { mrg_2 = 074; exp_2 = $2;
186 RELOMOVE(rel_2, relonami);
193 sizedef : /* empty */
197 sizenon : /* empty */
202 { mrg_1 = mrg_2; exp_1 = exp_2;
203 RELOMOVE(rel_1, rel_2);
210 | { co_id = DEF_FP; }
213 fp_op1 : FMOVE fsize ea ',' FPCR
214 { check_fsize($2, FSIZE_L);
215 if ((mrg_2&070) == 010 && $5 != 001)
217 emit2((0170000|co_id|mrg_2));
218 emit2((0100000|($5<<10)));
221 | FMOVE fsize FPCR ',' ea
222 { check_fsize($2, FSIZE_L);
223 if ((mrg_2&070) == 010 && $3 == 001)
225 emit2((0170000|co_id|mrg_2));
226 emit2((0120000|($3<<10)));
229 | FMOVE fsize FPREG ',' FPREG
230 { emit2(0170000|co_id);
231 emit2(($3<<10)|($5<<7));
233 | FMOVE fsize ea ',' FPREG
234 { ch_sz_dreg($2, mrg_2&070);
235 emit2((0170000|co_id|mrg_2));
236 emit2((0040000|($2<<10)|($5<<7)));
239 | FMOVE fsize FPREG ',' ea
240 { ch_sz_dreg($2, mrg_2&070);
242 serror("packed decimal needs k-factor");
243 emit2((0170000|co_id|mrg_2));
244 emit2((0060000|($2<<10)|($3<<7)));
245 ea_2(SIZE_L, DTA|ALT);
247 | FMOVE fsize FPREG ',' ea '{' '#' absexp '}'
248 { check_fsize($2, FSIZE_P);
250 emit2((0170000|co_id|mrg_2));
251 emit2((0066000|($3<<7)|low7($8)));
252 ea_2(SIZE_L, MEM|DTA|ALT);
254 | FMOVE fsize FPREG ',' ea '{' DREG '}'
255 { check_fsize($2, FSIZE_P);
256 emit2((0170000|co_id|mrg_2));
257 emit2((0076000|($3<<7)|($7<<4)));
258 ea_2(SIZE_L, MEM|DTA|ALT);
260 | FMOVECR fsize '#' absexp ',' FPREG
262 check_fsize($2, FSIZE_X);
263 emit2(0170000|co_id);
264 emit2(056000|($6<<7)|low7($4));
266 | FMOVEM FSIZE fregs ',' notimmreg
267 { check_fsize($2, FSIZE_X);
268 if ((mrg_2&070) == 030)
269 serror("bad addressing category");
270 emit2((0170000|co_id|mrg_2));
272 (((mrg_2&070)==040 || ($3&04000)) ?
274 (010000|reverse($3,8))));
275 ea_2(SIZE_L, MEM|ALT);
277 | FMOVEM FSIZE notimmreg ',' fregs
278 { check_fsize($2, FSIZE_X);
279 if ((mrg_2&070) == 040)
280 serror("bad addressing category");
281 emit2((0170000|co_id|mrg_2));
282 emit2((0150000|(($5&04000)?$5:reverse($5,8))));
285 | FMOVEM SIZE fcregs ',' ea
287 if ((mrg_2&070) == 1 && $3!= 02000)
288 serror("bad addressing category");
289 if ((mrg_2 & 070) == 0 &&
290 $3 != 02000 && $3 != 04000 && $3 != 010000)
291 serror("bad addressing category");
292 emit2((0170000|co_id|mrg_2));
296 | FMOVEM SIZE ea ',' fcregs
298 if ((mrg_2&070) == 1 && $5!= 02000)
299 serror("bad addressing category");
300 if ((mrg_2 & 070) == 0 &&
301 $5 != 02000 && $5 != 04000 && $5 != 010000)
302 serror("bad addressing category");
303 emit2((0170000|co_id|mrg_2));
307 | FDYADIC fsize ea ',' FPREG
308 { emit2((0170000|co_id|mrg_2));
309 emit2((0040000|($2<<10)|($5<<7)|$1));
310 ch_sz_dreg($2, mrg_2&070);
313 | FDYADIC fsize FPREG ',' FPREG
314 { check_fsize($2, FSIZE_X);
315 emit2(0170000|co_id);
316 emit2(($3<<10)|($5<<7)|$1);
318 | FMONADIC fsize ea ',' FPREG
319 { emit2((0170000|co_id|mrg_2));
320 emit2((0040000|($2<<10)|($5<<7)|$1));
321 ch_sz_dreg($2, mrg_2&070);
324 | FMONADIC fsize FPREG ',' FPREG
325 { check_fsize($2, FSIZE_X);
326 emit2(0170000|co_id);
327 emit2(($3<<10)|($5<<7)|$1);
329 | FMONADIC fsize FPREG
330 { check_fsize($2, FSIZE_X);
331 emit2(0170000|co_id);
332 emit2(($3<<10)|($3<<7)|$1);
334 | FSINCOS fsize ea ',' FPREG ':' FPREG
335 { emit2(0170000|co_id|mrg_2);
336 emit2(0040000|($2<<10)|($7<<7)|$1|$5);
339 | FSINCOS fsize FPREG ',' FPREG ':' FPREG
340 { check_fsize($2, FSIZE_X);
341 emit2(0170000|co_id);
342 emit2(($3<<10)|($7<<7)|$1|$5);
346 | FDBCC DREG ',' expr
347 { emit2(0170110|co_id|$2);
352 newrelo($4.typ, RELPC|RELO2|RELBR|RELWR);
357 { emit2(0170200|co_id);
361 { emit2(0170100|co_id|mrg_2);
363 ea_2(SIZE_B, DTA|ALT);
366 { emit2((0170000|co_id|mrg_2));
367 emit2((0040072|($2<<10)));
368 ch_sz_dreg($2, mrg_2&070);
372 { check_fsize($2, FSIZE_X);
373 emit2(0170000|co_id);
377 { if ((mrg_2&070) == ($1&070))
379 emit2((0170000|co_id|($1&0700)|mrg_2));
383 { emit2(0170174|co_id);
387 { checksize($2, 2|4);
388 emit2((0170170|co_id|($2==SIZE_L?03:02)));
394 { $$ = 04000 | $1 << 4; }
406 for ($$ = 0; $1 <= $3; $1++)
413 { $$ = $1 | ($3 << 10); }
420 else if ($1 == SIZE_W)