Commit | Line | Data |
---|---|---|
a87b3269 | 1 | /* tc-m68k.c All the m68020 specific stuff in one convenient, huge, |
fecd2382 | 2 | slow to compile, easy to find file. |
f8701a3f | 3 | |
a87b3269 | 4 | Copyright (C) 1987, 1991, 1992 Free Software Foundation, Inc. |
a39116f1 RP |
5 | |
6 | This file is part of GAS, the GNU Assembler. | |
7 | ||
8 | GAS is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 2, or (at your option) | |
11 | any later version. | |
12 | ||
13 | GAS is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with GAS; see the file COPYING. If not, write to | |
20 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
fecd2382 RP |
21 | |
22 | #include <ctype.h> | |
f8701a3f | 23 | #define NO_RELOC 0 |
fecd2382 RP |
24 | #include "as.h" |
25 | ||
26 | #include "obstack.h" | |
27 | ||
a39116f1 | 28 | /* note that this file includes real declarations and thus can only be included by one source file per executable. */ |
e0982afe | 29 | #include "opcode/m68k.h" |
f6e504fe RP |
30 | #ifdef TE_SUN |
31 | /* This variable contains the value to write out at the beginning of | |
32 | the a.out file. The 2<<16 means that this is a 68020 file instead | |
33 | of an old-style 68000 file */ | |
34 | ||
35 | long omagic = 2<<16|OMAGIC; /* Magic byte for header file */ | |
36 | #else | |
37 | long omagic = OMAGIC; | |
38 | #endif | |
fecd2382 RP |
39 | |
40 | /* This array holds the chars that always start a comment. If the | |
41 | pre-processor is disabled, these aren't very useful */ | |
42 | const char comment_chars[] = "|"; | |
43 | ||
44 | /* This array holds the chars that only start a comment at the beginning of | |
45 | a line. If the line seems to have the form '# 123 filename' | |
46 | .line and .file directives will appear in the pre-processed output */ | |
47 | /* Note that input_file.c hand checks for '#' at the beginning of the | |
48 | first line of the input file. This is because the compiler outputs | |
49 | #NO_APP at the beginning of its output. */ | |
50 | /* Also note that comments like this one will always work. */ | |
51 | const char line_comment_chars[] = "#"; | |
52 | ||
53 | /* Chars that can be used to separate mant from exp in floating point nums */ | |
54 | const char EXP_CHARS[] = "eE"; | |
55 | ||
56 | /* Chars that mean this number is a floating point constant */ | |
57 | /* As in 0f12.456 */ | |
58 | /* or 0d1.2345e12 */ | |
59 | ||
60 | const char FLT_CHARS[] = "rRsSfFdDxXeEpP"; | |
61 | ||
62 | /* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be | |
63 | changed in read.c . Ideally it shouldn't have to know about it at all, | |
64 | but nothing is ideal around here. | |
a39116f1 | 65 | */ |
fecd2382 RP |
66 | |
67 | int md_reloc_size = 8; /* Size of relocation record */ | |
68 | ||
69 | /* Its an arbitrary name: This means I don't approve of it */ | |
70 | /* See flames below */ | |
71 | static struct obstack robyn; | |
72 | ||
73 | #define TAB(x,y) (((x)<<2)+(y)) | |
74 | #define TABTYPE(xy) ((xy) >> 2) | |
75 | #define BYTE 0 | |
76 | #define SHORT 1 | |
77 | #define LONG 2 | |
78 | #define SZ_UNDEF 3 | |
79 | ||
80 | #define BRANCH 1 | |
81 | #define FBRANCH 2 | |
82 | #define PCREL 3 | |
83 | #define BCC68000 4 | |
84 | #define DBCC 5 | |
85 | #define PCLEA 6 | |
86 | ||
f6e504fe | 87 | /* Operands we can parse: (And associated modes) |
a39116f1 RP |
88 | |
89 | numb: 8 bit num | |
90 | numw: 16 bit num | |
91 | numl: 32 bit num | |
92 | dreg: data reg 0-7 | |
93 | reg: address or data register | |
94 | areg: address register | |
95 | apc: address register, PC, ZPC or empty string | |
96 | num: 16 or 32 bit num | |
97 | num2: like num | |
98 | sz: w or l if omitted, l assumed | |
99 | scale: 1 2 4 or 8 if omitted, 1 assumed | |
100 | ||
101 | 7.4 IMMED #num --> NUM | |
102 | 0.? DREG dreg --> dreg | |
103 | 1.? AREG areg --> areg | |
104 | 2.? AINDR areg@ --> *(areg) | |
105 | 3.? AINC areg@+ --> *(areg++) | |
106 | 4.? ADEC areg@- --> *(--areg) | |
107 | 5.? AOFF apc@(numw) --> *(apc+numw) -- empty string and ZPC not allowed here | |
108 | 6.? AINDX apc@(num,reg:sz:scale) --> *(apc+num+reg*scale) | |
109 | 6.? AINDX apc@(reg:sz:scale) --> same, with num=0 | |
110 | 6.? APODX apc@(num)@(num2,reg:sz:scale) --> *(*(apc+num)+num2+reg*scale) | |
111 | 6.? APODX apc@(num)@(reg:sz:scale) --> same, with num2=0 | |
112 | 6.? AMIND apc@(num)@(num2) --> *(*(apc+num)+num2) (previous mode without an index reg) | |
113 | 6.? APRDX apc@(num,reg:sz:scale)@(num2) --> *(*(apc+num+reg*scale)+num2) | |
114 | 6.? APRDX apc@(reg:sz:scale)@(num2) --> same, with num=0 | |
115 | 7.0 ABSL num:sz --> *(num) | |
116 | num --> *(num) (sz L assumed) | |
117 | *** MSCR otherreg --> Magic | |
118 | With -l option | |
119 | 5.? AOFF apc@(num) --> *(apc+num) -- empty string and ZPC not allowed here still | |
120 | ||
121 | examples: | |
122 | #foo #0x35 #12 | |
123 | d2 | |
124 | a4 | |
125 | a3@ | |
126 | a5@+ | |
127 | a6@- | |
128 | a2@(12) pc@(14) | |
129 | a1@(5,d2:w:1) @(45,d6:l:4) | |
130 | pc@(a2) @(d4) | |
131 | etc . . . | |
132 | ||
133 | ||
134 | #name@(numw) -->turn into PC rel mode | |
135 | apc@(num8,reg:sz:scale) --> *(apc+num8+reg*scale) | |
136 | ||
137 | */ | |
f6e504fe RP |
138 | |
139 | enum operand_type { | |
f8701a3f SC |
140 | IMMED = 1, |
141 | DREG, | |
142 | AREG, | |
143 | AINDR, | |
144 | ADEC, | |
145 | AINC, | |
146 | AOFF, | |
147 | AINDX, | |
148 | APODX, | |
149 | AMIND, | |
150 | APRDX, | |
151 | ABSL, | |
152 | MSCR, | |
153 | REGLST, | |
f6e504fe RP |
154 | }; |
155 | ||
156 | ||
fecd2382 | 157 | struct m68k_exp { |
f8701a3f SC |
158 | char *e_beg; |
159 | char *e_end; | |
160 | expressionS e_exp; | |
161 | short e_siz; /* 0== default 1==short/byte 2==word 3==long */ | |
fecd2382 RP |
162 | }; |
163 | ||
7c15cbe8 RP |
164 | /* DATA and ADDR have to be contiguous, so that reg-DATA gives 0-7==data reg, |
165 | 8-15==addr reg for operands that take both types */ | |
166 | ||
167 | enum _register { | |
f8701a3f SC |
168 | DATA = 1, /* 1- 8 == data registers 0-7 */ |
169 | DATA0 = DATA, | |
170 | DATA1, | |
171 | DATA2, | |
172 | DATA3, | |
173 | DATA4, | |
174 | DATA5, | |
175 | DATA6, | |
176 | DATA7, | |
177 | ||
178 | ADDR, | |
179 | ADDR0 = ADDR, | |
180 | ADDR1, | |
181 | ADDR2, | |
182 | ADDR3, | |
183 | ADDR4, | |
184 | ADDR5, | |
185 | ADDR6, | |
186 | ADDR7, | |
187 | ||
188 | /* Note that COPNUM==processor #1 -- COPNUM+7==#8, which stores as 000 */ | |
189 | /* I think. . . */ | |
190 | ||
191 | SP = ADDR7, | |
192 | ||
193 | FPREG, /* Eight FP registers */ | |
194 | FP0 = FPREG, | |
195 | FP1, | |
196 | FP2, | |
197 | FP3, | |
198 | FP4, | |
199 | FP5, | |
200 | FP6, | |
201 | FP7, | |
202 | COPNUM = (FPREG+8), /* Co-processor #1-#8 */ | |
203 | COP0 = COPNUM, | |
204 | COP1, | |
205 | COP2, | |
206 | COP3, | |
207 | COP4, | |
208 | COP5, | |
209 | COP6, | |
210 | COP7, | |
211 | PC, /* Program counter */ | |
212 | ZPC, /* Hack for Program space, but 0 addressing */ | |
213 | SR, /* Status Reg */ | |
214 | CCR, /* Condition code Reg */ | |
215 | ||
216 | /* These have to be in order for the movec instruction to work. */ | |
217 | USP, /* User Stack Pointer */ | |
218 | ISP, /* Interrupt stack pointer */ | |
219 | SFC, | |
220 | DFC, | |
221 | CACR, | |
222 | VBR, | |
223 | CAAR, | |
224 | MSP, | |
225 | ITT0, | |
226 | ITT1, | |
227 | DTT0, | |
228 | DTT1, | |
229 | MMUSR, | |
230 | TC, | |
231 | SRP, | |
232 | URP, | |
233 | /* end of movec ordering constraints */ | |
234 | ||
235 | FPI, | |
236 | FPS, | |
237 | FPC, | |
238 | ||
239 | DRP, | |
240 | CRP, | |
241 | CAL, | |
242 | VAL, | |
243 | SCC, | |
244 | AC, | |
245 | BAD, | |
246 | BAD0 = BAD, | |
247 | BAD1, | |
248 | BAD2, | |
249 | BAD3, | |
250 | BAD4, | |
251 | BAD5, | |
252 | BAD6, | |
253 | BAD7, | |
254 | BAC, | |
255 | BAC0 = BAC, | |
256 | BAC1, | |
257 | BAC2, | |
258 | BAC3, | |
259 | BAC4, | |
260 | BAC5, | |
261 | BAC6, | |
262 | BAC7, | |
263 | PSR, | |
264 | PCSR, | |
265 | ||
266 | IC, /* instruction cache token */ | |
267 | DC, /* data cache token */ | |
268 | NC, /* no cache token */ | |
269 | BC, /* both caches token */ | |
270 | ||
7c15cbe8 RP |
271 | }; |
272 | ||
fecd2382 RP |
273 | /* Internal form of an operand. */ |
274 | struct m68k_op { | |
f8701a3f SC |
275 | char *error; /* Couldn't parse it */ |
276 | enum operand_type mode; /* What mode this instruction is in. */ | |
277 | enum _register reg; /* Base register */ | |
278 | struct m68k_exp *con1; | |
279 | int ireg; /* Index register */ | |
280 | int isiz; /* 0==unspec 1==byte(?) 2==short 3==long */ | |
281 | int imul; /* Multipy ireg by this (1,2,4,or 8) */ | |
282 | struct m68k_exp *con2; | |
fecd2382 RP |
283 | }; |
284 | ||
285 | /* internal form of a 68020 instruction */ | |
7c15cbe8 | 286 | struct m68k_it { |
f8701a3f SC |
287 | char *error; |
288 | char *args; /* list of opcode info */ | |
289 | int numargs; | |
290 | ||
291 | int numo; /* Number of shorts in opcode */ | |
292 | short opcode[11]; | |
293 | ||
294 | struct m68k_op operands[6]; | |
295 | ||
296 | int nexp; /* number of exprs in use */ | |
297 | struct m68k_exp exprs[4]; | |
298 | ||
299 | int nfrag; /* Number of frags we have to produce */ | |
300 | struct { | |
301 | int fragoff; /* Where in the current opcode[] the frag ends */ | |
302 | symbolS *fadd; | |
303 | long foff; | |
304 | int fragty; | |
305 | } fragb[4]; | |
306 | ||
307 | int nrel; /* Num of reloc strucs in use */ | |
308 | struct { | |
309 | int n; | |
310 | symbolS *add, | |
311 | *sub; | |
312 | long off; | |
313 | char wid; | |
314 | char pcrel; | |
315 | } reloc[5]; /* Five is enough??? */ | |
fecd2382 RP |
316 | }; |
317 | ||
865a2edf MT |
318 | #define cpu_of_arch(x) ((x) & m68000up) |
319 | #define float_of_arch(x) ((x) & mfloat) | |
320 | #define mmu_of_arch(x) ((x) & mmmu) | |
321 | ||
7c15cbe8 | 322 | static struct m68k_it the_ins; /* the instruction being assembled */ |
fecd2382 | 323 | |
7c15cbe8 | 324 | /* Macros for adding things to the m68k_it struct */ |
fecd2382 RP |
325 | |
326 | #define addword(w) the_ins.opcode[the_ins.numo++]=(w) | |
327 | ||
328 | /* Like addword, but goes BEFORE general operands */ | |
329 | #define insop(w) {int z;\ | |
a39116f1 RP |
330 | for(z=the_ins.numo;z>opcode->m_codenum;--z)\ |
331 | the_ins.opcode[z]=the_ins.opcode[z-1];\ | |
332 | for(z=0;z<the_ins.nrel;z++)\ | |
333 | the_ins.reloc[z].n+=2;\ | |
334 | the_ins.opcode[opcode->m_codenum]=w;\ | |
335 | the_ins.numo++;\ | |
f8701a3f | 336 | } |
fecd2382 RP |
337 | |
338 | ||
339 | #define add_exp(beg,end) (\ | |
a39116f1 RP |
340 | the_ins.exprs[the_ins.nexp].e_beg=beg,\ |
341 | the_ins.exprs[the_ins.nexp].e_end=end,\ | |
342 | &the_ins.exprs[the_ins.nexp++]\ | |
343 | ) | |
fecd2382 RP |
344 | |
345 | ||
346 | /* The numo+1 kludge is so we can hit the low order byte of the prev word. Blecch*/ | |
347 | #define add_fix(width,exp,pc_rel) {\ | |
a39116f1 RP |
348 | the_ins.reloc[the_ins.nrel].n= ((width)=='B') ? (the_ins.numo*2-1) : \ |
349 | (((width)=='b') ? ((the_ins.numo-1)*2) : (the_ins.numo*2));\ | |
350 | the_ins.reloc[the_ins.nrel].add=adds((exp));\ | |
351 | the_ins.reloc[the_ins.nrel].sub=subs((exp));\ | |
352 | the_ins.reloc[the_ins.nrel].off=offs((exp));\ | |
353 | the_ins.reloc[the_ins.nrel].wid=width;\ | |
354 | the_ins.reloc[the_ins.nrel++].pcrel=pc_rel;\ | |
f8701a3f | 355 | } |
fecd2382 RP |
356 | |
357 | #define add_frag(add,off,type) {\ | |
a39116f1 RP |
358 | the_ins.fragb[the_ins.nfrag].fragoff=the_ins.numo;\ |
359 | the_ins.fragb[the_ins.nfrag].fadd=add;\ | |
360 | the_ins.fragb[the_ins.nfrag].foff=off;\ | |
361 | the_ins.fragb[the_ins.nfrag++].fragty=type;\ | |
f8701a3f | 362 | } |
fecd2382 RP |
363 | |
364 | #define isvar(exp) ((exp) && (adds(exp) || subs(exp))) | |
365 | ||
366 | #define seg(exp) ((exp)->e_exp.X_seg) | |
367 | #define adds(exp) ((exp)->e_exp.X_add_symbol) | |
368 | #define subs(exp) ((exp)->e_exp.X_subtract_symbol) | |
369 | #define offs(exp) ((exp)->e_exp.X_add_number) | |
370 | ||
371 | ||
7c15cbe8 | 372 | struct m68k_incant { |
f8701a3f SC |
373 | char *m_operands; |
374 | unsigned long m_opcode; | |
375 | short m_opnum; | |
376 | short m_codenum; | |
377 | enum m68k_architecture m_arch; | |
378 | struct m68k_incant *m_next; | |
fecd2382 RP |
379 | }; |
380 | ||
381 | #define getone(x) ((((x)->m_opcode)>>16)&0xffff) | |
382 | #define gettwo(x) (((x)->m_opcode)&0xffff) | |
383 | ||
384 | ||
a87b3269 | 385 | #if __STDC__ == 1 |
fecd2382 RP |
386 | |
387 | static char *crack_operand(char *str, struct m68k_op *opP); | |
388 | static int get_num(struct m68k_exp *exp, int ok); | |
389 | static int get_regs(int i, char *str, struct m68k_op *opP); | |
390 | static int reverse_16_bits(int in); | |
391 | static int reverse_8_bits(int in); | |
392 | static int try_index(char **s, struct m68k_op *opP); | |
393 | static void install_gen_operand(int mode, int val); | |
394 | static void install_operand(int mode, int val); | |
395 | static void s_bss(void); | |
396 | static void s_data1(void); | |
397 | static void s_data2(void); | |
398 | static void s_even(void); | |
399 | static void s_proc(void); | |
400 | ||
a87b3269 | 401 | #else /* not __STDC__ */ |
fecd2382 RP |
402 | |
403 | static char *crack_operand(); | |
404 | static int get_num(); | |
405 | static int get_regs(); | |
406 | static int reverse_16_bits(); | |
407 | static int reverse_8_bits(); | |
408 | static int try_index(); | |
409 | static void install_gen_operand(); | |
410 | static void install_operand(); | |
411 | static void s_bss(); | |
412 | static void s_data1(); | |
413 | static void s_data2(); | |
414 | static void s_even(); | |
415 | static void s_proc(); | |
416 | ||
a87b3269 | 417 | #endif /* not __STDC__ */ |
fecd2382 | 418 | |
865a2edf | 419 | static enum m68k_architecture current_architecture = 0; |
7c15cbe8 | 420 | |
fecd2382 RP |
421 | /* BCC68000 is for patching in an extra jmp instruction for long offsets |
422 | on the 68000. The 68000 doesn't support long branches with branchs */ | |
423 | ||
424 | /* This table desribes how you change sizes for the various types of variable | |
425 | size expressions. This version only supports two kinds. */ | |
426 | ||
427 | /* Note that calls to frag_var need to specify the maximum expansion needed */ | |
428 | /* This is currently 10 bytes for DBCC */ | |
429 | ||
430 | /* The fields are: | |
a39116f1 RP |
431 | How far Forward this mode will reach: |
432 | How far Backward this mode will reach: | |
433 | How many bytes this mode will add to the size of the frag | |
434 | Which mode to go to if the offset won't fit in this one | |
435 | */ | |
fecd2382 | 436 | const relax_typeS |
a39116f1 | 437 | md_relax_table[] = { |
f8701a3f SC |
438 | { 1, 1, 0, 0 }, /* First entries aren't used */ |
439 | { 1, 1, 0, 0 }, /* For no good reason except */ | |
440 | { 1, 1, 0, 0 }, /* that the VAX doesn't either */ | |
441 | { 1, 1, 0, 0 }, | |
442 | ||
443 | { (127), (-128), 0, TAB(BRANCH,SHORT)}, | |
444 | { (32767), (-32768), 2, TAB(BRANCH,LONG) }, | |
445 | { 0, 0, 4, 0 }, | |
446 | { 1, 1, 0, 0 }, | |
447 | ||
448 | { 1, 1, 0, 0 }, /* FBRANCH doesn't come BYTE */ | |
449 | { (32767), (-32768), 2, TAB(FBRANCH,LONG)}, | |
450 | { 0, 0, 4, 0 }, | |
451 | { 1, 1, 0, 0 }, | |
452 | ||
453 | { 1, 1, 0, 0 }, /* PCREL doesn't come BYTE */ | |
454 | { (32767), (-32768), 2, TAB(PCREL,LONG)}, | |
455 | { 0, 0, 4, 0 }, | |
456 | { 1, 1, 0, 0 }, | |
457 | ||
458 | { (127), (-128), 0, TAB(BCC68000,SHORT)}, | |
459 | { (32767), (-32768), 2, TAB(BCC68000,LONG) }, | |
460 | { 0, 0, 6, 0 }, /* jmp long space */ | |
461 | { 1, 1, 0, 0 }, | |
462 | ||
463 | { 1, 1, 0, 0 }, /* DBCC doesn't come BYTE */ | |
464 | { (32767), (-32768), 2, TAB(DBCC,LONG) }, | |
465 | { 0, 0, 10, 0 }, /* bra/jmp long space */ | |
466 | { 1, 1, 0, 0 }, | |
467 | ||
468 | { 1, 1, 0, 0 }, /* PCLEA doesn't come BYTE */ | |
469 | { 32767, -32768, 2, TAB(PCLEA,LONG) }, | |
470 | { 0, 0, 6, 0 }, | |
471 | { 1, 1, 0, 0 }, | |
472 | ||
473 | }; | |
fecd2382 RP |
474 | |
475 | /* These are the machine dependent pseudo-ops. These are included so | |
476 | the assembler can work on the output from the SUN C compiler, which | |
477 | generates these. | |
a39116f1 | 478 | */ |
fecd2382 RP |
479 | |
480 | /* This table describes all the machine specific pseudo-ops the assembler | |
481 | has to support. The fields are: | |
a39116f1 RP |
482 | pseudo-op name without dot |
483 | function to call to execute this pseudo-op | |
484 | Integer arg to pass to the function | |
485 | */ | |
fecd2382 | 486 | const pseudo_typeS md_pseudo_table[] = { |
f8701a3f SC |
487 | { "data1", s_data1, 0 }, |
488 | { "data2", s_data2, 0 }, | |
489 | { "bss", s_bss, 0 }, | |
490 | { "even", s_even, 0 }, | |
491 | { "skip", s_space, 0 }, | |
492 | { "proc", s_proc, 0 }, | |
493 | { 0, 0, 0 } | |
fecd2382 RP |
494 | }; |
495 | ||
496 | ||
497 | /* #define isbyte(x) ((x)>=-128 && (x)<=127) */ | |
498 | /* #define isword(x) ((x)>=-32768 && (x)<=32767) */ | |
499 | ||
500 | #define issbyte(x) ((x)>=-128 && (x)<=127) | |
501 | #define isubyte(x) ((x)>=0 && (x)<=255) | |
502 | #define issword(x) ((x)>=-32768 && (x)<=32767) | |
503 | #define isuword(x) ((x)>=0 && (x)<=65535) | |
f8701a3f | 504 | |
fecd2382 RP |
505 | #define isbyte(x) ((x)>=-128 && (x)<=255) |
506 | #define isword(x) ((x)>=-32768 && (x)<=65535) | |
507 | #define islong(x) (1) | |
f8701a3f SC |
508 | |
509 | extern char *input_line_pointer; | |
fecd2382 | 510 | |
7c15cbe8 | 511 | enum { |
f8701a3f SC |
512 | FAIL = 0, |
513 | OK = 1, | |
7c15cbe8 | 514 | }; |
fecd2382 RP |
515 | |
516 | /* JF these tables here are for speed at the expense of size */ | |
517 | /* You can replace them with the #if 0 versions if you really | |
518 | need space and don't mind it running a bit slower */ | |
519 | ||
520 | static char mklower_table[256]; | |
521 | #define mklower(c) (mklower_table[(unsigned char)(c)]) | |
f8701a3f | 522 | static char notend_table[256]; |
fecd2382 RP |
523 | static char alt_notend_table[256]; |
524 | #define notend(s) ( !(notend_table[(unsigned char)(*s)] || (*s==':' &&\ | |
a39116f1 | 525 | alt_notend_table[(unsigned char)(s[1])]))) |
fecd2382 RP |
526 | |
527 | #if 0 | |
528 | #define mklower(c) (isupper(c) ? tolower(c) : c) | |
529 | #endif | |
f8701a3f SC |
530 | |
531 | ||
532 | /* JF modified this to handle cases where the first part of a symbol name | |
533 | looks like a register */ | |
534 | ||
535 | /* | |
536 | * m68k_reg_parse() := if it looks like a register, return it's token & | |
537 | * advance the pointer. | |
538 | */ | |
539 | ||
540 | enum _register m68k_reg_parse(ccp) | |
fecd2382 RP |
541 | register char **ccp; |
542 | { | |
f8701a3f SC |
543 | char *start = *ccp; |
544 | ||
545 | if (isalpha(*start) && is_name_beginner(*start)) | |
546 | { | |
547 | char c; | |
548 | char *p = start; | |
549 | symbolS *symbolP; | |
a39116f1 | 550 | |
f8701a3f SC |
551 | while (is_part_of_name(c = *p++)) |
552 | ; | |
553 | * -- p = 0; | |
554 | symbolP = symbol_find(start); | |
555 | *p = c; | |
556 | ||
557 | if (symbolP && S_GET_SEGMENT(symbolP) == SEG_REGISTER) | |
a39116f1 | 558 | { |
f8701a3f SC |
559 | *ccp = p; |
560 | return S_GET_VALUE(symbolP); | |
a39116f1 | 561 | } |
f8701a3f SC |
562 | } |
563 | return FAIL; | |
564 | ||
565 | ||
fecd2382 RP |
566 | } |
567 | ||
568 | #define SKIP_WHITE() { str++; if(*str==' ') str++;} | |
569 | ||
7c15cbe8 RP |
570 | /* |
571 | * m68k_ip_op := '#' + <anything> | |
572 | * | <register> + range_sep + get_regs | |
573 | * ; | |
574 | * | |
575 | * range_sep := '/' | '-' ; | |
576 | * | |
577 | * SKIP_WHITE := <empty> | ' ' ; | |
578 | * | |
579 | */ | |
580 | ||
fecd2382 | 581 | int |
a39116f1 | 582 | m68k_ip_op(str,opP) |
fecd2382 RP |
583 | char *str; |
584 | register struct m68k_op *opP; | |
585 | { | |
f8701a3f SC |
586 | char *strend; |
587 | long i; | |
588 | char *parse_index(); | |
a39116f1 | 589 | |
f8701a3f SC |
590 | if (*str==' ') { |
591 | str++; | |
592 | } /* Find the beginning of the string */ | |
a39116f1 | 593 | |
f8701a3f SC |
594 | if(!*str) { |
595 | opP->error="Missing operand"; | |
fecd2382 | 596 | return FAIL; |
f8701a3f SC |
597 | } /* Out of gas */ |
598 | ||
599 | for(strend = str; *strend; strend++) ;; | |
600 | ||
601 | --strend; | |
602 | ||
603 | if(*str=='#') { | |
604 | str++; | |
605 | opP->con1=add_exp(str,strend); | |
606 | opP->mode=IMMED; | |
607 | return OK; | |
608 | } /* Guess what: A constant. Shar and enjoy */ | |
609 | ||
610 | i = m68k_reg_parse(&str); | |
611 | ||
612 | /* is a register, is exactly a register, and is followed by '@' */ | |
613 | ||
614 | if((i==FAIL || *str!='\0') && *str!='@') { | |
615 | char *stmp; | |
616 | ||
617 | if(i!=FAIL && (*str=='/' || *str=='-')) { | |
618 | opP->mode=REGLST; | |
619 | return(get_regs(i,str,opP)); | |
620 | } | |
621 | if ((stmp=strchr(str,'@')) != '\0') { | |
622 | opP->con1=add_exp(str,stmp-1); | |
623 | if(stmp==strend) { | |
624 | opP->mode=AINDX; | |
625 | return(OK); | |
626 | } | |
627 | ||
628 | if ((current_architecture & m68020up) == 0) { | |
629 | return(FAIL); | |
630 | } /* if target is not a '20 or better */ | |
631 | ||
632 | stmp++; | |
633 | if(*stmp++!='(' || *strend--!=')') { | |
634 | opP->error="Malformed operand"; | |
635 | return(FAIL); | |
636 | } | |
637 | i=try_index(&stmp,opP); | |
638 | opP->con2=add_exp(stmp,strend); | |
639 | ||
640 | if (i == FAIL) { | |
641 | opP->mode=AMIND; | |
642 | } else { | |
643 | opP->mode=APODX; | |
644 | } | |
645 | return(OK); | |
646 | } /* if there's an '@' */ | |
647 | opP->mode = ABSL; | |
648 | opP->con1 = add_exp(str,strend); | |
649 | return(OK); | |
650 | } /* not a register, not exactly a register, or no '@' */ | |
651 | ||
652 | opP->reg=i; | |
653 | ||
654 | if (*str=='\0') { | |
655 | if(i>=DATA+0 && i<=DATA+7) | |
656 | opP->mode=DREG; | |
657 | else if(i>=ADDR+0 && i<=ADDR+7) | |
658 | opP->mode=AREG; | |
659 | else | |
660 | opP->mode=MSCR; | |
661 | return OK; | |
fecd2382 | 662 | } |
f8701a3f SC |
663 | |
664 | if((i<ADDR+0 || i>ADDR+7) && i!=PC && i!=ZPC && i!=FAIL) { /* Can't indirect off non address regs */ | |
665 | opP->error="Invalid indirect register"; | |
a39116f1 | 666 | return FAIL; |
fecd2382 | 667 | } |
f8701a3f | 668 | know(*str == '@'); |
a39116f1 | 669 | |
f8701a3f SC |
670 | str++; |
671 | switch(*str) { | |
672 | case '\0': | |
673 | opP->mode=AINDR; | |
674 | return OK; | |
675 | case '-': | |
676 | opP->mode=ADEC; | |
677 | return OK; | |
678 | case '+': | |
679 | opP->mode=AINC; | |
680 | return OK; | |
681 | case '(': | |
682 | str++; | |
683 | break; | |
684 | default: | |
685 | opP->error="Junk after indirect"; | |
686 | return FAIL; | |
fecd2382 | 687 | } |
f8701a3f SC |
688 | /* Some kind of indexing involved. Lets find out how bad it is */ |
689 | i=try_index(&str,opP); | |
690 | /* Didn't start with an index reg, maybe its offset or offset,reg */ | |
691 | if(i==FAIL) { | |
692 | char *beg_str; | |
693 | ||
694 | beg_str=str; | |
695 | for(i=1;i;) { | |
696 | switch(*str++) { | |
697 | case '\0': | |
698 | opP->error="Missing )"; | |
699 | return FAIL; | |
700 | case ',': i=0; break; | |
701 | case '(': i++; break; | |
702 | case ')': --i; break; | |
703 | } | |
704 | } | |
705 | /* if(str[-3]==':') { | |
706 | int siz; | |
707 | ||
708 | switch(str[-2]) { | |
709 | case 'b': | |
710 | case 'B': | |
711 | siz=1; | |
712 | break; | |
713 | case 'w': | |
714 | case 'W': | |
715 | siz=2; | |
716 | break; | |
717 | case 'l': | |
718 | case 'L': | |
719 | siz=3; | |
720 | break; | |
721 | default: | |
722 | opP->error="Specified size isn't :w or :l"; | |
723 | return FAIL; | |
724 | } | |
725 | opP->con1=add_exp(beg_str,str-4); | |
726 | opP->con1->e_siz=siz; | |
727 | } else */ | |
728 | opP->con1=add_exp(beg_str,str-2); | |
729 | /* Should be offset,reg */ | |
730 | if(str[-1]==',') { | |
731 | i=try_index(&str,opP); | |
732 | if(i==FAIL) { | |
733 | opP->error="Malformed index reg"; | |
734 | return FAIL; | |
735 | } | |
736 | } | |
737 | } | |
738 | /* We've now got offset) offset,reg) or reg) */ | |
a39116f1 | 739 | |
f8701a3f SC |
740 | if (*str == '\0') { |
741 | /* Th-the-thats all folks */ | |
742 | if (opP->reg == FAIL) opP->mode = AINDX; /* Other form of indirect */ | |
743 | else if(opP->ireg == FAIL) opP->mode = AOFF; | |
744 | else opP->mode = AINDX; | |
745 | return(OK); | |
746 | } | |
747 | /* Next thing had better be another @ */ | |
748 | if(*str!='@' || str[1]!='(') { | |
749 | opP->error = "junk after indirect"; | |
865a2edf | 750 | return(FAIL); |
fecd2382 | 751 | } |
865a2edf | 752 | |
f8701a3f | 753 | if ((current_architecture & m68020up) == 0) { |
a39116f1 | 754 | return(FAIL); |
f8701a3f SC |
755 | } /* if target is not a '20 or better */ |
756 | ||
757 | str+=2; | |
758 | ||
759 | if(opP->ireg != FAIL) { | |
760 | opP->mode = APRDX; | |
761 | ||
762 | i = try_index(&str, opP); | |
763 | if (i != FAIL) { | |
764 | opP->error = "Two index registers! not allowed!"; | |
765 | return(FAIL); | |
766 | } | |
865a2edf | 767 | } else { |
f8701a3f | 768 | i = try_index(&str, opP); |
865a2edf | 769 | } |
f8701a3f SC |
770 | |
771 | if (i == FAIL) { | |
772 | char *beg_str; | |
773 | ||
774 | beg_str = str; | |
775 | ||
776 | for (i = 1; i; ) { | |
777 | switch(*str++) { | |
778 | case '\0': | |
779 | opP->error="Missing )"; | |
780 | return(FAIL); | |
781 | case ',': i=0; break; | |
782 | case '(': i++; break; | |
783 | case ')': --i; break; | |
784 | } | |
785 | } | |
786 | ||
787 | opP->con2=add_exp(beg_str,str-2); | |
788 | ||
789 | if (str[-1] == ',') { | |
790 | if (opP->ireg != FAIL) { | |
791 | opP->error = "Can't have two index regs"; | |
792 | return(FAIL); | |
793 | } | |
794 | ||
795 | i = try_index(&str, opP); | |
796 | ||
797 | if (i == FAIL) { | |
798 | opP->error = "malformed index reg"; | |
799 | return(FAIL); | |
800 | } | |
801 | ||
802 | opP->mode = APODX; | |
803 | } else if (opP->ireg != FAIL) { | |
804 | opP->mode = APRDX; | |
805 | } else { | |
806 | opP->mode = AMIND; | |
807 | } | |
808 | } else { | |
809 | opP->mode = APODX; | |
810 | } | |
811 | ||
812 | if(*str!='\0') { | |
813 | opP->error="Junk after indirect"; | |
814 | return FAIL; | |
815 | } | |
816 | return(OK); | |
a39116f1 | 817 | } /* m68k_ip_op() */ |
fecd2382 | 818 | |
7c15cbe8 RP |
819 | /* |
820 | * | |
821 | * try_index := data_or_address_register + ')' + SKIP_W | |
822 | * | data_or_address_register + ':' + SKIP_W + size_spec + SKIP_W + multiplier + ')' + SKIP_W | |
823 | * | |
824 | * multiplier := <empty> | |
825 | * | ':' + multiplier_number | |
826 | * ; | |
827 | * | |
828 | * multiplier_number := '1' | '2' | '4' | '8' ; | |
829 | * | |
830 | * size_spec := 'l' | 'L' | 'w' | 'W' ; | |
831 | * | |
832 | * SKIP_W := <empty> | ' ' ; | |
833 | * | |
834 | */ | |
835 | ||
fecd2382 | 836 | static int try_index(s,opP) |
f8701a3f SC |
837 | char **s; |
838 | struct m68k_op *opP; | |
fecd2382 | 839 | { |
f8701a3f SC |
840 | register int i; |
841 | char *ss; | |
7c15cbe8 | 842 | #define SKIP_W() { ss++; if (*ss==' ') ss++;} |
f8701a3f SC |
843 | |
844 | ss= *s; | |
845 | /* SKIP_W(); */ | |
846 | i=m68k_reg_parse(&ss); | |
847 | if(!(i>=DATA+0 && i<=ADDR+7)) { /* if i is not DATA or ADDR reg */ | |
848 | *s=ss; | |
849 | return FAIL; | |
850 | } | |
851 | opP->ireg=i; | |
852 | /* SKIP_W(); */ | |
853 | if(*ss==')') { | |
854 | opP->isiz=0; | |
855 | opP->imul=1; | |
856 | SKIP_W(); | |
857 | *s=ss; | |
858 | return OK; | |
859 | } | |
860 | if(*ss!=':') { | |
861 | opP->error="Missing : in index register"; | |
862 | *s=ss; | |
863 | return FAIL; | |
864 | } | |
fecd2382 RP |
865 | SKIP_W(); |
866 | switch(*ss) { | |
f8701a3f SC |
867 | case 'w': |
868 | case 'W': | |
869 | opP->isiz=2; | |
870 | break; | |
871 | case 'l': | |
872 | case 'L': | |
873 | opP->isiz=3; | |
874 | break; | |
fecd2382 | 875 | default: |
f8701a3f SC |
876 | opP->error="Index register size spec not :w or :l"; |
877 | *s=ss; | |
878 | return FAIL; | |
879 | } | |
880 | SKIP_W(); | |
881 | if(*ss==':') { | |
882 | SKIP_W(); | |
883 | switch(*ss) { | |
884 | case '1': | |
885 | case '2': | |
886 | case '4': | |
887 | case '8': | |
888 | opP->imul= *ss-'0'; | |
889 | break; | |
890 | default: | |
891 | opP->error="index multiplier not 1, 2, 4 or 8"; | |
892 | *s=ss; | |
893 | return FAIL; | |
894 | } | |
895 | SKIP_W(); | |
896 | } else opP->imul=1; | |
897 | if(*ss!=')') { | |
898 | opP->error="Missing )"; | |
899 | *s=ss; | |
900 | return FAIL; | |
fecd2382 RP |
901 | } |
902 | SKIP_W(); | |
903 | *s=ss; | |
f8701a3f | 904 | return OK; |
fecd2382 RP |
905 | } /* try_index() */ |
906 | ||
907 | #ifdef TEST1 /* TEST1 tests m68k_ip_op(), which parses operands */ | |
908 | main() | |
909 | { | |
f8701a3f SC |
910 | char buf[128]; |
911 | struct m68k_op thark; | |
912 | ||
913 | for(;;) { | |
914 | if(!gets(buf)) | |
915 | break; | |
916 | memset(&thark, '\0', sizeof(thark)); | |
917 | if(!m68k_ip_op(buf,&thark)) printf("FAIL:"); | |
918 | if(thark.error) | |
919 | printf("op1 error %s in %s\n",thark.error,buf); | |
920 | printf("mode %d, reg %d, ",thark.mode,thark.reg); | |
921 | if(thark.b_const) | |
922 | printf("Constant: '%.*s',",1+thark.e_const-thark.b_const,thark.b_const); | |
923 | printf("ireg %d, isiz %d, imul %d ",thark.ireg,thark.isiz,thark.imul); | |
924 | if(thark.b_iadd) | |
925 | printf("Iadd: '%.*s'",1+thark.e_iadd-thark.b_iadd,thark.b_iadd); | |
926 | printf("\n"); | |
927 | } | |
928 | exit(0); | |
fecd2382 RP |
929 | } |
930 | ||
931 | #endif | |
932 | ||
933 | ||
934 | static struct hash_control* op_hash = NULL; /* handle of the OPCODE hash table | |
a39116f1 RP |
935 | NULL means any use before m68k_ip_begin() |
936 | will crash */ | |
fecd2382 RP |
937 | |
938 | \f | |
939 | /* | |
7c15cbe8 | 940 | * m 6 8 k _ i p ( ) |
fecd2382 RP |
941 | * |
942 | * This converts a string into a 68k instruction. | |
943 | * The string must be a bare single instruction in sun format | |
944 | * with RMS-style 68020 indirects | |
945 | * (example: ) | |
946 | * | |
947 | * It provides some error messages: at most one fatal error message (which | |
948 | * stops the scan) and at most one warning message for each operand. | |
949 | * The 68k instruction is returned in exploded form, since we have no | |
950 | * knowledge of how you parse (or evaluate) your expressions. | |
951 | * We do however strip off and decode addressing modes and operation | |
952 | * mnemonic. | |
953 | * | |
954 | * This function's value is a string. If it is not "" then an internal | |
955 | * logic error was found: read this code to assign meaning to the string. | |
956 | * No argument string should generate such an error string: | |
957 | * it means a bug in our code, not in the user's text. | |
958 | * | |
7c15cbe8 | 959 | * You MUST have called m68k_ip_begin() once and m86_ip_end() never before using |
fecd2382 RP |
960 | * this function. |
961 | */ | |
962 | ||
963 | /* JF this function no longer returns a useful value. Sorry */ | |
7c15cbe8 | 964 | void m68k_ip (instring) |
f8701a3f | 965 | char *instring; |
fecd2382 | 966 | { |
f8701a3f SC |
967 | register char *p; |
968 | register struct m68k_op *opP; | |
969 | register struct m68k_incant *opcode; | |
970 | register char *s; | |
971 | register int tmpreg = 0, | |
972 | baseo = 0, | |
973 | outro = 0, | |
974 | nextword; | |
975 | int siz1, | |
976 | siz2; | |
977 | char c; | |
978 | int losing; | |
979 | int opsfound; | |
980 | char *crack_operand(); | |
981 | LITTLENUM_TYPE words[6]; | |
982 | LITTLENUM_TYPE *wordp; | |
983 | ||
984 | if (*instring == ' ') | |
985 | instring++; /* skip leading whitespace */ | |
986 | ||
987 | /* Scan up to end of operation-code, which MUST end in end-of-string | |
988 | or exactly 1 space. */ | |
989 | for (p = instring; *p != '\0'; p++) | |
990 | if (*p == ' ') | |
991 | break; | |
7c15cbe8 | 992 | |
7c15cbe8 | 993 | |
f8701a3f SC |
994 | if (p == instring) { |
995 | the_ins.error = "No operator"; | |
996 | the_ins.opcode[0] = NULL; | |
997 | /* the_ins.numo=1; */ | |
998 | return; | |
fecd2382 | 999 | } |
7c15cbe8 | 1000 | |
f8701a3f SC |
1001 | /* p now points to the end of the opcode name, probably whitespace. |
1002 | make sure the name is null terminated by clobbering the whitespace, | |
1003 | look it up in the hash table, then fix it back. */ | |
1004 | c = *p; | |
1005 | *p = '\0'; | |
1006 | opcode = (struct m68k_incant *)hash_find (op_hash, instring); | |
1007 | *p = c; | |
7c15cbe8 | 1008 | |
f8701a3f SC |
1009 | if (opcode == NULL) { |
1010 | the_ins.error = "Unknown operator"; | |
1011 | the_ins.opcode[0] = NULL; | |
1012 | /* the_ins.numo=1; */ | |
1013 | return; | |
1014 | } | |
1015 | ||
1016 | /* found a legitimate opcode, start matching operands */ | |
1017 | while (*p == ' ') ++p; | |
1018 | ||
1019 | for(opP = &the_ins.operands[0]; *p; opP++) { | |
1020 | ||
1021 | p = crack_operand(p, opP); | |
1022 | ||
1023 | if (opP->error) { | |
1024 | the_ins.error=opP->error; | |
1025 | return; | |
1026 | } | |
1027 | } | |
1028 | ||
1029 | opsfound = opP - &the_ins.operands[0]; | |
1030 | ||
1031 | /* This ugly hack is to support the floating pt opcodes in their standard form */ | |
1032 | /* Essentially, we fake a first enty of type COP#1 */ | |
1033 | if (opcode->m_operands[0]=='I') { | |
1034 | int n; | |
1035 | ||
1036 | for(n=opsfound;n>0;--n) | |
1037 | the_ins.operands[n]=the_ins.operands[n-1]; | |
1038 | ||
1039 | /* memcpy((char *)(&the_ins.operands[1]), (char *)(&the_ins.operands[0]), opsfound*sizeof(the_ins.operands[0])); */ | |
1040 | memset((char *)(&the_ins.operands[0]), '\0', sizeof(the_ins.operands[0])); | |
1041 | the_ins.operands[0].mode=MSCR; | |
1042 | the_ins.operands[0].reg=COPNUM; /* COP #1 */ | |
1043 | opsfound++; | |
1044 | } | |
1045 | ||
1046 | /* We've got the operands. Find an opcode that'll accept them */ | |
1047 | for (losing = 0; ; ) { | |
1048 | /* if we didn't get the right number of ops, | |
1049 | or we have no common model with this pattern | |
1050 | then reject this pattern. */ | |
1051 | ||
1052 | if (opsfound != opcode->m_opnum | |
1053 | || ((opcode->m_arch & current_architecture) == 0)) { | |
7c15cbe8 | 1054 | |
f8701a3f SC |
1055 | ++losing; |
1056 | ||
1057 | } else { | |
1058 | for (s=opcode->m_operands, opP = &the_ins.operands[0]; *s && !losing; s += 2, opP++) { | |
1059 | /* Warning: this switch is huge! */ | |
1060 | /* I've tried to organize the cases into this order: | |
1061 | non-alpha first, then alpha by letter. lower-case goes directly | |
1062 | before uppercase counterpart. */ | |
1063 | /* Code with multiple case ...: gets sorted by the lowest case ... | |
1064 | it belongs to. I hope this makes sense. */ | |
1065 | switch(*s) { | |
1066 | case '!': | |
1067 | if (opP->mode == MSCR || opP->mode == IMMED | |
1068 | || opP->mode == DREG || opP->mode == AREG | |
1069 | || opP->mode == AINC || opP->mode == ADEC | |
1070 | || opP->mode == REGLST) | |
1071 | losing++; | |
1072 | break; | |
1073 | ||
1074 | case '#': | |
1075 | if(opP->mode!=IMMED) | |
1076 | losing++; | |
1077 | else { | |
1078 | long t; | |
1079 | ||
1080 | t=get_num(opP->con1,80); | |
1081 | if(s[1]=='b' && !isbyte(t)) | |
1082 | losing++; | |
1083 | else if(s[1]=='w' && !isword(t)) | |
1084 | losing++; | |
1085 | } | |
1086 | break; | |
1087 | ||
1088 | case '^': | |
1089 | case 'T': | |
1090 | if(opP->mode!=IMMED) | |
1091 | losing++; | |
1092 | break; | |
1093 | ||
1094 | case '$': | |
1095 | if(opP->mode==MSCR || opP->mode==AREG || | |
1096 | opP->mode==IMMED || opP->reg==PC || opP->reg==ZPC || opP->mode==REGLST) | |
1097 | losing++; | |
1098 | break; | |
1099 | ||
1100 | case '%': | |
1101 | if(opP->mode==MSCR || opP->reg==PC || | |
1102 | opP->reg==ZPC || opP->mode==REGLST) | |
1103 | losing++; | |
1104 | break; | |
1105 | ||
1106 | ||
1107 | case '&': | |
1108 | if(opP->mode==MSCR || opP->mode==DREG || | |
1109 | opP->mode==AREG || opP->mode==IMMED || opP->reg==PC || opP->reg==ZPC || | |
1110 | opP->mode==AINC || opP->mode==ADEC || opP->mode==REGLST) | |
1111 | losing++; | |
1112 | break; | |
1113 | ||
1114 | case '*': | |
1115 | if(opP->mode==MSCR || opP->mode==REGLST) | |
1116 | losing++; | |
1117 | break; | |
1118 | ||
1119 | case '+': | |
1120 | if(opP->mode!=AINC) | |
1121 | losing++; | |
1122 | break; | |
1123 | ||
1124 | case '-': | |
1125 | if(opP->mode!=ADEC) | |
1126 | losing++; | |
1127 | break; | |
1128 | ||
1129 | case '/': | |
1130 | if(opP->mode==MSCR || opP->mode==AREG || | |
1131 | opP->mode==AINC || opP->mode==ADEC || opP->mode==IMMED || opP->mode==REGLST) | |
1132 | losing++; | |
1133 | break; | |
1134 | ||
1135 | case ';': | |
1136 | if(opP->mode==MSCR || opP->mode==AREG || opP->mode==REGLST) | |
1137 | losing++; | |
1138 | break; | |
1139 | ||
1140 | case '?': | |
1141 | if(opP->mode==MSCR || opP->mode==AREG || | |
1142 | opP->mode==AINC || opP->mode==ADEC || opP->mode==IMMED || opP->reg==PC || | |
1143 | opP->reg==ZPC || opP->mode==REGLST) | |
1144 | losing++; | |
1145 | break; | |
1146 | ||
1147 | case '@': | |
1148 | if(opP->mode==MSCR || opP->mode==AREG || | |
1149 | opP->mode==IMMED || opP->mode==REGLST) | |
1150 | losing++; | |
1151 | break; | |
1152 | ||
1153 | case '~': /* For now! (JF FOO is this right?) */ | |
1154 | if(opP->mode==MSCR || opP->mode==DREG || | |
1155 | opP->mode==AREG || opP->mode==IMMED || opP->reg==PC || opP->reg==ZPC || opP->mode==REGLST) | |
1156 | losing++; | |
1157 | break; | |
1158 | ||
1159 | case 'A': | |
1160 | if(opP->mode!=AREG) | |
1161 | losing++; | |
1162 | break; | |
1163 | case 'a': | |
1164 | if (opP->mode != AINDR) { | |
1165 | ++losing; | |
1166 | } /* if not address register indirect */ | |
1167 | break; | |
1168 | case 'B': /* FOO */ | |
1169 | if(opP->mode!=ABSL || (flagseen['S'] && instring[0] == 'j' | |
1170 | && instring[1] == 'b' | |
1171 | && instring[2] == 's' | |
1172 | && instring[3] == 'r')) | |
1173 | losing++; | |
1174 | break; | |
1175 | ||
1176 | case 'C': | |
1177 | if(opP->mode!=MSCR || opP->reg!=CCR) | |
1178 | losing++; | |
1179 | break; | |
1180 | ||
1181 | case 'd': /* FOO This mode is a KLUDGE!! */ | |
1182 | if(opP->mode!=AOFF && (opP->mode!=ABSL || | |
1183 | opP->con1->e_beg[0]!='(' || opP->con1->e_end[0]!=')')) | |
1184 | losing++; | |
1185 | break; | |
1186 | ||
1187 | case 'D': | |
1188 | if(opP->mode!=DREG) | |
1189 | losing++; | |
1190 | break; | |
1191 | ||
1192 | case 'F': | |
1193 | if(opP->mode!=MSCR || opP->reg<(FPREG+0) || opP->reg>(FPREG+7)) | |
1194 | losing++; | |
1195 | break; | |
1196 | ||
1197 | case 'I': | |
1198 | if(opP->mode!=MSCR || opP->reg<COPNUM || | |
1199 | opP->reg>=COPNUM+7) | |
1200 | losing++; | |
1201 | break; | |
1202 | ||
1203 | case 'J': | |
1204 | if (opP->mode != MSCR | |
1205 | || opP->reg < USP | |
1206 | || opP->reg > URP | |
1207 | || cpu_of_arch(current_architecture) < m68010 /* before 68010 had none */ | |
1208 | || (cpu_of_arch(current_architecture) < m68020 | |
1209 | && opP->reg != SFC | |
1210 | && opP->reg != DFC | |
1211 | && opP->reg != USP | |
1212 | && opP->reg != VBR) /* 68010's had only these */ | |
1213 | || (cpu_of_arch(current_architecture) < m68040 | |
1214 | && opP->reg != SFC | |
1215 | && opP->reg != DFC | |
1216 | && opP->reg != USP | |
1217 | && opP->reg != VBR | |
1218 | && opP->reg != CACR | |
1219 | && opP->reg != CAAR | |
1220 | && opP->reg != MSP | |
1221 | && opP->reg != ISP) /* 680[23]0's have only these */ | |
1222 | || (cpu_of_arch(current_architecture) == m68040 /* 68040 has all but this */ | |
1223 | && opP->reg == CAAR)) { | |
1224 | losing++; | |
1225 | } /* doesn't cut it */ | |
1226 | break; | |
1227 | ||
1228 | case 'k': | |
1229 | if(opP->mode!=IMMED) | |
1230 | losing++; | |
1231 | break; | |
1232 | ||
1233 | case 'l': | |
1234 | case 'L': | |
1235 | if(opP->mode==DREG || opP->mode==AREG || opP->mode==FPREG) { | |
1236 | if(s[1]=='8') | |
1237 | losing++; | |
1238 | else { | |
1239 | opP->mode=REGLST; | |
1240 | opP->reg=1<<(opP->reg-DATA); | |
1241 | } | |
1242 | } else if(opP->mode!=REGLST) { | |
1243 | losing++; | |
1244 | } else if(s[1]=='8' && opP->reg&0x0FFffFF) | |
1245 | losing++; | |
1246 | else if(s[1]=='3' && opP->reg&0x7000000) | |
1247 | losing++; | |
1248 | break; | |
1249 | ||
1250 | case 'M': | |
1251 | if(opP->mode!=IMMED) | |
1252 | losing++; | |
1253 | else { | |
1254 | long t; | |
1255 | ||
1256 | t=get_num(opP->con1,80); | |
1257 | if(!issbyte(t) || isvar(opP->con1)) | |
1258 | losing++; | |
1259 | } | |
1260 | break; | |
1261 | ||
1262 | case 'O': | |
1263 | if(opP->mode!=DREG && opP->mode!=IMMED) | |
1264 | losing++; | |
1265 | break; | |
1266 | ||
1267 | case 'Q': | |
1268 | if(opP->mode!=IMMED) | |
1269 | losing++; | |
1270 | else { | |
1271 | long t; | |
1272 | ||
1273 | t=get_num(opP->con1,80); | |
1274 | if(t<1 || t>8 || isvar(opP->con1)) | |
1275 | losing++; | |
1276 | } | |
1277 | break; | |
1278 | ||
1279 | case 'R': | |
1280 | if(opP->mode!=DREG && opP->mode!=AREG) | |
1281 | losing++; | |
1282 | break; | |
1283 | ||
1284 | case 's': | |
1285 | if(opP->mode!=MSCR || !(opP->reg==FPI || opP->reg==FPS || opP->reg==FPC)) | |
1286 | losing++; | |
1287 | break; | |
1288 | ||
1289 | case 'S': | |
1290 | if(opP->mode!=MSCR || opP->reg!=SR) | |
1291 | losing++; | |
1292 | break; | |
1293 | ||
1294 | case 'U': | |
1295 | if(opP->mode!=MSCR || opP->reg!=USP) | |
1296 | losing++; | |
1297 | break; | |
1298 | ||
1299 | /* JF these are out of order. We could put them | |
1300 | in order if we were willing to put up with | |
1301 | bunches of #ifdef m68851s in the code */ | |
1302 | #ifndef NO_68851 | |
1303 | /* Memory addressing mode used by pflushr */ | |
1304 | case '|': | |
1305 | if(opP->mode==MSCR || opP->mode==DREG || | |
1306 | opP->mode==AREG || opP->mode==REGLST) | |
1307 | losing++; | |
1308 | break; | |
1309 | ||
1310 | case 'f': | |
1311 | if (opP->mode != MSCR || (opP->reg != SFC && opP->reg != DFC)) | |
1312 | losing++; | |
1313 | break; | |
1314 | ||
1315 | case 'P': | |
1316 | if (opP->mode != MSCR || (opP->reg != TC && opP->reg != CAL && | |
1317 | opP->reg != VAL && opP->reg != SCC && opP->reg != AC)) | |
1318 | losing++; | |
1319 | break; | |
1320 | ||
1321 | case 'V': | |
1322 | if (opP->reg != VAL) | |
1323 | losing++; | |
1324 | break; | |
1325 | ||
1326 | case 'W': | |
1327 | if (opP->mode != MSCR || (opP->reg != DRP && opP->reg != SRP && | |
1328 | opP->reg != CRP)) | |
1329 | losing++; | |
1330 | break; | |
1331 | ||
1332 | case 'X': | |
1333 | if (opP->mode != MSCR || | |
1334 | (!(opP->reg >= BAD && opP->reg <= BAD+7) && | |
1335 | !(opP->reg >= BAC && opP->reg <= BAC+7))) | |
1336 | losing++; | |
1337 | break; | |
1338 | ||
1339 | case 'Y': | |
1340 | if (opP->reg != PSR) | |
1341 | losing++; | |
1342 | break; | |
1343 | ||
1344 | case 'Z': | |
1345 | if (opP->reg != PCSR) | |
1346 | losing++; | |
1347 | break; | |
1348 | #endif | |
1349 | case 'c': | |
1350 | if (opP->reg != NC | |
1351 | && opP->reg != IC | |
1352 | && opP->reg != DC | |
1353 | && opP->reg != BC) { | |
1354 | losing++; | |
1355 | } /* not a cache specifier. */ | |
1356 | break; | |
1357 | ||
1358 | case '_': | |
1359 | if (opP->mode != ABSL) { | |
1360 | ++losing; | |
1361 | } /* not absolute */ | |
1362 | break; | |
1363 | ||
1364 | default: | |
1365 | as_fatal("Internal error: Operand mode %c unknown in line %s of file \"%s\"", | |
1366 | *s, __LINE__, __FILE__); | |
1367 | } /* switch on type of operand */ | |
1368 | ||
1369 | if (losing) break; | |
1370 | } /* for each operand */ | |
1371 | } /* if immediately wrong */ | |
1372 | ||
1373 | if (!losing) { | |
1374 | break; | |
1375 | } /* got it. */ | |
1376 | ||
1377 | opcode = opcode->m_next; | |
1378 | ||
1379 | if (!opcode) { | |
1380 | the_ins.error = "instruction/operands mismatch"; | |
1381 | return; | |
1382 | } /* Fell off the end */ | |
1383 | ||
1384 | losing = 0; | |
1385 | } | |
1386 | ||
1387 | /* now assemble it */ | |
1388 | ||
1389 | the_ins.args=opcode->m_operands; | |
1390 | the_ins.numargs=opcode->m_opnum; | |
1391 | the_ins.numo=opcode->m_codenum; | |
1392 | the_ins.opcode[0]=getone(opcode); | |
1393 | the_ins.opcode[1]=gettwo(opcode); | |
1394 | ||
1395 | for (s = the_ins.args, opP = &the_ins.operands[0]; *s; s += 2, opP++) { | |
1396 | /* This switch is a doozy. | |
1397 | Watch the first step; its a big one! */ | |
1398 | switch(s[0]) { | |
1399 | ||
1400 | case '*': | |
1401 | case '~': | |
a39116f1 | 1402 | case '%': |
f8701a3f SC |
1403 | case ';': |
1404 | case '@': | |
1405 | case '!': | |
a39116f1 | 1406 | case '&': |
f8701a3f SC |
1407 | case '$': |
1408 | case '?': | |
1409 | case '/': | |
1410 | #ifndef NO_68851 | |
1411 | case '|': | |
1412 | #endif | |
1413 | switch(opP->mode) { | |
1414 | case IMMED: | |
1415 | tmpreg=0x3c; /* 7.4 */ | |
1416 | if (strchr("bwl",s[1])) nextword=get_num(opP->con1,80); | |
1417 | else nextword=nextword=get_num(opP->con1,0); | |
1418 | if(isvar(opP->con1)) | |
1419 | add_fix(s[1],opP->con1,0); | |
1420 | switch(s[1]) { | |
1421 | case 'b': | |
1422 | if(!isbyte(nextword)) | |
1423 | opP->error="operand out of range"; | |
1424 | addword(nextword); | |
1425 | baseo=0; | |
1426 | break; | |
1427 | case 'w': | |
1428 | if(!isword(nextword)) | |
1429 | opP->error="operand out of range"; | |
1430 | addword(nextword); | |
1431 | baseo=0; | |
1432 | break; | |
1433 | case 'l': | |
1434 | addword(nextword>>16); | |
1435 | addword(nextword); | |
1436 | baseo=0; | |
1437 | break; | |
1438 | ||
1439 | case 'f': | |
1440 | baseo=2; | |
1441 | outro=8; | |
1442 | break; | |
1443 | case 'F': | |
1444 | baseo=4; | |
1445 | outro=11; | |
1446 | break; | |
1447 | case 'x': | |
1448 | baseo=6; | |
1449 | outro=15; | |
1450 | break; | |
1451 | case 'p': | |
1452 | baseo=6; | |
1453 | outro= -1; | |
1454 | break; | |
1455 | default: | |
1456 | as_fatal("Internal error: Can't decode %c%c in line %s of file \"%s\"", | |
1457 | *s, s[1], __LINE__, __FILE__); | |
1458 | } | |
1459 | if(!baseo) | |
1460 | break; | |
1461 | ||
1462 | /* We gotta put out some float */ | |
1463 | if(seg(opP->con1)!=SEG_BIG) { | |
1464 | int_to_gen(nextword); | |
1465 | gen_to_words(words,baseo,(long int)outro); | |
1466 | for(wordp=words;baseo--;wordp++) | |
1467 | addword(*wordp); | |
1468 | break; | |
1469 | } /* Its BIG */ | |
1470 | if(offs(opP->con1)>0) { | |
1471 | as_warn("Bignum assumed to be binary bit-pattern"); | |
1472 | if(offs(opP->con1)>baseo) { | |
1473 | as_warn("Bignum too big for %c format; truncated",s[1]); | |
1474 | offs(opP->con1)=baseo; | |
1475 | } | |
1476 | baseo-=offs(opP->con1); | |
1477 | for(wordp=generic_bignum+offs(opP->con1)-1;offs(opP->con1)--;--wordp) | |
1478 | addword(*wordp); | |
1479 | while(baseo--) | |
1480 | addword(0); | |
1481 | break; | |
1482 | } | |
1483 | gen_to_words(words,baseo,(long)outro); | |
1484 | for (wordp=words;baseo--;wordp++) | |
1485 | addword(*wordp); | |
1486 | break; | |
1487 | case DREG: | |
1488 | tmpreg=opP->reg-DATA; /* 0.dreg */ | |
1489 | break; | |
1490 | case AREG: | |
1491 | tmpreg=0x08+opP->reg-ADDR; /* 1.areg */ | |
1492 | break; | |
1493 | case AINDR: | |
1494 | tmpreg=0x10+opP->reg-ADDR; /* 2.areg */ | |
1495 | break; | |
1496 | case ADEC: | |
1497 | tmpreg=0x20+opP->reg-ADDR; /* 4.areg */ | |
1498 | break; | |
1499 | case AINC: | |
1500 | tmpreg=0x18+opP->reg-ADDR; /* 3.areg */ | |
1501 | break; | |
1502 | case AOFF: | |
1503 | ||
1504 | nextword=get_num(opP->con1,80); | |
1505 | /* Force into index mode. Hope this works */ | |
1506 | ||
1507 | /* We do the first bit for 32-bit displacements, | |
1508 | and the second bit for 16 bit ones. It is | |
1509 | possible that we should make the default be | |
1510 | WORD instead of LONG, but I think that'd | |
1511 | break GCC, so we put up with a little | |
1512 | inefficiency for the sake of working output. | |
1513 | */ | |
1514 | ||
1515 | if( !issword(nextword) | |
1516 | || ( isvar(opP->con1) | |
1517 | && ( ( opP->con1->e_siz==0 | |
1518 | && flagseen['l']==0) | |
1519 | || opP->con1->e_siz==3))) { | |
1520 | ||
1521 | if(opP->reg==PC) | |
1522 | tmpreg=0x3B; /* 7.3 */ | |
1523 | else | |
1524 | tmpreg=0x30+opP->reg-ADDR; /* 6.areg */ | |
1525 | if(isvar(opP->con1)) { | |
1526 | if(opP->reg==PC) { | |
1527 | add_frag(adds(opP->con1), | |
1528 | offs(opP->con1), | |
1529 | TAB(PCLEA,SZ_UNDEF)); | |
1530 | break; | |
1531 | } else { | |
1532 | addword(0x0170); | |
1533 | add_fix('l',opP->con1,1); | |
1534 | } | |
1535 | } else | |
1536 | addword(0x0170); | |
1537 | addword(nextword>>16); | |
1538 | } else { | |
1539 | if(opP->reg==PC) | |
1540 | tmpreg=0x3A; /* 7.2 */ | |
1541 | else | |
1542 | tmpreg=0x28+opP->reg-ADDR; /* 5.areg */ | |
1543 | ||
1544 | if(isvar(opP->con1)) { | |
1545 | if(opP->reg==PC) { | |
1546 | add_fix('w',opP->con1,1); | |
1547 | } else | |
1548 | add_fix('w',opP->con1,0); | |
1549 | } | |
1550 | } | |
1551 | addword(nextword); | |
1552 | break; | |
1553 | ||
1554 | case APODX: | |
1555 | case AMIND: | |
1556 | case APRDX: | |
1557 | know(current_architecture & m68020up); | |
1558 | /* intentional fall-through */ | |
1559 | case AINDX: | |
1560 | nextword=0; | |
1561 | baseo=get_num(opP->con1,80); | |
1562 | outro=get_num(opP->con2,80); | |
1563 | /* Figure out the 'addressing mode' */ | |
1564 | /* Also turn on the BASE_DISABLE bit, if needed */ | |
1565 | if(opP->reg==PC || opP->reg==ZPC) { | |
1566 | tmpreg=0x3b; /* 7.3 */ | |
1567 | if(opP->reg==ZPC) | |
1568 | nextword|=0x80; | |
1569 | } else if(opP->reg==FAIL) { | |
1570 | nextword|=0x80; | |
1571 | tmpreg=0x30; /* 6.garbage */ | |
1572 | } else tmpreg=0x30+opP->reg-ADDR; /* 6.areg */ | |
1573 | ||
1574 | siz1= (opP->con1) ? opP->con1->e_siz : 0; | |
1575 | siz2= (opP->con2) ? opP->con2->e_siz : 0; | |
1576 | ||
1577 | /* Index register stuff */ | |
1578 | if(opP->ireg>=DATA+0 && opP->ireg<=ADDR+7) { | |
1579 | nextword|=(opP->ireg-DATA)<<12; | |
1580 | ||
1581 | if(opP->isiz==0 || opP->isiz==3) | |
1582 | nextword|=0x800; | |
1583 | switch(opP->imul) { | |
1584 | case 1: break; | |
1585 | case 2: nextword|=0x200; break; | |
1586 | case 4: nextword|=0x400; break; | |
1587 | case 8: nextword|=0x600; break; | |
1588 | default: as_fatal("failed sanity check."); | |
1589 | } | |
1590 | /* IF its simple, | |
1591 | GET US OUT OF HERE! */ | |
1592 | ||
1593 | /* Must be INDEX, with an index | |
1594 | register. Address register | |
1595 | cannot be ZERO-PC, and either | |
1596 | :b was forced, or we know | |
1597 | it will fit */ | |
1598 | if( opP->mode==AINDX | |
1599 | && opP->reg!=FAIL | |
1600 | && opP->reg!=ZPC | |
1601 | && ( siz1==1 | |
1602 | || ( issbyte(baseo) | |
1603 | && !isvar(opP->con1)))) { | |
1604 | nextword +=baseo&0xff; | |
1605 | addword(nextword); | |
1606 | if(isvar(opP->con1)) | |
1607 | add_fix('B',opP->con1,0); | |
1608 | break; | |
1609 | } | |
1610 | } else | |
1611 | nextword|=0x40; /* No index reg */ | |
1612 | ||
1613 | /* It aint simple */ | |
1614 | nextword|=0x100; | |
1615 | /* If the guy specified a width, we assume that | |
1616 | it is wide enough. Maybe it isn't. If so, we lose | |
1617 | */ | |
1618 | switch(siz1) { | |
1619 | case 0: | |
1620 | if(isvar(opP->con1) || !issword(baseo)) { | |
1621 | siz1=3; | |
1622 | nextword|=0x30; | |
1623 | } else if(baseo==0) | |
1624 | nextword|=0x10; | |
1625 | else { | |
1626 | nextword|=0x20; | |
1627 | siz1=2; | |
1628 | } | |
1629 | break; | |
1630 | case 1: | |
1631 | as_warn("Byte dispacement won't work. Defaulting to :w"); | |
1632 | case 2: | |
1633 | nextword|=0x20; | |
1634 | break; | |
1635 | case 3: | |
1636 | nextword|=0x30; | |
1637 | break; | |
1638 | } | |
1639 | ||
1640 | /* Figure out innner displacement stuff */ | |
1641 | if(opP->mode!=AINDX) { | |
1642 | switch(siz2) { | |
1643 | case 0: | |
1644 | if(isvar(opP->con2) || !issword(outro)) { | |
1645 | siz2=3; | |
1646 | nextword|=0x3; | |
1647 | } else if(outro==0) | |
1648 | nextword|=0x1; | |
1649 | else { | |
1650 | nextword|=0x2; | |
1651 | siz2=2; | |
1652 | } | |
1653 | break; | |
1654 | case 1: | |
1655 | as_warn("Byte dispacement won't work. Defaulting to :w"); | |
1656 | case 2: | |
1657 | nextword|=0x2; | |
1658 | break; | |
1659 | case 3: | |
1660 | nextword|=0x3; | |
1661 | break; | |
1662 | } | |
1663 | if(opP->mode==APODX) nextword|=0x04; | |
1664 | else if(opP->mode==AMIND) nextword|=0x40; | |
1665 | } | |
1666 | addword(nextword); | |
1667 | ||
1668 | if(isvar(opP->con1)) { | |
1669 | if(opP->reg==PC || opP->reg==ZPC) { | |
1670 | add_fix(siz1==3 ? 'l' : 'w',opP->con1,1); | |
1671 | opP->con1->e_exp.X_add_number+=6; | |
1672 | } else | |
1673 | add_fix(siz1==3 ? 'l' : 'w',opP->con1,0); | |
1674 | } | |
1675 | if(siz1==3) | |
1676 | addword(baseo>>16); | |
1677 | if(siz1) | |
1678 | addword(baseo); | |
1679 | ||
1680 | if(isvar(opP->con2)) { | |
1681 | if(opP->reg==PC || opP->reg==ZPC) { | |
1682 | add_fix(siz2==3 ? 'l' : 'w',opP->con2,1); | |
1683 | opP->con1->e_exp.X_add_number+=6; | |
1684 | } else | |
1685 | add_fix(siz2==3 ? 'l' : 'w',opP->con2,0); | |
1686 | } | |
1687 | if(siz2==3) | |
1688 | addword(outro>>16); | |
1689 | if(siz2) | |
1690 | addword(outro); | |
1691 | ||
1692 | break; | |
1693 | ||
1694 | case ABSL: | |
1695 | nextword=get_num(opP->con1,80); | |
1696 | switch(opP->con1->e_siz) { | |
1697 | default: | |
1698 | as_warn("Unknown size for absolute reference"); | |
1699 | case 0: | |
1700 | if(!isvar(opP->con1) && issword(offs(opP->con1))) { | |
1701 | tmpreg=0x38; /* 7.0 */ | |
1702 | addword(nextword); | |
1703 | break; | |
1704 | } | |
1705 | /* Don't generate pc relative code | |
1706 | on 68010 and 68000 */ | |
1707 | if(isvar(opP->con1) | |
1708 | && !subs(opP->con1) | |
1709 | && seg(opP->con1) == SEG_TEXT | |
1710 | && now_seg == SEG_TEXT | |
1711 | && cpu_of_arch(current_architecture) < m68020 | |
1712 | && !flagseen['S'] | |
1713 | && !strchr("~%&$?", s[0])) { | |
1714 | tmpreg=0x3A; /* 7.2 */ | |
1715 | add_frag(adds(opP->con1), | |
1716 | offs(opP->con1), | |
1717 | TAB(PCREL,SZ_UNDEF)); | |
1718 | break; | |
1719 | } | |
1720 | case 3: /* Fall through into long */ | |
1721 | if(isvar(opP->con1)) | |
1722 | add_fix('l',opP->con1,0); | |
1723 | ||
1724 | tmpreg=0x39; /* 7.1 mode */ | |
1725 | addword(nextword>>16); | |
1726 | addword(nextword); | |
1727 | break; | |
1728 | ||
1729 | case 2: /* Word */ | |
1730 | if(isvar(opP->con1)) | |
1731 | add_fix('w',opP->con1,0); | |
1732 | ||
1733 | tmpreg=0x38; /* 7.0 mode */ | |
1734 | addword(nextword); | |
1735 | break; | |
1736 | } | |
1737 | break; | |
1738 | case MSCR: | |
1739 | default: | |
1740 | as_bad("unknown/incorrect operand"); | |
1741 | /* abort(); */ | |
1742 | } | |
1743 | install_gen_operand(s[1],tmpreg); | |
1744 | break; | |
1745 | ||
1746 | case '#': | |
1747 | case '^': | |
1748 | switch(s[1]) { /* JF: I hate floating point! */ | |
1749 | case 'j': | |
1750 | tmpreg=70; | |
1751 | break; | |
1752 | case '8': | |
1753 | tmpreg=20; | |
1754 | break; | |
1755 | case 'C': | |
1756 | tmpreg=50; | |
1757 | break; | |
1758 | case '3': | |
1759 | default: | |
1760 | tmpreg=80; | |
1761 | break; | |
1762 | } | |
1763 | tmpreg=get_num(opP->con1,tmpreg); | |
1764 | if(isvar(opP->con1)) | |
1765 | add_fix(s[1],opP->con1,0); | |
1766 | switch(s[1]) { | |
1767 | case 'b': /* Danger: These do no check for | |
1768 | certain types of overflow. | |
1769 | user beware! */ | |
1770 | if(!isbyte(tmpreg)) | |
1771 | opP->error="out of range"; | |
1772 | insop(tmpreg); | |
1773 | if(isvar(opP->con1)) | |
1774 | the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2; | |
1775 | break; | |
1776 | case 'w': | |
1777 | if(!isword(tmpreg)) | |
1778 | opP->error="out of range"; | |
1779 | insop(tmpreg); | |
1780 | if(isvar(opP->con1)) | |
1781 | the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2; | |
1782 | break; | |
1783 | case 'l': | |
1784 | insop(tmpreg); /* Because of the way insop works, we put these two out backwards */ | |
1785 | insop(tmpreg>>16); | |
1786 | if(isvar(opP->con1)) | |
1787 | the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2; | |
1788 | break; | |
1789 | case '3': | |
1790 | tmpreg&=0xFF; | |
1791 | case '8': | |
1792 | case 'C': | |
1793 | install_operand(s[1],tmpreg); | |
1794 | break; | |
1795 | default: | |
1796 | as_fatal("Internal error: Unknown mode #%c in line %s of file \"%s\"", s[1], __LINE__, __FILE__); | |
1797 | } | |
1798 | break; | |
1799 | ||
fecd2382 RP |
1800 | case '+': |
1801 | case '-': | |
1802 | case 'A': | |
7c15cbe8 | 1803 | case 'a': |
f8701a3f SC |
1804 | install_operand(s[1],opP->reg-ADDR); |
1805 | break; | |
1806 | ||
1807 | case 'B': | |
1808 | tmpreg=get_num(opP->con1,80); | |
1809 | switch(s[1]) { | |
1810 | case 'B': | |
1811 | /* Needs no offsetting */ | |
1812 | add_fix('B',opP->con1,1); | |
1813 | break; | |
1814 | case 'W': | |
1815 | /* Offset the displacement to be relative to byte disp location */ | |
1816 | opP->con1->e_exp.X_add_number+=2; | |
1817 | add_fix('w',opP->con1,1); | |
1818 | addword(0); | |
1819 | break; | |
1820 | case 'L': | |
1821 | long_branch: | |
1822 | if (cpu_of_arch(current_architecture) < m68020) /* 68000 or 010 */ | |
1823 | as_warn("Can't use long branches on 68000/68010"); | |
1824 | the_ins.opcode[the_ins.numo-1]|=0xff; | |
1825 | /* Offset the displacement to be relative to byte disp location */ | |
1826 | opP->con1->e_exp.X_add_number+=4; | |
1827 | add_fix('l',opP->con1,1); | |
1828 | addword(0); | |
1829 | addword(0); | |
1830 | break; | |
1831 | case 'g': | |
1832 | if(subs(opP->con1)) /* We can't relax it */ | |
1833 | goto long_branch; | |
1834 | ||
1835 | /* This could either be a symbol, or an | |
1836 | absolute address. No matter, the | |
1837 | frag hacking will finger it out. | |
1838 | Not quite: it can't switch from | |
1839 | BRANCH to BCC68000 for the case | |
1840 | where opnd is absolute (it needs | |
1841 | to use the 68000 hack since no | |
1842 | conditional abs jumps). */ | |
1843 | if (((cpu_of_arch(current_architecture) < m68020) || (0==adds(opP->con1))) | |
1844 | && (the_ins.opcode[0] >= 0x6200) | |
1845 | && (the_ins.opcode[0] <= 0x6f00)) { | |
1846 | add_frag(adds(opP->con1),offs(opP->con1),TAB(BCC68000,SZ_UNDEF)); | |
1847 | } else { | |
1848 | add_frag(adds(opP->con1),offs(opP->con1),TAB(BRANCH,SZ_UNDEF)); | |
1849 | } | |
1850 | break; | |
1851 | case 'w': | |
1852 | if(isvar(opP->con1)) { | |
1853 | /* check for DBcc instruction */ | |
1854 | if ((the_ins.opcode[0] & 0xf0f8) ==0x50c8) { | |
1855 | /* size varies if patch */ | |
1856 | /* needed for long form */ | |
1857 | add_frag(adds(opP->con1),offs(opP->con1),TAB(DBCC,SZ_UNDEF)); | |
1858 | break; | |
1859 | } | |
1860 | ||
1861 | /* Don't ask! */ | |
1862 | opP->con1->e_exp.X_add_number+=2; | |
1863 | add_fix('w',opP->con1,1); | |
1864 | } | |
1865 | addword(0); | |
1866 | break; | |
1867 | case 'C': /* Fixed size LONG coproc branches */ | |
1868 | the_ins.opcode[the_ins.numo-1]|=0x40; | |
1869 | /* Offset the displacement to be relative to byte disp location */ | |
1870 | /* Coproc branches don't have a byte disp option, but they are | |
1871 | compatible with the ordinary branches, which do... */ | |
1872 | opP->con1->e_exp.X_add_number+=4; | |
1873 | add_fix('l',opP->con1,1); | |
1874 | addword(0); | |
1875 | addword(0); | |
1876 | break; | |
1877 | case 'c': /* Var size Coprocesssor branches */ | |
1878 | if(subs(opP->con1)) { | |
1879 | add_fix('l',opP->con1,1); | |
1880 | add_frag((symbolS *)0,(long)0,TAB(FBRANCH,LONG)); | |
1881 | } else if(adds(opP->con1)) { | |
1882 | add_frag(adds(opP->con1),offs(opP->con1),TAB(FBRANCH,SZ_UNDEF)); | |
1883 | } else { | |
1884 | /* add_frag((symbolS *)0,offs(opP->con1),TAB(FBRANCH,SHORT)); */ | |
1885 | the_ins.opcode[the_ins.numo-1]|=0x40; | |
1886 | add_fix('l',opP->con1,1); | |
1887 | addword(0); | |
1888 | addword(4); | |
1889 | } | |
1890 | break; | |
1891 | default: | |
1892 | as_fatal("Internal error: operand type B%c unknown in line %s of file \"%s\"", | |
1893 | s[1], __LINE__, __FILE__); | |
1894 | } | |
1895 | break; | |
1896 | ||
1897 | case 'C': /* Ignore it */ | |
1898 | break; | |
1899 | ||
1900 | case 'd': /* JF this is a kludge */ | |
1901 | if(opP->mode==AOFF) { | |
1902 | install_operand('s',opP->reg-ADDR); | |
1903 | } else { | |
1904 | char *tmpP; | |
1905 | ||
1906 | tmpP=opP->con1->e_end-2; | |
1907 | opP->con1->e_beg++; | |
1908 | opP->con1->e_end-=4; /* point to the , */ | |
1909 | baseo=m68k_reg_parse(&tmpP); | |
1910 | if(baseo<ADDR+0 || baseo>ADDR+7) { | |
1911 | as_bad("Unknown address reg, using A0"); | |
1912 | baseo=0; | |
1913 | } else baseo-=ADDR; | |
1914 | install_operand('s',baseo); | |
1915 | } | |
1916 | tmpreg=get_num(opP->con1,80); | |
1917 | if(!issword(tmpreg)) { | |
1918 | as_warn("Expression out of range, using 0"); | |
1919 | tmpreg=0; | |
1920 | } | |
1921 | addword(tmpreg); | |
1922 | break; | |
1923 | ||
fecd2382 | 1924 | case 'D': |
f8701a3f SC |
1925 | install_operand(s[1],opP->reg-DATA); |
1926 | break; | |
1927 | ||
fecd2382 | 1928 | case 'F': |
f8701a3f SC |
1929 | install_operand(s[1],opP->reg-FPREG); |
1930 | break; | |
1931 | ||
fecd2382 | 1932 | case 'I': |
f8701a3f SC |
1933 | tmpreg=1+opP->reg-COPNUM; |
1934 | if(tmpreg==8) | |
1935 | tmpreg=0; | |
1936 | install_operand(s[1],tmpreg); | |
1937 | break; | |
1938 | ||
1939 | case 'J': /* JF foo */ | |
1940 | switch(opP->reg) { | |
1941 | case SFC: tmpreg=0x000; break; | |
1942 | case DFC: tmpreg=0x001; break; | |
1943 | case CACR: tmpreg=0x002; break; | |
1944 | case TC: tmpreg=0x003; break; | |
1945 | case ITT0: tmpreg=0x004; break; | |
1946 | case ITT1: tmpreg=0x005; break; | |
1947 | case DTT0: tmpreg=0x006; break; | |
1948 | case DTT1: tmpreg=0x007; break; | |
1949 | ||
1950 | case USP: tmpreg=0x800; break; | |
1951 | case VBR: tmpreg=0x801; break; | |
1952 | case CAAR: tmpreg=0x802; break; | |
1953 | case MSP: tmpreg=0x803; break; | |
1954 | case ISP: tmpreg=0x804; break; | |
1955 | case MMUSR: tmpreg=0x805; break; | |
1956 | case URP: tmpreg=0x806; break; | |
1957 | case SRP: tmpreg=0x807; break; | |
1958 | default: | |
1959 | as_fatal("failed sanity check."); | |
1960 | } | |
1961 | install_operand(s[1],tmpreg); | |
1962 | break; | |
1963 | ||
fecd2382 | 1964 | case 'k': |
f8701a3f SC |
1965 | tmpreg=get_num(opP->con1,55); |
1966 | install_operand(s[1],tmpreg&0x7f); | |
1967 | break; | |
1968 | ||
fecd2382 | 1969 | case 'l': |
f8701a3f SC |
1970 | tmpreg=opP->reg; |
1971 | if(s[1]=='w') { | |
1972 | if(tmpreg&0x7FF0000) | |
1973 | as_bad("Floating point register in register list"); | |
1974 | insop(reverse_16_bits(tmpreg)); | |
1975 | } else { | |
1976 | if(tmpreg&0x700FFFF) | |
1977 | as_bad("Wrong register in floating-point reglist"); | |
1978 | install_operand(s[1],reverse_8_bits(tmpreg>>16)); | |
1979 | } | |
1980 | break; | |
1981 | ||
fecd2382 | 1982 | case 'L': |
f8701a3f SC |
1983 | tmpreg=opP->reg; |
1984 | if(s[1]=='w') { | |
1985 | if(tmpreg&0x7FF0000) | |
1986 | as_bad("Floating point register in register list"); | |
1987 | insop(tmpreg); | |
1988 | } else if(s[1]=='8') { | |
1989 | if(tmpreg&0x0FFFFFF) | |
1990 | as_bad("incorrect register in reglist"); | |
1991 | install_operand(s[1],tmpreg>>24); | |
1992 | } else { | |
1993 | if(tmpreg&0x700FFFF) | |
1994 | as_bad("wrong register in floating-point reglist"); | |
1995 | else | |
1996 | install_operand(s[1],tmpreg>>16); | |
fecd2382 | 1997 | } |
f8701a3f SC |
1998 | break; |
1999 | ||
fecd2382 | 2000 | case 'M': |
f8701a3f SC |
2001 | install_operand(s[1],get_num(opP->con1,60)); |
2002 | break; | |
7c15cbe8 | 2003 | |
fecd2382 | 2004 | case 'O': |
f8701a3f SC |
2005 | tmpreg= (opP->mode==DREG) |
2006 | ? 0x20+opP->reg-DATA | |
2007 | : (get_num(opP->con1,40)&0x1F); | |
2008 | install_operand(s[1],tmpreg); | |
2009 | break; | |
2010 | ||
fecd2382 | 2011 | case 'Q': |
f8701a3f SC |
2012 | tmpreg=get_num(opP->con1,10); |
2013 | if(tmpreg==8) | |
2014 | tmpreg=0; | |
2015 | install_operand(s[1],tmpreg); | |
2016 | break; | |
7c15cbe8 | 2017 | |
fecd2382 | 2018 | case 'R': |
f8701a3f SC |
2019 | /* This depends on the fact that ADDR registers are |
2020 | eight more than their corresponding DATA regs, so | |
2021 | the result will have the ADDR_REG bit set */ | |
2022 | install_operand(s[1],opP->reg-DATA); | |
2023 | break; | |
2024 | ||
fecd2382 | 2025 | case 's': |
f8701a3f SC |
2026 | if(opP->reg==FPI) tmpreg=0x1; |
2027 | else if(opP->reg==FPS) tmpreg=0x2; | |
2028 | else if(opP->reg==FPC) tmpreg=0x4; | |
2029 | else as_fatal("failed sanity check."); | |
2030 | install_operand(s[1],tmpreg); | |
2031 | break; | |
2032 | ||
2033 | case 'S': /* Ignore it */ | |
2034 | break; | |
2035 | ||
2036 | case 'T': | |
2037 | install_operand(s[1],get_num(opP->con1,30)); | |
2038 | break; | |
2039 | ||
2040 | case 'U': /* Ignore it */ | |
2041 | break; | |
2042 | ||
a39116f1 | 2043 | case 'c': |
f8701a3f SC |
2044 | switch (opP->reg) { |
2045 | case NC: tmpreg = 0; break; | |
2046 | case DC: tmpreg = 1; break; | |
2047 | case IC: tmpreg = 2; break; | |
2048 | case BC: tmpreg = 3; break; | |
2049 | default: | |
2050 | as_fatal("failed sanity check"); | |
2051 | } /* switch on cache token */ | |
2052 | install_operand(s[1], tmpreg); | |
2053 | break; | |
a39116f1 | 2054 | #ifndef NO_68851 |
f8701a3f | 2055 | /* JF: These are out of order, I fear. */ |
a39116f1 | 2056 | case 'f': |
f8701a3f SC |
2057 | switch (opP->reg) { |
2058 | case SFC: | |
2059 | tmpreg=0; | |
2060 | break; | |
2061 | case DFC: | |
2062 | tmpreg=1; | |
2063 | break; | |
2064 | default: | |
2065 | as_fatal("failed sanity check."); | |
fecd2382 | 2066 | } |
f8701a3f | 2067 | install_operand(s[1],tmpreg); |
fecd2382 | 2068 | break; |
f8701a3f SC |
2069 | |
2070 | case 'P': | |
2071 | switch(opP->reg) { | |
2072 | case TC: | |
2073 | tmpreg=0; | |
2074 | break; | |
2075 | case CAL: | |
2076 | tmpreg=4; | |
2077 | break; | |
2078 | case VAL: | |
2079 | tmpreg=5; | |
2080 | break; | |
2081 | case SCC: | |
2082 | tmpreg=6; | |
2083 | break; | |
2084 | case AC: | |
2085 | tmpreg=7; | |
2086 | break; | |
2087 | default: | |
2088 | as_fatal("failed sanity check."); | |
a39116f1 | 2089 | } |
f8701a3f | 2090 | install_operand(s[1],tmpreg); |
7c15cbe8 | 2091 | break; |
f8701a3f SC |
2092 | |
2093 | case 'V': | |
2094 | if (opP->reg == VAL) | |
2095 | break; | |
2096 | as_fatal("failed sanity check."); | |
2097 | ||
2098 | case 'W': | |
2099 | switch(opP->reg) { | |
2100 | ||
2101 | case DRP: | |
2102 | tmpreg=1; | |
2103 | break; | |
2104 | case SRP: | |
2105 | tmpreg=2; | |
2106 | break; | |
2107 | case CRP: | |
2108 | tmpreg=3; | |
2109 | break; | |
2110 | default: | |
2111 | as_fatal("failed sanity check."); | |
2112 | } | |
2113 | install_operand(s[1],tmpreg); | |
7c15cbe8 | 2114 | break; |
f8701a3f SC |
2115 | |
2116 | case 'X': | |
2117 | switch (opP->reg) { | |
2118 | case BAD: case BAD+1: case BAD+2: case BAD+3: | |
2119 | case BAD+4: case BAD+5: case BAD+6: case BAD+7: | |
2120 | tmpreg = (4 << 10) | ((opP->reg - BAD) << 2); | |
2121 | break; | |
2122 | ||
2123 | case BAC: case BAC+1: case BAC+2: case BAC+3: | |
2124 | case BAC+4: case BAC+5: case BAC+6: case BAC+7: | |
2125 | tmpreg = (5 << 10) | ((opP->reg - BAC) << 2); | |
2126 | break; | |
2127 | ||
2128 | default: | |
2129 | as_fatal("failed sanity check."); | |
2130 | } | |
2131 | install_operand(s[1], tmpreg); | |
7c15cbe8 | 2132 | break; |
f8701a3f SC |
2133 | case 'Y': |
2134 | know(opP->reg == PSR); | |
a39116f1 | 2135 | break; |
f8701a3f SC |
2136 | case 'Z': |
2137 | know(opP->reg == PCSR); | |
a39116f1 | 2138 | break; |
f8701a3f SC |
2139 | #endif /* m68851 */ |
2140 | case '_': | |
2141 | tmpreg=get_num(opP->con1,80); | |
2142 | install_operand(s[1], tmpreg); | |
a39116f1 | 2143 | break; |
f8701a3f SC |
2144 | default: |
2145 | as_fatal("Internal error: Operand type %c unknown in line %s of file \"%s\"", s[0], __LINE__, __FILE__); | |
a39116f1 | 2146 | } |
fecd2382 | 2147 | } |
f8701a3f SC |
2148 | /* By the time whe get here (FINALLY) the_ins contains the complete |
2149 | instruction, ready to be emitted. . . */ | |
7c15cbe8 RP |
2150 | } /* m68k_ip() */ |
2151 | ||
2152 | /* | |
2153 | * get_regs := '/' + ? | |
2154 | * | '-' + <register> | |
2155 | * | '-' + <register> + ? | |
2156 | * | <empty> | |
2157 | * ; | |
2158 | * | |
a39116f1 | 2159 | |
7c15cbe8 RP |
2160 | * The idea here must be to scan in a set of registers but I don't |
2161 | * understand it. Looks awfully sloppy to me but I don't have any doc on | |
2162 | * this format so... | |
a39116f1 | 2163 | |
7c15cbe8 RP |
2164 | * |
2165 | * | |
2166 | */ | |
fecd2382 RP |
2167 | |
2168 | static int get_regs(i,str,opP) | |
f8701a3f SC |
2169 | int i; |
2170 | struct m68k_op *opP; | |
2171 | char *str; | |
fecd2382 | 2172 | { |
f8701a3f SC |
2173 | /* 26, 25, 24, 23-16, 15-8, 0-7 */ |
2174 | /* Low order 24 bits encoded fpc,fps,fpi,fp7-fp0,a7-a0,d7-d0 */ | |
2175 | unsigned long cur_regs = 0; | |
2176 | int reg1, | |
2177 | reg2; | |
2178 | ||
fecd2382 | 2179 | #define ADD_REG(x) { if(x==FPI) cur_regs|=(1<<24);\ |
a39116f1 RP |
2180 | else if(x==FPS) cur_regs|=(1<<25);\ |
2181 | else if(x==FPC) cur_regs|=(1<<26);\ | |
2182 | else cur_regs|=(1<<(x-1)); } | |
f8701a3f SC |
2183 | |
2184 | reg1=i; | |
2185 | for(;;) { | |
2186 | if(*str=='/') { | |
2187 | ADD_REG(reg1); | |
2188 | str++; | |
2189 | } else if(*str=='-') { | |
2190 | str++; | |
2191 | reg2=m68k_reg_parse(&str); | |
2192 | if(reg2<DATA || reg2>=FPREG+8 || reg1==FPI || reg1==FPS || reg1==FPC) { | |
2193 | opP->error="unknown register in register list"; | |
2194 | return FAIL; | |
2195 | } | |
2196 | while(reg1<=reg2) { | |
2197 | ADD_REG(reg1); | |
2198 | reg1++; | |
2199 | } | |
2200 | if(*str=='\0') | |
2201 | break; | |
2202 | } else if(*str=='\0') { | |
2203 | ADD_REG(reg1); | |
2204 | break; | |
2205 | } else { | |
2206 | opP->error="unknow character in register list"; | |
2207 | return FAIL; | |
2208 | } | |
2209 | /* DJA -- Bug Fix. Did't handle d1-d2/a1 until the following instruction was added */ | |
2210 | if (*str=='/') | |
2211 | str ++; | |
2212 | reg1=m68k_reg_parse(&str); | |
2213 | if((reg1<DATA || reg1>=FPREG+8) && !(reg1==FPI || reg1==FPS || reg1==FPC)) { | |
2214 | opP->error="unknown register in register list"; | |
2215 | return FAIL; | |
2216 | } | |
a39116f1 | 2217 | } |
f8701a3f SC |
2218 | opP->reg=cur_regs; |
2219 | return OK; | |
fecd2382 RP |
2220 | } /* get_regs() */ |
2221 | ||
2222 | static int reverse_16_bits(in) | |
f8701a3f | 2223 | int in; |
fecd2382 | 2224 | { |
f8701a3f SC |
2225 | int out=0; |
2226 | int n; | |
2227 | ||
2228 | static int mask[16] = { | |
2229 | 0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080, | |
2230 | 0x0100,0x0200,0x0400,0x0800,0x1000,0x2000,0x4000,0x8000 | |
2231 | }; | |
2232 | for(n=0;n<16;n++) { | |
2233 | if(in&mask[n]) | |
2234 | out|=mask[15-n]; | |
2235 | } | |
2236 | return out; | |
fecd2382 RP |
2237 | } /* reverse_16_bits() */ |
2238 | ||
2239 | static int reverse_8_bits(in) | |
f8701a3f | 2240 | int in; |
fecd2382 | 2241 | { |
f8701a3f SC |
2242 | int out=0; |
2243 | int n; | |
2244 | ||
2245 | static int mask[8] = { | |
2246 | 0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080, | |
2247 | }; | |
2248 | ||
2249 | for(n=0;n<8;n++) { | |
2250 | if(in&mask[n]) | |
2251 | out|=mask[7-n]; | |
2252 | } | |
2253 | return out; | |
fecd2382 RP |
2254 | } /* reverse_8_bits() */ |
2255 | ||
2256 | static void install_operand(mode,val) | |
f8701a3f SC |
2257 | int mode; |
2258 | int val; | |
fecd2382 | 2259 | { |
f8701a3f SC |
2260 | switch(mode) { |
2261 | case 's': | |
2262 | the_ins.opcode[0]|=val & 0xFF; /* JF FF is for M kludge */ | |
2263 | break; | |
2264 | case 'd': | |
2265 | the_ins.opcode[0]|=val<<9; | |
2266 | break; | |
2267 | case '1': | |
2268 | the_ins.opcode[1]|=val<<12; | |
2269 | break; | |
2270 | case '2': | |
2271 | the_ins.opcode[1]|=val<<6; | |
2272 | break; | |
2273 | case '3': | |
2274 | the_ins.opcode[1]|=val; | |
2275 | break; | |
2276 | case '4': | |
2277 | the_ins.opcode[2]|=val<<12; | |
2278 | break; | |
2279 | case '5': | |
2280 | the_ins.opcode[2]|=val<<6; | |
2281 | break; | |
2282 | case '6': | |
2283 | /* DANGER! This is a hack to force cas2l and cas2w cmds | |
2284 | to be three words long! */ | |
2285 | the_ins.numo++; | |
2286 | the_ins.opcode[2]|=val; | |
2287 | break; | |
2288 | case '7': | |
2289 | the_ins.opcode[1]|=val<<7; | |
2290 | break; | |
2291 | case '8': | |
2292 | the_ins.opcode[1]|=val<<10; | |
2293 | break; | |
2294 | #ifndef NO_68851 | |
2295 | case '9': | |
2296 | the_ins.opcode[1]|=val<<5; | |
2297 | break; | |
2298 | #endif | |
2299 | ||
2300 | case 't': | |
2301 | the_ins.opcode[1]|=(val<<10)|(val<<7); | |
2302 | break; | |
2303 | case 'D': | |
2304 | the_ins.opcode[1]|=(val<<12)|val; | |
2305 | break; | |
2306 | case 'g': | |
2307 | the_ins.opcode[0]|=val=0xff; | |
2308 | break; | |
2309 | case 'i': | |
2310 | the_ins.opcode[0]|=val<<9; | |
2311 | break; | |
2312 | case 'C': | |
2313 | the_ins.opcode[1]|=val; | |
2314 | break; | |
2315 | case 'j': | |
2316 | the_ins.opcode[1]|=val; | |
2317 | the_ins.numo++; /* What a hack */ | |
2318 | break; | |
2319 | case 'k': | |
2320 | the_ins.opcode[1]|=val<<4; | |
2321 | break; | |
2322 | case 'b': | |
2323 | case 'w': | |
2324 | case 'l': | |
2325 | break; | |
2326 | case 'e': | |
2327 | the_ins.opcode[0] |= (val << 6); | |
2328 | break; | |
2329 | case 'L': | |
2330 | the_ins.opcode[1] = (val >> 16); | |
2331 | the_ins.opcode[2] = val & 0xffff; | |
2332 | break; | |
2333 | case 'c': | |
2334 | default: | |
2335 | as_fatal("failed sanity check."); | |
2336 | } | |
fecd2382 RP |
2337 | } /* install_operand() */ |
2338 | ||
2339 | static void install_gen_operand(mode,val) | |
f8701a3f SC |
2340 | int mode; |
2341 | int val; | |
fecd2382 | 2342 | { |
f8701a3f SC |
2343 | switch(mode) { |
2344 | case 's': | |
2345 | the_ins.opcode[0]|=val; | |
2346 | break; | |
2347 | case 'd': | |
2348 | /* This is a kludge!!! */ | |
2349 | the_ins.opcode[0]|=(val&0x07)<<9|(val&0x38)<<3; | |
2350 | break; | |
2351 | case 'b': | |
2352 | case 'w': | |
2353 | case 'l': | |
2354 | case 'f': | |
2355 | case 'F': | |
2356 | case 'x': | |
2357 | case 'p': | |
2358 | the_ins.opcode[0]|=val; | |
2359 | break; | |
2360 | /* more stuff goes here */ | |
2361 | default: | |
2362 | as_fatal("failed sanity check."); | |
2363 | } | |
fecd2382 RP |
2364 | } /* install_gen_operand() */ |
2365 | ||
7c15cbe8 RP |
2366 | /* |
2367 | * verify that we have some number of paren pairs, do m68k_ip_op(), and | |
2368 | * then deal with the bitfield hack. | |
2369 | */ | |
2370 | ||
fecd2382 | 2371 | static char *crack_operand(str,opP) |
f8701a3f SC |
2372 | register char *str; |
2373 | register struct m68k_op *opP; | |
fecd2382 | 2374 | { |
f8701a3f SC |
2375 | register int parens; |
2376 | register int c; | |
2377 | register char *beg_str; | |
2378 | ||
2379 | if(!str) { | |
2380 | return str; | |
2381 | } | |
2382 | beg_str=str; | |
2383 | for(parens=0;*str && (parens>0 || notend(str));str++) { | |
2384 | if(*str=='(') parens++; | |
2385 | else if(*str==')') { | |
2386 | if(!parens) { /* ERROR */ | |
2387 | opP->error="Extra )"; | |
2388 | return str; | |
2389 | } | |
2390 | --parens; | |
2391 | } | |
2392 | } | |
2393 | if(!*str && parens) { /* ERROR */ | |
2394 | opP->error="Missing )"; | |
2395 | return str; | |
2396 | } | |
2397 | c= *str; | |
2398 | *str='\0'; | |
2399 | if(m68k_ip_op(beg_str,opP)==FAIL) { | |
2400 | *str=c; | |
fecd2382 RP |
2401 | return str; |
2402 | } | |
2403 | *str=c; | |
f8701a3f SC |
2404 | if(c=='}') |
2405 | c= *++str; /* JF bitfield hack */ | |
2406 | if(c) { | |
2407 | c= *++str; | |
2408 | if(!c) | |
2409 | as_bad("Missing operand"); | |
2410 | } | |
fecd2382 RP |
2411 | return str; |
2412 | } | |
2413 | ||
2414 | /* See the comment up above where the #define notend(... is */ | |
2415 | #if 0 | |
2416 | notend(s) | |
f8701a3f | 2417 | char *s; |
fecd2382 | 2418 | { |
f8701a3f SC |
2419 | if(*s==',') return 0; |
2420 | if(*s=='{' || *s=='}') | |
2421 | return 0; | |
2422 | if(*s!=':') return 1; | |
2423 | /* This kludge here is for the division cmd, which is a kludge */ | |
2424 | if(index("aAdD#",s[1])) return 0; | |
2425 | return 1; | |
fecd2382 RP |
2426 | } |
2427 | #endif | |
2428 | ||
2429 | /* This is the guts of the machine-dependent assembler. STR points to a | |
7c15cbe8 | 2430 | machine dependent instruction. This function is supposed to emit |
fecd2382 | 2431 | the frags/bytes it assembles to. |
a39116f1 | 2432 | */ |
fecd2382 | 2433 | void |
a39116f1 | 2434 | md_assemble(str) |
fecd2382 RP |
2435 | char *str; |
2436 | { | |
f8701a3f SC |
2437 | char *er; |
2438 | short *fromP; | |
2439 | char *toP = NULL; | |
2440 | int m,n = 0; | |
2441 | char *to_beg_P; | |
2442 | int shorts_this_frag; | |
2443 | ||
2444 | ||
2445 | if (current_architecture == 0) { | |
2446 | current_architecture = (m68020 | |
865a2edf | 2447 | #ifndef NO_68881 |
f8701a3f | 2448 | | m68881 |
865a2edf MT |
2449 | #endif |
2450 | #ifndef NO_68851 | |
f8701a3f | 2451 | | m68851 |
865a2edf | 2452 | #endif |
f8701a3f SC |
2453 | ); |
2454 | } /* default current_architecture */ | |
2455 | ||
2456 | memset((char *)(&the_ins), '\0', sizeof(the_ins)); /* JF for paranoia sake */ | |
2457 | m68k_ip(str); | |
2458 | er=the_ins.error; | |
2459 | if(!er) { | |
2460 | for(n=the_ins.numargs;n;--n) | |
2461 | if(the_ins.operands[n].error) { | |
2462 | er=the_ins.operands[n].error; | |
2463 | break; | |
2464 | } | |
fecd2382 | 2465 | } |
f8701a3f SC |
2466 | if(er) { |
2467 | as_bad("\"%s\" -- Statement '%s' ignored",er,str); | |
2468 | return; | |
fecd2382 | 2469 | } |
f8701a3f SC |
2470 | |
2471 | if(the_ins.nfrag==0) { /* No frag hacking involved; just put it out */ | |
2472 | toP=frag_more(2*the_ins.numo); | |
2473 | fromP= &the_ins.opcode[0]; | |
2474 | for(m=the_ins.numo;m;--m) { | |
2475 | md_number_to_chars(toP,(long)(*fromP),2); | |
2476 | toP+=2; | |
2477 | fromP++; | |
2478 | } | |
2479 | /* put out symbol-dependent info */ | |
2480 | for(m=0;m<the_ins.nrel;m++) { | |
2481 | switch(the_ins.reloc[m].wid) { | |
2482 | case 'B': | |
2483 | n=1; | |
2484 | break; | |
2485 | case 'b': | |
2486 | n=1; | |
2487 | break; | |
2488 | case '3': | |
2489 | n=2; | |
2490 | break; | |
2491 | case 'w': | |
2492 | n=2; | |
2493 | break; | |
2494 | case 'l': | |
2495 | n=4; | |
2496 | break; | |
2497 | default: | |
2498 | as_fatal("Don't know how to figure width of %c in md_assemble()",the_ins.reloc[m].wid); | |
2499 | } | |
2500 | ||
2501 | fix_new(frag_now, | |
2502 | (toP-frag_now->fr_literal)-the_ins.numo*2+the_ins.reloc[m].n, | |
2503 | n, | |
2504 | the_ins.reloc[m].add, | |
2505 | the_ins.reloc[m].sub, | |
2506 | the_ins.reloc[m].off, | |
2507 | the_ins.reloc[m].pcrel, | |
2508 | NO_RELOC); | |
2509 | } | |
2510 | return; | |
2511 | } | |
2512 | ||
2513 | /* There's some frag hacking */ | |
2514 | for(n=0,fromP= &the_ins.opcode[0];n<the_ins.nfrag;n++) { | |
2515 | int wid; | |
2516 | ||
2517 | if(n==0) wid=2*the_ins.fragb[n].fragoff; | |
2518 | else wid=2*(the_ins.numo-the_ins.fragb[n-1].fragoff); | |
2519 | toP=frag_more(wid); | |
2520 | to_beg_P=toP; | |
2521 | shorts_this_frag=0; | |
2522 | for(m=wid/2;m;--m) { | |
2523 | md_number_to_chars(toP,(long)(*fromP),2); | |
2524 | toP+=2; | |
2525 | fromP++; | |
2526 | shorts_this_frag++; | |
2527 | } | |
2528 | for(m=0;m<the_ins.nrel;m++) { | |
2529 | if((the_ins.reloc[m].n)>= 2*shorts_this_frag /* 2*the_ins.fragb[n].fragoff */) { | |
2530 | the_ins.reloc[m].n-= 2*shorts_this_frag /* 2*the_ins.fragb[n].fragoff */; | |
2531 | break; | |
2532 | } | |
2533 | wid=the_ins.reloc[m].wid; | |
2534 | if(wid==0) | |
2535 | continue; | |
2536 | the_ins.reloc[m].wid=0; | |
2537 | wid = (wid=='b') ? 1 : (wid=='w') ? 2 : (wid=='l') ? 4 : 4000; | |
2538 | ||
2539 | fix_new(frag_now, | |
2540 | (toP-frag_now->fr_literal)-the_ins.numo*2+the_ins.reloc[m].n, | |
2541 | wid, | |
2542 | the_ins.reloc[m].add, | |
2543 | the_ins.reloc[m].sub, | |
2544 | the_ins.reloc[m].off, | |
2545 | the_ins.reloc[m].pcrel, | |
2546 | NO_RELOC); | |
2547 | } | |
2548 | /* know(the_ins.fragb[n].fadd); */ | |
2549 | (void)frag_var(rs_machine_dependent,10,0,(relax_substateT)(the_ins.fragb[n].fragty), | |
2550 | the_ins.fragb[n].fadd,the_ins.fragb[n].foff,to_beg_P); | |
2551 | } | |
2552 | n=(the_ins.numo-the_ins.fragb[n-1].fragoff); | |
fecd2382 | 2553 | shorts_this_frag=0; |
f8701a3f SC |
2554 | if(n) { |
2555 | toP=frag_more(n*sizeof(short)); | |
2556 | while(n--) { | |
2557 | md_number_to_chars(toP,(long)(*fromP),2); | |
2558 | toP+=2; | |
2559 | fromP++; | |
2560 | shorts_this_frag++; | |
2561 | } | |
fecd2382 RP |
2562 | } |
2563 | for(m=0;m<the_ins.nrel;m++) { | |
f8701a3f SC |
2564 | int wid; |
2565 | ||
2566 | wid=the_ins.reloc[m].wid; | |
2567 | if(wid==0) | |
2568 | continue; | |
2569 | the_ins.reloc[m].wid=0; | |
2570 | wid = (wid=='b') ? 1 : (wid=='w') ? 2 : (wid=='l') ? 4 : 4000; | |
2571 | ||
2572 | fix_new(frag_now, | |
2573 | (the_ins.reloc[m].n + toP-frag_now->fr_literal)-/* the_ins.numo */ shorts_this_frag*2, | |
2574 | wid, | |
2575 | the_ins.reloc[m].add, | |
2576 | the_ins.reloc[m].sub, | |
2577 | the_ins.reloc[m].off, | |
2578 | the_ins.reloc[m].pcrel, | |
2579 | NO_RELOC); | |
fecd2382 RP |
2580 | } |
2581 | } | |
2582 | ||
2583 | /* This function is called once, at assembler startup time. This should | |
2584 | set up all the tables, etc that the MD part of the assembler needs | |
a39116f1 | 2585 | */ |
f8701a3f SC |
2586 | |
2587 | void | |
2588 | insert_reg(regname, regnum) | |
2589 | char *regname; | |
2590 | int regnum; | |
2591 | { | |
2592 | char buf[100]; | |
2593 | int i; | |
2594 | symbol_table_insert(symbol_new(regname, SEG_REGISTER, regnum, &zero_address_frag)); | |
2595 | ||
2596 | for (i = 0; regname[i]; i++) | |
2597 | buf[i] = islower (regname[i]) ? toupper (regname[i]) : regname[i]; | |
2598 | buf[i] = '\0'; | |
2599 | ||
2600 | symbol_table_insert(symbol_new(buf, SEG_REGISTER, regnum, &zero_address_frag)); | |
2601 | } | |
2602 | ||
2603 | static struct { | |
2604 | char *name; | |
2605 | int number; | |
2606 | } init_table[] = | |
2607 | { | |
2608 | "d0", DATA0, | |
2609 | "d1", DATA1, | |
2610 | "d2", DATA2, | |
2611 | "d3", DATA3, | |
2612 | "d4", DATA4, | |
2613 | "d5", DATA5, | |
2614 | "d6", DATA6, | |
2615 | "d7", DATA7, | |
2616 | "a0", ADDR0, | |
2617 | "a1", ADDR1, | |
2618 | "a2", ADDR2, | |
2619 | "a3", ADDR3, | |
2620 | "a4", ADDR4, | |
2621 | "a5", ADDR5, | |
2622 | "a6", ADDR6, | |
2623 | "fp", ADDR6, | |
2624 | "a7", ADDR7, | |
2625 | "sp", ADDR7, | |
2626 | "fp0", FP0, | |
2627 | "fp1", FP1, | |
2628 | "fp2", FP2, | |
2629 | "fp3", FP3, | |
2630 | "fp4", FP4, | |
2631 | "fp5", FP5, | |
2632 | "fp6", FP6, | |
2633 | "fp7", FP7, | |
2634 | "fpi", FPI, | |
2635 | "fps", FPS, | |
2636 | "fpc", FPC, | |
2637 | ||
2638 | "cop0", COP0, | |
2639 | "cop1", COP1, | |
2640 | "cop2", COP2, | |
2641 | "cop3", COP3, | |
2642 | "cop4", COP4, | |
2643 | "cop5", COP5, | |
2644 | "cop6", COP6, | |
2645 | "cop7", COP7, | |
2646 | "pc", PC, | |
2647 | "zpc", ZPC, | |
2648 | "sr", SR, | |
2649 | ||
2650 | "ccr", CCR, | |
2651 | "cc", CCR, | |
2652 | ||
2653 | "usp", USP, | |
2654 | "isp", ISP, | |
2655 | "sfc", SFC, | |
2656 | "dfc", DFC, | |
2657 | "cacr", CACR, | |
2658 | "caar", CAAR, | |
2659 | ||
2660 | "vbr", VBR, | |
2661 | ||
2662 | "msp", MSP, | |
2663 | "itt0", ITT0, | |
2664 | "itt1", ITT1, | |
2665 | "dtt0", DTT0, | |
2666 | "dtt1", DTT1, | |
2667 | "mmusr", MMUSR, | |
2668 | "tc", TC, | |
2669 | "srp", SRP, | |
2670 | "urp", URP, | |
2671 | ||
2672 | #ifndef NO_68851 | |
2673 | "ac", AC, | |
2674 | "bc", BC, | |
2675 | "cal", CAL, | |
2676 | "crp", CRP, | |
2677 | "drp", DRP, | |
2678 | "pcsr", PCSR, | |
2679 | "psr", PSR, | |
2680 | "scc", SCC, | |
2681 | "val", VAL, | |
2682 | "bad0", BAD0, | |
2683 | "bad1", BAD1, | |
2684 | "bad2", BAD2, | |
2685 | "bad3", BAD3, | |
2686 | "bad4", BAD4, | |
2687 | "bad5", BAD5, | |
2688 | "bad6", BAD6, | |
2689 | "bad7", BAD7, | |
2690 | "bac0", BAC0, | |
2691 | "bac1", BAC1, | |
2692 | "bac2", BAC2, | |
2693 | "bac3", BAC3, | |
2694 | "bac4", BAC4, | |
2695 | "bac5", BAC5, | |
2696 | "bac6", BAC6, | |
2697 | "bac7", BAC7, | |
2698 | #endif | |
2699 | ||
2700 | "ic", IC, | |
2701 | "dc", DC, | |
2702 | "nc", NC, | |
2703 | ||
2704 | 0, | |
2705 | ||
2706 | }; | |
2707 | ||
2708 | ||
2709 | void | |
2710 | init_regtable() | |
2711 | { | |
2712 | int i; | |
2713 | for (i = 0; init_table[i].name; i++) | |
2714 | { | |
2715 | insert_reg(init_table[i].name, init_table[i].number); | |
2716 | } | |
2717 | } | |
2718 | ||
2719 | ||
fecd2382 | 2720 | void |
a39116f1 | 2721 | md_begin() |
fecd2382 | 2722 | { |
f8701a3f SC |
2723 | /* |
2724 | * md_begin -- set up hash tables with 68000 instructions. | |
2725 | * similar to what the vax assembler does. ---phr | |
2726 | */ | |
2727 | /* RMS claims the thing to do is take the m68k-opcode.h table, and make | |
2728 | a copy of it at runtime, adding in the information we want but isn't | |
2729 | there. I think it'd be better to have an awk script hack the table | |
2730 | at compile time. Or even just xstr the table and use it as-is. But | |
2731 | my lord ghod hath spoken, so we do it this way. Excuse the ugly var | |
2732 | names. */ | |
2733 | ||
2734 | register const struct m68k_opcode *ins; | |
2735 | register struct m68k_incant *hack, | |
2736 | *slak; | |
2737 | register char *retval = 0; /* empty string, or error msg text */ | |
2738 | register unsigned int i; | |
2739 | register char c; | |
2740 | ||
2741 | if ((op_hash = hash_new()) == NULL) | |
2742 | as_fatal("Virtual memory exhausted"); | |
2743 | ||
2744 | obstack_begin(&robyn,4000); | |
2745 | for (ins = m68k_opcodes; ins < endop; ins++) { | |
2746 | hack=slak=(struct m68k_incant *)obstack_alloc(&robyn,sizeof(struct m68k_incant)); | |
2747 | do { | |
2748 | /* we *could* ignore insns that don't match our | |
2749 | arch here but just leaving them out of the | |
2750 | hash. */ | |
2751 | slak->m_operands=ins->args; | |
2752 | slak->m_opnum=strlen(slak->m_operands)/2; | |
2753 | slak->m_arch = ins->arch; | |
2754 | slak->m_opcode=ins->opcode; | |
2755 | /* This is kludgey */ | |
2756 | slak->m_codenum=((ins->match)&0xffffL) ? 2 : 1; | |
2757 | if((ins+1)!=endop && !strcmp(ins->name,(ins+1)->name)) { | |
2758 | slak->m_next=(struct m68k_incant *) obstack_alloc(&robyn,sizeof(struct m68k_incant)); | |
2759 | ins++; | |
2760 | } else | |
2761 | slak->m_next=0; | |
2762 | slak=slak->m_next; | |
2763 | } while(slak); | |
2764 | ||
2765 | retval = hash_insert (op_hash, ins->name,(char *)hack); | |
2766 | /* Didn't his mommy tell him about null pointers? */ | |
2767 | if(retval && *retval) | |
2768 | as_fatal("Internal Error: Can't hash %s: %s",ins->name,retval); | |
2769 | } | |
2770 | ||
2771 | for (i = 0; i < sizeof(mklower_table) ; i++) | |
2772 | mklower_table[i] = (isupper(c = (char) i)) ? tolower(c) : c; | |
2773 | ||
2774 | for (i = 0 ; i < sizeof(notend_table) ; i++) { | |
2775 | notend_table[i] = 0; | |
2776 | alt_notend_table[i] = 0; | |
2777 | } | |
2778 | notend_table[','] = 1; | |
2779 | notend_table['{'] = 1; | |
2780 | notend_table['}'] = 1; | |
2781 | alt_notend_table['a'] = 1; | |
2782 | alt_notend_table['A'] = 1; | |
2783 | alt_notend_table['d'] = 1; | |
2784 | alt_notend_table['D'] = 1; | |
2785 | alt_notend_table['#'] = 1; | |
2786 | alt_notend_table['f'] = 1; | |
2787 | alt_notend_table['F'] = 1; | |
fecd2382 | 2788 | #ifdef REGISTER_PREFIX |
f8701a3f | 2789 | alt_notend_table[REGISTER_PREFIX] = 1; |
fecd2382 | 2790 | #endif |
f8701a3f SC |
2791 | |
2792 | init_regtable(); | |
fecd2382 RP |
2793 | } |
2794 | ||
2795 | #if 0 | |
2796 | #define notend(s) ((*s == ',' || *s == '}' || *s == '{' \ | |
a39116f1 RP |
2797 | || (*s == ':' && strchr("aAdD#", s[1]))) \ |
2798 | ? 0 : 1) | |
fecd2382 RP |
2799 | #endif |
2800 | ||
2801 | /* This funciton is called once, before the assembler exits. It is | |
2802 | supposed to do any final cleanup for this part of the assembler. | |
a39116f1 | 2803 | */ |
fecd2382 | 2804 | void |
a39116f1 | 2805 | md_end() |
fecd2382 RP |
2806 | { |
2807 | } | |
2808 | ||
2809 | /* Equal to MAX_PRECISION in atof-ieee.c */ | |
2810 | #define MAX_LITTLENUMS 6 | |
2811 | ||
2812 | /* Turn a string in input_line_pointer into a floating point constant of type | |
2813 | type, and store the appropriate bytes in *litP. The number of LITTLENUMS | |
2814 | emitted is stored in *sizeP . An error message is returned, or NULL on OK. | |
a39116f1 | 2815 | */ |
fecd2382 | 2816 | char * |
a39116f1 | 2817 | md_atof(type,litP,sizeP) |
fecd2382 RP |
2818 | char type; |
2819 | char *litP; | |
2820 | int *sizeP; | |
2821 | { | |
f8701a3f SC |
2822 | int prec; |
2823 | LITTLENUM_TYPE words[MAX_LITTLENUMS]; | |
2824 | LITTLENUM_TYPE *wordP; | |
2825 | char *t; | |
2826 | char *atof_ieee(); | |
a39116f1 | 2827 | |
f8701a3f SC |
2828 | switch(type) { |
2829 | case 'f': | |
2830 | case 'F': | |
2831 | case 's': | |
2832 | case 'S': | |
2833 | prec = 2; | |
2834 | break; | |
2835 | ||
2836 | case 'd': | |
2837 | case 'D': | |
2838 | case 'r': | |
2839 | case 'R': | |
2840 | prec = 4; | |
2841 | break; | |
2842 | ||
2843 | case 'x': | |
2844 | case 'X': | |
2845 | prec = 6; | |
2846 | break; | |
2847 | ||
2848 | case 'p': | |
2849 | case 'P': | |
2850 | prec = 6; | |
2851 | break; | |
2852 | ||
2853 | default: | |
2854 | *sizeP=0; | |
2855 | return "Bad call to MD_ATOF()"; | |
2856 | } | |
2857 | t=atof_ieee(input_line_pointer,type,words); | |
2858 | if(t) | |
2859 | input_line_pointer=t; | |
a39116f1 | 2860 | |
f8701a3f SC |
2861 | *sizeP=prec * sizeof(LITTLENUM_TYPE); |
2862 | for(wordP=words;prec--;) { | |
2863 | md_number_to_chars(litP,(long)(*wordP++),sizeof(LITTLENUM_TYPE)); | |
2864 | litP+=sizeof(LITTLENUM_TYPE); | |
2865 | } | |
2866 | return ""; /* Someone should teach Dean about null pointers */ | |
fecd2382 RP |
2867 | } |
2868 | ||
2869 | /* Turn an integer of n bytes (in val) into a stream of bytes appropriate | |
2870 | for use in the a.out file, and stores them in the array pointed to by buf. | |
2871 | This knows about the endian-ness of the target machine and does | |
2872 | THE RIGHT THING, whatever it is. Possible values for n are 1 (byte) | |
2873 | 2 (short) and 4 (long) Floating numbers are put out as a series of | |
2874 | LITTLENUMS (shorts, here at least) | |
a39116f1 | 2875 | */ |
fecd2382 | 2876 | void |
a39116f1 | 2877 | md_number_to_chars(buf,val,n) |
fecd2382 RP |
2878 | char *buf; |
2879 | long val; | |
2880 | int n; | |
2881 | { | |
f8701a3f SC |
2882 | switch(n) { |
2883 | case 1: | |
2884 | *buf++=val; | |
2885 | break; | |
2886 | case 2: | |
2887 | *buf++=(val>>8); | |
2888 | *buf++=val; | |
2889 | break; | |
2890 | case 4: | |
2891 | *buf++=(val>>24); | |
2892 | *buf++=(val>>16); | |
2893 | *buf++=(val>>8); | |
2894 | *buf++=val; | |
2895 | break; | |
2896 | default: | |
2897 | as_fatal("failed sanity check."); | |
2898 | } | |
fecd2382 RP |
2899 | } |
2900 | ||
2901 | void | |
a39116f1 RP |
2902 | md_apply_fix(fixP, val) |
2903 | fixS *fixP; | |
2904 | long val; | |
fecd2382 | 2905 | { |
f8701a3f SC |
2906 | char *buf = fixP->fx_where + fixP->fx_frag->fr_literal; |
2907 | ||
2908 | switch(fixP->fx_size) { | |
2909 | case 1: | |
2910 | *buf++=val; | |
2911 | break; | |
2912 | case 2: | |
2913 | *buf++=(val>>8); | |
2914 | *buf++=val; | |
2915 | break; | |
2916 | case 4: | |
2917 | *buf++=(val>>24); | |
2918 | *buf++=(val>>16); | |
2919 | *buf++=(val>>8); | |
2920 | *buf++=val; | |
2921 | break; | |
2922 | default: | |
2923 | BAD_CASE (fixP->fx_size); | |
2924 | } | |
fecd2382 RP |
2925 | } |
2926 | ||
2927 | ||
2928 | /* *fragP has been relaxed to its final size, and now needs to have | |
2929 | the bytes inside it modified to conform to the new size There is UGLY | |
2930 | MAGIC here. .. | |
a39116f1 | 2931 | */ |
fecd2382 | 2932 | void |
a39116f1 | 2933 | md_convert_frag(headers, fragP) |
f6e504fe | 2934 | object_headers *headers; |
fecd2382 RP |
2935 | register fragS *fragP; |
2936 | { | |
f8701a3f SC |
2937 | long disp; |
2938 | long ext = 0; | |
2939 | ||
2940 | /* Address in object code of the displacement. */ | |
2941 | register int object_address = fragP -> fr_fix + fragP -> fr_address; | |
2942 | ||
f6e504fe | 2943 | #ifdef IBM_COMPILER_SUX |
f8701a3f SC |
2944 | /* This is wrong but it convinces the native rs6000 compiler to |
2945 | generate the code we want. */ | |
2946 | register char *buffer_address = fragP -> fr_literal; | |
2947 | buffer_address += fragP -> fr_fix; | |
f6e504fe | 2948 | #else /* IBM_COMPILER_SUX */ |
f8701a3f SC |
2949 | /* Address in gas core of the place to store the displacement. */ |
2950 | register char *buffer_address = fragP->fr_fix + fragP->fr_literal; | |
f6e504fe | 2951 | #endif /* IBM_COMPILER_SUX */ |
f8701a3f SC |
2952 | |
2953 | /* No longer true: know(fragP->fr_symbol); */ | |
2954 | ||
2955 | /* The displacement of the address, from current location. */ | |
2956 | disp = fragP->fr_symbol ? S_GET_VALUE(fragP->fr_symbol) : 0; | |
2957 | disp = (disp + fragP->fr_offset) - object_address; | |
2958 | ||
2959 | switch(fragP->fr_subtype) { | |
2960 | case TAB(BCC68000,BYTE): | |
a39116f1 RP |
2961 | case TAB(BRANCH,BYTE): |
2962 | know(issbyte(disp)); | |
2963 | if(disp==0) | |
2964 | as_bad("short branch with zero offset: use :w"); | |
2965 | fragP->fr_opcode[1]=disp; | |
fecd2382 | 2966 | ext=0; |
a39116f1 | 2967 | break; |
f8701a3f SC |
2968 | case TAB(DBCC,SHORT): |
2969 | know(issword(disp)); | |
a39116f1 RP |
2970 | ext=2; |
2971 | break; | |
f8701a3f SC |
2972 | case TAB(BCC68000,SHORT): |
2973 | case TAB(BRANCH,SHORT): | |
2974 | know(issword(disp)); | |
a39116f1 RP |
2975 | fragP->fr_opcode[1]=0x00; |
2976 | ext=2; | |
2977 | break; | |
f8701a3f SC |
2978 | case TAB(BRANCH,LONG): |
2979 | if (cpu_of_arch(current_architecture) < m68020) { | |
2980 | if (fragP->fr_opcode[0]==0x61) { | |
2981 | fragP->fr_opcode[0]= 0x4E; | |
2982 | fragP->fr_opcode[1]= 0xB9; /* JBSR with ABSL LONG offset */ | |
2983 | subseg_change(SEG_TEXT, 0); | |
2984 | ||
2985 | fix_new(fragP, | |
2986 | fragP->fr_fix, | |
2987 | 4, | |
2988 | fragP->fr_symbol, | |
2989 | 0, | |
2990 | fragP->fr_offset, | |
2991 | 0, | |
2992 | NO_RELOC); | |
2993 | ||
2994 | fragP->fr_fix+=4; | |
2995 | ext=0; | |
2996 | } else if (fragP->fr_opcode[0]==0x60) { | |
2997 | fragP->fr_opcode[0]= 0x4E; | |
2998 | fragP->fr_opcode[1]= 0xF9; /* JMP with ABSL LONG offset */ | |
2999 | subseg_change(SEG_TEXT, 0); | |
3000 | fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, fragP->fr_offset,0, | |
3001 | NO_RELOC); | |
3002 | fragP->fr_fix+=4; | |
3003 | ext=0; | |
3004 | } else { | |
3005 | as_bad("Long branch offset not supported."); | |
3006 | } | |
3007 | } else { | |
3008 | fragP->fr_opcode[1]=0xff; | |
3009 | ext=4; | |
3010 | } | |
3011 | break; | |
3012 | case TAB(BCC68000,LONG): | |
3013 | /* only Bcc 68000 instructions can come here */ | |
3014 | /* change bcc into b!cc/jmp absl long */ | |
3015 | fragP->fr_opcode[0] ^= 0x01; /* invert bcc */ | |
fecd2382 | 3016 | fragP->fr_opcode[1] = 0x6; /* branch offset = 6 */ |
a39116f1 | 3017 | |
fecd2382 RP |
3018 | /* JF: these used to be fr_opcode[2,3], but they may be in a |
3019 | different frag, in which case refering to them is a no-no. | |
3020 | Only fr_opcode[0,1] are guaranteed to work. */ | |
3021 | *buffer_address++ = 0x4e; /* put in jmp long (0x4ef9) */ | |
3022 | *buffer_address++ = 0xf9; | |
3023 | fragP->fr_fix += 2; /* account for jmp instruction */ | |
3024 | subseg_change(SEG_TEXT,0); | |
3025 | fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, | |
a39116f1 RP |
3026 | fragP->fr_offset,0, |
3027 | NO_RELOC); | |
fecd2382 RP |
3028 | fragP->fr_fix += 4; |
3029 | ext=0; | |
3030 | break; | |
f8701a3f SC |
3031 | case TAB(DBCC,LONG): |
3032 | /* only DBcc 68000 instructions can come here */ | |
3033 | /* change dbcc into dbcc/jmp absl long */ | |
3034 | /* JF: these used to be fr_opcode[2-7], but that's wrong */ | |
3035 | *buffer_address++ = 0x00; /* branch offset = 4 */ | |
fecd2382 RP |
3036 | *buffer_address++ = 0x04; |
3037 | *buffer_address++ = 0x60; /* put in bra pc+6 */ | |
3038 | *buffer_address++ = 0x06; | |
3039 | *buffer_address++ = 0x4e; /* put in jmp long (0x4ef9) */ | |
3040 | *buffer_address++ = 0xf9; | |
a39116f1 | 3041 | |
fecd2382 RP |
3042 | fragP->fr_fix += 6; /* account for bra/jmp instructions */ |
3043 | subseg_change(SEG_TEXT,0); | |
3044 | fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, | |
a39116f1 RP |
3045 | fragP->fr_offset,0, |
3046 | NO_RELOC); | |
fecd2382 RP |
3047 | fragP->fr_fix += 4; |
3048 | ext=0; | |
a39116f1 | 3049 | break; |
f8701a3f SC |
3050 | case TAB(FBRANCH,SHORT): |
3051 | know((fragP->fr_opcode[1]&0x40)==0); | |
a39116f1 RP |
3052 | ext=2; |
3053 | break; | |
f8701a3f SC |
3054 | case TAB(FBRANCH,LONG): |
3055 | fragP->fr_opcode[1]|=0x40; /* Turn on LONG bit */ | |
a39116f1 RP |
3056 | ext=4; |
3057 | break; | |
f8701a3f SC |
3058 | case TAB(PCREL,SHORT): |
3059 | ext=2; | |
a39116f1 | 3060 | break; |
f8701a3f SC |
3061 | case TAB(PCREL,LONG): |
3062 | /* The thing to do here is force it to ABSOLUTE LONG, since | |
3063 | PCREL is really trying to shorten an ABSOLUTE address anyway */ | |
3064 | /* JF FOO This code has not been tested */ | |
3065 | subseg_change(SEG_TEXT,0); | |
a39116f1 RP |
3066 | fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, fragP->fr_offset, 0, NO_RELOC); |
3067 | if((fragP->fr_opcode[1] & 0x3F) != 0x3A) | |
3068 | as_bad("Internal error (long PC-relative operand) for insn 0x%04lx at 0x%lx", | |
3069 | fragP->fr_opcode[0],fragP->fr_address); | |
3070 | fragP->fr_opcode[1]&= ~0x3F; | |
3071 | fragP->fr_opcode[1]|=0x39; /* Mode 7.1 */ | |
3072 | fragP->fr_fix+=4; | |
3073 | /* md_number_to_chars(buffer_address, | |
3074 | (long)(fragP->fr_symbol->sy_value + fragP->fr_offset), | |
3075 | 4); */ | |
3076 | ext=0; | |
3077 | break; | |
f8701a3f SC |
3078 | case TAB(PCLEA,SHORT): |
3079 | subseg_change(SEG_TEXT,0); | |
a39116f1 RP |
3080 | fix_new(fragP,(int)(fragP->fr_fix),2,fragP->fr_symbol,(symbolS *)0,fragP->fr_offset,1, |
3081 | NO_RELOC); | |
3082 | fragP->fr_opcode[1] &= ~0x3F; | |
3083 | fragP->fr_opcode[1] |= 0x3A; | |
3084 | ext=2; | |
3085 | break; | |
f8701a3f SC |
3086 | case TAB(PCLEA,LONG): |
3087 | subseg_change(SEG_TEXT,0); | |
3088 | fix_new(fragP,(int)(fragP->fr_fix)+2,4,fragP->fr_symbol,(symbolS *)0,fragP->fr_offset+2,1, | |
3089 | NO_RELOC); | |
3090 | *buffer_address++ = 0x01; | |
3091 | *buffer_address++ = 0x70; | |
3092 | fragP->fr_fix+=2; | |
3093 | /* buffer_address+=2; */ | |
3094 | ext=4; | |
a39116f1 | 3095 | break; |
a39116f1 | 3096 | |
f8701a3f | 3097 | } /* switch on subtype */ |
a39116f1 | 3098 | |
f8701a3f SC |
3099 | if (ext) { |
3100 | md_number_to_chars(buffer_address, (long) disp, (int) ext); | |
3101 | fragP->fr_fix += ext; | |
3102 | /* H_SET_TEXT_SIZE(headers, H_GET_TEXT_SIZE(headers) + ext); */ | |
3103 | } /* if extending */ | |
a39116f1 | 3104 | |
f8701a3f SC |
3105 | return; |
3106 | } /* md_convert_frag() */ | |
3107 | ||
3108 | /* Force truly undefined symbols to their maximum size, and generally set up | |
3109 | the frag list to be relaxed | |
3110 | */ | |
3111 | int md_estimate_size_before_relax(fragP, segment) | |
3112 | register fragS *fragP; | |
3113 | segT segment; | |
3114 | { | |
3115 | int old_fix; | |
3116 | register char *buffer_address = fragP->fr_fix + fragP->fr_literal; | |
a39116f1 | 3117 | |
f8701a3f | 3118 | old_fix = fragP->fr_fix; |
a39116f1 | 3119 | |
f8701a3f SC |
3120 | /* handle SZ_UNDEF first, it can be changed to BYTE or SHORT */ |
3121 | switch (fragP->fr_subtype) { | |
3122 | ||
3123 | case TAB(BRANCH,SZ_UNDEF): { | |
3124 | if((fragP->fr_symbol != NULL) /* Not absolute */ | |
3125 | && S_GET_SEGMENT(fragP->fr_symbol) == segment) { | |
3126 | fragP->fr_subtype=TAB(TABTYPE(fragP->fr_subtype),BYTE); | |
3127 | break; | |
3128 | } else if((fragP->fr_symbol == 0) || (cpu_of_arch(current_architecture) < m68020)) { | |
3129 | /* On 68000, or for absolute value, switch to abs long */ | |
3130 | /* FIXME, we should check abs val, pick short or long */ | |
3131 | if(fragP->fr_opcode[0]==0x61) { | |
3132 | fragP->fr_opcode[0]= 0x4E; | |
3133 | fragP->fr_opcode[1]= 0xB9; /* JBSR with ABSL LONG offset */ | |
3134 | subseg_change(SEG_TEXT, 0); | |
3135 | fix_new(fragP, fragP->fr_fix, 4, | |
3136 | fragP->fr_symbol, 0, fragP->fr_offset, 0, NO_RELOC); | |
3137 | fragP->fr_fix+=4; | |
3138 | frag_wane(fragP); | |
3139 | } else if(fragP->fr_opcode[0]==0x60) { | |
3140 | fragP->fr_opcode[0]= 0x4E; | |
3141 | fragP->fr_opcode[1]= 0xF9; /* JMP with ABSL LONG offset */ | |
3142 | subseg_change(SEG_TEXT, 0); | |
3143 | fix_new(fragP, fragP->fr_fix, 4, | |
3144 | fragP->fr_symbol, 0, fragP->fr_offset, 0, NO_RELOC); | |
3145 | fragP->fr_fix+=4; | |
3146 | frag_wane(fragP); | |
3147 | } else { | |
3148 | as_warn("Long branch offset to extern symbol not supported."); | |
3149 | } | |
3150 | } else { /* Symbol is still undefined. Make it simple */ | |
3151 | fix_new(fragP, (int)(fragP->fr_fix), 4, fragP->fr_symbol, | |
3152 | (symbolS *)0, fragP->fr_offset+4, 1, NO_RELOC); | |
3153 | fragP->fr_fix+=4; | |
3154 | fragP->fr_opcode[1]=0xff; | |
3155 | frag_wane(fragP); | |
3156 | break; | |
3157 | } | |
3158 | ||
3159 | break; | |
3160 | } /* case TAB(BRANCH,SZ_UNDEF) */ | |
3161 | ||
3162 | case TAB(FBRANCH,SZ_UNDEF): { | |
3163 | if(S_GET_SEGMENT(fragP->fr_symbol) == segment || flagseen['l']) { | |
3164 | fragP->fr_subtype = TAB(FBRANCH,SHORT); | |
3165 | fragP->fr_var += 2; | |
3166 | } else { | |
3167 | fragP->fr_subtype = TAB(FBRANCH,LONG); | |
3168 | fragP->fr_var += 4; | |
3169 | } | |
3170 | break; | |
3171 | } /* TAB(FBRANCH,SZ_UNDEF) */ | |
3172 | ||
3173 | case TAB(PCREL,SZ_UNDEF): { | |
3174 | if(S_GET_SEGMENT(fragP->fr_symbol) == segment || flagseen['l']) { | |
3175 | fragP->fr_subtype = TAB(PCREL,SHORT); | |
3176 | fragP->fr_var += 2; | |
3177 | } else { | |
3178 | fragP->fr_subtype = TAB(PCREL,LONG); | |
3179 | fragP->fr_var += 4; | |
3180 | } | |
3181 | break; | |
3182 | } /* TAB(PCREL,SZ_UNDEF) */ | |
3183 | ||
3184 | case TAB(BCC68000,SZ_UNDEF): { | |
3185 | if((fragP->fr_symbol != NULL) | |
3186 | && S_GET_SEGMENT(fragP->fr_symbol) == segment) { | |
3187 | fragP->fr_subtype=TAB(BCC68000,BYTE); | |
3188 | break; | |
3189 | } | |
3190 | /* only Bcc 68000 instructions can come here */ | |
3191 | /* change bcc into b!cc/jmp absl long */ | |
3192 | fragP->fr_opcode[0] ^= 0x01; /* invert bcc */ | |
3193 | if(flagseen['l']) { | |
3194 | fragP->fr_opcode[1] = 0x04; /* branch offset = 6 */ | |
3195 | /* JF: these were fr_opcode[2,3] */ | |
3196 | buffer_address[0] = 0x4e; /* put in jmp long (0x4ef9) */ | |
3197 | buffer_address[1] = 0xf8; | |
3198 | fragP->fr_fix += 2; /* account for jmp instruction */ | |
3199 | subseg_change(SEG_TEXT,0); | |
3200 | fix_new(fragP, fragP->fr_fix, 2, fragP->fr_symbol, 0, | |
3201 | fragP->fr_offset, 0, NO_RELOC); | |
3202 | fragP->fr_fix += 2; | |
3203 | } else { | |
3204 | fragP->fr_opcode[1] = 0x06; /* branch offset = 6 */ | |
3205 | /* JF: these were fr_opcode[2,3] */ | |
3206 | buffer_address[2] = 0x4e; /* put in jmp long (0x4ef9) */ | |
3207 | buffer_address[3] = 0xf9; | |
3208 | fragP->fr_fix += 2; /* account for jmp instruction */ | |
3209 | subseg_change(SEG_TEXT,0); | |
3210 | fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, | |
3211 | fragP->fr_offset, 0, NO_RELOC); | |
3212 | fragP->fr_fix += 4; | |
3213 | } | |
3214 | frag_wane(fragP); | |
3215 | break; | |
3216 | } /* case TAB(BCC68000,SZ_UNDEF) */ | |
3217 | ||
3218 | case TAB(DBCC,SZ_UNDEF): { | |
3219 | if (fragP->fr_symbol != NULL && S_GET_SEGMENT(fragP->fr_symbol) == segment) { | |
3220 | fragP->fr_subtype=TAB(DBCC,SHORT); | |
3221 | fragP->fr_var+=2; | |
3222 | break; | |
3223 | } | |
3224 | /* only DBcc 68000 instructions can come here */ | |
3225 | /* change dbcc into dbcc/jmp absl long */ | |
3226 | /* JF: these used to be fr_opcode[2-4], which is wrong. */ | |
3227 | buffer_address[0] = 0x00; /* branch offset = 4 */ | |
3228 | buffer_address[1] = 0x04; | |
3229 | buffer_address[2] = 0x60; /* put in bra pc + ... */ | |
3230 | ||
3231 | if(flagseen['l']) { | |
3232 | /* JF: these were fr_opcode[5-7] */ | |
3233 | buffer_address[3] = 0x04; /* plus 4 */ | |
3234 | buffer_address[4] = 0x4e;/* Put in Jump Word */ | |
3235 | buffer_address[5] = 0xf8; | |
3236 | fragP->fr_fix += 6; /* account for bra/jmp instruction */ | |
3237 | subseg_change(SEG_TEXT,0); | |
3238 | fix_new(fragP, fragP->fr_fix, 2, fragP->fr_symbol, 0, | |
3239 | fragP->fr_offset, 0, NO_RELOC); | |
3240 | fragP->fr_fix += 2; | |
3241 | } else { | |
3242 | /* JF: these were fr_opcode[5-7] */ | |
3243 | buffer_address[3] = 0x06; /* Plus 6 */ | |
3244 | buffer_address[4] = 0x4e; /* put in jmp long (0x4ef9) */ | |
3245 | buffer_address[5] = 0xf9; | |
3246 | fragP->fr_fix += 6; /* account for bra/jmp instruction */ | |
3247 | subseg_change(SEG_TEXT,0); | |
3248 | fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, | |
3249 | fragP->fr_offset, 0, NO_RELOC); | |
3250 | fragP->fr_fix += 4; | |
3251 | } | |
3252 | ||
3253 | frag_wane(fragP); | |
3254 | break; | |
3255 | } /* case TAB(DBCC,SZ_UNDEF) */ | |
3256 | ||
3257 | case TAB(PCLEA,SZ_UNDEF): { | |
3258 | if ((S_GET_SEGMENT(fragP->fr_symbol))==segment || flagseen['l']) { | |
3259 | fragP->fr_subtype=TAB(PCLEA,SHORT); | |
3260 | fragP->fr_var+=2; | |
3261 | } else { | |
3262 | fragP->fr_subtype=TAB(PCLEA,LONG); | |
3263 | fragP->fr_var+=6; | |
3264 | } | |
3265 | break; | |
3266 | } /* TAB(PCLEA,SZ_UNDEF) */ | |
3267 | ||
3268 | default: | |
3269 | break; | |
3270 | ||
3271 | } /* switch on subtype looking for SZ_UNDEF's. */ | |
a39116f1 | 3272 | |
f8701a3f SC |
3273 | /* now that SZ_UNDEF are taken care of, check others */ |
3274 | switch (fragP->fr_subtype) { | |
3275 | case TAB(BCC68000,BYTE): | |
a39116f1 RP |
3276 | case TAB(BRANCH,BYTE): |
3277 | /* We can't do a short jump to the next instruction, | |
3278 | so we force word mode. */ | |
3279 | if (fragP->fr_symbol && S_GET_VALUE(fragP->fr_symbol)==0 && | |
3280 | fragP->fr_symbol->sy_frag==fragP->fr_next) { | |
f8701a3f SC |
3281 | fragP->fr_subtype=TAB(TABTYPE(fragP->fr_subtype),SHORT); |
3282 | fragP->fr_var+=2; | |
fecd2382 | 3283 | } |
a39116f1 | 3284 | break; |
f8701a3f | 3285 | default: |
a39116f1 | 3286 | break; |
f8701a3f SC |
3287 | } |
3288 | return fragP->fr_var + fragP->fr_fix - old_fix; | |
fecd2382 RP |
3289 | } |
3290 | ||
3291 | #if defined(OBJ_AOUT) | defined(OBJ_BOUT) | |
3292 | /* the bit-field entries in the relocation_info struct plays hell | |
3293 | with the byte-order problems of cross-assembly. So as a hack, | |
3294 | I added this mach. dependent ri twiddler. Ugly, but it gets | |
3295 | you there. -KWK */ | |
3296 | /* on m68k: first 4 bytes are normal unsigned long, next three bytes | |
a39116f1 RP |
3297 | are symbolnum, most sig. byte first. Last byte is broken up with |
3298 | bit 7 as pcrel, bits 6 & 5 as length, bit 4 as pcrel, and the lower | |
3299 | nibble as nuthin. (on Sun 3 at least) */ | |
fecd2382 RP |
3300 | /* Translate the internal relocation information into target-specific |
3301 | format. */ | |
a79c6033 | 3302 | #ifdef comment |
fecd2382 | 3303 | void |
a39116f1 RP |
3304 | md_ri_to_chars(the_bytes, ri) |
3305 | char *the_bytes; | |
3306 | struct reloc_info_generic *ri; | |
fecd2382 | 3307 | { |
f8701a3f SC |
3308 | /* this is easy */ |
3309 | md_number_to_chars(the_bytes, ri->r_address, 4); | |
3310 | /* now the fun stuff */ | |
3311 | the_bytes[4] = (ri->r_symbolnum >> 16) & 0x0ff; | |
3312 | the_bytes[5] = (ri->r_symbolnum >> 8) & 0x0ff; | |
3313 | the_bytes[6] = ri->r_symbolnum & 0x0ff; | |
3314 | the_bytes[7] = (((ri->r_pcrel << 7) & 0x80) | ((ri->r_length << 5) & 0x60) | | |
3315 | ((ri->r_extern << 4) & 0x10)); | |
fecd2382 | 3316 | } |
a79c6033 RP |
3317 | #endif /* comment */ |
3318 | ||
3319 | void tc_aout_fix_to_chars(where, fixP, segment_address_in_file) | |
f8701a3f SC |
3320 | char *where; |
3321 | fixS *fixP; | |
3322 | relax_addressT segment_address_in_file; | |
a79c6033 | 3323 | { |
f8701a3f SC |
3324 | /* |
3325 | * In: length of relocation (or of address) in chars: 1, 2 or 4. | |
3326 | * Out: GNU LD relocation length code: 0, 1, or 2. | |
3327 | */ | |
3328 | ||
3329 | static unsigned char nbytes_r_length [] = { 42, 0, 1, 42, 2 }; | |
3330 | long r_symbolnum; | |
3331 | ||
3332 | know(fixP->fx_addsy != NULL); | |
3333 | ||
3334 | md_number_to_chars(where, | |
3335 | fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file, | |
3336 | 4); | |
3337 | ||
3338 | r_symbolnum = (S_IS_DEFINED(fixP->fx_addsy) | |
3339 | ? S_GET_TYPE(fixP->fx_addsy) | |
3340 | : fixP->fx_addsy->sy_number); | |
3341 | ||
3342 | where[4] = (r_symbolnum >> 16) & 0x0ff; | |
3343 | where[5] = (r_symbolnum >> 8) & 0x0ff; | |
3344 | where[6] = r_symbolnum & 0x0ff; | |
3345 | where[7] = (((fixP->fx_pcrel << 7) & 0x80) | ((nbytes_r_length[fixP->fx_size] << 5) & 0x60) | | |
3346 | (((!S_IS_DEFINED(fixP->fx_addsy)) << 4) & 0x10)); | |
3347 | ||
3348 | return; | |
a79c6033 RP |
3349 | } /* tc_aout_fix_to_chars() */ |
3350 | ||
fecd2382 RP |
3351 | #endif /* OBJ_AOUT or OBJ_BOUT */ |
3352 | ||
3353 | #ifndef WORKING_DOT_WORD | |
3354 | const int md_short_jump_size = 4; | |
3355 | const int md_long_jump_size = 6; | |
3356 | ||
3357 | void | |
a39116f1 | 3358 | md_create_short_jump(ptr,from_addr,to_addr,frag,to_symbol) |
fecd2382 RP |
3359 | char *ptr; |
3360 | long from_addr, | |
a39116f1 | 3361 | to_addr; |
fecd2382 RP |
3362 | fragS *frag; |
3363 | symbolS *to_symbol; | |
3364 | { | |
f8701a3f SC |
3365 | long offset; |
3366 | ||
3367 | offset = to_addr - (from_addr+2); | |
3368 | ||
3369 | md_number_to_chars(ptr ,(long)0x6000,2); | |
3370 | md_number_to_chars(ptr+2,(long)offset,2); | |
fecd2382 RP |
3371 | } |
3372 | ||
3373 | void | |
a39116f1 | 3374 | md_create_long_jump(ptr,from_addr,to_addr,frag,to_symbol) |
fecd2382 RP |
3375 | char *ptr; |
3376 | long from_addr, | |
a39116f1 | 3377 | to_addr; |
fecd2382 RP |
3378 | fragS *frag; |
3379 | symbolS *to_symbol; | |
3380 | { | |
f8701a3f SC |
3381 | long offset; |
3382 | ||
3383 | if (cpu_of_arch(current_architecture) < m68020) { | |
3384 | offset=to_addr-S_GET_VALUE(to_symbol); | |
3385 | md_number_to_chars(ptr ,(long)0x4EF9,2); | |
3386 | md_number_to_chars(ptr+2,(long)offset,4); | |
3387 | fix_new(frag,(ptr+2)-frag->fr_literal,4,to_symbol,(symbolS *)0,(long)0,0, | |
3388 | NO_RELOC); | |
3389 | } else { | |
3390 | offset=to_addr - (from_addr+2); | |
3391 | md_number_to_chars(ptr ,(long)0x60ff,2); | |
3392 | md_number_to_chars(ptr+2,(long)offset,4); | |
3393 | } | |
fecd2382 RP |
3394 | } |
3395 | ||
3396 | #endif | |
3397 | /* Different values of OK tell what its OK to return. Things that aren't OK are an error (what a shock, no?) | |
a39116f1 RP |
3398 | |
3399 | 0: Everything is OK | |
3400 | 10: Absolute 1:8 only | |
3401 | 20: Absolute 0:7 only | |
3402 | 30: absolute 0:15 only | |
3403 | 40: Absolute 0:31 only | |
3404 | 50: absolute 0:127 only | |
3405 | 55: absolute -64:63 only | |
3406 | 60: absolute -128:127 only | |
3407 | 70: absolute 0:4095 only | |
3408 | 80: No bignums | |
3409 | ||
3410 | */ | |
fecd2382 RP |
3411 | |
3412 | static int get_num(exp,ok) | |
f8701a3f SC |
3413 | struct m68k_exp *exp; |
3414 | int ok; | |
fecd2382 RP |
3415 | { |
3416 | #ifdef TEST2 | |
f8701a3f SC |
3417 | long l = 0; |
3418 | ||
3419 | if(!exp->e_beg) | |
3420 | return 0; | |
3421 | if(*exp->e_beg=='0') { | |
3422 | if(exp->e_beg[1]=='x') | |
3423 | sscanf(exp->e_beg+2,"%x",&l); | |
3424 | else | |
3425 | sscanf(exp->e_beg+1,"%O",&l); | |
3426 | return l; | |
3427 | } | |
3428 | return atol(exp->e_beg); | |
fecd2382 | 3429 | #else |
f8701a3f SC |
3430 | char *save_in; |
3431 | char c_save; | |
3432 | ||
3433 | if(!exp) { | |
3434 | /* Can't do anything */ | |
3435 | return 0; | |
3436 | } | |
3437 | if(!exp->e_beg || !exp->e_end) { | |
3438 | seg(exp)=SEG_ABSOLUTE; | |
3439 | adds(exp)=0; | |
3440 | subs(exp)=0; | |
3441 | offs(exp)= (ok==10) ? 1 : 0; | |
3442 | as_warn("Null expression defaults to %ld",offs(exp)); | |
3443 | return 0; | |
fecd2382 | 3444 | } |
a39116f1 | 3445 | |
f8701a3f SC |
3446 | exp->e_siz=0; |
3447 | if(/* ok!=80 && */exp->e_end[-1]==':' && (exp->e_end-exp->e_beg)>=2) { | |
3448 | switch(exp->e_end[0]) { | |
3449 | case 's': | |
3450 | case 'S': | |
3451 | case 'b': | |
3452 | case 'B': | |
3453 | exp->e_siz=1; | |
3454 | break; | |
3455 | case 'w': | |
3456 | case 'W': | |
3457 | exp->e_siz=2; | |
3458 | break; | |
3459 | case 'l': | |
3460 | case 'L': | |
3461 | exp->e_siz=3; | |
3462 | break; | |
3463 | default: | |
3464 | as_bad("Unknown size for expression \"%c\"",exp->e_end[0]); | |
3465 | } | |
3466 | exp->e_end-=2; | |
fecd2382 | 3467 | } |
f8701a3f SC |
3468 | c_save=exp->e_end[1]; |
3469 | exp->e_end[1]='\0'; | |
3470 | save_in=input_line_pointer; | |
3471 | input_line_pointer=exp->e_beg; | |
3472 | switch(expression(&(exp->e_exp))) { | |
3473 | case SEG_PASS1: | |
3474 | seg(exp)=SEG_ABSOLUTE; | |
3475 | adds(exp)=0; | |
3476 | subs(exp)=0; | |
3477 | offs(exp)= (ok==10) ? 1 : 0; | |
3478 | as_warn("Unknown expression: '%s' defaulting to %d",exp->e_beg,offs(exp)); | |
3479 | break; | |
3480 | ||
3481 | case SEG_ABSENT: | |
3482 | /* Do the same thing the VAX asm does */ | |
3483 | seg(exp)=SEG_ABSOLUTE; | |
3484 | adds(exp)=0; | |
3485 | subs(exp)=0; | |
fecd2382 | 3486 | offs(exp)=0; |
f8701a3f SC |
3487 | if(ok==10) { |
3488 | as_warn("expression out of range: defaulting to 1"); | |
3489 | offs(exp)=1; | |
3490 | } | |
3491 | break; | |
3492 | case SEG_ABSOLUTE: | |
3493 | switch(ok) { | |
3494 | case 10: | |
3495 | if(offs(exp)<1 || offs(exp)>8) { | |
3496 | as_warn("expression out of range: defaulting to 1"); | |
3497 | offs(exp)=1; | |
3498 | } | |
3499 | break; | |
3500 | case 20: | |
3501 | if(offs(exp)<0 || offs(exp)>7) | |
3502 | goto outrange; | |
3503 | break; | |
3504 | case 30: | |
3505 | if(offs(exp)<0 || offs(exp)>15) | |
3506 | goto outrange; | |
3507 | break; | |
3508 | case 40: | |
3509 | if(offs(exp)<0 || offs(exp)>32) | |
3510 | goto outrange; | |
3511 | break; | |
3512 | case 50: | |
3513 | if(offs(exp)<0 || offs(exp)>127) | |
3514 | goto outrange; | |
3515 | break; | |
3516 | case 55: | |
3517 | if(offs(exp)<-64 || offs(exp)>63) | |
3518 | goto outrange; | |
3519 | break; | |
3520 | case 60: | |
3521 | if(offs(exp)<-128 || offs(exp)>127) | |
3522 | goto outrange; | |
3523 | break; | |
3524 | case 70: | |
3525 | if(offs(exp)<0 || offs(exp)>4095) { | |
3526 | outrange: | |
3527 | as_warn("expression out of range: defaulting to 0"); | |
3528 | offs(exp)=0; | |
3529 | } | |
3530 | break; | |
3531 | default: | |
3532 | break; | |
3533 | } | |
3534 | break; | |
3535 | case SEG_TEXT: | |
3536 | case SEG_DATA: | |
3537 | case SEG_BSS: | |
3538 | case SEG_UNKNOWN: | |
3539 | case SEG_DIFFERENCE: | |
3540 | if(ok>=10 && ok<=70) { | |
3541 | seg(exp)=SEG_ABSOLUTE; | |
3542 | adds(exp)=0; | |
3543 | subs(exp)=0; | |
3544 | offs(exp)= (ok==10) ? 1 : 0; | |
3545 | as_warn("Can't deal with expression \"%s\": defaulting to %ld",exp->e_beg,offs(exp)); | |
3546 | } | |
3547 | break; | |
3548 | case SEG_BIG: | |
3549 | if(ok==80 && offs(exp)<0) { /* HACK! Turn it into a long */ | |
3550 | LITTLENUM_TYPE words[6]; | |
3551 | ||
3552 | gen_to_words(words,2,8L);/* These numbers are magic! */ | |
3553 | seg(exp)=SEG_ABSOLUTE; | |
3554 | adds(exp)=0; | |
3555 | subs(exp)=0; | |
3556 | offs(exp)=words[1]|(words[0]<<16); | |
3557 | } else if(ok!=0) { | |
3558 | seg(exp)=SEG_ABSOLUTE; | |
3559 | adds(exp)=0; | |
3560 | subs(exp)=0; | |
3561 | offs(exp)= (ok==10) ? 1 : 0; | |
3562 | as_warn("Can't deal with expression \"%s\": defaulting to %ld",exp->e_beg,offs(exp)); | |
3563 | } | |
3564 | break; | |
fecd2382 | 3565 | default: |
f8701a3f | 3566 | as_fatal("failed sanity check."); |
a39116f1 | 3567 | } |
f8701a3f SC |
3568 | if(input_line_pointer!=exp->e_end+1) |
3569 | as_bad("Ignoring junk after expression"); | |
3570 | exp->e_end[1]=c_save; | |
3571 | input_line_pointer=save_in; | |
3572 | if(exp->e_siz) { | |
3573 | switch(exp->e_siz) { | |
3574 | case 1: | |
3575 | if(!isbyte(offs(exp))) | |
3576 | as_warn("expression doesn't fit in BYTE"); | |
3577 | break; | |
3578 | case 2: | |
3579 | if(!isword(offs(exp))) | |
3580 | as_warn("expression doesn't fit in WORD"); | |
3581 | break; | |
3582 | } | |
a39116f1 | 3583 | } |
f8701a3f | 3584 | return offs(exp); |
fecd2382 RP |
3585 | #endif |
3586 | } /* get_num() */ | |
3587 | ||
3588 | /* These are the back-ends for the various machine dependent pseudo-ops. */ | |
f6e504fe | 3589 | void demand_empty_rest_of_line(); /* Hate those extra verbose names */ |
fecd2382 RP |
3590 | |
3591 | static void s_data1() { | |
f8701a3f SC |
3592 | subseg_new(SEG_DATA,1); |
3593 | demand_empty_rest_of_line(); | |
fecd2382 RP |
3594 | } /* s_data1() */ |
3595 | ||
3596 | static void s_data2() { | |
f8701a3f SC |
3597 | subseg_new(SEG_DATA,2); |
3598 | demand_empty_rest_of_line(); | |
fecd2382 RP |
3599 | } /* s_data2() */ |
3600 | ||
3601 | static void s_bss() { | |
f8701a3f SC |
3602 | /* We don't support putting frags in the BSS segment, but we |
3603 | can put them into initialized data for now... */ | |
3604 | subseg_new(SEG_DATA,255); /* FIXME-SOON */ | |
3605 | demand_empty_rest_of_line(); | |
fecd2382 RP |
3606 | } /* s_bss() */ |
3607 | ||
3608 | static void s_even() { | |
f8701a3f SC |
3609 | register int temp; |
3610 | register long temp_fill; | |
3611 | ||
3612 | temp = 1; /* JF should be 2? */ | |
3613 | temp_fill = get_absolute_expression (); | |
3614 | if ( ! need_pass_2 ) /* Never make frag if expect extra pass. */ | |
3615 | frag_align (temp, (int)temp_fill); | |
3616 | demand_empty_rest_of_line(); | |
fecd2382 RP |
3617 | } /* s_even() */ |
3618 | ||
3619 | static void s_proc() { | |
f8701a3f | 3620 | demand_empty_rest_of_line(); |
fecd2382 RP |
3621 | } /* s_proc() */ |
3622 | ||
3623 | /* s_space is defined in read.c .skip is simply an alias to it. */ | |
3624 | ||
7c15cbe8 RP |
3625 | /* |
3626 | * md_parse_option | |
3627 | * Invocation line includes a switch not recognized by the base assembler. | |
3628 | * See if it's a processor-specific option. These are: | |
3629 | * | |
3630 | * -[A]m[c]68000, -[A]m[c]68008, -[A]m[c]68010, -[A]m[c]68020, -[A]m[c]68030, -[A]m[c]68040 | |
3631 | * -[A]m[c]68881, -[A]m[c]68882, -[A]m[c]68851 | |
3632 | * Select the architecture. Instructions or features not | |
3633 | * supported by the selected architecture cause fatal | |
3634 | * errors. More than one may be specified. The default is | |
3635 | * -m68020 -m68851 -m68881. Note that -m68008 is a synonym | |
3636 | * for -m68000, and -m68882 is a synonym for -m68881. | |
3637 | * | |
a39116f1 RP |
3638 | * MAYBE_FLOAT_TOO is defined below so that specifying a processor type |
3639 | * (e.g. m68020) also requests that float instructions be included. This | |
3640 | * is the default setup, mostly to avoid hassling users. A better | |
3641 | * rearrangement of this structure would be to add an option to DENY | |
3642 | * floating point opcodes, for people who want to really know there's none | |
3643 | * of that funny floaty stuff going on. FIXME-later. | |
7c15cbe8 | 3644 | */ |
a39116f1 RP |
3645 | #ifndef MAYBE_FLOAT_TOO |
3646 | #define MAYBE_FLOAT_TOO m68881 | |
3647 | #endif | |
7c15cbe8 RP |
3648 | |
3649 | int md_parse_option(argP,cntP,vecP) | |
f8701a3f SC |
3650 | char **argP; |
3651 | int *cntP; | |
3652 | char ***vecP; | |
fecd2382 | 3653 | { |
f8701a3f SC |
3654 | switch(**argP) { |
3655 | case 'l': /* -l means keep external to 2 bit offset | |
3656 | rather than 16 bit one */ | |
3657 | break; | |
3658 | ||
3659 | case 'S': /* -S means that jbsr's always turn into jsr's. */ | |
3660 | break; | |
3661 | ||
3662 | case 'A': | |
3663 | (*argP)++; | |
3664 | /* intentional fall-through */ | |
3665 | case 'm': | |
3666 | (*argP)++; | |
3667 | ||
3668 | if (**argP=='c') { | |
3669 | (*argP)++; | |
3670 | } /* allow an optional "c" */ | |
3671 | ||
3672 | if (!strcmp(*argP, "68000") | |
3673 | || !strcmp(*argP, "68008")) { | |
3674 | current_architecture |= m68000; | |
3675 | } else if (!strcmp(*argP, "68010")) { | |
fecd2382 | 3676 | #ifdef TE_SUN |
f8701a3f | 3677 | omagic= 1<<16|OMAGIC; |
fecd2382 | 3678 | #endif |
f8701a3f SC |
3679 | current_architecture |= m68010; |
3680 | ||
3681 | } else if (!strcmp(*argP, "68020")) { | |
3682 | current_architecture |= m68020 | MAYBE_FLOAT_TOO; | |
3683 | ||
3684 | } else if (!strcmp(*argP, "68030")) { | |
3685 | current_architecture |= m68030 | MAYBE_FLOAT_TOO; | |
3686 | ||
3687 | } else if (!strcmp(*argP, "68040")) { | |
3688 | current_architecture |= m68040 | MAYBE_FLOAT_TOO; | |
3689 | ||
7c15cbe8 | 3690 | #ifndef NO_68881 |
f8701a3f SC |
3691 | } else if (!strcmp(*argP, "68881")) { |
3692 | current_architecture |= m68881; | |
3693 | ||
3694 | } else if (!strcmp(*argP, "68882")) { | |
3695 | current_architecture |= m68882; | |
3696 | ||
7c15cbe8 RP |
3697 | #endif /* NO_68881 */ |
3698 | #ifndef NO_68851 | |
f8701a3f SC |
3699 | } else if (!strcmp(*argP,"68851")) { |
3700 | current_architecture |= m68851; | |
3701 | ||
7c15cbe8 | 3702 | #endif /* NO_68851 */ |
f8701a3f SC |
3703 | } else { |
3704 | as_warn("Unknown architecture, \"%s\". option ignored", *argP); | |
3705 | } /* switch on architecture */ | |
3706 | ||
3707 | while(**argP) (*argP)++; | |
3708 | ||
3709 | break; | |
3710 | ||
3711 | case 'p': | |
3712 | if (!strcmp(*argP,"pic")) { | |
3713 | (*argP) += 3; | |
3714 | break; /* -pic, Position Independent Code */ | |
3715 | } else { | |
3716 | return(0); | |
3717 | } /* pic or not */ | |
3718 | ||
3719 | default: | |
3720 | return 0; | |
3721 | } | |
3722 | return 1; | |
fecd2382 RP |
3723 | } |
3724 | ||
3725 | ||
3726 | #ifdef TEST2 | |
3727 | ||
3728 | /* TEST2: Test md_assemble() */ | |
3729 | /* Warning, this routine probably doesn't work anymore */ | |
3730 | ||
3731 | main() | |
3732 | { | |
f8701a3f SC |
3733 | struct m68k_it the_ins; |
3734 | char buf[120]; | |
3735 | char *cp; | |
3736 | int n; | |
3737 | ||
3738 | m68k_ip_begin(); | |
3739 | for(;;) { | |
3740 | if(!gets(buf) || !*buf) | |
3741 | break; | |
3742 | if(buf[0]=='|' || buf[1]=='.') | |
3743 | continue; | |
3744 | for(cp=buf;*cp;cp++) | |
3745 | if(*cp=='\t') | |
3746 | *cp=' '; | |
3747 | if(is_label(buf)) | |
3748 | continue; | |
3749 | memset(&the_ins, '\0', sizeof(the_ins)); | |
3750 | m68k_ip(&the_ins,buf); | |
3751 | if(the_ins.error) { | |
3752 | printf("Error %s in %s\n",the_ins.error,buf); | |
3753 | } else { | |
3754 | printf("Opcode(%d.%s): ",the_ins.numo,the_ins.args); | |
3755 | for(n=0;n<the_ins.numo;n++) | |
3756 | printf(" 0x%x",the_ins.opcode[n]&0xffff); | |
3757 | printf(" "); | |
3758 | print_the_insn(&the_ins.opcode[0],stdout); | |
3759 | (void)putchar('\n'); | |
3760 | } | |
3761 | for(n=0;n<strlen(the_ins.args)/2;n++) { | |
3762 | if(the_ins.operands[n].error) { | |
3763 | printf("op%d Error %s in %s\n",n,the_ins.operands[n].error,buf); | |
3764 | continue; | |
3765 | } | |
3766 | printf("mode %d, reg %d, ",the_ins.operands[n].mode,the_ins.operands[n].reg); | |
3767 | if(the_ins.operands[n].b_const) | |
3768 | printf("Constant: '%.*s', ",1+the_ins.operands[n].e_const-the_ins.operands[n].b_const,the_ins.operands[n].b_const); | |
3769 | printf("ireg %d, isiz %d, imul %d, ",the_ins.operands[n].ireg,the_ins.operands[n].isiz,the_ins.operands[n].imul); | |
3770 | if(the_ins.operands[n].b_iadd) | |
3771 | printf("Iadd: '%.*s',",1+the_ins.operands[n].e_iadd-the_ins.operands[n].b_iadd,the_ins.operands[n].b_iadd); | |
3772 | (void)putchar('\n'); | |
3773 | } | |
a39116f1 | 3774 | } |
f8701a3f SC |
3775 | m68k_ip_end(); |
3776 | return 0; | |
fecd2382 RP |
3777 | } |
3778 | ||
3779 | is_label(str) | |
f8701a3f | 3780 | char *str; |
fecd2382 | 3781 | { |
f8701a3f SC |
3782 | while(*str==' ') |
3783 | str++; | |
3784 | while(*str && *str!=' ') | |
3785 | str++; | |
3786 | if(str[-1]==':' || str[1]=='=') | |
3787 | return 1; | |
3788 | return 0; | |
fecd2382 RP |
3789 | } |
3790 | ||
3791 | #endif | |
3792 | ||
3793 | /* Possible states for relaxation: | |
a39116f1 RP |
3794 | |
3795 | 0 0 branch offset byte (bra, etc) | |
3796 | 0 1 word | |
3797 | 0 2 long | |
3798 | ||
3799 | 1 0 indexed offsets byte a0@(32,d4:w:1) etc | |
3800 | 1 1 word | |
3801 | 1 2 long | |
3802 | ||
3803 | 2 0 two-offset index word-word a0@(32,d4)@(45) etc | |
3804 | 2 1 word-long | |
3805 | 2 2 long-word | |
3806 | 2 3 long-long | |
3807 | ||
3808 | */ | |
fecd2382 RP |
3809 | |
3810 | ||
3811 | ||
3812 | #ifdef DONTDEF | |
3813 | abort() | |
3814 | { | |
f8701a3f SC |
3815 | printf("ABORT!\n"); |
3816 | exit(12); | |
fecd2382 RP |
3817 | } |
3818 | ||
3819 | print_frags() | |
3820 | { | |
f8701a3f SC |
3821 | fragS *fragP; |
3822 | extern fragS *text_frag_root; | |
3823 | ||
3824 | for(fragP=text_frag_root;fragP;fragP=fragP->fr_next) { | |
3825 | printf("addr %lu next 0x%x fix %ld var %ld symbol 0x%x offset %ld\n", | |
3826 | fragP->fr_address,fragP->fr_next,fragP->fr_fix,fragP->fr_var,fragP->fr_symbol,fragP->fr_offset); | |
3827 | printf("opcode 0x%x type %d subtype %d\n\n",fragP->fr_opcode,fragP->fr_type,fragP->fr_subtype); | |
3828 | } | |
3829 | fflush(stdout); | |
3830 | return 0; | |
fecd2382 RP |
3831 | } |
3832 | #endif | |
3833 | ||
3834 | #ifdef DONTDEF | |
3835 | /*VARARGS1*/ | |
3836 | panic(format,args) | |
f8701a3f | 3837 | char *format; |
fecd2382 | 3838 | { |
f8701a3f SC |
3839 | fputs("Internal error:",stderr); |
3840 | _doprnt(format,&args,stderr); | |
3841 | (void)putc('\n',stderr); | |
3842 | as_where(); | |
3843 | abort(); | |
fecd2382 RP |
3844 | } |
3845 | #endif | |
3846 | ||
3847 | /* We have no need to default values of symbols. */ | |
3848 | ||
3849 | /* ARGSUSED */ | |
3850 | symbolS * | |
a39116f1 RP |
3851 | md_undefined_symbol (name) |
3852 | char *name; | |
fecd2382 | 3853 | { |
f8701a3f | 3854 | return 0; |
fecd2382 RP |
3855 | } |
3856 | ||
3857 | /* Parse an operand that is machine-specific. | |
3858 | We just return without modifying the expression if we have nothing | |
3859 | to do. */ | |
3860 | ||
3861 | /* ARGSUSED */ | |
3862 | void | |
a39116f1 RP |
3863 | md_operand (expressionP) |
3864 | expressionS *expressionP; | |
fecd2382 RP |
3865 | { |
3866 | } | |
3867 | ||
3868 | /* Round up a section size to the appropriate boundary. */ | |
3869 | long | |
a39116f1 RP |
3870 | md_section_align (segment, size) |
3871 | segT segment; | |
3872 | long size; | |
fecd2382 | 3873 | { |
f8701a3f | 3874 | return size; /* Byte alignment is fine */ |
fecd2382 RP |
3875 | } |
3876 | ||
3877 | /* Exactly what point is a PC-relative offset relative TO? | |
3878 | On the 68k, they're relative to the address of the offset, plus | |
3879 | its size. (??? Is this right? FIXME-SOON!) */ | |
3880 | long | |
a39116f1 RP |
3881 | md_pcrel_from (fixP) |
3882 | fixS *fixP; | |
fecd2382 | 3883 | { |
f8701a3f | 3884 | return(fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address); |
fecd2382 RP |
3885 | } |
3886 | ||
fecd2382 RP |
3887 | /* |
3888 | * Local Variables: | |
3889 | * comment-column: 0 | |
3890 | * fill-column: 131 | |
3891 | * End: | |
3892 | */ | |
3893 | ||
3894 | /* end of tc-m68k.c */ |