1 /* tc-m68k.c -- Assemble for the m68k family
2 Copyright 1987, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
23 #include "safe-ctype.h"
26 #include "dwarf2dbg.h"
27 #include "dw2gencfi.h"
29 #include "opcode/m68k.h"
30 #include "m68k-parse.h"
40 /* This string holds the chars that always start a comment. If the
41 pre-processor is disabled, these aren't very useful. The macro
42 tc_comment_chars points to this. We use this, rather than the
43 usual comment_chars, so that the --bitwise-or option will work. */
44 #if defined (TE_SVR4) || defined (TE_DELTA)
45 const char *m68k_comment_chars = "|#";
47 const char *m68k_comment_chars = "|";
50 /* This array holds the chars that only start a comment at the beginning of
51 a line. If the line seems to have the form '# 123 filename'
52 .line and .file directives will appear in the pre-processed output */
53 /* Note that input_file.c hand checks for '#' at the beginning of the
54 first line of the input file. This is because the compiler outputs
55 #NO_APP at the beginning of its output. */
56 /* Also note that comments like this one will always work. */
57 const char line_comment_chars[] = "#*";
59 const char line_separator_chars[] = ";";
61 /* Chars that can be used to separate mant from exp in floating point nums. */
62 const char EXP_CHARS[] = "eE";
64 /* Chars that mean this number is a floating point constant, as
65 in "0f12.456" or "0d1.2345e12". */
67 const char FLT_CHARS[] = "rRsSfFdDxXeEpP";
69 /* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
70 changed in read.c . Ideally it shouldn't have to know about it at all,
71 but nothing is ideal around here. */
73 /* Are we trying to generate PIC code? If so, absolute references
74 ought to be made into linkage table references or pc-relative
75 references. Not implemented. For ELF there are other means
76 to denote pic relocations. */
79 static int flag_short_refs; /* -l option. */
80 static int flag_long_jumps; /* -S option. */
81 static int flag_keep_pcrel; /* --pcrel option. */
83 #ifdef REGISTER_PREFIX_OPTIONAL
84 int flag_reg_prefix_optional = REGISTER_PREFIX_OPTIONAL;
86 int flag_reg_prefix_optional;
89 /* Whether --register-prefix-optional was used on the command line. */
90 static int reg_prefix_optional_seen;
92 /* The floating point coprocessor to use by default. */
93 static enum m68k_register m68k_float_copnum = COP1;
95 /* If this is non-zero, then references to number(%pc) will be taken
96 to refer to number, rather than to %pc + number. */
97 static int m68k_abspcadd;
99 /* If this is non-zero, then the quick forms of the move, add, and sub
100 instructions are used when possible. */
101 static int m68k_quick = 1;
103 /* If this is non-zero, then if the size is not specified for a base
104 or outer displacement, the assembler assumes that the size should
106 static int m68k_rel32 = 1;
108 /* This is non-zero if m68k_rel32 was set from the command line. */
109 static int m68k_rel32_from_cmdline;
111 /* The default width to use for an index register when using a base
113 static enum m68k_size m68k_index_width_default = SIZE_LONG;
115 /* We want to warn if any text labels are misaligned. In order to get
116 the right line number, we need to record the line number for each
120 struct label_line *next;
127 /* The list of labels. */
129 static struct label_line *labels;
131 /* The current label. */
133 static struct label_line *current_label;
135 /* Pointer to list holding the opcodes sorted by name. */
136 static struct m68k_opcode const ** m68k_sorted_opcodes;
138 /* Its an arbitrary name: This means I don't approve of it.
140 static struct obstack robyn;
144 const char *m_operands;
145 unsigned long m_opcode;
149 struct m68k_incant *m_next;
152 #define getone(x) ((((x)->m_opcode)>>16)&0xffff)
153 #define gettwo(x) (((x)->m_opcode)&0xffff)
155 static const enum m68k_register m68000_control_regs[] = { 0 };
156 static const enum m68k_register m68010_control_regs[] = {
160 static const enum m68k_register m68020_control_regs[] = {
161 SFC, DFC, USP, VBR, CACR, CAAR, MSP, ISP,
164 static const enum m68k_register m68040_control_regs[] = {
165 SFC, DFC, CACR, TC, ITT0, ITT1, DTT0, DTT1,
166 USP, VBR, MSP, ISP, MMUSR, URP, SRP,
169 static const enum m68k_register m68060_control_regs[] = {
170 SFC, DFC, CACR, TC, ITT0, ITT1, DTT0, DTT1, BUSCR,
171 USP, VBR, URP, SRP, PCR,
174 static const enum m68k_register mcf_control_regs[] = {
175 CACR, TC, ACR0, ACR1, ACR2, ACR3, VBR, ROMBAR,
176 RAMBAR0, RAMBAR1, MBAR,
179 static const enum m68k_register mcf5249_control_regs[] = {
180 CACR, ACR0, ACR1, VBR, RAMBAR0, RAMBAR1, MBAR, MBAR2,
183 static const enum m68k_register mcf528x_control_regs[] = {
184 CACR, ACR0, ACR1, VBR, FLASHBAR, RAMBAR,
187 static const enum m68k_register mcfv4e_control_regs[] = {
188 CACR, TC, ITT0, ITT1, DTT0, DTT1, BUSCR, VBR, PC, ROMBAR,
189 ROMBAR1, RAMBAR0, RAMBAR1, MPCR, EDRAMBAR, SECMBAR, MBAR, MBAR0, MBAR1,
190 PCR1U0, PCR1L0, PCR1U1, PCR1L1, PCR2U0, PCR2L0, PCR2U1, PCR2L1,
191 PCR3U0, PCR3L0, PCR3U1, PCR3L1,
194 #define cpu32_control_regs m68010_control_regs
196 static const enum m68k_register *control_regs;
198 /* Internal form of a 68020 instruction. */
202 const char *args; /* List of opcode info. */
205 int numo; /* Number of shorts in opcode. */
208 struct m68k_op operands[6];
210 int nexp; /* Number of exprs in use. */
211 struct m68k_exp exprs[4];
213 int nfrag; /* Number of frags we have to produce. */
216 int fragoff; /* Where in the current opcode the frag ends. */
223 int nrel; /* Num of reloc strucs in use. */
230 /* In a pc relative address the difference between the address
231 of the offset and the address that the offset is relative
232 to. This depends on the addressing mode. Basically this
233 is the value to put in the offset field to address the
234 first byte of the offset, without regarding the special
235 significance of some values (in the branch instruction, for
239 /* Whether this expression needs special pic relocation, and if
241 enum pic_relocation pic_reloc;
244 reloc[5]; /* Five is enough??? */
247 #define cpu_of_arch(x) ((x) & (m68000up | mcfisa_a))
248 #define float_of_arch(x) ((x) & mfloat)
249 #define mmu_of_arch(x) ((x) & mmmu)
250 #define arch_coldfire_p(x) ((x) & mcfisa_a)
251 #define arch_coldfire_fpu(x) ((x) & cfloat)
253 /* Macros for determining if cpu supports a specific addressing mode. */
254 #define HAVE_LONG_BRANCH(x) ((x) & (m68020|m68030|m68040|m68060|cpu32|mcfisa_b))
256 static struct m68k_it the_ins; /* The instruction being assembled. */
258 #define op(ex) ((ex)->exp.X_op)
259 #define adds(ex) ((ex)->exp.X_add_symbol)
260 #define subs(ex) ((ex)->exp.X_op_symbol)
261 #define offs(ex) ((ex)->exp.X_add_number)
263 /* Macros for adding things to the m68k_it struct. */
264 #define addword(w) (the_ins.opcode[the_ins.numo++] = (w))
266 /* Like addword, but goes BEFORE general operands. */
269 insop (int w, const struct m68k_incant *opcode)
272 for (z = the_ins.numo; z > opcode->m_codenum; --z)
273 the_ins.opcode[z] = the_ins.opcode[z - 1];
274 for (z = 0; z < the_ins.nrel; z++)
275 the_ins.reloc[z].n += 2;
276 for (z = 0; z < the_ins.nfrag; z++)
277 the_ins.fragb[z].fragoff++;
278 the_ins.opcode[opcode->m_codenum] = w;
282 /* The numo+1 kludge is so we can hit the low order byte of the prev word.
285 add_fix (int width, struct m68k_exp *exp, int pc_rel, int pc_fix)
287 the_ins.reloc[the_ins.nrel].n = (width == 'B' || width == '3'
288 ? the_ins.numo * 2 - 1
290 ? the_ins.numo * 2 + 1
291 : the_ins.numo * 2));
292 the_ins.reloc[the_ins.nrel].exp = exp->exp;
293 the_ins.reloc[the_ins.nrel].wid = width;
294 the_ins.reloc[the_ins.nrel].pcrel_fix = pc_fix;
296 the_ins.reloc[the_ins.nrel].pic_reloc = exp->pic_reloc;
298 the_ins.reloc[the_ins.nrel++].pcrel = pc_rel;
301 /* Cause an extra frag to be generated here, inserting up to 10 bytes
302 (that value is chosen in the frag_var call in md_assemble). TYPE
303 is the subtype of the frag to be generated; its primary type is
304 rs_machine_dependent.
306 The TYPE parameter is also used by md_convert_frag_1 and
307 md_estimate_size_before_relax. The appropriate type of fixup will
308 be emitted by md_convert_frag_1.
310 ADD becomes the FR_SYMBOL field of the frag, and OFF the FR_OFFSET. */
312 add_frag (symbolS *add, offsetT off, int type)
314 the_ins.fragb[the_ins.nfrag].fragoff = the_ins.numo;
315 the_ins.fragb[the_ins.nfrag].fadd = add;
316 the_ins.fragb[the_ins.nfrag].foff = off;
317 the_ins.fragb[the_ins.nfrag++].fragty = type;
321 (op (ex) != O_constant && op (ex) != O_big)
323 static char *crack_operand (char *str, struct m68k_op *opP);
324 static int get_num (struct m68k_exp *exp, int ok);
325 static int reverse_16_bits (int in);
326 static int reverse_8_bits (int in);
327 static void install_gen_operand (int mode, int val);
328 static void install_operand (int mode, int val);
329 static void s_bss (int);
330 static void s_data1 (int);
331 static void s_data2 (int);
332 static void s_even (int);
333 static void s_proc (int);
334 static void s_chip (int);
335 static void s_fopt (int);
336 static void s_opt (int);
337 static void s_reg (int);
338 static void s_restore (int);
339 static void s_save (int);
340 static void s_mri_if (int);
341 static void s_mri_else (int);
342 static void s_mri_endi (int);
343 static void s_mri_break (int);
344 static void s_mri_next (int);
345 static void s_mri_for (int);
346 static void s_mri_endf (int);
347 static void s_mri_repeat (int);
348 static void s_mri_until (int);
349 static void s_mri_while (int);
350 static void s_mri_endw (int);
352 static int current_architecture;
353 static int current_chip;
363 static const struct m68k_cpu archs[] =
365 { m68000, m68000, "68000", 0 },
366 { m68010, m68010, "68010", 0 },
367 { m68020, m68020, "68020", 0 },
368 { m68030, m68030, "68030", 0 },
369 { m68040, m68040, "68040", 0 },
370 { m68060, m68060, "68060", 0 },
371 { cpu32, cpu32, "cpu32", 0 },
372 { m68881, m68881, "68881", 0 },
373 { m68851, m68851, "68851", 0 },
374 { mcfisa_a, mcf5200, "5200", 0 },
375 { mcfisa_a|mcfhwdiv|mcfmac, mcf5206e, "5206e", 0 },
376 { mcfisa_a|mcfisa_aa|mcfhwdiv|mcfemac|mcfusp, mcf521x, "521x", 0 },
377 { mcfisa_a|mcfhwdiv|mcfemac, mcf5249, "5249", 0 },
378 { mcfisa_a|mcfisa_aa|mcfhwdiv|mcfemac|mcfusp, mcf528x, "528x", 0 },
379 { mcfisa_a|mcfhwdiv|mcfmac, mcf5307, "5307", 0 },
380 { mcfisa_a|mcfhwdiv|mcfisa_b|mcfmac, mcf5407, "5407", 0 },
381 { mcfisa_a|mcfhwdiv|mcfisa_b|mcfemac|mcfusp|cfloat, mcf5470, "547x", 0 },
382 { mcfisa_a|mcfhwdiv|mcfisa_b|mcfemac|mcfusp|cfloat, mcf5480, "548x", 0 },
383 /* Aliases (effectively, so far as gas is concerned) for the above
385 { m68020, m68020, "68k", 1 },
386 { m68000, m68000, "68008", 1 },
387 { m68000, m68000, "68302", 1 },
388 { m68000, m68000, "68306", 1 },
389 { m68000, m68000, "68307", 1 },
390 { m68000, m68000, "68322", 1 },
391 { m68000, m68000, "68356", 1 },
392 { m68000, m68000, "68ec000", 1 },
393 { m68000, m68000, "68hc000", 1 },
394 { m68000, m68000, "68hc001", 1 },
395 { m68020, m68020, "68ec020", 1 },
396 { m68030, m68030, "68ec030", 1 },
397 { m68040, m68040, "68ec040", 1 },
398 { m68060, m68060, "68ec060", 1 },
399 { cpu32, cpu32, "68330", 1 },
400 { cpu32, cpu32, "68331", 1 },
401 { cpu32, cpu32, "68332", 1 },
402 { cpu32, cpu32, "68333", 1 },
403 { cpu32, cpu32, "68334", 1 },
404 { cpu32, cpu32, "68336", 1 },
405 { cpu32, cpu32, "68340", 1 },
406 { cpu32, cpu32, "68341", 1 },
407 { cpu32, cpu32, "68349", 1 },
408 { cpu32, cpu32, "68360", 1 },
409 { m68881, m68881, "68882", 1 },
410 { mcfisa_a, mcf5200, "5202", 1 },
411 { mcfisa_a, mcf5200, "5204", 1 },
412 { mcfisa_a, mcf5200, "5206", 1 },
413 { mcfisa_a|mcfhwdiv|mcfisa_aa|mcfemac, mcf521x, "5214", 1 },
414 { mcfisa_a|mcfhwdiv|mcfisa_aa|mcfemac, mcf521x, "5216", 1 },
415 { mcfisa_a|mcfisa_aa|mcfhwdiv|mcfemac, mcf528x, "5280", 1 },
416 { mcfisa_a|mcfisa_aa|mcfhwdiv|mcfemac, mcf528x, "5281", 1 },
417 { mcfisa_a|mcfisa_aa|mcfhwdiv|mcfemac, mcf528x, "5282", 1 },
418 { mcfisa_a|mcfhwdiv|mcfisa_b|mcfmac, mcf5407, "cfv4", 1 },
419 { mcfisa_a|mcfhwdiv|mcfisa_b|mcfemac|mcfusp|cfloat, mcf5470, "5470", 1 },
420 { mcfisa_a|mcfhwdiv|mcfisa_b|mcfemac|mcfusp|cfloat, mcf5470, "5471", 1 },
421 { mcfisa_a|mcfhwdiv|mcfisa_b|mcfemac|mcfusp|cfloat, mcf5470, "5472", 1 },
422 { mcfisa_a|mcfhwdiv|mcfisa_b|mcfemac|mcfusp|cfloat, mcf5470, "5473", 1 },
423 { mcfisa_a|mcfhwdiv|mcfisa_b|mcfemac|mcfusp|cfloat, mcf5470, "5474", 1 },
424 { mcfisa_a|mcfhwdiv|mcfisa_b|mcfemac|mcfusp|cfloat, mcf5470, "5475", 1 },
425 { mcfisa_a|mcfhwdiv|mcfisa_b|mcfemac|mcfusp|cfloat, mcf5470, "5480", 1 },
426 { mcfisa_a|mcfhwdiv|mcfisa_b|mcfemac|mcfusp|cfloat, mcf5470, "5481", 1 },
427 { mcfisa_a|mcfhwdiv|mcfisa_b|mcfemac|mcfusp|cfloat, mcf5470, "5482", 1 },
428 { mcfisa_a|mcfhwdiv|mcfisa_b|mcfemac|mcfusp|cfloat, mcf5470, "5483", 1 },
429 { mcfisa_a|mcfhwdiv|mcfisa_b|mcfemac|mcfusp|cfloat, mcf5470, "5484", 1 },
430 { mcfisa_a|mcfhwdiv|mcfisa_b|mcfemac|mcfusp|cfloat, mcf5470, "5485", 1 },
431 { mcfisa_a|mcfhwdiv|mcfisa_b|mcfemac|mcfusp|cfloat, mcf5470, "cfv4e", 1 },
434 static const int n_archs = sizeof (archs) / sizeof (archs[0]);
436 /* This is the assembler relaxation table for m68k. m68k is a rich CISC
437 architecture and we have a lot of relaxation modes. */
439 /* Macros used in the relaxation code. */
440 #define TAB(x,y) (((x) << 2) + (y))
441 #define TABTYPE(x) ((x) >> 2)
443 /* Relaxation states. */
449 /* Here are all the relaxation modes we support. First we can relax ordinary
450 branches. On 68020 and higher and on CPU32 all branch instructions take
451 three forms, so on these CPUs all branches always remain as such. When we
452 have to expand to the LONG form on a 68000, though, we substitute an
453 absolute jump instead. This is a direct replacement for unconditional
454 branches and a branch over a jump for conditional branches. However, if the
455 user requires PIC and disables this with --pcrel, we can only relax between
456 BYTE and SHORT forms, punting if that isn't enough. This gives us four
457 different relaxation modes for branches: */
459 #define BRANCHBWL 0 /* Branch byte, word, or long. */
460 #define BRABSJUNC 1 /* Absolute jump for LONG, unconditional. */
461 #define BRABSJCOND 2 /* Absolute jump for LONG, conditional. */
462 #define BRANCHBW 3 /* Branch byte or word. */
464 /* We also relax coprocessor branches and DBcc's. All CPUs that support
465 coprocessor branches support them in word and long forms, so we have only
466 one relaxation mode for them. DBcc's are word only on all CPUs. We can
467 relax them to the LONG form with a branch-around sequence. This sequence
468 can use a long branch (if available) or an absolute jump (if acceptable).
469 This gives us two relaxation modes. If long branches are not available and
470 absolute jumps are not acceptable, we don't relax DBcc's. */
472 #define FBRANCH 4 /* Coprocessor branch. */
473 #define DBCCLBR 5 /* DBcc relaxable with a long branch. */
474 #define DBCCABSJ 6 /* DBcc relaxable with an absolute jump. */
476 /* That's all for instruction relaxation. However, we also relax PC-relative
477 operands. Specifically, we have three operand relaxation modes. On the
478 68000 PC-relative operands can only be 16-bit, but on 68020 and higher and
479 on CPU32 they may be 16-bit or 32-bit. For the latter we relax between the
480 two. Also PC+displacement+index operands in their simple form (with a non-
481 suppressed index without memory indirection) are supported on all CPUs, but
482 on the 68000 the displacement can be 8-bit only, whereas on 68020 and higher
483 and on CPU32 we relax it to SHORT and LONG forms as well using the extended
484 form of the PC+displacement+index operand. Finally, some absolute operands
485 can be relaxed down to 16-bit PC-relative. */
487 #define PCREL1632 7 /* 16-bit or 32-bit PC-relative. */
488 #define PCINDEX 8 /* PC + displacement + index. */
489 #define ABSTOPCREL 9 /* Absolute relax down to 16-bit PC-relative. */
491 /* Note that calls to frag_var need to specify the maximum expansion
492 needed; this is currently 10 bytes for DBCC. */
495 How far Forward this mode will reach:
496 How far Backward this mode will reach:
497 How many bytes this mode will add to the size of the frag
498 Which mode to go to if the offset won't fit in this one
500 Please check tc-m68k.h:md_prepare_relax_scan if changing this table. */
501 relax_typeS md_relax_table[] =
503 { 127, -128, 0, TAB (BRANCHBWL, SHORT) },
504 { 32767, -32768, 2, TAB (BRANCHBWL, LONG) },
508 { 127, -128, 0, TAB (BRABSJUNC, SHORT) },
509 { 32767, -32768, 2, TAB (BRABSJUNC, LONG) },
513 { 127, -128, 0, TAB (BRABSJCOND, SHORT) },
514 { 32767, -32768, 2, TAB (BRABSJCOND, LONG) },
518 { 127, -128, 0, TAB (BRANCHBW, SHORT) },
523 { 1, 1, 0, 0 }, /* FBRANCH doesn't come BYTE. */
524 { 32767, -32768, 2, TAB (FBRANCH, LONG) },
528 { 1, 1, 0, 0 }, /* DBCC doesn't come BYTE. */
529 { 32767, -32768, 2, TAB (DBCCLBR, LONG) },
533 { 1, 1, 0, 0 }, /* DBCC doesn't come BYTE. */
534 { 32767, -32768, 2, TAB (DBCCABSJ, LONG) },
538 { 1, 1, 0, 0 }, /* PCREL1632 doesn't come BYTE. */
539 { 32767, -32768, 2, TAB (PCREL1632, LONG) },
543 { 125, -130, 0, TAB (PCINDEX, SHORT) },
544 { 32765, -32770, 2, TAB (PCINDEX, LONG) },
548 { 1, 1, 0, 0 }, /* ABSTOPCREL doesn't come BYTE. */
549 { 32767, -32768, 2, TAB (ABSTOPCREL, LONG) },
554 /* These are the machine dependent pseudo-ops. These are included so
555 the assembler can work on the output from the SUN C compiler, which
558 /* This table describes all the machine specific pseudo-ops the assembler
559 has to support. The fields are:
560 pseudo-op name without dot
561 function to call to execute this pseudo-op
562 Integer arg to pass to the function. */
563 const pseudo_typeS md_pseudo_table[] =
565 {"data1", s_data1, 0},
566 {"data2", s_data2, 0},
569 {"skip", s_space, 0},
571 #if defined (TE_SUN3) || defined (OBJ_ELF)
572 {"align", s_align_bytes, 0},
575 {"swbeg", s_ignore, 0},
577 {"extend", float_cons, 'x'},
578 {"ldouble", float_cons, 'x'},
580 /* The following pseudo-ops are supported for MRI compatibility. */
582 {"comline", s_space, 1},
584 {"mask2", s_ignore, 0},
587 {"restore", s_restore, 0},
591 {"if.b", s_mri_if, 'b'},
592 {"if.w", s_mri_if, 'w'},
593 {"if.l", s_mri_if, 'l'},
594 {"else", s_mri_else, 0},
595 {"else.s", s_mri_else, 's'},
596 {"else.l", s_mri_else, 'l'},
597 {"endi", s_mri_endi, 0},
598 {"break", s_mri_break, 0},
599 {"break.s", s_mri_break, 's'},
600 {"break.l", s_mri_break, 'l'},
601 {"next", s_mri_next, 0},
602 {"next.s", s_mri_next, 's'},
603 {"next.l", s_mri_next, 'l'},
604 {"for", s_mri_for, 0},
605 {"for.b", s_mri_for, 'b'},
606 {"for.w", s_mri_for, 'w'},
607 {"for.l", s_mri_for, 'l'},
608 {"endf", s_mri_endf, 0},
609 {"repeat", s_mri_repeat, 0},
610 {"until", s_mri_until, 0},
611 {"until.b", s_mri_until, 'b'},
612 {"until.w", s_mri_until, 'w'},
613 {"until.l", s_mri_until, 'l'},
614 {"while", s_mri_while, 0},
615 {"while.b", s_mri_while, 'b'},
616 {"while.w", s_mri_while, 'w'},
617 {"while.l", s_mri_while, 'l'},
618 {"endw", s_mri_endw, 0},
623 /* The mote pseudo ops are put into the opcode table, since they
624 don't start with a . they look like opcodes to gas. */
626 const pseudo_typeS mote_pseudo_table[] =
639 {"xdef", s_globl, 0},
641 {"align", s_align_bytes, 0},
643 {"align", s_align_ptwo, 0},
646 {"sect", obj_coff_section, 0},
647 {"section", obj_coff_section, 0},
652 /* Truncate and sign-extend at 32 bits, so that building on a 64-bit host
653 gives identical results to a 32-bit host. */
654 #define TRUNC(X) ((valueT) (X) & 0xffffffff)
655 #define SEXT(X) ((TRUNC (X) ^ 0x80000000) - 0x80000000)
657 #define issbyte(x) ((valueT) SEXT (x) + 0x80 < 0x100)
658 #define isubyte(x) ((valueT) TRUNC (x) < 0x100)
659 #define issword(x) ((valueT) SEXT (x) + 0x8000 < 0x10000)
660 #define isuword(x) ((valueT) TRUNC (x) < 0x10000)
662 #define isbyte(x) ((valueT) SEXT (x) + 0xff < 0x1ff)
663 #define isword(x) ((valueT) SEXT (x) + 0xffff < 0x1ffff)
664 #define islong(x) (1)
666 static char notend_table[256];
667 static char alt_notend_table[256];
669 (! (notend_table[(unsigned char) *s] \
671 && alt_notend_table[(unsigned char) s[1]])))
673 /* Return a human readable string holding the list of chips that are
674 valid for a particular architecture, suppressing aliases (unless
675 there is only one of them). */
678 find_cf_chip (int architecture)
680 static char buf[1024];
681 int i, j, n_chips, n_alias;
685 cp = buf + strlen (buf);
687 for (i = 0, n_chips = 0, n_alias = 0; i < n_archs; ++i)
688 if (archs[i].arch & architecture)
696 as_fatal (_("no matching ColdFire architectures found"));
701 for (i = 0, j = 0; i < n_archs && j < n_chips; ++i)
702 if (archs[i].arch & architecture)
706 if ((j == n_chips - 1 && !(n_alias > 1)) || ! n_alias)
710 strncpy (cp, _(" or "), (sizeof (buf) - (cp - buf)));
715 strncpy (cp, _(", or "), (sizeof (buf) - (cp - buf)));
721 strncpy (cp, ", ", (sizeof (buf) - (cp - buf)));
725 strncpy (cp, archs[i].name, (sizeof (buf) - (cp - buf)));
732 strncpy (cp, _(", or aliases"), (sizeof (buf) - (cp - buf)));
736 strncpy (cp, ")", (sizeof (buf) - (cp - buf)));
743 /* Return zero if the reference to SYMBOL from within the same segment may
746 /* On an ELF system, we can't relax an externally visible symbol,
747 because it may be overridden by a shared library. However, if
748 TARGET_OS is "elf", then we presume that we are assembling for an
749 embedded system, in which case we don't have to worry about shared
750 libraries, and we can relax any external sym. */
752 #define relaxable_symbol(symbol) \
753 (!((S_IS_EXTERNAL (symbol) && EXTERN_FORCE_RELOC) \
754 || S_IS_WEAK (symbol)))
756 /* Compute the relocation code for a fixup of SIZE bytes, using pc
757 relative relocation if PCREL is non-zero. PIC says whether a special
758 pic relocation was requested. */
760 static bfd_reloc_code_real_type
761 get_reloc_code (int size, int pcrel, enum pic_relocation pic)
769 return BFD_RELOC_8_GOT_PCREL;
771 return BFD_RELOC_16_GOT_PCREL;
773 return BFD_RELOC_32_GOT_PCREL;
781 return BFD_RELOC_8_GOTOFF;
783 return BFD_RELOC_16_GOTOFF;
785 return BFD_RELOC_32_GOTOFF;
793 return BFD_RELOC_8_PLT_PCREL;
795 return BFD_RELOC_16_PLT_PCREL;
797 return BFD_RELOC_32_PLT_PCREL;
805 return BFD_RELOC_8_PLTOFF;
807 return BFD_RELOC_16_PLTOFF;
809 return BFD_RELOC_32_PLTOFF;
819 return BFD_RELOC_8_PCREL;
821 return BFD_RELOC_16_PCREL;
823 return BFD_RELOC_32_PCREL;
843 as_bad (_("Can not do %d byte pc-relative relocation"), size);
845 as_bad (_("Can not do %d byte pc-relative pic relocation"), size);
850 as_bad (_("Can not do %d byte relocation"), size);
852 as_bad (_("Can not do %d byte pic relocation"), size);
855 return BFD_RELOC_NONE;
858 /* Here we decide which fixups can be adjusted to make them relative
859 to the beginning of the section instead of the symbol. Basically
860 we need to make sure that the dynamic relocations are done
861 correctly, so in some cases we force the original symbol to be
864 tc_m68k_fix_adjustable (fixS *fixP)
866 /* Adjust_reloc_syms doesn't know about the GOT. */
867 switch (fixP->fx_r_type)
869 case BFD_RELOC_8_GOT_PCREL:
870 case BFD_RELOC_16_GOT_PCREL:
871 case BFD_RELOC_32_GOT_PCREL:
872 case BFD_RELOC_8_GOTOFF:
873 case BFD_RELOC_16_GOTOFF:
874 case BFD_RELOC_32_GOTOFF:
875 case BFD_RELOC_8_PLT_PCREL:
876 case BFD_RELOC_16_PLT_PCREL:
877 case BFD_RELOC_32_PLT_PCREL:
878 case BFD_RELOC_8_PLTOFF:
879 case BFD_RELOC_16_PLTOFF:
880 case BFD_RELOC_32_PLTOFF:
883 case BFD_RELOC_VTABLE_INHERIT:
884 case BFD_RELOC_VTABLE_ENTRY:
894 #define get_reloc_code(SIZE,PCREL,OTHER) NO_RELOC
896 #define relaxable_symbol(symbol) 1
901 tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
904 bfd_reloc_code_real_type code;
906 /* If the tcbit is set, then this was a fixup of a negative value
907 that was never resolved. We do not have a reloc to handle this,
908 so just return. We assume that other code will have detected this
909 situation and produced a helpful error message, so we just tell the
910 user that the reloc cannot be produced. */
914 as_bad_where (fixp->fx_file, fixp->fx_line,
915 _("Unable to produce reloc against symbol '%s'"),
916 S_GET_NAME (fixp->fx_addsy));
920 if (fixp->fx_r_type != BFD_RELOC_NONE)
922 code = fixp->fx_r_type;
924 /* Since DIFF_EXPR_OK is defined in tc-m68k.h, it is possible
925 that fixup_segment converted a non-PC relative reloc into a
926 PC relative reloc. In such a case, we need to convert the
933 code = BFD_RELOC_8_PCREL;
936 code = BFD_RELOC_16_PCREL;
939 code = BFD_RELOC_32_PCREL;
941 case BFD_RELOC_8_PCREL:
942 case BFD_RELOC_16_PCREL:
943 case BFD_RELOC_32_PCREL:
944 case BFD_RELOC_8_GOT_PCREL:
945 case BFD_RELOC_16_GOT_PCREL:
946 case BFD_RELOC_32_GOT_PCREL:
947 case BFD_RELOC_8_GOTOFF:
948 case BFD_RELOC_16_GOTOFF:
949 case BFD_RELOC_32_GOTOFF:
950 case BFD_RELOC_8_PLT_PCREL:
951 case BFD_RELOC_16_PLT_PCREL:
952 case BFD_RELOC_32_PLT_PCREL:
953 case BFD_RELOC_8_PLTOFF:
954 case BFD_RELOC_16_PLTOFF:
955 case BFD_RELOC_32_PLTOFF:
958 as_bad_where (fixp->fx_file, fixp->fx_line,
959 _("Cannot make %s relocation PC relative"),
960 bfd_get_reloc_code_name (code));
966 #define F(SZ,PCREL) (((SZ) << 1) + (PCREL))
967 switch (F (fixp->fx_size, fixp->fx_pcrel))
969 #define MAP(SZ,PCREL,TYPE) case F(SZ,PCREL): code = (TYPE); break
970 MAP (1, 0, BFD_RELOC_8);
971 MAP (2, 0, BFD_RELOC_16);
972 MAP (4, 0, BFD_RELOC_32);
973 MAP (1, 1, BFD_RELOC_8_PCREL);
974 MAP (2, 1, BFD_RELOC_16_PCREL);
975 MAP (4, 1, BFD_RELOC_32_PCREL);
983 reloc = (arelent *) xmalloc (sizeof (arelent));
984 reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
985 *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
986 reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
989 reloc->addend = fixp->fx_addnumber;
994 reloc->addend = fixp->fx_addnumber;
996 reloc->addend = (section->vma
997 /* Explicit sign extension in case char is
999 + ((fixp->fx_pcrel_adjust & 0xff) ^ 0x80) - 0x80
1000 + fixp->fx_addnumber
1001 + md_pcrel_from (fixp));
1004 reloc->howto = bfd_reloc_type_lookup (stdoutput, code);
1005 assert (reloc->howto != 0);
1010 /* Handle of the OPCODE hash table. NULL means any use before
1011 m68k_ip_begin() will crash. */
1012 static struct hash_control *op_hash;
1014 /* Assemble an m68k instruction. */
1017 m68k_ip (char *instring)
1020 register struct m68k_op *opP;
1021 register const struct m68k_incant *opcode;
1022 register const char *s;
1023 register int tmpreg = 0, baseo = 0, outro = 0, nextword;
1024 char *pdot, *pdotmove;
1025 enum m68k_size siz1, siz2;
1029 struct m68k_op operands_backup[6];
1030 LITTLENUM_TYPE words[6];
1031 LITTLENUM_TYPE *wordp;
1032 unsigned long ok_arch = 0;
1034 if (*instring == ' ')
1035 instring++; /* Skip leading whitespace. */
1037 /* Scan up to end of operation-code, which MUST end in end-of-string
1038 or exactly 1 space. */
1040 for (p = instring; *p != '\0'; p++)
1050 the_ins.error = _("No operator");
1054 /* p now points to the end of the opcode name, probably whitespace.
1055 Make sure the name is null terminated by clobbering the
1056 whitespace, look it up in the hash table, then fix it back.
1057 Remove a dot, first, since the opcode tables have none. */
1060 for (pdotmove = pdot; pdotmove < p; pdotmove++)
1061 *pdotmove = pdotmove[1];
1067 opcode = (const struct m68k_incant *) hash_find (op_hash, instring);
1072 for (pdotmove = p; pdotmove > pdot; pdotmove--)
1073 *pdotmove = pdotmove[-1];
1080 the_ins.error = _("Unknown operator");
1084 /* Found a legitimate opcode, start matching operands. */
1088 if (opcode->m_operands == 0)
1090 char *old = input_line_pointer;
1092 input_line_pointer = p;
1093 /* Ahh - it's a motorola style psuedo op. */
1094 mote_pseudo_table[opcode->m_opnum].poc_handler
1095 (mote_pseudo_table[opcode->m_opnum].poc_val);
1096 input_line_pointer = old;
1102 if (flag_mri && opcode->m_opnum == 0)
1104 /* In MRI mode, random garbage is allowed after an instruction
1105 which accepts no operands. */
1106 the_ins.args = opcode->m_operands;
1107 the_ins.numargs = opcode->m_opnum;
1108 the_ins.numo = opcode->m_codenum;
1109 the_ins.opcode[0] = getone (opcode);
1110 the_ins.opcode[1] = gettwo (opcode);
1114 for (opP = &the_ins.operands[0]; *p; opP++)
1116 p = crack_operand (p, opP);
1120 the_ins.error = opP->error;
1125 opsfound = opP - &the_ins.operands[0];
1127 /* This ugly hack is to support the floating pt opcodes in their
1128 standard form. Essentially, we fake a first enty of type COP#1 */
1129 if (opcode->m_operands[0] == 'I')
1133 for (n = opsfound; n > 0; --n)
1134 the_ins.operands[n] = the_ins.operands[n - 1];
1136 memset (&the_ins.operands[0], '\0', sizeof (the_ins.operands[0]));
1137 the_ins.operands[0].mode = CONTROL;
1138 the_ins.operands[0].reg = m68k_float_copnum;
1142 /* We've got the operands. Find an opcode that'll accept them. */
1145 /* If we didn't get the right number of ops, or we have no
1146 common model with this pattern then reject this pattern. */
1148 ok_arch |= opcode->m_arch;
1149 if (opsfound != opcode->m_opnum
1150 || ((opcode->m_arch & current_architecture) == 0))
1156 /* Make a copy of the operands of this insn so that
1157 we can modify them safely, should we want to. */
1158 assert (opsfound <= (int) ARRAY_SIZE (operands_backup));
1159 for (i = 0; i < opsfound; i++)
1160 operands_backup[i] = the_ins.operands[i];
1162 for (s = opcode->m_operands, opP = &operands_backup[0];
1166 /* Warning: this switch is huge! */
1167 /* I've tried to organize the cases into this order:
1168 non-alpha first, then alpha by letter. Lower-case
1169 goes directly before uppercase counterpart. */
1170 /* Code with multiple case ...: gets sorted by the lowest
1171 case ... it belongs to. I hope this makes sense. */
1277 if (opP->reg == PC || opP->reg == ZPC)
1294 if (opP->reg == PC || opP->reg == ZPC)
1313 if (opP->reg == PC || opP->reg == ZPC)
1323 if (opP->mode != IMMED)
1325 else if (s[1] == 'b'
1326 && ! isvar (&opP->disp)
1327 && (opP->disp.exp.X_op != O_constant
1328 || ! isbyte (opP->disp.exp.X_add_number)))
1330 else if (s[1] == 'B'
1331 && ! isvar (&opP->disp)
1332 && (opP->disp.exp.X_op != O_constant
1333 || ! issbyte (opP->disp.exp.X_add_number)))
1335 else if (s[1] == 'w'
1336 && ! isvar (&opP->disp)
1337 && (opP->disp.exp.X_op != O_constant
1338 || ! isword (opP->disp.exp.X_add_number)))
1340 else if (s[1] == 'W'
1341 && ! isvar (&opP->disp)
1342 && (opP->disp.exp.X_op != O_constant
1343 || ! issword (opP->disp.exp.X_add_number)))
1349 if (opP->mode != IMMED)
1354 if (opP->mode == AREG
1355 || opP->mode == CONTROL
1356 || opP->mode == FPREG
1357 || opP->mode == IMMED
1358 || opP->mode == REGLST
1359 || (opP->mode != ABSL
1361 || opP->reg == ZPC)))
1366 if (opP->mode == CONTROL
1367 || opP->mode == FPREG
1368 || opP->mode == REGLST
1369 || opP->mode == IMMED
1370 || (opP->mode != ABSL
1372 || opP->reg == ZPC)))
1400 if (opP->mode == CONTROL
1401 || opP->mode == FPREG
1402 || opP->mode == REGLST)
1407 if (opP->mode != AINC)
1412 if (opP->mode != ADEC)
1462 if (opP->reg == PC || opP->reg == ZPC)
1483 case '~': /* For now! (JF FOO is this right?) */
1505 if (opP->mode != CONTROL
1506 || (opP->reg != TT0 && opP->reg != TT1))
1511 if (opP->mode != AREG)
1516 if (opP->mode != AINDR)
1521 if (opP->mode != AINDR && opP->mode != AINC && opP->mode != ADEC
1522 && (opP->mode != DISP
1524 || opP->reg > ADDR7))
1529 if (opP->mode != ABSL
1531 && strncmp (instring, "jbsr", 4) == 0))
1554 if (opP->mode != CONTROL || opP->reg != CCR)
1559 if (opP->mode != DISP
1561 || opP->reg > ADDR7)
1566 if (opP->mode != DREG)
1571 if (opP->reg != ACC)
1576 if (opP->reg != ACC && opP->reg != ACC1
1577 && opP->reg != ACC2 && opP->reg != ACC3)
1582 if (opP->mode != FPREG)
1587 if (opP->reg != MACSR)
1592 if (opP->reg != ACCEXT01 && opP->reg != ACCEXT23)
1597 if (opP->reg != MASK)
1602 if (opP->mode != CONTROL
1609 if (opP->mode != LSH && opP->mode != RSH)
1614 if (opP->mode != CONTROL
1616 || opP->reg > last_movec_reg)
1620 const enum m68k_register *rp;
1621 for (rp = control_regs; *rp; rp++)
1622 if (*rp == opP->reg)
1630 if (opP->mode != IMMED)
1636 if (opP->mode == DREG
1637 || opP->mode == AREG
1638 || opP->mode == FPREG)
1647 opP->mask = 1 << (opP->reg - DATA0);
1650 opP->mask = 1 << (opP->reg - ADDR0 + 8);
1653 opP->mask = 1 << (opP->reg - FP0 + 16);
1661 else if (opP->mode == CONTROL)
1670 opP->mask = 1 << 24;
1673 opP->mask = 1 << 25;
1676 opP->mask = 1 << 26;
1685 else if (opP->mode != REGLST)
1687 else if (s[1] == '8' && (opP->mask & 0x0ffffff) != 0)
1689 else if (s[1] == '3' && (opP->mask & 0x7000000) != 0)
1694 if (opP->mode != IMMED)
1696 else if (opP->disp.exp.X_op != O_constant
1697 || ! issbyte (opP->disp.exp.X_add_number))
1699 else if (! m68k_quick
1700 && instring[3] != 'q'
1701 && instring[4] != 'q')
1706 if (opP->mode != DREG
1707 && opP->mode != IMMED
1708 && opP->mode != ABSL)
1713 if (opP->mode != IMMED)
1715 else if (opP->disp.exp.X_op != O_constant
1716 || TRUNC (opP->disp.exp.X_add_number) - 1 > 7)
1718 else if (! m68k_quick
1719 && (strncmp (instring, "add", 3) == 0
1720 || strncmp (instring, "sub", 3) == 0)
1721 && instring[3] != 'q')
1726 if (opP->mode != DREG && opP->mode != AREG)
1731 if (opP->mode != AINDR
1732 && (opP->mode != BASE
1734 && opP->reg != ZADDR0)
1735 || opP->disp.exp.X_op != O_absent
1736 || ((opP->index.reg < DATA0
1737 || opP->index.reg > DATA7)
1738 && (opP->index.reg < ADDR0
1739 || opP->index.reg > ADDR7))
1740 || opP->index.size != SIZE_UNSPEC
1741 || opP->index.scale != 1))
1746 if (opP->mode != CONTROL
1747 || ! (opP->reg == FPI
1749 || opP->reg == FPC))
1754 if (opP->mode != CONTROL || opP->reg != SR)
1759 if (opP->mode != IMMED)
1761 else if (opP->disp.exp.X_op != O_constant
1762 || TRUNC (opP->disp.exp.X_add_number) > 7)
1767 if (opP->mode != CONTROL || opP->reg != USP)
1772 if (opP->mode != IMMED)
1774 else if (opP->disp.exp.X_op != O_constant
1775 || (TRUNC (opP->disp.exp.X_add_number) != 0xffffffff
1776 && TRUNC (opP->disp.exp.X_add_number) - 1 > 6))
1780 /* JF these are out of order. We could put them
1781 in order if we were willing to put up with
1782 bunches of #ifdef m68851s in the code.
1784 Don't forget that you need these operands
1785 to use 68030 MMU instructions. */
1787 /* Memory addressing mode used by pflushr. */
1789 if (opP->mode == CONTROL
1790 || opP->mode == FPREG
1791 || opP->mode == DREG
1792 || opP->mode == AREG
1793 || opP->mode == REGLST)
1795 /* We should accept immediate operands, but they
1796 supposedly have to be quad word, and we don't
1797 handle that. I would like to see what a Motorola
1798 assembler does before doing something here. */
1799 if (opP->mode == IMMED)
1804 if (opP->mode != CONTROL
1805 || (opP->reg != SFC && opP->reg != DFC))
1810 if (opP->mode != CONTROL || opP->reg != TC)
1815 if (opP->mode != CONTROL || opP->reg != AC)
1820 if (opP->mode != CONTROL
1823 && opP->reg != SCC))
1828 if (opP->mode != CONTROL
1834 if (opP->mode != CONTROL
1837 && opP->reg != CRP))
1861 if (opP->mode != CONTROL
1862 || (!(opP->reg >= BAD && opP->reg <= BAD + 7)
1863 && !(opP->reg >= BAC && opP->reg <= BAC + 7)))
1868 if (opP->mode != CONTROL || opP->reg != PSR)
1873 if (opP->mode != CONTROL || opP->reg != PCSR)
1878 if (opP->mode != CONTROL
1887 if (opP->mode != ABSL)
1892 if (opP->reg < DATA0L || opP->reg > ADDR7U)
1894 /* FIXME: kludge instead of fixing parser:
1895 upper/lower registers are *not* CONTROL
1896 registers, but ordinary ones. */
1897 if ((opP->reg >= DATA0L && opP->reg <= DATA7L)
1898 || (opP->reg >= DATA0U && opP->reg <= DATA7U))
1905 if (!(opP->mode == AINDR
1906 || (opP->mode == DISP
1907 && !(opP->reg == PC || opP->reg == ZPC))))
1912 if (!(opP->mode == AINDR || opP->mode == DISP))
1924 /* Since we have found the correct instruction, copy
1925 in the modifications that we may have made. */
1927 for (i = 0; i < opsfound; i++)
1928 the_ins.operands[i] = operands_backup[i];
1934 opcode = opcode->m_next;
1939 && !(ok_arch & current_architecture))
1944 _("invalid instruction for this architecture; needs "),
1946 cp = buf + strlen (buf);
1950 strncpy (cp, _("ColdFire ISA_A"),
1951 sizeof (buf) - (cp - buf));
1953 strncpy (cp, find_cf_chip (ok_arch),
1954 sizeof (buf) - (cp - buf));
1958 strncpy (cp, _("ColdFire hardware divide"),
1959 sizeof (buf) - (cp - buf));
1961 strncpy (cp, find_cf_chip (ok_arch),
1962 sizeof (buf) - (cp - buf));
1966 strncpy (cp, _("ColdFire ISA_A+"),
1967 sizeof (buf) - (cp - buf));
1969 strncpy (cp, find_cf_chip (ok_arch),
1970 sizeof (buf) - (cp - buf));
1974 strncpy (cp, _("ColdFire ISA_B"),
1975 sizeof (buf) - (cp - buf));
1977 strncpy (cp, find_cf_chip (ok_arch),
1978 sizeof (buf) - (cp - buf));
1982 strncpy (cp, _("ColdFire fpu"), sizeof (buf) - (cp - buf));
1984 strncpy (cp, find_cf_chip (ok_arch),
1985 sizeof (buf) - (cp - buf));
1989 strcpy (cp, _("fpu (68040, 68060 or 68881/68882)"));
1992 strcpy (cp, _("mmu (68030 or 68851)"));
1995 strcpy (cp, _("68020 or higher"));
1998 strcpy (cp, _("68000 or higher"));
2001 strcpy (cp, _("68010 or higher"));
2005 int got_one = 0, idx;
2007 for (idx = 0; idx < n_archs; idx++)
2009 if ((archs[idx].arch & ok_arch)
2010 && ! archs[idx].alias)
2014 strcpy (cp, " or ");
2018 strcpy (cp, archs[idx].name);
2024 cp = xmalloc (strlen (buf) + 1);
2029 the_ins.error = _("operands mismatch");
2036 /* Now assemble it. */
2037 the_ins.args = opcode->m_operands;
2038 the_ins.numargs = opcode->m_opnum;
2039 the_ins.numo = opcode->m_codenum;
2040 the_ins.opcode[0] = getone (opcode);
2041 the_ins.opcode[1] = gettwo (opcode);
2043 for (s = the_ins.args, opP = &the_ins.operands[0]; *s; s += 2, opP++)
2045 /* This switch is a doozy.
2046 Watch the first step; its a big one! */
2079 tmpreg = 0x3c; /* 7.4 */
2080 if (strchr ("bwl", s[1]))
2081 nextword = get_num (&opP->disp, 90);
2083 nextword = get_num (&opP->disp, 0);
2084 if (isvar (&opP->disp))
2085 add_fix (s[1], &opP->disp, 0, 0);
2089 if (!isbyte (nextword))
2090 opP->error = _("operand out of range");
2095 if (!isword (nextword))
2096 opP->error = _("operand out of range");
2101 if (!issword (nextword))
2102 opP->error = _("operand out of range");
2107 addword (nextword >> 16);
2134 /* We gotta put out some float. */
2135 if (op (&opP->disp) != O_big)
2140 /* Can other cases happen here? */
2141 if (op (&opP->disp) != O_constant)
2144 val = (valueT) offs (&opP->disp);
2148 generic_bignum[gencnt] = (LITTLENUM_TYPE) val;
2149 val >>= LITTLENUM_NUMBER_OF_BITS;
2153 offs (&opP->disp) = gencnt;
2155 if (offs (&opP->disp) > 0)
2157 if (offs (&opP->disp) > baseo)
2159 as_warn (_("Bignum too big for %c format; truncated"),
2161 offs (&opP->disp) = baseo;
2163 baseo -= offs (&opP->disp);
2166 for (wordp = generic_bignum + offs (&opP->disp) - 1;
2167 offs (&opP->disp)--;
2172 gen_to_words (words, baseo, (long) outro);
2173 for (wordp = words; baseo--; wordp++)
2177 tmpreg = opP->reg - DATA; /* 0.dreg */
2180 tmpreg = 0x08 + opP->reg - ADDR; /* 1.areg */
2183 tmpreg = 0x10 + opP->reg - ADDR; /* 2.areg */
2186 tmpreg = 0x20 + opP->reg - ADDR; /* 4.areg */
2189 tmpreg = 0x18 + opP->reg - ADDR; /* 3.areg */
2193 nextword = get_num (&opP->disp, 90);
2195 /* Convert mode 5 addressing with a zero offset into
2196 mode 2 addressing to reduce the instruction size by a
2198 if (! isvar (&opP->disp)
2200 && (opP->disp.size == SIZE_UNSPEC)
2201 && (opP->reg >= ADDR0)
2202 && (opP->reg <= ADDR7))
2204 tmpreg = 0x10 + opP->reg - ADDR; /* 2.areg */
2209 && ! isvar (&opP->disp)
2212 opP->disp.exp.X_op = O_symbol;
2213 opP->disp.exp.X_add_symbol =
2214 section_symbol (absolute_section);
2217 /* Force into index mode. Hope this works. */
2219 /* We do the first bit for 32-bit displacements, and the
2220 second bit for 16 bit ones. It is possible that we
2221 should make the default be WORD instead of LONG, but
2222 I think that'd break GCC, so we put up with a little
2223 inefficiency for the sake of working output. */
2225 if (!issword (nextword)
2226 || (isvar (&opP->disp)
2227 && ((opP->disp.size == SIZE_UNSPEC
2228 && flag_short_refs == 0
2229 && cpu_of_arch (current_architecture) >= m68020
2230 && ! arch_coldfire_p (current_architecture))
2231 || opP->disp.size == SIZE_LONG)))
2233 if (cpu_of_arch (current_architecture) < m68020
2234 || arch_coldfire_p (current_architecture))
2236 _("displacement too large for this architecture; needs 68020 or higher");
2238 tmpreg = 0x3B; /* 7.3 */
2240 tmpreg = 0x30 + opP->reg - ADDR; /* 6.areg */
2241 if (isvar (&opP->disp))
2245 if (opP->disp.size == SIZE_LONG
2247 /* If the displacement needs pic
2248 relocation it cannot be relaxed. */
2249 || opP->disp.pic_reloc != pic_none
2254 add_fix ('l', &opP->disp, 1, 2);
2258 add_frag (adds (&opP->disp),
2259 SEXT (offs (&opP->disp)),
2260 TAB (PCREL1632, SZ_UNDEF));
2267 add_fix ('l', &opP->disp, 0, 0);
2272 addword (nextword >> 16);
2277 tmpreg = 0x3A; /* 7.2 */
2279 tmpreg = 0x28 + opP->reg - ADDR; /* 5.areg */
2281 if (isvar (&opP->disp))
2285 add_fix ('w', &opP->disp, 1, 0);
2288 add_fix ('w', &opP->disp, 0, 0);
2298 baseo = get_num (&opP->disp, 90);
2299 if (opP->mode == POST || opP->mode == PRE)
2300 outro = get_num (&opP->odisp, 90);
2301 /* Figure out the `addressing mode'.
2302 Also turn on the BASE_DISABLE bit, if needed. */
2303 if (opP->reg == PC || opP->reg == ZPC)
2305 tmpreg = 0x3b; /* 7.3 */
2306 if (opP->reg == ZPC)
2309 else if (opP->reg == 0)
2312 tmpreg = 0x30; /* 6.garbage */
2314 else if (opP->reg >= ZADDR0 && opP->reg <= ZADDR7)
2317 tmpreg = 0x30 + opP->reg - ZADDR0;
2320 tmpreg = 0x30 + opP->reg - ADDR; /* 6.areg */
2322 siz1 = opP->disp.size;
2323 if (opP->mode == POST || opP->mode == PRE)
2324 siz2 = opP->odisp.size;
2328 /* Index register stuff. */
2329 if (opP->index.reg != 0
2330 && opP->index.reg >= DATA
2331 && opP->index.reg <= ADDR7)
2333 nextword |= (opP->index.reg - DATA) << 12;
2335 if (opP->index.size == SIZE_LONG
2336 || (opP->index.size == SIZE_UNSPEC
2337 && m68k_index_width_default == SIZE_LONG))
2340 if ((opP->index.scale != 1
2341 && cpu_of_arch (current_architecture) < m68020)
2342 || (opP->index.scale == 8
2343 && (arch_coldfire_p (current_architecture)
2344 && !arch_coldfire_fpu (current_architecture))))
2347 _("scale factor invalid on this architecture; needs cpu32 or 68020 or higher");
2350 if (arch_coldfire_p (current_architecture)
2351 && opP->index.size == SIZE_WORD)
2352 opP->error = _("invalid index size for coldfire");
2354 switch (opP->index.scale)
2371 GET US OUT OF HERE! */
2373 /* Must be INDEX, with an index register. Address
2374 register cannot be ZERO-PC, and either :b was
2375 forced, or we know it will fit. For a 68000 or
2376 68010, force this mode anyways, because the
2377 larger modes aren't supported. */
2378 if (opP->mode == BASE
2379 && ((opP->reg >= ADDR0
2380 && opP->reg <= ADDR7)
2383 if (siz1 == SIZE_BYTE
2384 || cpu_of_arch (current_architecture) < m68020
2385 || arch_coldfire_p (current_architecture)
2386 || (siz1 == SIZE_UNSPEC
2387 && ! isvar (&opP->disp)
2388 && issbyte (baseo)))
2390 nextword += baseo & 0xff;
2392 if (isvar (&opP->disp))
2394 /* Do a byte relocation. If it doesn't
2395 fit (possible on m68000) let the
2396 fixup processing complain later. */
2398 add_fix ('B', &opP->disp, 1, 1);
2400 add_fix ('B', &opP->disp, 0, 0);
2402 else if (siz1 != SIZE_BYTE)
2404 if (siz1 != SIZE_UNSPEC)
2405 as_warn (_("Forcing byte displacement"));
2406 if (! issbyte (baseo))
2407 opP->error = _("byte displacement out of range");
2412 else if (siz1 == SIZE_UNSPEC
2414 && isvar (&opP->disp)
2415 && subs (&opP->disp) == NULL
2417 /* If the displacement needs pic
2418 relocation it cannot be relaxed. */
2419 && opP->disp.pic_reloc == pic_none
2423 /* The code in md_convert_frag_1 needs to be
2424 able to adjust nextword. Call frag_grow
2425 to ensure that we have enough space in
2426 the frag obstack to make all the bytes
2429 nextword += baseo & 0xff;
2431 add_frag (adds (&opP->disp),
2432 SEXT (offs (&opP->disp)),
2433 TAB (PCINDEX, SZ_UNDEF));
2441 nextword |= 0x40; /* No index reg. */
2442 if (opP->index.reg >= ZDATA0
2443 && opP->index.reg <= ZDATA7)
2444 nextword |= (opP->index.reg - ZDATA0) << 12;
2445 else if (opP->index.reg >= ZADDR0
2446 || opP->index.reg <= ZADDR7)
2447 nextword |= (opP->index.reg - ZADDR0 + 8) << 12;
2450 /* It isn't simple. */
2452 if (cpu_of_arch (current_architecture) < m68020
2453 || arch_coldfire_p (current_architecture))
2455 _("invalid operand mode for this architecture; needs 68020 or higher");
2458 /* If the guy specified a width, we assume that it is
2459 wide enough. Maybe it isn't. If so, we lose. */
2463 if (isvar (&opP->disp)
2465 : ! issword (baseo))
2470 else if (! isvar (&opP->disp) && baseo == 0)
2479 as_warn (_(":b not permitted; defaulting to :w"));
2489 /* Figure out inner displacement stuff. */
2490 if (opP->mode == POST || opP->mode == PRE)
2492 if (cpu_of_arch (current_architecture) & cpu32)
2493 opP->error = _("invalid operand mode for this architecture; needs 68020 or higher");
2497 if (isvar (&opP->odisp)
2499 : ! issword (outro))
2504 else if (! isvar (&opP->odisp) && outro == 0)
2513 as_warn (_(":b not permitted; defaulting to :w"));
2522 if (opP->mode == POST
2523 && (nextword & 0x40) == 0)
2528 if (siz1 != SIZE_UNSPEC && isvar (&opP->disp))
2530 if (opP->reg == PC || opP->reg == ZPC)
2531 add_fix (siz1 == SIZE_LONG ? 'l' : 'w', &opP->disp, 1, 2);
2533 add_fix (siz1 == SIZE_LONG ? 'l' : 'w', &opP->disp, 0, 0);
2535 if (siz1 == SIZE_LONG)
2536 addword (baseo >> 16);
2537 if (siz1 != SIZE_UNSPEC)
2540 if (siz2 != SIZE_UNSPEC && isvar (&opP->odisp))
2541 add_fix (siz2 == SIZE_LONG ? 'l' : 'w', &opP->odisp, 0, 0);
2542 if (siz2 == SIZE_LONG)
2543 addword (outro >> 16);
2544 if (siz2 != SIZE_UNSPEC)
2550 nextword = get_num (&opP->disp, 90);
2551 switch (opP->disp.size)
2556 if (!isvar (&opP->disp) && issword (offs (&opP->disp)))
2558 tmpreg = 0x38; /* 7.0 */
2562 if (isvar (&opP->disp)
2563 && !subs (&opP->disp)
2564 && adds (&opP->disp)
2566 /* If the displacement needs pic relocation it
2567 cannot be relaxed. */
2568 && opP->disp.pic_reloc == pic_none
2571 && !strchr ("~%&$?", s[0]))
2573 tmpreg = 0x3A; /* 7.2 */
2574 add_frag (adds (&opP->disp),
2575 SEXT (offs (&opP->disp)),
2576 TAB (ABSTOPCREL, SZ_UNDEF));
2579 /* Fall through into long. */
2581 if (isvar (&opP->disp))
2582 add_fix ('l', &opP->disp, 0, 0);
2584 tmpreg = 0x39;/* 7.1 mode */
2585 addword (nextword >> 16);
2590 as_bad (_("unsupported byte value; use a different suffix"));
2594 if (isvar (&opP->disp))
2595 add_fix ('w', &opP->disp, 0, 0);
2597 tmpreg = 0x38;/* 7.0 mode */
2605 as_bad (_("unknown/incorrect operand"));
2609 /* If s[0] is '4', then this is for the mac instructions
2610 that can have a trailing_ampersand set. If so, set 0x100
2611 bit on tmpreg so install_gen_operand can check for it and
2612 set the appropriate bit (word2, bit 5). */
2615 if (opP->trailing_ampersand)
2618 install_gen_operand (s[1], tmpreg);
2624 { /* JF: I hate floating point! */
2639 tmpreg = get_num (&opP->disp, tmpreg);
2640 if (isvar (&opP->disp))
2641 add_fix (s[1], &opP->disp, 0, 0);
2644 case 'b': /* Danger: These do no check for
2645 certain types of overflow.
2647 if (!isbyte (tmpreg))
2648 opP->error = _("out of range");
2649 insop (tmpreg, opcode);
2650 if (isvar (&opP->disp))
2651 the_ins.reloc[the_ins.nrel - 1].n =
2652 (opcode->m_codenum) * 2 + 1;
2655 if (!issbyte (tmpreg))
2656 opP->error = _("out of range");
2657 the_ins.opcode[the_ins.numo - 1] |= tmpreg & 0xff;
2658 if (isvar (&opP->disp))
2659 the_ins.reloc[the_ins.nrel - 1].n = opcode->m_codenum * 2 - 1;
2662 if (!isword (tmpreg))
2663 opP->error = _("out of range");
2664 insop (tmpreg, opcode);
2665 if (isvar (&opP->disp))
2666 the_ins.reloc[the_ins.nrel - 1].n = (opcode->m_codenum) * 2;
2669 if (!issword (tmpreg))
2670 opP->error = _("out of range");
2671 insop (tmpreg, opcode);
2672 if (isvar (&opP->disp))
2673 the_ins.reloc[the_ins.nrel - 1].n = (opcode->m_codenum) * 2;
2676 /* Because of the way insop works, we put these two out
2678 insop (tmpreg, opcode);
2679 insop (tmpreg >> 16, opcode);
2680 if (isvar (&opP->disp))
2681 the_ins.reloc[the_ins.nrel - 1].n = (opcode->m_codenum) * 2;
2688 install_operand (s[1], tmpreg);
2699 install_operand (s[1], opP->reg - ADDR);
2703 tmpreg = get_num (&opP->disp, 90);
2707 add_fix ('B', &opP->disp, 1, -1);
2710 add_fix ('w', &opP->disp, 1, 0);
2715 if (! HAVE_LONG_BRANCH (current_architecture))
2716 as_warn (_("Can't use long branches on 68000/68010/5200"));
2717 the_ins.opcode[0] |= 0xff;
2718 add_fix ('l', &opP->disp, 1, 0);
2723 if (subs (&opP->disp)) /* We can't relax it. */
2727 /* If the displacement needs pic relocation it cannot be
2729 if (opP->disp.pic_reloc != pic_none)
2732 /* This could either be a symbol, or an absolute
2733 address. If it's an absolute address, turn it into
2734 an absolute jump right here and keep it out of the
2736 if (adds (&opP->disp) == 0)
2738 if (the_ins.opcode[0] == 0x6000) /* jbra */
2739 the_ins.opcode[0] = 0x4EF9;
2740 else if (the_ins.opcode[0] == 0x6100) /* jbsr */
2741 the_ins.opcode[0] = 0x4EB9;
2744 the_ins.opcode[0] ^= 0x0100;
2745 the_ins.opcode[0] |= 0x0006;
2748 add_fix ('l', &opP->disp, 0, 0);
2754 /* Now we know it's going into the relaxer. Now figure
2755 out which mode. We try in this order of preference:
2756 long branch, absolute jump, byte/word branches only. */
2757 if (HAVE_LONG_BRANCH (current_architecture))
2758 add_frag (adds (&opP->disp),
2759 SEXT (offs (&opP->disp)),
2760 TAB (BRANCHBWL, SZ_UNDEF));
2761 else if (! flag_keep_pcrel)
2763 if ((the_ins.opcode[0] == 0x6000)
2764 || (the_ins.opcode[0] == 0x6100))
2765 add_frag (adds (&opP->disp),
2766 SEXT (offs (&opP->disp)),
2767 TAB (BRABSJUNC, SZ_UNDEF));
2769 add_frag (adds (&opP->disp),
2770 SEXT (offs (&opP->disp)),
2771 TAB (BRABSJCOND, SZ_UNDEF));
2774 add_frag (adds (&opP->disp),
2775 SEXT (offs (&opP->disp)),
2776 TAB (BRANCHBW, SZ_UNDEF));
2779 if (isvar (&opP->disp))
2781 /* Check for DBcc instructions. We can relax them,
2782 but only if we have long branches and/or absolute
2784 if (((the_ins.opcode[0] & 0xf0f8) == 0x50c8)
2785 && (HAVE_LONG_BRANCH (current_architecture)
2786 || (! flag_keep_pcrel)))
2788 if (HAVE_LONG_BRANCH (current_architecture))
2789 add_frag (adds (&opP->disp),
2790 SEXT (offs (&opP->disp)),
2791 TAB (DBCCLBR, SZ_UNDEF));
2793 add_frag (adds (&opP->disp),
2794 SEXT (offs (&opP->disp)),
2795 TAB (DBCCABSJ, SZ_UNDEF));
2798 add_fix ('w', &opP->disp, 1, 0);
2802 case 'C': /* Fixed size LONG coproc branches. */
2803 add_fix ('l', &opP->disp, 1, 0);
2807 case 'c': /* Var size Coprocesssor branches. */
2808 if (subs (&opP->disp) || (adds (&opP->disp) == 0))
2810 the_ins.opcode[the_ins.numo - 1] |= 0x40;
2811 add_fix ('l', &opP->disp, 1, 0);
2816 add_frag (adds (&opP->disp),
2817 SEXT (offs (&opP->disp)),
2818 TAB (FBRANCH, SZ_UNDEF));
2825 case 'C': /* Ignore it. */
2828 case 'd': /* JF this is a kludge. */
2829 install_operand ('s', opP->reg - ADDR);
2830 tmpreg = get_num (&opP->disp, 90);
2831 if (!issword (tmpreg))
2833 as_warn (_("Expression out of range, using 0"));
2840 install_operand (s[1], opP->reg - DATA);
2843 case 'e': /* EMAC ACCx, reg/reg. */
2844 install_operand (s[1], opP->reg - ACC);
2847 case 'E': /* Ignore it. */
2851 install_operand (s[1], opP->reg - FP0);
2854 case 'g': /* EMAC ACCEXTx. */
2855 install_operand (s[1], opP->reg - ACCEXT01);
2858 case 'G': /* Ignore it. */
2863 tmpreg = opP->reg - COP0;
2864 install_operand (s[1], tmpreg);
2867 case 'i': /* MAC/EMAC scale factor. */
2868 install_operand (s[1], opP->mode == LSH ? 0x1 : 0x3);
2871 case 'J': /* JF foo. */
3001 install_operand (s[1], tmpreg);
3005 tmpreg = get_num (&opP->disp, 55);
3006 install_operand (s[1], tmpreg & 0x7f);
3013 if (tmpreg & 0x7FF0000)
3014 as_bad (_("Floating point register in register list"));
3015 insop (reverse_16_bits (tmpreg), opcode);
3019 if (tmpreg & 0x700FFFF)
3020 as_bad (_("Wrong register in floating-point reglist"));
3021 install_operand (s[1], reverse_8_bits (tmpreg >> 16));
3029 if (tmpreg & 0x7FF0000)
3030 as_bad (_("Floating point register in register list"));
3031 insop (tmpreg, opcode);
3033 else if (s[1] == '8')
3035 if (tmpreg & 0x0FFFFFF)
3036 as_bad (_("incorrect register in reglist"));
3037 install_operand (s[1], tmpreg >> 24);
3041 if (tmpreg & 0x700FFFF)
3042 as_bad (_("wrong register in floating-point reglist"));
3044 install_operand (s[1], tmpreg >> 16);
3049 install_operand (s[1], get_num (&opP->disp, 60));
3053 tmpreg = ((opP->mode == DREG)
3054 ? 0x20 + (int) (opP->reg - DATA)
3055 : (get_num (&opP->disp, 40) & 0x1F));
3056 install_operand (s[1], tmpreg);
3060 tmpreg = get_num (&opP->disp, 10);
3063 install_operand (s[1], tmpreg);
3067 /* This depends on the fact that ADDR registers are eight
3068 more than their corresponding DATA regs, so the result
3069 will have the ADDR_REG bit set. */
3070 install_operand (s[1], opP->reg - DATA);
3074 if (opP->mode == AINDR)
3075 install_operand (s[1], opP->reg - DATA);
3077 install_operand (s[1], opP->index.reg - DATA);
3081 if (opP->reg == FPI)
3083 else if (opP->reg == FPS)
3085 else if (opP->reg == FPC)
3089 install_operand (s[1], tmpreg);
3092 case 'S': /* Ignore it. */
3096 install_operand (s[1], get_num (&opP->disp, 30));
3099 case 'U': /* Ignore it. */
3118 as_fatal (_("failed sanity check"));
3119 } /* switch on cache token. */
3120 install_operand (s[1], tmpreg);
3123 /* JF: These are out of order, I fear. */
3136 install_operand (s[1], tmpreg);
3162 install_operand (s[1], tmpreg);
3166 if (opP->reg == VAL)
3185 install_operand (s[1], tmpreg);
3199 tmpreg = (4 << 10) | ((opP->reg - BAD) << 2);
3210 tmpreg = (5 << 10) | ((opP->reg - BAC) << 2);
3216 install_operand (s[1], tmpreg);
3219 know (opP->reg == PSR);
3222 know (opP->reg == PCSR);
3237 install_operand (s[1], tmpreg);
3240 tmpreg = get_num (&opP->disp, 20);
3241 install_operand (s[1], tmpreg);
3243 case '_': /* used only for move16 absolute 32-bit address. */
3244 if (isvar (&opP->disp))
3245 add_fix ('l', &opP->disp, 0, 0);
3246 tmpreg = get_num (&opP->disp, 90);
3247 addword (tmpreg >> 16);
3248 addword (tmpreg & 0xFFFF);
3251 install_operand (s[1], opP->reg - DATA0L);
3252 opP->reg -= (DATA0L);
3253 opP->reg &= 0x0F; /* remove upper/lower bit. */
3256 tmpreg = get_num (&opP->disp, 80);
3259 install_operand (s[1], tmpreg);
3266 /* By the time whe get here (FINALLY) the_ins contains the complete
3267 instruction, ready to be emitted. . . */
3271 reverse_16_bits (int in)
3276 static int mask[16] =
3278 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
3279 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000
3281 for (n = 0; n < 16; n++)
3284 out |= mask[15 - n];
3287 } /* reverse_16_bits() */
3290 reverse_8_bits (int in)
3295 static int mask[8] =
3297 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
3300 for (n = 0; n < 8; n++)
3306 } /* reverse_8_bits() */
3308 /* Cause an extra frag to be generated here, inserting up to 10 bytes
3309 (that value is chosen in the frag_var call in md_assemble). TYPE
3310 is the subtype of the frag to be generated; its primary type is
3311 rs_machine_dependent.
3313 The TYPE parameter is also used by md_convert_frag_1 and
3314 md_estimate_size_before_relax. The appropriate type of fixup will
3315 be emitted by md_convert_frag_1.
3317 ADD becomes the FR_SYMBOL field of the frag, and OFF the FR_OFFSET. */
3319 install_operand (int mode, int val)
3324 the_ins.opcode[0] |= val & 0xFF; /* JF FF is for M kludge. */
3327 the_ins.opcode[0] |= val << 9;
3330 the_ins.opcode[1] |= val << 12;
3333 the_ins.opcode[1] |= val << 6;
3336 the_ins.opcode[1] |= val;
3339 the_ins.opcode[2] |= val << 12;
3342 the_ins.opcode[2] |= val << 6;
3345 /* DANGER! This is a hack to force cas2l and cas2w cmds to be
3346 three words long! */
3348 the_ins.opcode[2] |= val;
3351 the_ins.opcode[1] |= val << 7;
3354 the_ins.opcode[1] |= val << 10;
3358 the_ins.opcode[1] |= val << 5;
3363 the_ins.opcode[1] |= (val << 10) | (val << 7);
3366 the_ins.opcode[1] |= (val << 12) | val;
3369 the_ins.opcode[0] |= val = 0xff;
3372 the_ins.opcode[0] |= val << 9;
3375 the_ins.opcode[1] |= val;
3378 the_ins.opcode[1] |= val;
3379 the_ins.numo++; /* What a hack. */
3382 the_ins.opcode[1] |= val << 4;
3390 the_ins.opcode[0] |= (val << 6);
3393 the_ins.opcode[1] = (val >> 16);
3394 the_ins.opcode[2] = val & 0xffff;
3397 the_ins.opcode[0] |= ((val & 0x8) << (6 - 3));
3398 the_ins.opcode[0] |= ((val & 0x7) << 9);
3399 the_ins.opcode[1] |= ((val & 0x10) << (7 - 4));
3401 case 'n': /* MAC/EMAC Rx on !load. */
3402 the_ins.opcode[0] |= ((val & 0x8) << (6 - 3));
3403 the_ins.opcode[0] |= ((val & 0x7) << 9);
3404 the_ins.opcode[1] |= ((val & 0x10) << (7 - 4));
3406 case 'o': /* MAC/EMAC Rx on load. */
3407 the_ins.opcode[1] |= val << 12;
3408 the_ins.opcode[1] |= ((val & 0x10) << (7 - 4));
3410 case 'M': /* MAC/EMAC Ry on !load. */
3411 the_ins.opcode[0] |= (val & 0xF);
3412 the_ins.opcode[1] |= ((val & 0x10) << (6 - 4));
3414 case 'N': /* MAC/EMAC Ry on load. */
3415 the_ins.opcode[1] |= (val & 0xF);
3416 the_ins.opcode[1] |= ((val & 0x10) << (6 - 4));
3419 the_ins.opcode[1] |= ((val != 1) << 10);
3422 the_ins.opcode[0] |= ((val & 0x3) << 9);
3425 the_ins.opcode[0] |= ((val & 0x3) << 0);
3427 case 'G': /* EMAC accumulator in a EMAC load instruction. */
3428 the_ins.opcode[0] |= ((~val & 0x1) << 7);
3429 the_ins.opcode[1] |= ((val & 0x2) << (4 - 1));
3431 case 'H': /* EMAC accumulator in a EMAC non-load instruction. */
3432 the_ins.opcode[0] |= ((val & 0x1) << 7);
3433 the_ins.opcode[1] |= ((val & 0x2) << (4 - 1));
3436 the_ins.opcode[1] |= ((val & 0x3) << 9);
3439 the_ins.opcode[0] |= (val & 0x1) <<10;
3443 as_fatal (_("failed sanity check."));
3448 install_gen_operand (int mode, int val)
3452 case '/': /* Special for mask loads for mac/msac insns with
3453 possible mask; trailing_ampersend set in bit 8. */
3454 the_ins.opcode[0] |= (val & 0x3f);
3455 the_ins.opcode[1] |= (((val & 0x100) >> 8) << 5);
3458 the_ins.opcode[0] |= val;
3461 /* This is a kludge!!! */
3462 the_ins.opcode[0] |= (val & 0x07) << 9 | (val & 0x38) << 3;
3471 the_ins.opcode[0] |= val;
3473 /* more stuff goes here. */
3475 as_fatal (_("failed sanity check."));
3479 /* Verify that we have some number of paren pairs, do m68k_ip_op(), and
3480 then deal with the bitfield hack. */
3483 crack_operand (char *str, struct m68k_op *opP)
3485 register int parens;
3487 register char *beg_str;
3495 for (parens = 0; *str && (parens > 0 || inquote || notend (str)); str++)
3501 else if (*str == ')')
3505 opP->error = _("Extra )");
3511 if (flag_mri && *str == '\'')
3512 inquote = ! inquote;
3514 if (!*str && parens)
3516 opP->error = _("Missing )");
3521 if (m68k_ip_op (beg_str, opP) != 0)
3528 c = *++str; /* JF bitfield hack. */
3533 as_bad (_("Missing operand"));
3536 /* Detect MRI REG symbols and convert them to REGLSTs. */
3537 if (opP->mode == CONTROL && (int)opP->reg < 0)
3540 opP->mask = ~(int)opP->reg;
3547 /* This is the guts of the machine-dependent assembler. STR points to a
3548 machine dependent instruction. This function is supposed to emit
3549 the frags/bytes it assembles to.
3553 insert_reg (const char *regname, int regnum)
3558 #ifdef REGISTER_PREFIX
3559 if (!flag_reg_prefix_optional)
3561 buf[0] = REGISTER_PREFIX;
3562 strcpy (buf + 1, regname);
3567 symbol_table_insert (symbol_new (regname, reg_section, regnum,
3568 &zero_address_frag));
3570 for (i = 0; regname[i]; i++)
3571 buf[i] = TOUPPER (regname[i]);
3574 symbol_table_insert (symbol_new (buf, reg_section, regnum,
3575 &zero_address_frag));
3584 static const struct init_entry init_table[] =
3644 { "accext01", ACCEXT01 },
3645 { "accext23", ACCEXT23 },
3649 /* Control registers. */
3650 { "sfc", SFC }, /* Source Function Code. */
3652 { "dfc", DFC }, /* Destination Function Code. */
3654 { "cacr", CACR }, /* Cache Control Register. */
3655 { "caar", CAAR }, /* Cache Address Register. */
3657 { "usp", USP }, /* User Stack Pointer. */
3658 { "vbr", VBR }, /* Vector Base Register. */
3659 { "msp", MSP }, /* Master Stack Pointer. */
3660 { "isp", ISP }, /* Interrupt Stack Pointer. */
3662 { "itt0", ITT0 }, /* Instruction Transparent Translation Reg 0. */
3663 { "itt1", ITT1 }, /* Instruction Transparent Translation Reg 1. */
3664 { "dtt0", DTT0 }, /* Data Transparent Translation Register 0. */
3665 { "dtt1", DTT1 }, /* Data Transparent Translation Register 1. */
3667 /* 68ec040 versions of same */
3668 { "iacr0", ITT0 }, /* Instruction Access Control Register 0. */
3669 { "iacr1", ITT1 }, /* Instruction Access Control Register 0. */
3670 { "dacr0", DTT0 }, /* Data Access Control Register 0. */
3671 { "dacr1", DTT1 }, /* Data Access Control Register 0. */
3673 /* mcf5200 versions of same. The ColdFire programmer's reference
3674 manual indicated that the order is 2,3,0,1, but Ken Rose
3675 <rose@netcom.com> says that 0,1,2,3 is the correct order. */
3676 { "acr0", ACR0 }, /* Access Control Unit 0. */
3677 { "acr1", ACR1 }, /* Access Control Unit 1. */
3678 { "acr2", ACR2 }, /* Access Control Unit 2. */
3679 { "acr3", ACR3 }, /* Access Control Unit 3. */
3681 { "tc", TC }, /* MMU Translation Control Register. */
3684 { "mmusr", MMUSR }, /* MMU Status Register. */
3685 { "srp", SRP }, /* User Root Pointer. */
3686 { "urp", URP }, /* Supervisor Root Pointer. */
3691 { "rombar", ROMBAR }, /* ROM Base Address Register. */
3692 { "rambar0", RAMBAR0 }, /* ROM Base Address Register. */
3693 { "rambar1", RAMBAR1 }, /* ROM Base Address Register. */
3694 { "mbar", MBAR }, /* Module Base Address Register. */
3696 { "mbar0", MBAR0 }, /* mcfv4e registers. */
3697 { "mbar1", MBAR1 }, /* mcfv4e registers. */
3698 { "rombar0", ROMBAR }, /* mcfv4e registers. */
3699 { "rombar1", ROMBAR1 }, /* mcfv4e registers. */
3700 { "mpcr", MPCR }, /* mcfv4e registers. */
3701 { "edrambar", EDRAMBAR }, /* mcfv4e registers. */
3702 { "secmbar", SECMBAR }, /* mcfv4e registers. */
3703 { "asid", TC }, /* mcfv4e registers. */
3704 { "mmubar", BUSCR }, /* mcfv4e registers. */
3705 { "pcr1u0", PCR1U0 }, /* mcfv4e registers. */
3706 { "pcr1l0", PCR1L0 }, /* mcfv4e registers. */
3707 { "pcr2u0", PCR2U0 }, /* mcfv4e registers. */
3708 { "pcr2l0", PCR2L0 }, /* mcfv4e registers. */
3709 { "pcr3u0", PCR3U0 }, /* mcfv4e registers. */
3710 { "pcr3l0", PCR3L0 }, /* mcfv4e registers. */
3711 { "pcr1u1", PCR1U1 }, /* mcfv4e registers. */
3712 { "pcr1l1", PCR1L1 }, /* mcfv4e registers. */
3713 { "pcr2u1", PCR2U1 }, /* mcfv4e registers. */
3714 { "pcr2l1", PCR2L1 }, /* mcfv4e registers. */
3715 { "pcr3u1", PCR3U1 }, /* mcfv4e registers. */
3716 { "pcr3l1", PCR3L1 }, /* mcfv4e registers. */
3718 { "flashbar", FLASHBAR }, /* mcf528x registers. */
3719 { "rambar", RAMBAR }, /* mcf528x registers. */
3721 { "mbar2", MBAR2 }, /* mcf5249 registers. */
3722 /* End of control registers. */
3756 /* 68ec030 versions of same. */
3759 /* 68ec030 access control unit, identical to 030 MMU status reg. */
3762 /* Suppressed data and address registers. */
3780 /* Upper and lower data and address registers, used by macw and msacw. */
3821 init_regtable (void)
3824 for (i = 0; init_table[i].name; i++)
3825 insert_reg (init_table[i].name, init_table[i].number);
3828 static int no_68851, no_68881;
3831 md_assemble (char *str)
3838 int shorts_this_frag;
3841 /* In MRI mode, the instruction and operands are separated by a
3842 space. Anything following the operands is a comment. The label
3843 has already been removed. */
3851 for (s = str; *s != '\0'; s++)
3853 if ((*s == ' ' || *s == '\t') && ! inquote)
3871 inquote = ! inquote;
3876 memset (&the_ins, '\0', sizeof (the_ins));
3881 for (n = 0; n < the_ins.numargs; n++)
3882 if (the_ins.operands[n].error)
3884 er = the_ins.operands[n].error;
3890 as_bad (_("%s -- statement `%s' ignored"), er, str);
3894 /* If there is a current label, record that it marks an instruction. */
3895 if (current_label != NULL)
3897 current_label->text = 1;
3898 current_label = NULL;
3902 /* Tie dwarf2 debug info to the address at the start of the insn. */
3903 dwarf2_emit_insn (0);
3906 if (the_ins.nfrag == 0)
3908 /* No frag hacking involved; just put it out. */
3909 toP = frag_more (2 * the_ins.numo);
3910 fromP = &the_ins.opcode[0];
3911 for (m = the_ins.numo; m; --m)
3913 md_number_to_chars (toP, (long) (*fromP), 2);
3917 /* Put out symbol-dependent info. */
3918 for (m = 0; m < the_ins.nrel; m++)
3920 switch (the_ins.reloc[m].wid)
3939 as_fatal (_("Don't know how to figure width of %c in md_assemble()"),
3940 the_ins.reloc[m].wid);
3943 fixP = fix_new_exp (frag_now,
3944 ((toP - frag_now->fr_literal)
3945 - the_ins.numo * 2 + the_ins.reloc[m].n),
3947 &the_ins.reloc[m].exp,
3948 the_ins.reloc[m].pcrel,
3949 get_reloc_code (n, the_ins.reloc[m].pcrel,
3950 the_ins.reloc[m].pic_reloc));
3951 fixP->fx_pcrel_adjust = the_ins.reloc[m].pcrel_fix;
3952 if (the_ins.reloc[m].wid == 'B')
3953 fixP->fx_signed = 1;
3958 /* There's some frag hacking. */
3960 /* Calculate the max frag size. */
3963 wid = 2 * the_ins.fragb[0].fragoff;
3964 for (n = 1; n < the_ins.nfrag; n++)
3965 wid += 2 * (the_ins.numo - the_ins.fragb[n - 1].fragoff);
3966 /* frag_var part. */
3968 /* Make sure the whole insn fits in one chunk, in particular that
3969 the var part is attached, as we access one byte before the
3970 variable frag for byte branches. */
3974 for (n = 0, fromP = &the_ins.opcode[0]; n < the_ins.nfrag; n++)
3979 wid = 2 * the_ins.fragb[n].fragoff;
3981 wid = 2 * (the_ins.numo - the_ins.fragb[n - 1].fragoff);
3982 toP = frag_more (wid);
3984 shorts_this_frag = 0;
3985 for (m = wid / 2; m; --m)
3987 md_number_to_chars (toP, (long) (*fromP), 2);
3992 for (m = 0; m < the_ins.nrel; m++)
3994 if ((the_ins.reloc[m].n) >= 2 * shorts_this_frag)
3996 the_ins.reloc[m].n -= 2 * shorts_this_frag;
3999 wid = the_ins.reloc[m].wid;
4002 the_ins.reloc[m].wid = 0;
4003 wid = (wid == 'b') ? 1 : (wid == 'w') ? 2 : (wid == 'l') ? 4 : 4000;
4005 fixP = fix_new_exp (frag_now,
4006 ((toP - frag_now->fr_literal)
4007 - the_ins.numo * 2 + the_ins.reloc[m].n),
4009 &the_ins.reloc[m].exp,
4010 the_ins.reloc[m].pcrel,
4011 get_reloc_code (wid, the_ins.reloc[m].pcrel,
4012 the_ins.reloc[m].pic_reloc));
4013 fixP->fx_pcrel_adjust = the_ins.reloc[m].pcrel_fix;
4015 (void) frag_var (rs_machine_dependent, 10, 0,
4016 (relax_substateT) (the_ins.fragb[n].fragty),
4017 the_ins.fragb[n].fadd, the_ins.fragb[n].foff, to_beg_P);
4019 n = (the_ins.numo - the_ins.fragb[n - 1].fragoff);
4020 shorts_this_frag = 0;
4023 toP = frag_more (n * 2);
4026 md_number_to_chars (toP, (long) (*fromP), 2);
4032 for (m = 0; m < the_ins.nrel; m++)
4036 wid = the_ins.reloc[m].wid;
4039 the_ins.reloc[m].wid = 0;
4040 wid = (wid == 'b') ? 1 : (wid == 'w') ? 2 : (wid == 'l') ? 4 : 4000;
4042 fixP = fix_new_exp (frag_now,
4043 ((the_ins.reloc[m].n + toP - frag_now->fr_literal)
4044 - shorts_this_frag * 2),
4046 &the_ins.reloc[m].exp,
4047 the_ins.reloc[m].pcrel,
4048 get_reloc_code (wid, the_ins.reloc[m].pcrel,
4049 the_ins.reloc[m].pic_reloc));
4050 fixP->fx_pcrel_adjust = the_ins.reloc[m].pcrel_fix;
4054 /* Comparison function used by qsort to rank the opcode entries by name. */
4057 m68k_compare_opcode (const void * v1, const void * v2)
4059 struct m68k_opcode * op1, * op2;
4065 op1 = *(struct m68k_opcode **) v1;
4066 op2 = *(struct m68k_opcode **) v2;
4068 /* Compare the two names. If different, return the comparison.
4069 If the same, return the order they are in the opcode table. */
4070 ret = strcmp (op1->name, op2->name);
4081 const struct m68k_opcode *ins;
4082 struct m68k_incant *hack, *slak;
4083 const char *retval = 0; /* Empty string, or error msg text. */
4086 /* Set up hash tables with 68000 instructions.
4087 similar to what the vax assembler does. */
4088 /* RMS claims the thing to do is take the m68k-opcode.h table, and make
4089 a copy of it at runtime, adding in the information we want but isn't
4090 there. I think it'd be better to have an awk script hack the table
4091 at compile time. Or even just xstr the table and use it as-is. But
4092 my lord ghod hath spoken, so we do it this way. Excuse the ugly var
4097 flag_reg_prefix_optional = 1;
4099 if (! m68k_rel32_from_cmdline)
4103 /* First sort the opcode table into alphabetical order to seperate
4104 the order that the assembler wants to see the opcodes from the
4105 order that the disassembler wants to see them. */
4106 m68k_sorted_opcodes = xmalloc (m68k_numopcodes * sizeof (* m68k_sorted_opcodes));
4107 if (!m68k_sorted_opcodes)
4108 as_fatal (_("Internal Error: Can't allocate m68k_sorted_opcodes of size %d"),
4109 m68k_numopcodes * ((int) sizeof (* m68k_sorted_opcodes)));
4111 for (i = m68k_numopcodes; i--;)
4112 m68k_sorted_opcodes[i] = m68k_opcodes + i;
4114 qsort (m68k_sorted_opcodes, m68k_numopcodes,
4115 sizeof (m68k_sorted_opcodes[0]), m68k_compare_opcode);
4117 op_hash = hash_new ();
4119 obstack_begin (&robyn, 4000);
4120 for (i = 0; i < m68k_numopcodes; i++)
4122 hack = slak = (struct m68k_incant *) obstack_alloc (&robyn, sizeof (struct m68k_incant));
4125 ins = m68k_sorted_opcodes[i];
4127 /* We *could* ignore insns that don't match our
4128 arch here by just leaving them out of the hash. */
4129 slak->m_operands = ins->args;
4130 slak->m_opnum = strlen (slak->m_operands) / 2;
4131 slak->m_arch = ins->arch;
4132 slak->m_opcode = ins->opcode;
4133 /* This is kludgey. */
4134 slak->m_codenum = ((ins->match) & 0xffffL) ? 2 : 1;
4135 if (i + 1 != m68k_numopcodes
4136 && !strcmp (ins->name, m68k_sorted_opcodes[i + 1]->name))
4138 slak->m_next = obstack_alloc (&robyn, sizeof (struct m68k_incant));
4143 slak = slak->m_next;
4147 retval = hash_insert (op_hash, ins->name, (char *) hack);
4149 as_fatal (_("Internal Error: Can't hash %s: %s"), ins->name, retval);
4152 for (i = 0; i < m68k_numaliases; i++)
4154 const char *name = m68k_opcode_aliases[i].primary;
4155 const char *alias = m68k_opcode_aliases[i].alias;
4156 PTR val = hash_find (op_hash, name);
4159 as_fatal (_("Internal Error: Can't find %s in hash table"), name);
4160 retval = hash_insert (op_hash, alias, val);
4162 as_fatal (_("Internal Error: Can't hash %s: %s"), alias, retval);
4165 /* In MRI mode, all unsized branches are variable sized. Normally,
4166 they are word sized. */
4169 static struct m68k_opcode_alias mri_aliases[] =
4190 i < (int) (sizeof mri_aliases / sizeof mri_aliases[0]);
4193 const char *name = mri_aliases[i].primary;
4194 const char *alias = mri_aliases[i].alias;
4195 PTR val = hash_find (op_hash, name);
4198 as_fatal (_("Internal Error: Can't find %s in hash table"), name);
4199 retval = hash_jam (op_hash, alias, val);
4201 as_fatal (_("Internal Error: Can't hash %s: %s"), alias, retval);
4205 for (i = 0; i < (int) sizeof (notend_table); i++)
4207 notend_table[i] = 0;
4208 alt_notend_table[i] = 0;
4211 notend_table[','] = 1;
4212 notend_table['{'] = 1;
4213 notend_table['}'] = 1;
4214 alt_notend_table['a'] = 1;
4215 alt_notend_table['A'] = 1;
4216 alt_notend_table['d'] = 1;
4217 alt_notend_table['D'] = 1;
4218 alt_notend_table['#'] = 1;
4219 alt_notend_table['&'] = 1;
4220 alt_notend_table['f'] = 1;
4221 alt_notend_table['F'] = 1;
4222 #ifdef REGISTER_PREFIX
4223 alt_notend_table[REGISTER_PREFIX] = 1;
4226 /* We need to put '(' in alt_notend_table to handle
4227 cas2 %d0:%d2,%d3:%d4,(%a0):(%a1) */
4228 alt_notend_table['('] = 1;
4230 /* We need to put '@' in alt_notend_table to handle
4231 cas2 %d0:%d2,%d3:%d4,@(%d0):@(%d1) */
4232 alt_notend_table['@'] = 1;
4234 /* We need to put digits in alt_notend_table to handle
4235 bfextu %d0{24:1},%d0 */
4236 alt_notend_table['0'] = 1;
4237 alt_notend_table['1'] = 1;
4238 alt_notend_table['2'] = 1;
4239 alt_notend_table['3'] = 1;
4240 alt_notend_table['4'] = 1;
4241 alt_notend_table['5'] = 1;
4242 alt_notend_table['6'] = 1;
4243 alt_notend_table['7'] = 1;
4244 alt_notend_table['8'] = 1;
4245 alt_notend_table['9'] = 1;
4247 #ifndef MIT_SYNTAX_ONLY
4248 /* Insert pseudo ops, these have to go into the opcode table since
4249 gas expects pseudo ops to start with a dot. */
4253 while (mote_pseudo_table[n].poc_name)
4255 hack = obstack_alloc (&robyn, sizeof (struct m68k_incant));
4256 hash_insert (op_hash,
4257 mote_pseudo_table[n].poc_name, (char *) hack);
4258 hack->m_operands = 0;
4268 record_alignment (text_section, 2);
4269 record_alignment (data_section, 2);
4270 record_alignment (bss_section, 2);
4275 select_control_regs (void)
4277 /* Note which set of "movec" control registers is available. */
4278 switch (current_chip)
4282 as_warn (_("architecture not yet selected: defaulting to 68020"));
4283 control_regs = m68020_control_regs;
4287 control_regs = m68000_control_regs;
4290 control_regs = m68010_control_regs;
4294 control_regs = m68020_control_regs;
4297 control_regs = m68040_control_regs;
4300 control_regs = m68060_control_regs;
4303 control_regs = cpu32_control_regs;
4309 control_regs = mcf_control_regs;
4312 control_regs = mcf5249_control_regs;
4316 control_regs = mcf528x_control_regs;
4320 control_regs = mcfv4e_control_regs;
4328 m68k_init_after_args (void)
4330 if (cpu_of_arch (current_architecture) == 0)
4333 const char *default_cpu = TARGET_CPU;
4335 if (*default_cpu == 'm')
4337 for (i = 0; i < n_archs; i++)
4338 if (strcasecmp (default_cpu, archs[i].name) == 0)
4342 as_bad (_("unrecognized default cpu `%s' ???"), TARGET_CPU);
4343 current_architecture |= m68020;
4346 current_architecture |= archs[i].arch;
4348 /* Permit m68881 specification with all cpus; those that can't work
4349 with a coprocessor could be doing emulation. */
4350 if (current_architecture & m68851)
4352 if (current_architecture & m68040)
4353 as_warn (_("68040 and 68851 specified; mmu instructions may assemble incorrectly"));
4355 /* What other incompatibilities could we check for? */
4357 /* Toss in some default assumptions about coprocessors. */
4359 && (cpu_of_arch (current_architecture)
4360 /* Can CPU32 have a 68881 coprocessor?? */
4361 & (m68020 | m68030 | cpu32)))
4362 current_architecture |= m68881;
4365 && (cpu_of_arch (current_architecture) & m68020up) != 0
4366 && (cpu_of_arch (current_architecture) & m68040up) == 0)
4367 current_architecture |= m68851;
4369 if (no_68881 && (current_architecture & m68881))
4370 as_bad (_("options for 68881 and no-68881 both given"));
4372 if (no_68851 && (current_architecture & m68851))
4373 as_bad (_("options for 68851 and no-68851 both given"));
4375 /* Note which set of "movec" control registers is available. */
4376 select_control_regs ();
4378 if (cpu_of_arch (current_architecture) < m68020
4379 || arch_coldfire_p (current_architecture))
4380 md_relax_table[TAB (PCINDEX, BYTE)].rlx_more = 0;
4383 /* This is called when a label is defined. */
4386 m68k_frob_label (symbolS *sym)
4388 struct label_line *n;
4390 n = (struct label_line *) xmalloc (sizeof *n);
4393 as_where (&n->file, &n->line);
4399 dwarf2_emit_label (sym);
4403 /* This is called when a value that is not an instruction is emitted. */
4406 m68k_flush_pending_output (void)
4408 current_label = NULL;
4411 /* This is called at the end of the assembly, when the final value of
4412 the label is known. We warn if this is a text symbol aligned at an
4416 m68k_frob_symbol (symbolS *sym)
4418 if (S_GET_SEGMENT (sym) == reg_section
4419 && (int) S_GET_VALUE (sym) < 0)
4421 S_SET_SEGMENT (sym, absolute_section);
4422 S_SET_VALUE (sym, ~(int)S_GET_VALUE (sym));
4424 else if ((S_GET_VALUE (sym) & 1) != 0)
4426 struct label_line *l;
4428 for (l = labels; l != NULL; l = l->next)
4430 if (l->label == sym)
4433 as_warn_where (l->file, l->line,
4434 _("text label `%s' aligned to odd boundary"),
4442 /* This is called if we go in or out of MRI mode because of the .mri
4446 m68k_mri_mode_change (int on)
4450 if (! flag_reg_prefix_optional)
4452 flag_reg_prefix_optional = 1;
4453 #ifdef REGISTER_PREFIX
4458 if (! m68k_rel32_from_cmdline)
4463 if (! reg_prefix_optional_seen)
4465 #ifdef REGISTER_PREFIX_OPTIONAL
4466 flag_reg_prefix_optional = REGISTER_PREFIX_OPTIONAL;
4468 flag_reg_prefix_optional = 0;
4470 #ifdef REGISTER_PREFIX
4475 if (! m68k_rel32_from_cmdline)
4480 /* Equal to MAX_PRECISION in atof-ieee.c. */
4481 #define MAX_LITTLENUMS 6
4483 /* Turn a string in input_line_pointer into a floating point constant
4484 of type TYPE, and store the appropriate bytes in *LITP. The number
4485 of LITTLENUMS emitted is stored in *SIZEP. An error message is
4486 returned, or NULL on OK. */
4489 md_atof (int type, char *litP, int *sizeP)
4492 LITTLENUM_TYPE words[MAX_LITTLENUMS];
4493 LITTLENUM_TYPE *wordP;
4524 return _("Bad call to MD_ATOF()");
4526 t = atof_ieee (input_line_pointer, type, words);
4528 input_line_pointer = t;
4530 *sizeP = prec * sizeof (LITTLENUM_TYPE);
4531 for (wordP = words; prec--;)
4533 md_number_to_chars (litP, (long) (*wordP++), sizeof (LITTLENUM_TYPE));
4534 litP += sizeof (LITTLENUM_TYPE);
4540 md_number_to_chars (char *buf, valueT val, int n)
4542 number_to_chars_bigendian (buf, val, n);
4546 md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
4548 offsetT val = *valP;
4549 addressT upper_limit;
4550 offsetT lower_limit;
4552 /* This is unnecessary but it convinces the native rs6000 compiler
4553 to generate the code we want. */
4554 char *buf = fixP->fx_frag->fr_literal;
4555 buf += fixP->fx_where;
4556 /* End ibm compiler workaround. */
4560 if (fixP->fx_addsy == NULL && fixP->fx_pcrel == 0)
4566 memset (buf, 0, fixP->fx_size);
4567 fixP->fx_addnumber = val; /* Remember value for emit_reloc. */
4569 if (fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT
4570 && !S_IS_DEFINED (fixP->fx_addsy)
4571 && !S_IS_WEAK (fixP->fx_addsy))
4572 S_SET_WEAK (fixP->fx_addsy);
4577 if (fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT
4578 || fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
4581 switch (fixP->fx_size)
4583 /* The cast to offsetT below are necessary to make code
4584 correct for machines where ints are smaller than offsetT. */
4588 lower_limit = - (offsetT) 0x80;
4591 *buf++ = (val >> 8);
4593 upper_limit = 0x7fff;
4594 lower_limit = - (offsetT) 0x8000;
4597 *buf++ = (val >> 24);
4598 *buf++ = (val >> 16);
4599 *buf++ = (val >> 8);
4601 upper_limit = 0x7fffffff;
4602 lower_limit = - (offsetT) 0x7fffffff - 1; /* Avoid constant overflow. */
4605 BAD_CASE (fixP->fx_size);
4608 /* Fix up a negative reloc. */
4609 if (fixP->fx_addsy == NULL && fixP->fx_subsy != NULL)
4611 fixP->fx_addsy = fixP->fx_subsy;
4612 fixP->fx_subsy = NULL;
4616 /* For non-pc-relative values, it's conceivable we might get something
4617 like "0xff" for a byte field. So extend the upper part of the range
4618 to accept such numbers. We arbitrarily disallow "-0xff" or "0xff+0xff",
4619 so that we can do any range checking at all. */
4620 if (! fixP->fx_pcrel && ! fixP->fx_signed)
4621 upper_limit = upper_limit * 2 + 1;
4623 if ((addressT) val > upper_limit
4624 && (val > 0 || val < lower_limit))
4625 as_bad_where (fixP->fx_file, fixP->fx_line, _("value out of range"));
4627 /* A one byte PC-relative reloc means a short branch. We can't use
4628 a short branch with a value of 0 or -1, because those indicate
4629 different opcodes (branches with longer offsets). fixup_segment
4630 in write.c may have clobbered fx_pcrel, so we need to examine the
4633 || fixP->fx_r_type == BFD_RELOC_8_PCREL)
4634 && fixP->fx_size == 1
4635 && (fixP->fx_addsy == NULL
4636 || S_IS_DEFINED (fixP->fx_addsy))
4637 && (val == 0 || val == -1))
4638 as_bad_where (fixP->fx_file, fixP->fx_line, _("invalid byte branch offset"));
4641 /* *fragP has been relaxed to its final size, and now needs to have
4642 the bytes inside it modified to conform to the new size There is UGLY
4646 md_convert_frag_1 (fragS *fragP)
4651 /* Address in object code of the displacement. */
4652 register int object_address = fragP->fr_fix + fragP->fr_address;
4654 /* Address in gas core of the place to store the displacement. */
4655 /* This convinces the native rs6000 compiler to generate the code we
4657 register char *buffer_address = fragP->fr_literal;
4658 buffer_address += fragP->fr_fix;
4659 /* End ibm compiler workaround. */
4661 /* The displacement of the address, from current location. */
4662 disp = fragP->fr_symbol ? S_GET_VALUE (fragP->fr_symbol) : 0;
4663 disp = (disp + fragP->fr_offset) - object_address;
4665 switch (fragP->fr_subtype)
4667 case TAB (BRANCHBWL, BYTE):
4668 case TAB (BRABSJUNC, BYTE):
4669 case TAB (BRABSJCOND, BYTE):
4670 case TAB (BRANCHBW, BYTE):
4671 know (issbyte (disp));
4673 as_bad_where (fragP->fr_file, fragP->fr_line,
4674 _("short branch with zero offset: use :w"));
4675 fixP = fix_new (fragP, fragP->fr_fix - 1, 1, fragP->fr_symbol,
4676 fragP->fr_offset, 1, RELAX_RELOC_PC8);
4677 fixP->fx_pcrel_adjust = -1;
4679 case TAB (BRANCHBWL, SHORT):
4680 case TAB (BRABSJUNC, SHORT):
4681 case TAB (BRABSJCOND, SHORT):
4682 case TAB (BRANCHBW, SHORT):
4683 fragP->fr_opcode[1] = 0x00;
4684 fix_new (fragP, fragP->fr_fix, 2, fragP->fr_symbol, fragP->fr_offset,
4685 1, RELAX_RELOC_PC16);
4688 case TAB (BRANCHBWL, LONG):
4689 fragP->fr_opcode[1] = (char) 0xFF;
4690 fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, fragP->fr_offset,
4691 1, RELAX_RELOC_PC32);
4694 case TAB (BRABSJUNC, LONG):
4695 if (fragP->fr_opcode[0] == 0x61) /* jbsr */
4697 if (flag_keep_pcrel)
4698 as_fatal (_("Tried to convert PC relative BSR to absolute JSR"));
4699 fragP->fr_opcode[0] = 0x4E;
4700 fragP->fr_opcode[1] = (char) 0xB9; /* JSR with ABSL LONG operand. */
4701 fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, fragP->fr_offset,
4702 0, RELAX_RELOC_ABS32);
4705 else if (fragP->fr_opcode[0] == 0x60) /* jbra */
4707 if (flag_keep_pcrel)
4708 as_fatal (_("Tried to convert PC relative branch to absolute jump"));
4709 fragP->fr_opcode[0] = 0x4E;
4710 fragP->fr_opcode[1] = (char) 0xF9; /* JMP with ABSL LONG operand. */
4711 fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, fragP->fr_offset,
4712 0, RELAX_RELOC_ABS32);
4717 /* This cannot happen, because jbsr and jbra are the only two
4718 unconditional branches. */
4722 case TAB (BRABSJCOND, LONG):
4723 if (flag_keep_pcrel)
4724 as_fatal (_("Tried to convert PC relative conditional branch to absolute jump"));
4726 /* Only Bcc 68000 instructions can come here
4727 Change bcc into b!cc/jmp absl long. */
4728 fragP->fr_opcode[0] ^= 0x01; /* Invert bcc. */
4729 fragP->fr_opcode[1] = 0x06; /* Branch offset = 6. */
4731 /* JF: these used to be fr_opcode[2,3], but they may be in a
4732 different frag, in which case referring to them is a no-no.
4733 Only fr_opcode[0,1] are guaranteed to work. */
4734 *buffer_address++ = 0x4e; /* put in jmp long (0x4ef9) */
4735 *buffer_address++ = (char) 0xf9;
4736 fragP->fr_fix += 2; /* Account for jmp instruction. */
4737 fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol,
4738 fragP->fr_offset, 0, RELAX_RELOC_ABS32);
4741 case TAB (FBRANCH, SHORT):
4742 know ((fragP->fr_opcode[1] & 0x40) == 0);
4743 fix_new (fragP, fragP->fr_fix, 2, fragP->fr_symbol, fragP->fr_offset,
4744 1, RELAX_RELOC_PC16);
4747 case TAB (FBRANCH, LONG):
4748 fragP->fr_opcode[1] |= 0x40; /* Turn on LONG bit. */
4749 fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, fragP->fr_offset,
4750 1, RELAX_RELOC_PC32);
4753 case TAB (DBCCLBR, SHORT):
4754 case TAB (DBCCABSJ, SHORT):
4755 fix_new (fragP, fragP->fr_fix, 2, fragP->fr_symbol, fragP->fr_offset,
4756 1, RELAX_RELOC_PC16);
4759 case TAB (DBCCLBR, LONG):
4760 /* Only DBcc instructions can come here.
4761 Change dbcc into dbcc/bral.
4762 JF: these used to be fr_opcode[2-7], but that's wrong. */
4763 if (flag_keep_pcrel)
4764 as_fatal (_("Tried to convert DBcc to absolute jump"));
4766 *buffer_address++ = 0x00; /* Branch offset = 4. */
4767 *buffer_address++ = 0x04;
4768 *buffer_address++ = 0x60; /* Put in bra pc+6. */
4769 *buffer_address++ = 0x06;
4770 *buffer_address++ = 0x60; /* Put in bral (0x60ff). */
4771 *buffer_address++ = (char) 0xff;
4773 fragP->fr_fix += 6; /* Account for bra/jmp instructions. */
4774 fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, fragP->fr_offset, 1,
4778 case TAB (DBCCABSJ, LONG):
4779 /* Only DBcc instructions can come here.
4780 Change dbcc into dbcc/jmp.
4781 JF: these used to be fr_opcode[2-7], but that's wrong. */
4782 if (flag_keep_pcrel)
4783 as_fatal (_("Tried to convert PC relative conditional branch to absolute jump"));
4785 *buffer_address++ = 0x00; /* Branch offset = 4. */
4786 *buffer_address++ = 0x04;
4787 *buffer_address++ = 0x60; /* Put in bra pc + 6. */
4788 *buffer_address++ = 0x06;
4789 *buffer_address++ = 0x4e; /* Put in jmp long (0x4ef9). */
4790 *buffer_address++ = (char) 0xf9;
4792 fragP->fr_fix += 6; /* Account for bra/jmp instructions. */
4793 fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, fragP->fr_offset, 0,
4797 case TAB (PCREL1632, SHORT):
4798 fragP->fr_opcode[1] &= ~0x3F;
4799 fragP->fr_opcode[1] |= 0x3A; /* 072 - mode 7.2 */
4800 fix_new (fragP, (int) (fragP->fr_fix), 2, fragP->fr_symbol,
4801 fragP->fr_offset, 1, RELAX_RELOC_PC16);
4804 case TAB (PCREL1632, LONG):
4805 /* Already set to mode 7.3; this indicates: PC indirect with
4806 suppressed index, 32-bit displacement. */
4807 *buffer_address++ = 0x01;
4808 *buffer_address++ = 0x70;
4810 fixP = fix_new (fragP, (int) (fragP->fr_fix), 4, fragP->fr_symbol,
4811 fragP->fr_offset, 1, RELAX_RELOC_PC32);
4812 fixP->fx_pcrel_adjust = 2;
4815 case TAB (PCINDEX, BYTE):
4816 assert (fragP->fr_fix >= 2);
4817 buffer_address[-2] &= ~1;
4818 fixP = fix_new (fragP, fragP->fr_fix - 1, 1, fragP->fr_symbol,
4819 fragP->fr_offset, 1, RELAX_RELOC_PC8);
4820 fixP->fx_pcrel_adjust = 1;
4822 case TAB (PCINDEX, SHORT):
4823 assert (fragP->fr_fix >= 2);
4824 buffer_address[-2] |= 0x1;
4825 buffer_address[-1] = 0x20;
4826 fixP = fix_new (fragP, (int) (fragP->fr_fix), 2, fragP->fr_symbol,
4827 fragP->fr_offset, 1, RELAX_RELOC_PC16);
4828 fixP->fx_pcrel_adjust = 2;
4831 case TAB (PCINDEX, LONG):
4832 assert (fragP->fr_fix >= 2);
4833 buffer_address[-2] |= 0x1;
4834 buffer_address[-1] = 0x30;
4835 fixP = fix_new (fragP, (int) (fragP->fr_fix), 4, fragP->fr_symbol,
4836 fragP->fr_offset, 1, RELAX_RELOC_PC32);
4837 fixP->fx_pcrel_adjust = 2;
4840 case TAB (ABSTOPCREL, SHORT):
4841 fix_new (fragP, fragP->fr_fix, 2, fragP->fr_symbol, fragP->fr_offset,
4842 1, RELAX_RELOC_PC16);
4845 case TAB (ABSTOPCREL, LONG):
4846 if (flag_keep_pcrel)
4847 as_fatal (_("Tried to convert PC relative conditional branch to absolute jump"));
4848 /* The thing to do here is force it to ABSOLUTE LONG, since
4849 ABSTOPCREL is really trying to shorten an ABSOLUTE address anyway. */
4850 if ((fragP->fr_opcode[1] & 0x3F) != 0x3A)
4852 fragP->fr_opcode[1] &= ~0x3F;
4853 fragP->fr_opcode[1] |= 0x39; /* Mode 7.1 */
4854 fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, fragP->fr_offset,
4855 0, RELAX_RELOC_ABS32);
4862 md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED,
4863 segT sec ATTRIBUTE_UNUSED,
4866 md_convert_frag_1 (fragP);
4869 /* Force truly undefined symbols to their maximum size, and generally set up
4870 the frag list to be relaxed
4873 md_estimate_size_before_relax (fragS *fragP, segT segment)
4875 /* Handle SZ_UNDEF first, it can be changed to BYTE or SHORT. */
4876 switch (fragP->fr_subtype)
4878 case TAB (BRANCHBWL, SZ_UNDEF):
4879 case TAB (BRABSJUNC, SZ_UNDEF):
4880 case TAB (BRABSJCOND, SZ_UNDEF):
4882 if (S_GET_SEGMENT (fragP->fr_symbol) == segment
4883 && relaxable_symbol (fragP->fr_symbol))
4885 fragP->fr_subtype = TAB (TABTYPE (fragP->fr_subtype), BYTE);
4887 else if (flag_short_refs)
4889 /* Symbol is undefined and we want short ref. */
4890 fragP->fr_subtype = TAB (TABTYPE (fragP->fr_subtype), SHORT);
4894 /* Symbol is still undefined. Make it LONG. */
4895 fragP->fr_subtype = TAB (TABTYPE (fragP->fr_subtype), LONG);
4900 case TAB (BRANCHBW, SZ_UNDEF):
4902 if (S_GET_SEGMENT (fragP->fr_symbol) == segment
4903 && relaxable_symbol (fragP->fr_symbol))
4905 fragP->fr_subtype = TAB (TABTYPE (fragP->fr_subtype), BYTE);
4909 /* Symbol is undefined and we don't have long branches. */
4910 fragP->fr_subtype = TAB (TABTYPE (fragP->fr_subtype), SHORT);
4915 case TAB (FBRANCH, SZ_UNDEF):
4916 case TAB (DBCCLBR, SZ_UNDEF):
4917 case TAB (DBCCABSJ, SZ_UNDEF):
4918 case TAB (PCREL1632, SZ_UNDEF):
4920 if ((S_GET_SEGMENT (fragP->fr_symbol) == segment
4921 && relaxable_symbol (fragP->fr_symbol))
4924 fragP->fr_subtype = TAB (TABTYPE (fragP->fr_subtype), SHORT);
4928 fragP->fr_subtype = TAB (TABTYPE (fragP->fr_subtype), LONG);
4933 case TAB (PCINDEX, SZ_UNDEF):
4934 if ((S_GET_SEGMENT (fragP->fr_symbol) == segment
4935 && relaxable_symbol (fragP->fr_symbol)))
4937 fragP->fr_subtype = TAB (PCINDEX, BYTE);
4941 fragP->fr_subtype = TAB (PCINDEX, LONG);
4945 case TAB (ABSTOPCREL, SZ_UNDEF):
4947 if ((S_GET_SEGMENT (fragP->fr_symbol) == segment
4948 && relaxable_symbol (fragP->fr_symbol)))
4950 fragP->fr_subtype = TAB (ABSTOPCREL, SHORT);
4954 fragP->fr_subtype = TAB (ABSTOPCREL, LONG);
4963 /* Now that SZ_UNDEF are taken care of, check others. */
4964 switch (fragP->fr_subtype)
4966 case TAB (BRANCHBWL, BYTE):
4967 case TAB (BRABSJUNC, BYTE):
4968 case TAB (BRABSJCOND, BYTE):
4969 case TAB (BRANCHBW, BYTE):
4970 /* We can't do a short jump to the next instruction, so in that
4971 case we force word mode. If the symbol is at the start of a
4972 frag, and it is the next frag with any data in it (usually
4973 this is just the next frag, but assembler listings may
4974 introduce empty frags), we must use word mode. */
4975 if (fragP->fr_symbol)
4979 sym_frag = symbol_get_frag (fragP->fr_symbol);
4980 if (S_GET_VALUE (fragP->fr_symbol) == sym_frag->fr_address)
4984 for (l = fragP->fr_next; l && l != sym_frag; l = l->fr_next)
4988 fragP->fr_subtype = TAB (TABTYPE (fragP->fr_subtype), SHORT);
4995 return md_relax_table[fragP->fr_subtype].rlx_length;
4998 #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
4999 /* the bit-field entries in the relocation_info struct plays hell
5000 with the byte-order problems of cross-assembly. So as a hack,
5001 I added this mach. dependent ri twiddler. Ugly, but it gets
5003 /* on m68k: first 4 bytes are normal unsigned long, next three bytes
5004 are symbolnum, most sig. byte first. Last byte is broken up with
5005 bit 7 as pcrel, bits 6 & 5 as length, bit 4 as pcrel, and the lower
5006 nibble as nuthin. (on Sun 3 at least) */
5007 /* Translate the internal relocation information into target-specific
5011 md_ri_to_chars (char *the_bytes, struct reloc_info_generic *ri)
5014 md_number_to_chars (the_bytes, ri->r_address, 4);
5015 /* Now the fun stuff. */
5016 the_bytes[4] = (ri->r_symbolnum >> 16) & 0x0ff;
5017 the_bytes[5] = (ri->r_symbolnum >> 8) & 0x0ff;
5018 the_bytes[6] = ri->r_symbolnum & 0x0ff;
5019 the_bytes[7] = (((ri->r_pcrel << 7) & 0x80)
5020 | ((ri->r_length << 5) & 0x60)
5021 | ((ri->r_extern << 4) & 0x10));
5026 #endif /* OBJ_AOUT or OBJ_BOUT */
5028 #ifndef WORKING_DOT_WORD
5029 int md_short_jump_size = 4;
5030 int md_long_jump_size = 6;
5033 md_create_short_jump (char *ptr, addressT from_addr, addressT to_addr,
5034 fragS *frag ATTRIBUTE_UNUSED,
5035 symbolS *to_symbol ATTRIBUTE_UNUSED)
5039 offset = to_addr - (from_addr + 2);
5041 md_number_to_chars (ptr, (valueT) 0x6000, 2);
5042 md_number_to_chars (ptr + 2, (valueT) offset, 2);
5046 md_create_long_jump (char *ptr, addressT from_addr, addressT to_addr,
5047 fragS *frag, symbolS *to_symbol)
5051 if (!HAVE_LONG_BRANCH (current_architecture))
5053 if (flag_keep_pcrel)
5054 as_fatal (_("Tried to convert PC relative branch to absolute jump"));
5055 offset = to_addr - S_GET_VALUE (to_symbol);
5056 md_number_to_chars (ptr, (valueT) 0x4EF9, 2);
5057 md_number_to_chars (ptr + 2, (valueT) offset, 4);
5058 fix_new (frag, (ptr + 2) - frag->fr_literal, 4, to_symbol, (offsetT) 0,
5063 offset = to_addr - (from_addr + 2);
5064 md_number_to_chars (ptr, (valueT) 0x60ff, 2);
5065 md_number_to_chars (ptr + 2, (valueT) offset, 4);
5071 /* Different values of OK tell what its OK to return. Things that
5072 aren't OK are an error (what a shock, no?)
5075 10: Absolute 1:8 only
5076 20: Absolute 0:7 only
5077 30: absolute 0:15 only
5078 40: Absolute 0:31 only
5079 50: absolute 0:127 only
5080 55: absolute -64:63 only
5081 60: absolute -128:127 only
5082 70: absolute 0:4095 only
5083 80: absolute -1, 1:7 only
5087 get_num (struct m68k_exp *exp, int ok)
5089 if (exp->exp.X_op == O_absent)
5091 /* Do the same thing the VAX asm does. */
5092 op (exp) = O_constant;
5098 as_warn (_("expression out of range: defaulting to 1"));
5102 else if (exp->exp.X_op == O_constant)
5107 if ((valueT) TRUNC (offs (exp)) - 1 > 7)
5109 as_warn (_("expression out of range: defaulting to 1"));
5114 if ((valueT) TRUNC (offs (exp)) > 7)
5118 if ((valueT) TRUNC (offs (exp)) > 15)
5122 if ((valueT) TRUNC (offs (exp)) > 32)
5126 if ((valueT) TRUNC (offs (exp)) > 127)
5130 if ((valueT) SEXT (offs (exp)) + 64 > 127)
5134 if ((valueT) SEXT (offs (exp)) + 128 > 255)
5138 if ((valueT) TRUNC (offs (exp)) > 4095)
5141 as_warn (_("expression out of range: defaulting to 0"));
5146 if ((valueT) TRUNC (offs (exp)) != 0xffffffff
5147 && (valueT) TRUNC (offs (exp)) - 1 > 6)
5149 as_warn (_("expression out of range: defaulting to 1"));
5157 else if (exp->exp.X_op == O_big)
5159 if (offs (exp) <= 0 /* flonum. */
5160 && (ok == 90 /* no bignums */
5161 || (ok > 10 /* Small-int ranges including 0 ok. */
5162 /* If we have a flonum zero, a zero integer should
5163 do as well (e.g., in moveq). */
5164 && generic_floating_point_number.exponent == 0
5165 && generic_floating_point_number.low[0] == 0)))
5167 /* HACK! Turn it into a long. */
5168 LITTLENUM_TYPE words[6];
5170 gen_to_words (words, 2, 8L); /* These numbers are magic! */
5171 op (exp) = O_constant;
5174 offs (exp) = words[1] | (words[0] << 16);
5178 op (exp) = O_constant;
5181 offs (exp) = (ok == 10) ? 1 : 0;
5182 as_warn (_("Can't deal with expression; defaulting to %ld"),
5188 if (ok >= 10 && ok <= 80)
5190 op (exp) = O_constant;
5193 offs (exp) = (ok == 10) ? 1 : 0;
5194 as_warn (_("Can't deal with expression; defaulting to %ld"),
5199 if (exp->size != SIZE_UNSPEC)
5207 if (!isbyte (offs (exp)))
5208 as_warn (_("expression doesn't fit in BYTE"));
5211 if (!isword (offs (exp)))
5212 as_warn (_("expression doesn't fit in WORD"));
5220 /* These are the back-ends for the various machine dependent pseudo-ops. */
5223 s_data1 (int ignore ATTRIBUTE_UNUSED)
5225 subseg_set (data_section, 1);
5226 demand_empty_rest_of_line ();
5230 s_data2 (int ignore ATTRIBUTE_UNUSED)
5232 subseg_set (data_section, 2);
5233 demand_empty_rest_of_line ();
5237 s_bss (int ignore ATTRIBUTE_UNUSED)
5239 /* We don't support putting frags in the BSS segment, we fake it
5240 by marking in_bss, then looking at s_skip for clues. */
5242 subseg_set (bss_section, 0);
5243 demand_empty_rest_of_line ();
5247 s_even (int ignore ATTRIBUTE_UNUSED)
5250 register long temp_fill;
5252 temp = 1; /* JF should be 2? */
5253 temp_fill = get_absolute_expression ();
5254 if (!need_pass_2) /* Never make frag if expect extra pass. */
5255 frag_align (temp, (int) temp_fill, 0);
5256 demand_empty_rest_of_line ();
5257 record_alignment (now_seg, temp);
5261 s_proc (int ignore ATTRIBUTE_UNUSED)
5263 demand_empty_rest_of_line ();
5266 /* Pseudo-ops handled for MRI compatibility. */
5268 /* This function returns non-zero if the argument is a conditional
5269 pseudo-op. This is called when checking whether a pending
5270 alignment is needed. */
5273 m68k_conditional_pseudoop (pseudo_typeS *pop)
5275 return (pop->poc_handler == s_mri_if
5276 || pop->poc_handler == s_mri_else);
5279 /* Handle an MRI style chip specification. */
5288 s = input_line_pointer;
5289 /* We can't use get_symbol_end since the processor names are not proper
5291 while (is_part_of_name (c = *input_line_pointer++))
5293 *--input_line_pointer = 0;
5294 for (i = 0; i < n_archs; i++)
5295 if (strcasecmp (s, archs[i].name) == 0)
5299 as_bad (_("%s: unrecognized processor name"), s);
5300 *input_line_pointer = c;
5301 ignore_rest_of_line ();
5304 *input_line_pointer = c;
5306 if (*input_line_pointer == '/')
5307 current_architecture = 0;
5309 current_architecture &= m68881 | m68851;
5310 current_architecture |= archs[i].arch;
5311 current_chip = archs[i].chip;
5313 while (*input_line_pointer == '/')
5315 ++input_line_pointer;
5316 s = input_line_pointer;
5317 /* We can't use get_symbol_end since the processor names are not
5319 while (is_part_of_name (c = *input_line_pointer++))
5321 *--input_line_pointer = 0;
5322 if (strcmp (s, "68881") == 0)
5323 current_architecture |= m68881;
5324 else if (strcmp (s, "68851") == 0)
5325 current_architecture |= m68851;
5326 *input_line_pointer = c;
5329 /* Update info about available control registers. */
5330 select_control_regs ();
5333 /* The MRI CHIP pseudo-op. */
5336 s_chip (int ignore ATTRIBUTE_UNUSED)
5342 stop = mri_comment_field (&stopc);
5345 mri_comment_end (stop, stopc);
5346 demand_empty_rest_of_line ();
5349 /* The MRI FOPT pseudo-op. */
5352 s_fopt (int ignore ATTRIBUTE_UNUSED)
5356 if (strncasecmp (input_line_pointer, "ID=", 3) == 0)
5360 input_line_pointer += 3;
5361 temp = get_absolute_expression ();
5362 if (temp < 0 || temp > 7)
5363 as_bad (_("bad coprocessor id"));
5365 m68k_float_copnum = COP0 + temp;
5369 as_bad (_("unrecognized fopt option"));
5370 ignore_rest_of_line ();
5374 demand_empty_rest_of_line ();
5377 /* The structure used to handle the MRI OPT pseudo-op. */
5381 /* The name of the option. */
5384 /* If this is not NULL, just call this function. The first argument
5385 is the ARG field of this structure, the second argument is
5386 whether the option was negated. */
5387 void (*pfn) (int arg, int on);
5389 /* If this is not NULL, and the PFN field is NULL, set the variable
5390 this points to. Set it to the ARG field if the option was not
5391 negated, and the NOTARG field otherwise. */
5394 /* The value to pass to PFN or to assign to *PVAR. */
5397 /* The value to assign to *PVAR if the option is negated. If PFN is
5398 NULL, and PVAR is not NULL, and ARG and NOTARG are the same, then
5399 the option may not be negated. */
5403 /* The table used to handle the MRI OPT pseudo-op. */
5405 static void skip_to_comma (int, int);
5406 static void opt_nest (int, int);
5407 static void opt_chip (int, int);
5408 static void opt_list (int, int);
5409 static void opt_list_symbols (int, int);
5411 static const struct opt_action opt_table[] =
5413 { "abspcadd", 0, &m68k_abspcadd, 1, 0 },
5415 /* We do relaxing, so there is little use for these options. */
5416 { "b", 0, 0, 0, 0 },
5417 { "brs", 0, 0, 0, 0 },
5418 { "brb", 0, 0, 0, 0 },
5419 { "brl", 0, 0, 0, 0 },
5420 { "brw", 0, 0, 0, 0 },
5422 { "c", 0, 0, 0, 0 },
5423 { "cex", 0, 0, 0, 0 },
5424 { "case", 0, &symbols_case_sensitive, 1, 0 },
5425 { "cl", 0, 0, 0, 0 },
5426 { "cre", 0, 0, 0, 0 },
5427 { "d", 0, &flag_keep_locals, 1, 0 },
5428 { "e", 0, 0, 0, 0 },
5429 { "f", 0, &flag_short_refs, 1, 0 },
5430 { "frs", 0, &flag_short_refs, 1, 0 },
5431 { "frl", 0, &flag_short_refs, 0, 1 },
5432 { "g", 0, 0, 0, 0 },
5433 { "i", 0, 0, 0, 0 },
5434 { "m", 0, 0, 0, 0 },
5435 { "mex", 0, 0, 0, 0 },
5436 { "mc", 0, 0, 0, 0 },
5437 { "md", 0, 0, 0, 0 },
5438 { "nest", opt_nest, 0, 0, 0 },
5439 { "next", skip_to_comma, 0, 0, 0 },
5440 { "o", 0, 0, 0, 0 },
5441 { "old", 0, 0, 0, 0 },
5442 { "op", skip_to_comma, 0, 0, 0 },
5443 { "pco", 0, 0, 0, 0 },
5444 { "p", opt_chip, 0, 0, 0 },
5445 { "pcr", 0, 0, 0, 0 },
5446 { "pcs", 0, 0, 0, 0 },
5447 { "r", 0, 0, 0, 0 },
5448 { "quick", 0, &m68k_quick, 1, 0 },
5449 { "rel32", 0, &m68k_rel32, 1, 0 },
5450 { "s", opt_list, 0, 0, 0 },
5451 { "t", opt_list_symbols, 0, 0, 0 },
5452 { "w", 0, &flag_no_warnings, 0, 1 },
5456 #define OPTCOUNT ((int) (sizeof opt_table / sizeof opt_table[0]))
5458 /* The MRI OPT pseudo-op. */
5461 s_opt (int ignore ATTRIBUTE_UNUSED)
5469 const struct opt_action *o;
5474 if (*input_line_pointer == '-')
5476 ++input_line_pointer;
5479 else if (strncasecmp (input_line_pointer, "NO", 2) == 0)
5481 input_line_pointer += 2;
5485 s = input_line_pointer;
5486 c = get_symbol_end ();
5488 for (i = 0, o = opt_table; i < OPTCOUNT; i++, o++)
5490 if (strcasecmp (s, o->name) == 0)
5494 /* Restore input_line_pointer now in case the option
5496 *input_line_pointer = c;
5497 (*o->pfn) (o->arg, t);
5499 else if (o->pvar != NULL)
5501 if (! t && o->arg == o->notarg)
5502 as_bad (_("option `%s' may not be negated"), s);
5503 *input_line_pointer = c;
5504 *o->pvar = t ? o->arg : o->notarg;
5507 *input_line_pointer = c;
5513 as_bad (_("option `%s' not recognized"), s);
5514 *input_line_pointer = c;
5517 while (*input_line_pointer++ == ',');
5519 /* Move back to terminating character. */
5520 --input_line_pointer;
5521 demand_empty_rest_of_line ();
5524 /* Skip ahead to a comma. This is used for OPT options which we do
5525 not support and which take arguments. */
5528 skip_to_comma (int arg ATTRIBUTE_UNUSED, int on ATTRIBUTE_UNUSED)
5530 while (*input_line_pointer != ','
5531 && ! is_end_of_line[(unsigned char) *input_line_pointer])
5532 ++input_line_pointer;
5535 /* Handle the OPT NEST=depth option. */
5538 opt_nest (int arg ATTRIBUTE_UNUSED, int on ATTRIBUTE_UNUSED)
5540 if (*input_line_pointer != '=')
5542 as_bad (_("bad format of OPT NEST=depth"));
5546 ++input_line_pointer;
5547 max_macro_nest = get_absolute_expression ();
5550 /* Handle the OPT P=chip option. */
5553 opt_chip (int arg ATTRIBUTE_UNUSED, int on ATTRIBUTE_UNUSED)
5555 if (*input_line_pointer != '=')
5557 /* This is just OPT P, which we do not support. */
5561 ++input_line_pointer;
5565 /* Handle the OPT S option. */
5568 opt_list (int arg ATTRIBUTE_UNUSED, int on)
5573 /* Handle the OPT T option. */
5576 opt_list_symbols (int arg ATTRIBUTE_UNUSED, int on)
5579 listing |= LISTING_SYMBOLS;
5581 listing &= ~LISTING_SYMBOLS;
5584 /* Handle the MRI REG pseudo-op. */
5587 s_reg (int ignore ATTRIBUTE_UNUSED)
5596 if (line_label == NULL)
5598 as_bad (_("missing label"));
5599 ignore_rest_of_line ();
5604 stop = mri_comment_field (&stopc);
5608 s = input_line_pointer;
5609 while (ISALNUM (*input_line_pointer)
5610 #ifdef REGISTER_PREFIX
5611 || *input_line_pointer == REGISTER_PREFIX
5613 || *input_line_pointer == '/'
5614 || *input_line_pointer == '-')
5615 ++input_line_pointer;
5616 c = *input_line_pointer;
5617 *input_line_pointer = '\0';
5619 if (m68k_ip_op (s, &rop) != 0)
5621 if (rop.error == NULL)
5622 as_bad (_("bad register list"));
5624 as_bad (_("bad register list: %s"), rop.error);
5625 *input_line_pointer = c;
5626 ignore_rest_of_line ();
5630 *input_line_pointer = c;
5632 if (rop.mode == REGLST)
5634 else if (rop.mode == DREG)
5635 mask = 1 << (rop.reg - DATA0);
5636 else if (rop.mode == AREG)
5637 mask = 1 << (rop.reg - ADDR0 + 8);
5638 else if (rop.mode == FPREG)
5639 mask = 1 << (rop.reg - FP0 + 16);
5640 else if (rop.mode == CONTROL
5643 else if (rop.mode == CONTROL
5646 else if (rop.mode == CONTROL
5651 as_bad (_("bad register list"));
5652 ignore_rest_of_line ();
5656 S_SET_SEGMENT (line_label, reg_section);
5657 S_SET_VALUE (line_label, ~mask);
5658 symbol_set_frag (line_label, &zero_address_frag);
5661 mri_comment_end (stop, stopc);
5663 demand_empty_rest_of_line ();
5666 /* This structure is used for the MRI SAVE and RESTORE pseudo-ops. */
5670 struct save_opts *next;
5672 int symbols_case_sensitive;
5681 /* FIXME: We don't save OPT S. */
5684 /* This variable holds the stack of saved options. */
5686 static struct save_opts *save_stack;
5688 /* The MRI SAVE pseudo-op. */
5691 s_save (int ignore ATTRIBUTE_UNUSED)
5693 struct save_opts *s;
5695 s = (struct save_opts *) xmalloc (sizeof (struct save_opts));
5696 s->abspcadd = m68k_abspcadd;
5697 s->symbols_case_sensitive = symbols_case_sensitive;
5698 s->keep_locals = flag_keep_locals;
5699 s->short_refs = flag_short_refs;
5700 s->architecture = current_architecture;
5701 s->chip = current_chip;
5702 s->quick = m68k_quick;
5703 s->rel32 = m68k_rel32;
5704 s->listing = listing;
5705 s->no_warnings = flag_no_warnings;
5707 s->next = save_stack;
5710 demand_empty_rest_of_line ();
5713 /* The MRI RESTORE pseudo-op. */
5716 s_restore (int ignore ATTRIBUTE_UNUSED)
5718 struct save_opts *s;
5720 if (save_stack == NULL)
5722 as_bad (_("restore without save"));
5723 ignore_rest_of_line ();
5728 save_stack = s->next;
5730 m68k_abspcadd = s->abspcadd;
5731 symbols_case_sensitive = s->symbols_case_sensitive;
5732 flag_keep_locals = s->keep_locals;
5733 flag_short_refs = s->short_refs;
5734 current_architecture = s->architecture;
5735 current_chip = s->chip;
5736 m68k_quick = s->quick;
5737 m68k_rel32 = s->rel32;
5738 listing = s->listing;
5739 flag_no_warnings = s->no_warnings;
5743 demand_empty_rest_of_line ();
5746 /* Types of MRI structured control directives. */
5748 enum mri_control_type
5756 /* This structure is used to stack the MRI structured control
5759 struct mri_control_info
5761 /* The directive within which this one is enclosed. */
5762 struct mri_control_info *outer;
5764 /* The type of directive. */
5765 enum mri_control_type type;
5767 /* Whether an ELSE has been in an IF. */
5770 /* The add or sub statement at the end of a FOR. */
5773 /* The label of the top of a FOR or REPEAT loop. */
5776 /* The label to jump to for the next iteration, or the else
5777 expression of a conditional. */
5780 /* The label to jump to to break out of the loop, or the label past
5781 the end of a conditional. */
5785 /* The stack of MRI structured control directives. */
5787 static struct mri_control_info *mri_control_stack;
5789 /* The current MRI structured control directive index number, used to
5790 generate label names. */
5792 static int mri_control_index;
5794 /* Assemble an instruction for an MRI structured control directive. */
5797 mri_assemble (char *str)
5801 /* md_assemble expects the opcode to be in lower case. */
5802 for (s = str; *s != ' ' && *s != '\0'; s++)
5808 /* Generate a new MRI label structured control directive label name. */
5811 mri_control_label (void)
5815 n = (char *) xmalloc (20);
5816 sprintf (n, "%smc%d", FAKE_LABEL_NAME, mri_control_index);
5817 ++mri_control_index;
5821 /* Create a new MRI structured control directive. */
5823 static struct mri_control_info *
5824 push_mri_control (enum mri_control_type type)
5826 struct mri_control_info *n;
5828 n = (struct mri_control_info *) xmalloc (sizeof (struct mri_control_info));
5832 if (type == mri_if || type == mri_while)
5835 n->top = mri_control_label ();
5836 n->next = mri_control_label ();
5837 n->bottom = mri_control_label ();
5839 n->outer = mri_control_stack;
5840 mri_control_stack = n;
5845 /* Pop off the stack of MRI structured control directives. */
5848 pop_mri_control (void)
5850 struct mri_control_info *n;
5852 n = mri_control_stack;
5853 mri_control_stack = n->outer;
5861 /* Recognize a condition code in an MRI structured control expression. */
5864 parse_mri_condition (int *pcc)
5868 know (*input_line_pointer == '<');
5870 ++input_line_pointer;
5871 c1 = *input_line_pointer++;
5872 c2 = *input_line_pointer++;
5874 if (*input_line_pointer != '>')
5876 as_bad (_("syntax error in structured control directive"));
5880 ++input_line_pointer;
5886 *pcc = (c1 << 8) | c2;
5891 /* Parse a single operand in an MRI structured control expression. */
5894 parse_mri_control_operand (int *pcc, char **leftstart, char **leftstop,
5895 char **rightstart, char **rightstop)
5907 if (*input_line_pointer == '<')
5909 /* It's just a condition code. */
5910 return parse_mri_condition (pcc);
5913 /* Look ahead for the condition code. */
5914 for (s = input_line_pointer; *s != '\0'; ++s)
5916 if (*s == '<' && s[1] != '\0' && s[2] != '\0' && s[3] == '>')
5921 as_bad (_("missing condition code in structured control directive"));
5925 *leftstart = input_line_pointer;
5927 if (*leftstop > *leftstart
5928 && ((*leftstop)[-1] == ' ' || (*leftstop)[-1] == '\t'))
5931 input_line_pointer = s;
5932 if (! parse_mri_condition (pcc))
5935 /* Look ahead for AND or OR or end of line. */
5936 for (s = input_line_pointer; *s != '\0'; ++s)
5938 /* We must make sure we don't misinterpret AND/OR at the end of labels!
5939 if d0 <eq> #FOOAND and d1 <ne> #BAROR then
5941 if ((s == input_line_pointer
5944 && ((strncasecmp (s, "AND", 3) == 0
5945 && (s[3] == '.' || ! is_part_of_name (s[3])))
5946 || (strncasecmp (s, "OR", 2) == 0
5947 && (s[2] == '.' || ! is_part_of_name (s[2])))))
5951 *rightstart = input_line_pointer;
5953 if (*rightstop > *rightstart
5954 && ((*rightstop)[-1] == ' ' || (*rightstop)[-1] == '\t'))
5957 input_line_pointer = s;
5962 #define MCC(b1, b2) (((b1) << 8) | (b2))
5964 /* Swap the sense of a condition. This changes the condition so that
5965 it generates the same result when the operands are swapped. */
5968 swap_mri_condition (int cc)
5972 case MCC ('h', 'i'): return MCC ('c', 's');
5973 case MCC ('l', 's'): return MCC ('c', 'c');
5974 /* <HS> is an alias for <CC>. */
5975 case MCC ('h', 's'):
5976 case MCC ('c', 'c'): return MCC ('l', 's');
5977 /* <LO> is an alias for <CS>. */
5978 case MCC ('l', 'o'):
5979 case MCC ('c', 's'): return MCC ('h', 'i');
5980 case MCC ('p', 'l'): return MCC ('m', 'i');
5981 case MCC ('m', 'i'): return MCC ('p', 'l');
5982 case MCC ('g', 'e'): return MCC ('l', 'e');
5983 case MCC ('l', 't'): return MCC ('g', 't');
5984 case MCC ('g', 't'): return MCC ('l', 't');
5985 case MCC ('l', 'e'): return MCC ('g', 'e');
5986 /* Issue a warning for conditions we can not swap. */
5987 case MCC ('n', 'e'): return MCC ('n', 'e'); // no problem here
5988 case MCC ('e', 'q'): return MCC ('e', 'q'); // also no problem
5989 case MCC ('v', 'c'):
5990 case MCC ('v', 's'):
5992 as_warn (_("Condition <%c%c> in structured control directive can not be encoded correctly"),
5993 (char) (cc >> 8), (char) (cc));
5999 /* Reverse the sense of a condition. */
6002 reverse_mri_condition (int cc)
6006 case MCC ('h', 'i'): return MCC ('l', 's');
6007 case MCC ('l', 's'): return MCC ('h', 'i');
6008 /* <HS> is an alias for <CC> */
6009 case MCC ('h', 's'): return MCC ('l', 'o');
6010 case MCC ('c', 'c'): return MCC ('c', 's');
6011 /* <LO> is an alias for <CS> */
6012 case MCC ('l', 'o'): return MCC ('h', 's');
6013 case MCC ('c', 's'): return MCC ('c', 'c');
6014 case MCC ('n', 'e'): return MCC ('e', 'q');
6015 case MCC ('e', 'q'): return MCC ('n', 'e');
6016 case MCC ('v', 'c'): return MCC ('v', 's');
6017 case MCC ('v', 's'): return MCC ('v', 'c');
6018 case MCC ('p', 'l'): return MCC ('m', 'i');
6019 case MCC ('m', 'i'): return MCC ('p', 'l');
6020 case MCC ('g', 'e'): return MCC ('l', 't');
6021 case MCC ('l', 't'): return MCC ('g', 'e');
6022 case MCC ('g', 't'): return MCC ('l', 'e');
6023 case MCC ('l', 'e'): return MCC ('g', 't');
6028 /* Build an MRI structured control expression. This generates test
6029 and branch instructions. It goes to TRUELAB if the condition is
6030 true, and to FALSELAB if the condition is false. Exactly one of
6031 TRUELAB and FALSELAB will be NULL, meaning to fall through. QUAL
6032 is the size qualifier for the expression. EXTENT is the size to
6033 use for the branch. */
6036 build_mri_control_operand (int qual, int cc, char *leftstart, char *leftstop,
6037 char *rightstart, char *rightstop,
6038 const char *truelab, const char *falselab,
6044 if (leftstart != NULL)
6046 struct m68k_op leftop, rightop;
6049 /* Swap the compare operands, if necessary, to produce a legal
6050 m68k compare instruction. Comparing a register operand with
6051 a non-register operand requires the register to be on the
6052 right (cmp, cmpa). Comparing an immediate value with
6053 anything requires the immediate value to be on the left
6058 (void) m68k_ip_op (leftstart, &leftop);
6063 (void) m68k_ip_op (rightstart, &rightop);
6066 if (rightop.mode == IMMED
6067 || ((leftop.mode == DREG || leftop.mode == AREG)
6068 && (rightop.mode != DREG && rightop.mode != AREG)))
6072 /* Correct conditional handling:
6073 if #1 <lt> d0 then ;means if (1 < d0)
6079 cmp #1,d0 if we do *not* swap the operands
6080 bgt true we need the swapped condition!
6087 leftstart = rightstart;
6090 leftstop = rightstop;
6095 cc = swap_mri_condition (cc);
6099 if (truelab == NULL)
6101 cc = reverse_mri_condition (cc);
6105 if (leftstart != NULL)
6107 buf = (char *) xmalloc (20
6108 + (leftstop - leftstart)
6109 + (rightstop - rightstart));
6115 *s++ = TOLOWER (qual);
6117 memcpy (s, leftstart, leftstop - leftstart);
6118 s += leftstop - leftstart;
6120 memcpy (s, rightstart, rightstop - rightstart);
6121 s += rightstop - rightstart;
6127 buf = (char *) xmalloc (20 + strlen (truelab));
6133 *s++ = TOLOWER (extent);
6135 strcpy (s, truelab);
6140 /* Parse an MRI structured control expression. This generates test
6141 and branch instructions. STOP is where the expression ends. It
6142 goes to TRUELAB if the condition is true, and to FALSELAB if the
6143 condition is false. Exactly one of TRUELAB and FALSELAB will be
6144 NULL, meaning to fall through. QUAL is the size qualifier for the
6145 expression. EXTENT is the size to use for the branch. */
6148 parse_mri_control_expression (char *stop, int qual, const char *truelab,
6149 const char *falselab, int extent)
6161 if (! parse_mri_control_operand (&cc, &leftstart, &leftstop,
6162 &rightstart, &rightstop))
6168 if (strncasecmp (input_line_pointer, "AND", 3) == 0)
6172 if (falselab != NULL)
6175 flab = mri_control_label ();
6177 build_mri_control_operand (qual, cc, leftstart, leftstop, rightstart,
6178 rightstop, (const char *) NULL, flab, extent);
6180 input_line_pointer += 3;
6181 if (*input_line_pointer != '.'
6182 || input_line_pointer[1] == '\0')
6186 qual = input_line_pointer[1];
6187 input_line_pointer += 2;
6190 if (! parse_mri_control_operand (&cc, &leftstart, &leftstop,
6191 &rightstart, &rightstop))
6197 build_mri_control_operand (qual, cc, leftstart, leftstop, rightstart,
6198 rightstop, truelab, falselab, extent);
6200 if (falselab == NULL)
6203 else if (strncasecmp (input_line_pointer, "OR", 2) == 0)
6207 if (truelab != NULL)
6210 tlab = mri_control_label ();
6212 build_mri_control_operand (qual, cc, leftstart, leftstop, rightstart,
6213 rightstop, tlab, (const char *) NULL, extent);
6215 input_line_pointer += 2;
6216 if (*input_line_pointer != '.'
6217 || input_line_pointer[1] == '\0')
6221 qual = input_line_pointer[1];
6222 input_line_pointer += 2;
6225 if (! parse_mri_control_operand (&cc, &leftstart, &leftstop,
6226 &rightstart, &rightstop))
6232 build_mri_control_operand (qual, cc, leftstart, leftstop, rightstart,
6233 rightstop, truelab, falselab, extent);
6235 if (truelab == NULL)
6240 build_mri_control_operand (qual, cc, leftstart, leftstop, rightstart,
6241 rightstop, truelab, falselab, extent);
6245 if (input_line_pointer != stop)
6246 as_bad (_("syntax error in structured control directive"));
6249 /* Handle the MRI IF pseudo-op. This may be a structured control
6250 directive, or it may be a regular assembler conditional, depending
6258 struct mri_control_info *n;
6260 /* A structured control directive must end with THEN with an
6261 optional qualifier. */
6262 s = input_line_pointer;
6263 /* We only accept '*' as introduction of comments if preceded by white space
6264 or at first column of a line (I think this can't actually happen here?)
6265 This is important when assembling:
6266 if d0 <ne> 12(a0,d0*2) then
6267 if d0 <ne> #CONST*20 then. */
6268 while (! (is_end_of_line[(unsigned char) *s]
6271 && (s == input_line_pointer
6273 || *(s-1) == '\t'))))
6276 while (s > input_line_pointer && (*s == ' ' || *s == '\t'))
6279 if (s - input_line_pointer > 1
6283 if (s - input_line_pointer < 3
6284 || strncasecmp (s - 3, "THEN", 4) != 0)
6288 as_bad (_("missing then"));
6289 ignore_rest_of_line ();
6293 /* It's a conditional. */
6298 /* Since this might be a conditional if, this pseudo-op will be
6299 called even if we are supported to be ignoring input. Double
6300 check now. Clobber *input_line_pointer so that ignore_input
6301 thinks that this is not a special pseudo-op. */
6302 c = *input_line_pointer;
6303 *input_line_pointer = 0;
6304 if (ignore_input ())
6306 *input_line_pointer = c;
6307 while (! is_end_of_line[(unsigned char) *input_line_pointer])
6308 ++input_line_pointer;
6309 demand_empty_rest_of_line ();
6312 *input_line_pointer = c;
6314 n = push_mri_control (mri_if);
6316 parse_mri_control_expression (s - 3, qual, (const char *) NULL,
6317 n->next, s[1] == '.' ? s[2] : '\0');
6320 input_line_pointer = s + 3;
6322 input_line_pointer = s + 1;
6326 while (! is_end_of_line[(unsigned char) *input_line_pointer])
6327 ++input_line_pointer;
6330 demand_empty_rest_of_line ();
6333 /* Handle the MRI else pseudo-op. If we are currently doing an MRI
6334 structured IF, associate the ELSE with the IF. Otherwise, assume
6335 it is a conditional else. */
6338 s_mri_else (int qual)
6345 && (mri_control_stack == NULL
6346 || mri_control_stack->type != mri_if
6347 || mri_control_stack->else_seen))
6353 c = *input_line_pointer;
6354 *input_line_pointer = 0;
6355 if (ignore_input ())
6357 *input_line_pointer = c;
6358 while (! is_end_of_line[(unsigned char) *input_line_pointer])
6359 ++input_line_pointer;
6360 demand_empty_rest_of_line ();
6363 *input_line_pointer = c;
6365 if (mri_control_stack == NULL
6366 || mri_control_stack->type != mri_if
6367 || mri_control_stack->else_seen)
6369 as_bad (_("else without matching if"));
6370 ignore_rest_of_line ();
6374 mri_control_stack->else_seen = 1;
6376 buf = (char *) xmalloc (20 + strlen (mri_control_stack->bottom));
6377 q[0] = TOLOWER (qual);
6379 sprintf (buf, "bra%s %s", q, mri_control_stack->bottom);
6383 colon (mri_control_stack->next);
6387 while (! is_end_of_line[(unsigned char) *input_line_pointer])
6388 ++input_line_pointer;
6391 demand_empty_rest_of_line ();
6394 /* Handle the MRI ENDI pseudo-op. */
6397 s_mri_endi (int ignore ATTRIBUTE_UNUSED)
6399 if (mri_control_stack == NULL
6400 || mri_control_stack->type != mri_if)
6402 as_bad (_("endi without matching if"));
6403 ignore_rest_of_line ();
6407 /* ignore_input will not return true for ENDI, so we don't need to
6408 worry about checking it again here. */
6410 if (! mri_control_stack->else_seen)
6411 colon (mri_control_stack->next);
6412 colon (mri_control_stack->bottom);
6418 while (! is_end_of_line[(unsigned char) *input_line_pointer])
6419 ++input_line_pointer;
6422 demand_empty_rest_of_line ();
6425 /* Handle the MRI BREAK pseudo-op. */
6428 s_mri_break (int extent)
6430 struct mri_control_info *n;
6434 n = mri_control_stack;
6436 && n->type != mri_for
6437 && n->type != mri_repeat
6438 && n->type != mri_while)
6442 as_bad (_("break outside of structured loop"));
6443 ignore_rest_of_line ();
6447 buf = (char *) xmalloc (20 + strlen (n->bottom));
6448 ex[0] = TOLOWER (extent);
6450 sprintf (buf, "bra%s %s", ex, n->bottom);
6456 while (! is_end_of_line[(unsigned char) *input_line_pointer])
6457 ++input_line_pointer;
6460 demand_empty_rest_of_line ();
6463 /* Handle the MRI NEXT pseudo-op. */
6466 s_mri_next (int extent)
6468 struct mri_control_info *n;
6472 n = mri_control_stack;
6474 && n->type != mri_for
6475 && n->type != mri_repeat
6476 && n->type != mri_while)
6480 as_bad (_("next outside of structured loop"));
6481 ignore_rest_of_line ();
6485 buf = (char *) xmalloc (20 + strlen (n->next));
6486 ex[0] = TOLOWER (extent);
6488 sprintf (buf, "bra%s %s", ex, n->next);
6494 while (! is_end_of_line[(unsigned char) *input_line_pointer])
6495 ++input_line_pointer;
6498 demand_empty_rest_of_line ();
6501 /* Handle the MRI FOR pseudo-op. */
6504 s_mri_for (int qual)
6506 const char *varstart, *varstop;
6507 const char *initstart, *initstop;
6508 const char *endstart, *endstop;
6509 const char *bystart, *bystop;
6513 struct mri_control_info *n;
6519 FOR.q var = init { TO | DOWNTO } end [ BY by ] DO.e
6523 varstart = input_line_pointer;
6525 /* Look for the '='. */
6526 while (! is_end_of_line[(unsigned char) *input_line_pointer]
6527 && *input_line_pointer != '=')
6528 ++input_line_pointer;
6529 if (*input_line_pointer != '=')
6531 as_bad (_("missing ="));
6532 ignore_rest_of_line ();
6536 varstop = input_line_pointer;
6537 if (varstop > varstart
6538 && (varstop[-1] == ' ' || varstop[-1] == '\t'))
6541 ++input_line_pointer;
6543 initstart = input_line_pointer;
6545 /* Look for TO or DOWNTO. */
6548 while (! is_end_of_line[(unsigned char) *input_line_pointer])
6550 if (strncasecmp (input_line_pointer, "TO", 2) == 0
6551 && ! is_part_of_name (input_line_pointer[2]))
6553 initstop = input_line_pointer;
6554 input_line_pointer += 2;
6557 if (strncasecmp (input_line_pointer, "DOWNTO", 6) == 0
6558 && ! is_part_of_name (input_line_pointer[6]))
6560 initstop = input_line_pointer;
6562 input_line_pointer += 6;
6565 ++input_line_pointer;
6567 if (initstop == NULL)
6569 as_bad (_("missing to or downto"));
6570 ignore_rest_of_line ();
6573 if (initstop > initstart
6574 && (initstop[-1] == ' ' || initstop[-1] == '\t'))
6578 endstart = input_line_pointer;
6580 /* Look for BY or DO. */
6583 while (! is_end_of_line[(unsigned char) *input_line_pointer])
6585 if (strncasecmp (input_line_pointer, "BY", 2) == 0
6586 && ! is_part_of_name (input_line_pointer[2]))
6588 endstop = input_line_pointer;
6590 input_line_pointer += 2;
6593 if (strncasecmp (input_line_pointer, "DO", 2) == 0
6594 && (input_line_pointer[2] == '.'
6595 || ! is_part_of_name (input_line_pointer[2])))
6597 endstop = input_line_pointer;
6598 input_line_pointer += 2;
6601 ++input_line_pointer;
6603 if (endstop == NULL)
6605 as_bad (_("missing do"));
6606 ignore_rest_of_line ();
6609 if (endstop > endstart
6610 && (endstop[-1] == ' ' || endstop[-1] == '\t'))
6616 bystop = bystart + 2;
6621 bystart = input_line_pointer;
6625 while (! is_end_of_line[(unsigned char) *input_line_pointer])
6627 if (strncasecmp (input_line_pointer, "DO", 2) == 0
6628 && (input_line_pointer[2] == '.'
6629 || ! is_part_of_name (input_line_pointer[2])))
6631 bystop = input_line_pointer;
6632 input_line_pointer += 2;
6635 ++input_line_pointer;
6639 as_bad (_("missing do"));
6640 ignore_rest_of_line ();
6643 if (bystop > bystart
6644 && (bystop[-1] == ' ' || bystop[-1] == '\t'))
6648 if (*input_line_pointer != '.')
6652 extent = input_line_pointer[1];
6653 input_line_pointer += 2;
6656 /* We have fully parsed the FOR operands. Now build the loop. */
6657 n = push_mri_control (mri_for);
6659 buf = (char *) xmalloc (50 + (input_line_pointer - varstart));
6661 /* Move init,var. */
6668 *s++ = TOLOWER (qual);
6670 memcpy (s, initstart, initstop - initstart);
6671 s += initstop - initstart;
6673 memcpy (s, varstart, varstop - varstart);
6674 s += varstop - varstart;
6686 *s++ = TOLOWER (qual);
6688 memcpy (s, endstart, endstop - endstart);
6689 s += endstop - endstart;
6691 memcpy (s, varstart, varstop - varstart);
6692 s += varstop - varstart;
6697 ex[0] = TOLOWER (extent);
6700 sprintf (buf, "blt%s %s", ex, n->bottom);
6702 sprintf (buf, "bgt%s %s", ex, n->bottom);
6705 /* Put together the add or sub instruction used by ENDF. */
6713 *s++ = TOLOWER (qual);
6715 memcpy (s, bystart, bystop - bystart);
6716 s += bystop - bystart;
6718 memcpy (s, varstart, varstop - varstart);
6719 s += varstop - varstart;
6725 while (! is_end_of_line[(unsigned char) *input_line_pointer])
6726 ++input_line_pointer;
6729 demand_empty_rest_of_line ();
6732 /* Handle the MRI ENDF pseudo-op. */
6735 s_mri_endf (int ignore ATTRIBUTE_UNUSED)
6737 if (mri_control_stack == NULL
6738 || mri_control_stack->type != mri_for)
6740 as_bad (_("endf without for"));
6741 ignore_rest_of_line ();
6745 colon (mri_control_stack->next);
6747 mri_assemble (mri_control_stack->incr);
6749 sprintf (mri_control_stack->incr, "bra %s", mri_control_stack->top);
6750 mri_assemble (mri_control_stack->incr);
6752 free (mri_control_stack->incr);
6754 colon (mri_control_stack->bottom);
6760 while (! is_end_of_line[(unsigned char) *input_line_pointer])
6761 ++input_line_pointer;
6764 demand_empty_rest_of_line ();
6767 /* Handle the MRI REPEAT pseudo-op. */
6770 s_mri_repeat (int ignore ATTRIBUTE_UNUSED)
6772 struct mri_control_info *n;
6774 n = push_mri_control (mri_repeat);
6778 while (! is_end_of_line[(unsigned char) *input_line_pointer])
6779 ++input_line_pointer;
6781 demand_empty_rest_of_line ();
6784 /* Handle the MRI UNTIL pseudo-op. */
6787 s_mri_until (int qual)
6791 if (mri_control_stack == NULL
6792 || mri_control_stack->type != mri_repeat)
6794 as_bad (_("until without repeat"));
6795 ignore_rest_of_line ();
6799 colon (mri_control_stack->next);
6801 for (s = input_line_pointer; ! is_end_of_line[(unsigned char) *s]; s++)
6804 parse_mri_control_expression (s, qual, (const char *) NULL,
6805 mri_control_stack->top, '\0');
6807 colon (mri_control_stack->bottom);
6809 input_line_pointer = s;
6815 while (! is_end_of_line[(unsigned char) *input_line_pointer])
6816 ++input_line_pointer;
6819 demand_empty_rest_of_line ();
6822 /* Handle the MRI WHILE pseudo-op. */
6825 s_mri_while (int qual)
6829 struct mri_control_info *n;
6831 s = input_line_pointer;
6832 /* We only accept '*' as introduction of comments if preceded by white space
6833 or at first column of a line (I think this can't actually happen here?)
6834 This is important when assembling:
6835 while d0 <ne> 12(a0,d0*2) do
6836 while d0 <ne> #CONST*20 do. */
6837 while (! (is_end_of_line[(unsigned char) *s]
6840 && (s == input_line_pointer
6842 || *(s-1) == '\t'))))
6845 while (*s == ' ' || *s == '\t')
6847 if (s - input_line_pointer > 1
6850 if (s - input_line_pointer < 2
6851 || strncasecmp (s - 1, "DO", 2) != 0)
6853 as_bad (_("missing do"));
6854 ignore_rest_of_line ();
6858 n = push_mri_control (mri_while);
6862 parse_mri_control_expression (s - 1, qual, (const char *) NULL, n->bottom,
6863 s[1] == '.' ? s[2] : '\0');
6865 input_line_pointer = s + 1;
6866 if (*input_line_pointer == '.')
6867 input_line_pointer += 2;
6871 while (! is_end_of_line[(unsigned char) *input_line_pointer])
6872 ++input_line_pointer;
6875 demand_empty_rest_of_line ();
6878 /* Handle the MRI ENDW pseudo-op. */
6881 s_mri_endw (int ignore ATTRIBUTE_UNUSED)
6885 if (mri_control_stack == NULL
6886 || mri_control_stack->type != mri_while)
6888 as_bad (_("endw without while"));
6889 ignore_rest_of_line ();
6893 buf = (char *) xmalloc (20 + strlen (mri_control_stack->next));
6894 sprintf (buf, "bra %s", mri_control_stack->next);
6898 colon (mri_control_stack->bottom);
6904 while (! is_end_of_line[(unsigned char) *input_line_pointer])
6905 ++input_line_pointer;
6908 demand_empty_rest_of_line ();
6912 Invocation line includes a switch not recognized by the base assembler.
6913 See if it's a processor-specific option. These are:
6915 -[A]m[c]68000, -[A]m[c]68008, -[A]m[c]68010, -[A]m[c]68020, -[A]m[c]68030, -[A]m[c]68040
6916 -[A]m[c]68881, -[A]m[c]68882, -[A]m[c]68851
6917 Select the architecture. Instructions or features not
6918 supported by the selected architecture cause fatal
6919 errors. More than one may be specified. The default is
6920 -m68020 -m68851 -m68881. Note that -m68008 is a synonym
6921 for -m68000, and -m68882 is a synonym for -m68881.
6922 -[A]m[c]no-68851, -[A]m[c]no-68881
6923 Don't accept 688?1 instructions. (The "c" is kind of silly,
6924 so don't use or document it, but that's the way the parsing
6928 -k Indicates PIC. (Sun 3 only.)
6930 Never turn PC-relative branches into absolute jumps.
6932 Permit `|' to be used in expressions. */
6935 const char *md_shortopts = "lSA:m:kQ:V";
6937 const char *md_shortopts = "lSA:m:k";
6940 struct option md_longopts[] = {
6941 #define OPTION_PIC (OPTION_MD_BASE)
6942 {"pic", no_argument, NULL, OPTION_PIC},
6943 #define OPTION_REGISTER_PREFIX_OPTIONAL (OPTION_MD_BASE + 1)
6944 {"register-prefix-optional", no_argument, NULL,
6945 OPTION_REGISTER_PREFIX_OPTIONAL},
6946 #define OPTION_BITWISE_OR (OPTION_MD_BASE + 2)
6947 {"bitwise-or", no_argument, NULL, OPTION_BITWISE_OR},
6948 #define OPTION_BASE_SIZE_DEFAULT_16 (OPTION_MD_BASE + 3)
6949 {"base-size-default-16", no_argument, NULL, OPTION_BASE_SIZE_DEFAULT_16},
6950 #define OPTION_BASE_SIZE_DEFAULT_32 (OPTION_MD_BASE + 4)
6951 {"base-size-default-32", no_argument, NULL, OPTION_BASE_SIZE_DEFAULT_32},
6952 #define OPTION_DISP_SIZE_DEFAULT_16 (OPTION_MD_BASE + 5)
6953 {"disp-size-default-16", no_argument, NULL, OPTION_DISP_SIZE_DEFAULT_16},
6954 #define OPTION_DISP_SIZE_DEFAULT_32 (OPTION_MD_BASE + 6)
6955 {"disp-size-default-32", no_argument, NULL, OPTION_DISP_SIZE_DEFAULT_32},
6956 #define OPTION_PCREL (OPTION_MD_BASE + 7)
6957 {"pcrel", no_argument, NULL, OPTION_PCREL},
6958 {NULL, no_argument, NULL, 0}
6960 size_t md_longopts_size = sizeof (md_longopts);
6963 md_parse_option (int c, char *arg)
6967 case 'l': /* -l means keep external to 2 bit offset
6968 rather than 16 bit one. */
6969 flag_short_refs = 1;
6972 case 'S': /* -S means that jbsr's always turn into
6974 flag_long_jumps = 1;
6977 case OPTION_PCREL: /* --pcrel means never turn PC-relative
6978 branches into absolute jumps. */
6979 flag_keep_pcrel = 1;
6985 /* Intentional fall-through. */
6988 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-')
6997 if (arg[0] == 'c' && arg[1] == '6')
7000 for (i = 0; i < n_archs; i++)
7001 if (!strcmp (arg, archs[i].name))
7006 arch = archs[i].arch;
7009 else if (arch == m68851)
7018 if (arg[0] == 'c' && arg[1] == '6')
7021 for (i = 0; i < n_archs; i++)
7022 if (!strcmp (arg, archs[i].name))
7024 unsigned long arch = archs[i].arch;
7026 if (cpu_of_arch (arch))
7027 /* It's a cpu spec. */
7029 current_architecture &= ~m68000up;
7030 current_architecture |= arch;
7031 current_chip = archs[i].chip;
7033 else if (arch == m68881)
7035 current_architecture |= m68881;
7038 else if (arch == m68851)
7040 current_architecture |= m68851;
7050 as_bad (_("unrecognized architecture specification `%s'"), arg);
7059 break; /* -pic, Position Independent Code. */
7061 case OPTION_REGISTER_PREFIX_OPTIONAL:
7062 flag_reg_prefix_optional = 1;
7063 reg_prefix_optional_seen = 1;
7066 /* -V: SVR4 argument to print version ID. */
7068 print_version_id ();
7071 /* -Qy, -Qn: SVR4 arguments controlling whether a .comment section
7072 should be emitted or not. FIXME: Not implemented. */
7076 case OPTION_BITWISE_OR:
7081 n = (char *) xmalloc (strlen (m68k_comment_chars) + 1);
7083 for (s = m68k_comment_chars; *s != '\0'; s++)
7087 m68k_comment_chars = n;
7091 case OPTION_BASE_SIZE_DEFAULT_16:
7092 m68k_index_width_default = SIZE_WORD;
7095 case OPTION_BASE_SIZE_DEFAULT_32:
7096 m68k_index_width_default = SIZE_LONG;
7099 case OPTION_DISP_SIZE_DEFAULT_16:
7101 m68k_rel32_from_cmdline = 1;
7104 case OPTION_DISP_SIZE_DEFAULT_32:
7106 m68k_rel32_from_cmdline = 1;
7117 md_show_usage (FILE *stream)
7119 const char *default_cpu = TARGET_CPU;
7121 unsigned int default_arch;
7123 /* Get the canonical name for the default target CPU. */
7124 if (*default_cpu == 'm')
7126 for (i = 0; i < n_archs; i++)
7128 if (strcasecmp (default_cpu, archs[i].name) == 0)
7130 default_arch = archs[i].arch;
7131 for (i = 0; i < n_archs; i++)
7133 if (archs[i].arch == default_arch
7136 default_cpu = archs[i].name;
7143 fprintf (stream, _("\
7145 -l use 1 word for refs to undefined symbols [default 2]\n\
7146 -m68000 | -m68008 | -m68010 | -m68020 | -m68030 | -m68040 | -m68060 |\n\
7147 -m68302 | -m68331 | -m68332 | -m68333 | -m68340 | -m68360 | -mcpu32 |\n\
7148 -m5200 | -m5202 | -m5204 | -m5206 | -m5206e | -m521x | -m5249 |\n\
7149 -m528x | -m5307 | -m5407 | -m547x | -m548x | -mcfv4 | -mcfv4e\n\
7150 specify variant of 680X0 architecture [default %s]\n\
7151 -m68881 | -m68882 | -mno-68881 | -mno-68882\n\
7152 target has/lacks floating-point coprocessor\n\
7153 [default yes for 68020, 68030, and cpu32]\n"),
7155 fprintf (stream, _("\
7156 -m68851 | -mno-68851\n\
7157 target has/lacks memory-management unit coprocessor\n\
7158 [default yes for 68020 and up]\n\
7159 -pic, -k generate position independent code\n\
7160 -S turn jbsr into jsr\n\
7161 --pcrel never turn PC-relative branches into absolute jumps\n\
7162 --register-prefix-optional\n\
7163 recognize register names without prefix character\n\
7164 --bitwise-or do not treat `|' as a comment character\n"));
7165 fprintf (stream, _("\
7166 --base-size-default-16 base reg without size is 16 bits\n\
7167 --base-size-default-32 base reg without size is 32 bits (default)\n\
7168 --disp-size-default-16 displacement with unknown size is 16 bits\n\
7169 --disp-size-default-32 displacement with unknown size is 32 bits (default)\n"));
7174 /* TEST2: Test md_assemble() */
7175 /* Warning, this routine probably doesn't work anymore. */
7179 struct m68k_it the_ins;
7187 if (!gets (buf) || !*buf)
7189 if (buf[0] == '|' || buf[1] == '.')
7191 for (cp = buf; *cp; cp++)
7196 memset (&the_ins, '\0', sizeof (the_ins));
7197 m68k_ip (&the_ins, buf);
7200 printf (_("Error %s in %s\n"), the_ins.error, buf);
7204 printf (_("Opcode(%d.%s): "), the_ins.numo, the_ins.args);
7205 for (n = 0; n < the_ins.numo; n++)
7206 printf (" 0x%x", the_ins.opcode[n] & 0xffff);
7208 print_the_insn (&the_ins.opcode[0], stdout);
7209 (void) putchar ('\n');
7211 for (n = 0; n < strlen (the_ins.args) / 2; n++)
7213 if (the_ins.operands[n].error)
7215 printf ("op%d Error %s in %s\n", n, the_ins.operands[n].error, buf);
7218 printf ("mode %d, reg %d, ", the_ins.operands[n].mode,
7219 the_ins.operands[n].reg);
7220 if (the_ins.operands[n].b_const)
7221 printf ("Constant: '%.*s', ",
7222 1 + the_ins.operands[n].e_const - the_ins.operands[n].b_const,
7223 the_ins.operands[n].b_const);
7224 printf ("ireg %d, isiz %d, imul %d, ", the_ins.operands[n].ireg,
7225 the_ins.operands[n].isiz, the_ins.operands[n].imul);
7226 if (the_ins.operands[n].b_iadd)
7227 printf ("Iadd: '%.*s',",
7228 1 + the_ins.operands[n].e_iadd - the_ins.operands[n].b_iadd,
7229 the_ins.operands[n].b_iadd);
7238 is_label (char *str)
7242 while (*str && *str != ' ')
7244 if (str[-1] == ':' || str[1] == '=')
7251 /* Possible states for relaxation:
7253 0 0 branch offset byte (bra, etc)
7257 1 0 indexed offsets byte a0@(32,d4:w:1) etc
7261 2 0 two-offset index word-word a0@(32,d4)@(45) etc
7268 /* We have no need to default values of symbols. */
7271 md_undefined_symbol (char *name ATTRIBUTE_UNUSED)
7276 /* Round up a section size to the appropriate boundary. */
7278 md_section_align (segT segment ATTRIBUTE_UNUSED, valueT size)
7281 /* For a.out, force the section size to be aligned. If we don't do
7282 this, BFD will align it for us, but it will not write out the
7283 final bytes of the section. This may be a bug in BFD, but it is
7284 easier to fix it here since that is how the other a.out targets
7288 align = bfd_get_section_alignment (stdoutput, segment);
7289 size = ((size + (1 << align) - 1) & ((valueT) -1 << align));
7295 /* Exactly what point is a PC-relative offset relative TO?
7296 On the 68k, it is relative to the address of the first extension
7297 word. The difference between the addresses of the offset and the
7298 first extension word is stored in fx_pcrel_adjust. */
7300 md_pcrel_from (fixS *fixP)
7304 /* Because fx_pcrel_adjust is a char, and may be unsigned, we explicitly
7305 sign extend the value here. */
7306 adjust = ((fixP->fx_pcrel_adjust & 0xff) ^ 0x80) - 0x80;
7309 return fixP->fx_where + fixP->fx_frag->fr_address - adjust;
7314 m68k_elf_final_processing (void)
7316 /* Set file-specific flags if this is a cpu32 processor. */
7317 if (arch_coldfire_fpu (current_architecture))
7318 elf_elfheader (stdoutput)->e_flags |= EF_CFV4E;
7319 if (cpu_of_arch (current_architecture) & cpu32)
7320 elf_elfheader (stdoutput)->e_flags |= EF_CPU32;
7321 else if ((cpu_of_arch (current_architecture) & m68000up)
7322 && !(cpu_of_arch (current_architecture) & m68020up))
7323 elf_elfheader (stdoutput)->e_flags |= EF_M68000;
7328 tc_m68k_regname_to_dw2regnum (const char *regname)
7330 unsigned int regnum;
7331 static const char *const regnames[] =
7333 "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
7334 "a0", "a1", "a2", "a3", "a4", "a5", "a6", "sp",
7335 "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7",
7339 for (regnum = 0; regnum < ARRAY_SIZE (regnames); regnum++)
7340 if (strcmp (regname, regnames[regnum]) == 0)
7347 tc_m68k_frame_initial_instructions (void)
7349 static int sp_regno = -1;
7352 sp_regno = tc_m68k_regname_to_dw2regnum ("sp");
7354 cfi_add_CFA_def_cfa (sp_regno, -DWARF2_CIE_DATA_ALIGNMENT);
7355 cfi_add_CFA_offset (DWARF2_DEFAULT_RETURN_COLUMN, DWARF2_CIE_DATA_ALIGNMENT);