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, 2006 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_ctrl
[] = { 0 };
156 static const enum m68k_register m68010_ctrl
[] = {
160 static const enum m68k_register m68020_ctrl
[] = {
161 SFC
, DFC
, USP
, VBR
, CACR
, CAAR
, MSP
, ISP
,
164 static const enum m68k_register m68040_ctrl
[] = {
165 SFC
, DFC
, CACR
, TC
, ITT0
, ITT1
, DTT0
, DTT1
,
166 USP
, VBR
, MSP
, ISP
, MMUSR
, URP
, SRP
,
169 static const enum m68k_register m68060_ctrl
[] = {
170 SFC
, DFC
, CACR
, TC
, ITT0
, ITT1
, DTT0
, DTT1
, BUSCR
,
171 USP
, VBR
, URP
, SRP
, PCR
,
174 static const enum m68k_register mcf_ctrl
[] = {
175 CACR
, TC
, ACR0
, ACR1
, ACR2
, ACR3
, VBR
, ROMBAR
,
176 RAMBAR0
, RAMBAR1
, MBAR
,
179 static const enum m68k_register mcf5208_ctrl
[] = {
180 CACR
, ACR0
, ACR1
, VBR
, RAMBAR1
,
183 static const enum m68k_register mcf5213_ctrl
[] = {
184 VBR
, RAMBAR
, FLASHBAR
,
187 static const enum m68k_register mcf5216_ctrl
[] = {
188 VBR
, CACR
, ACR0
, ACR1
, FLASHBAR
, RAMBAR
,
191 static const enum m68k_register mcf5235_ctrl
[] = {
192 VBR
, CACR
, ACR0
, ACR1
, RAMBAR
,
195 static const enum m68k_register mcf5249_ctrl
[] = {
196 VBR
, CACR
, ACR0
, ACR1
, RAMBAR0
, RAMBAR1
, MBAR
, MBAR2
,
199 static const enum m68k_register mcf5250_ctrl
[] = {
203 static const enum m68k_register mcf5271_ctrl
[] = {
204 VBR
, CACR
, ACR0
, ACR1
, RAMBAR
,
207 static const enum m68k_register mcf5272_ctrl
[] = {
208 VBR
, CACR
, ACR0
, ACR1
, ROMBAR
, RAMBAR
, MBAR
,
211 static const enum m68k_register mcf5275_ctrl
[] = {
212 VBR
, CACR
, ACR0
, ACR1
, RAMBAR
,
215 static const enum m68k_register mcf5282_ctrl
[] = {
216 VBR
, CACR
, ACR0
, ACR1
, FLASHBAR
, RAMBAR
,
219 static const enum m68k_register mcf5329_ctrl
[] = {
220 VBR
, CACR
, ACR0
, ACR1
, RAMBAR
,
223 static const enum m68k_register mcf5373_ctrl
[] = {
224 VBR
, CACR
, ACR0
, ACR1
, RAMBAR
,
227 static const enum m68k_register mcfv4e_ctrl
[] = {
228 CACR
, TC
, ITT0
, ITT1
, DTT0
, DTT1
, BUSCR
, VBR
, PC
, ROMBAR
,
229 ROMBAR1
, RAMBAR0
, RAMBAR1
, MPCR
, EDRAMBAR
, SECMBAR
, MBAR
, MBAR0
, MBAR1
,
230 PCR1U0
, PCR1L0
, PCR1U1
, PCR1L1
, PCR2U0
, PCR2L0
, PCR2U1
, PCR2L1
,
231 PCR3U0
, PCR3L0
, PCR3U1
, PCR3L1
,
234 static const enum m68k_register fido_ctrl
[] = {
235 SFC
, DFC
, USP
, VBR
, CAC
, MBB
,
238 #define cpu32_ctrl m68010_ctrl
240 static const enum m68k_register
*control_regs
;
242 /* Internal form of a 68020 instruction. */
246 const char *args
; /* List of opcode info. */
249 int numo
; /* Number of shorts in opcode. */
252 struct m68k_op operands
[6];
254 int nexp
; /* Number of exprs in use. */
255 struct m68k_exp exprs
[4];
257 int nfrag
; /* Number of frags we have to produce. */
260 int fragoff
; /* Where in the current opcode the frag ends. */
267 int nrel
; /* Num of reloc strucs in use. */
274 /* In a pc relative address the difference between the address
275 of the offset and the address that the offset is relative
276 to. This depends on the addressing mode. Basically this
277 is the value to put in the offset field to address the
278 first byte of the offset, without regarding the special
279 significance of some values (in the branch instruction, for
283 /* Whether this expression needs special pic relocation, and if
285 enum pic_relocation pic_reloc
;
288 reloc
[5]; /* Five is enough??? */
291 #define cpu_of_arch(x) ((x) & (m68000up | mcfisa_a | fido_a))
292 #define float_of_arch(x) ((x) & mfloat)
293 #define mmu_of_arch(x) ((x) & mmmu)
294 #define arch_coldfire_p(x) ((x) & mcfisa_a)
295 #define arch_coldfire_fpu(x) ((x) & cfloat)
297 /* Macros for determining if cpu supports a specific addressing mode. */
298 #define HAVE_LONG_BRANCH(x) ((x) & (m68020|m68030|m68040|m68060|cpu32|mcfisa_b))
300 static struct m68k_it the_ins
; /* The instruction being assembled. */
302 #define op(ex) ((ex)->exp.X_op)
303 #define adds(ex) ((ex)->exp.X_add_symbol)
304 #define subs(ex) ((ex)->exp.X_op_symbol)
305 #define offs(ex) ((ex)->exp.X_add_number)
307 /* Macros for adding things to the m68k_it struct. */
308 #define addword(w) (the_ins.opcode[the_ins.numo++] = (w))
310 /* Like addword, but goes BEFORE general operands. */
313 insop (int w
, const struct m68k_incant
*opcode
)
316 for (z
= the_ins
.numo
; z
> opcode
->m_codenum
; --z
)
317 the_ins
.opcode
[z
] = the_ins
.opcode
[z
- 1];
318 for (z
= 0; z
< the_ins
.nrel
; z
++)
319 the_ins
.reloc
[z
].n
+= 2;
320 for (z
= 0; z
< the_ins
.nfrag
; z
++)
321 the_ins
.fragb
[z
].fragoff
++;
322 the_ins
.opcode
[opcode
->m_codenum
] = w
;
326 /* The numo+1 kludge is so we can hit the low order byte of the prev word.
329 add_fix (int width
, struct m68k_exp
*exp
, int pc_rel
, int pc_fix
)
331 the_ins
.reloc
[the_ins
.nrel
].n
= (width
== 'B' || width
== '3'
332 ? the_ins
.numo
* 2 - 1
334 ? the_ins
.numo
* 2 + 1
335 : the_ins
.numo
* 2));
336 the_ins
.reloc
[the_ins
.nrel
].exp
= exp
->exp
;
337 the_ins
.reloc
[the_ins
.nrel
].wid
= width
;
338 the_ins
.reloc
[the_ins
.nrel
].pcrel_fix
= pc_fix
;
340 the_ins
.reloc
[the_ins
.nrel
].pic_reloc
= exp
->pic_reloc
;
342 the_ins
.reloc
[the_ins
.nrel
++].pcrel
= pc_rel
;
345 /* Cause an extra frag to be generated here, inserting up to 10 bytes
346 (that value is chosen in the frag_var call in md_assemble). TYPE
347 is the subtype of the frag to be generated; its primary type is
348 rs_machine_dependent.
350 The TYPE parameter is also used by md_convert_frag_1 and
351 md_estimate_size_before_relax. The appropriate type of fixup will
352 be emitted by md_convert_frag_1.
354 ADD becomes the FR_SYMBOL field of the frag, and OFF the FR_OFFSET. */
356 add_frag (symbolS
*add
, offsetT off
, int type
)
358 the_ins
.fragb
[the_ins
.nfrag
].fragoff
= the_ins
.numo
;
359 the_ins
.fragb
[the_ins
.nfrag
].fadd
= add
;
360 the_ins
.fragb
[the_ins
.nfrag
].foff
= off
;
361 the_ins
.fragb
[the_ins
.nfrag
++].fragty
= type
;
365 (op (ex) != O_constant && op (ex) != O_big)
367 static char *crack_operand (char *str
, struct m68k_op
*opP
);
368 static int get_num (struct m68k_exp
*exp
, int ok
);
369 static int reverse_16_bits (int in
);
370 static int reverse_8_bits (int in
);
371 static void install_gen_operand (int mode
, int val
);
372 static void install_operand (int mode
, int val
);
373 static void s_bss (int);
374 static void s_data1 (int);
375 static void s_data2 (int);
376 static void s_even (int);
377 static void s_proc (int);
378 static void s_chip (int);
379 static void s_fopt (int);
380 static void s_opt (int);
381 static void s_reg (int);
382 static void s_restore (int);
383 static void s_save (int);
384 static void s_mri_if (int);
385 static void s_mri_else (int);
386 static void s_mri_endi (int);
387 static void s_mri_break (int);
388 static void s_mri_next (int);
389 static void s_mri_for (int);
390 static void s_mri_endf (int);
391 static void s_mri_repeat (int);
392 static void s_mri_until (int);
393 static void s_mri_while (int);
394 static void s_mri_endw (int);
395 static void s_m68k_cpu (int);
396 static void s_m68k_arch (int);
400 unsigned long arch
; /* Architecture features. */
401 const enum m68k_register
*control_regs
; /* Control regs on chip */
402 const char *name
; /* Name */
403 int alias
; /* Alias for a cannonical name. If 1, then
404 succeeds canonical name, if -1 then
405 succeeds canonical name, if <-1 ||>1 this is a
406 deprecated name, and the next/previous name
410 /* We hold flags for features explicitly enabled and explicitly
412 static int current_architecture
;
413 static int not_current_architecture
;
414 static const struct m68k_cpu
*selected_arch
;
415 static const struct m68k_cpu
*selected_cpu
;
416 static int initialized
;
418 /* Architecture models. */
419 static const struct m68k_cpu m68k_archs
[] =
421 {m68000
, m68000_ctrl
, "68000", 0},
422 {m68010
, m68010_ctrl
, "68010", 0},
423 {m68020
|m68881
|m68851
, m68020_ctrl
, "68020", 0},
424 {m68030
|m68881
|m68851
, m68020_ctrl
, "68030", 0},
425 {m68040
, m68040_ctrl
, "68040", 0},
426 {m68060
, m68060_ctrl
, "68060", 0},
427 {cpu32
|m68881
, cpu32_ctrl
, "cpu32", 0},
428 {cpu32
|fido_a
, fido_ctrl
, "fidoa", 0},
429 {mcfisa_a
|mcfhwdiv
, NULL
, "isaa", 0},
430 {mcfisa_a
|mcfhwdiv
|mcfisa_aa
|mcfusp
, NULL
, "isaaplus", 0},
431 {mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfusp
, NULL
, "isab", 0},
432 {mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfmac
|mcfusp
, mcf_ctrl
, "cfv4", 0},
433 {mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "cfv4e", 0},
437 /* Architecture extensions, here 'alias' -1 for m68k, +1 for cf and 0
439 static const struct m68k_cpu m68k_extensions
[] =
441 {m68851
, NULL
, "68851", -1},
442 {m68881
, NULL
, "68881", -1},
443 {m68881
, NULL
, "68882", -1},
445 {cfloat
|m68881
, NULL
, "float", 0},
447 {mcfhwdiv
, NULL
, "div", 1},
448 {mcfusp
, NULL
, "usp", 1},
449 {mcfmac
, NULL
, "mac", 1},
450 {mcfemac
, NULL
, "emac", 1},
456 static const struct m68k_cpu m68k_cpus
[] =
458 {m68000
, m68000_ctrl
, "68000", 0},
459 {m68000
, m68000_ctrl
, "68ec000", 1},
460 {m68000
, m68000_ctrl
, "68hc000", 1},
461 {m68000
, m68000_ctrl
, "68hc001", 1},
462 {m68000
, m68000_ctrl
, "68008", 1},
463 {m68000
, m68000_ctrl
, "68302", 1},
464 {m68000
, m68000_ctrl
, "68306", 1},
465 {m68000
, m68000_ctrl
, "68307", 1},
466 {m68000
, m68000_ctrl
, "68322", 1},
467 {m68000
, m68000_ctrl
, "68356", 1},
468 {m68010
, m68010_ctrl
, "68010", 0},
469 {m68020
|m68881
|m68851
, m68020_ctrl
, "68020", 0},
470 {m68020
|m68881
|m68851
, m68020_ctrl
, "68k", 1},
471 {m68020
|m68881
|m68851
, m68020_ctrl
, "68ec020", 1},
472 {m68030
|m68881
|m68851
, m68020_ctrl
, "68030", 0},
473 {m68030
|m68881
|m68851
, m68020_ctrl
, "68ec030", 1},
474 {m68040
, m68040_ctrl
, "68040", 0},
475 {m68040
, m68040_ctrl
, "68ec040", 1},
476 {m68060
, m68060_ctrl
, "68060", 0},
477 {m68060
, m68060_ctrl
, "68ec060", 1},
479 {cpu32
|m68881
, cpu32_ctrl
, "cpu32", 0},
480 {cpu32
|m68881
, cpu32_ctrl
, "68330", 1},
481 {cpu32
|m68881
, cpu32_ctrl
, "68331", 1},
482 {cpu32
|m68881
, cpu32_ctrl
, "68332", 1},
483 {cpu32
|m68881
, cpu32_ctrl
, "68333", 1},
484 {cpu32
|m68881
, cpu32_ctrl
, "68334", 1},
485 {cpu32
|m68881
, cpu32_ctrl
, "68336", 1},
486 {cpu32
|m68881
, cpu32_ctrl
, "68340", 1},
487 {cpu32
|m68881
, cpu32_ctrl
, "68341", 1},
488 {cpu32
|m68881
, cpu32_ctrl
, "68349", 1},
489 {cpu32
|m68881
, cpu32_ctrl
, "68360", 1},
491 {mcfisa_a
, mcf_ctrl
, "5200", 0},
492 {mcfisa_a
, mcf_ctrl
, "5202", 1},
493 {mcfisa_a
, mcf_ctrl
, "5204", 1},
494 {mcfisa_a
, mcf_ctrl
, "5206", 1},
496 {mcfisa_a
|mcfhwdiv
|mcfmac
, mcf_ctrl
, "5206e", 0},
498 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5208_ctrl
, "5207", -1},
499 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5208_ctrl
, "5208", 0},
501 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfmac
|mcfusp
, mcf5213_ctrl
, "5211", -1},
502 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfmac
|mcfusp
, mcf5213_ctrl
, "5212", -1},
503 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfmac
|mcfusp
, mcf5213_ctrl
, "5213", 0},
505 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5216_ctrl
, "5214", -1},
506 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5216_ctrl
, "5216", 0},
507 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5216_ctrl
, "521x", 2},
509 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5235_ctrl
, "5232", -1},
510 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5235_ctrl
, "5233", -1},
511 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5235_ctrl
, "5234", -1},
512 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5235_ctrl
, "5235", -1},
513 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5235_ctrl
, "523x", 0},
515 {mcfisa_a
|mcfhwdiv
|mcfemac
, mcf5249_ctrl
, "5249", 0},
516 {mcfisa_a
|mcfhwdiv
|mcfemac
, mcf5250_ctrl
, "5250", 0},
518 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5271_ctrl
, "5270", -1},
519 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5271_ctrl
, "5271", 0},
521 {mcfisa_a
|mcfhwdiv
|mcfmac
, mcf5272_ctrl
, "5272", 0},
523 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5275_ctrl
, "5274", -1},
524 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5275_ctrl
, "5275", 0},
526 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5282_ctrl
, "5280", -1},
527 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5282_ctrl
, "5281", -1},
528 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5282_ctrl
, "5282", -1},
529 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5282_ctrl
, "528x", 0},
531 {mcfisa_a
|mcfhwdiv
|mcfmac
, mcf_ctrl
, "5307", 0},
533 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5329_ctrl
, "5327", -1},
534 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5329_ctrl
, "5328", -1},
535 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5329_ctrl
, "5329", -1},
536 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5329_ctrl
, "532x", 0},
538 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5373_ctrl
, "5372", -1},
539 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5373_ctrl
, "5373", -1},
540 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5373_ctrl
, "537x", 0},
542 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfmac
, mcf_ctrl
, "5407",0},
544 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5470", -1},
545 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5471", -1},
546 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5472", -1},
547 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5473", -1},
548 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5474", -1},
549 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5475", -1},
550 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "547x", 0},
552 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5480", -1},
553 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5481", -1},
554 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5482", -1},
555 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5483", -1},
556 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5484", -1},
557 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5485", -1},
558 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "548x", 0},
560 {cpu32
|fido_a
, fido_ctrl
, "fido", 1},
565 static const struct m68k_cpu
*m68k_lookup_cpu
566 (const char *, const struct m68k_cpu
*, int, int *);
567 static int m68k_set_arch (const char *, int, int);
568 static int m68k_set_cpu (const char *, int, int);
569 static int m68k_set_extension (const char *, int, int);
570 static void m68k_init_arch (void);
572 /* This is the assembler relaxation table for m68k. m68k is a rich CISC
573 architecture and we have a lot of relaxation modes. */
575 /* Macros used in the relaxation code. */
576 #define TAB(x,y) (((x) << 2) + (y))
577 #define TABTYPE(x) ((x) >> 2)
579 /* Relaxation states. */
585 /* Here are all the relaxation modes we support. First we can relax ordinary
586 branches. On 68020 and higher and on CPU32 all branch instructions take
587 three forms, so on these CPUs all branches always remain as such. When we
588 have to expand to the LONG form on a 68000, though, we substitute an
589 absolute jump instead. This is a direct replacement for unconditional
590 branches and a branch over a jump for conditional branches. However, if the
591 user requires PIC and disables this with --pcrel, we can only relax between
592 BYTE and SHORT forms, punting if that isn't enough. This gives us four
593 different relaxation modes for branches: */
595 #define BRANCHBWL 0 /* Branch byte, word, or long. */
596 #define BRABSJUNC 1 /* Absolute jump for LONG, unconditional. */
597 #define BRABSJCOND 2 /* Absolute jump for LONG, conditional. */
598 #define BRANCHBW 3 /* Branch byte or word. */
600 /* We also relax coprocessor branches and DBcc's. All CPUs that support
601 coprocessor branches support them in word and long forms, so we have only
602 one relaxation mode for them. DBcc's are word only on all CPUs. We can
603 relax them to the LONG form with a branch-around sequence. This sequence
604 can use a long branch (if available) or an absolute jump (if acceptable).
605 This gives us two relaxation modes. If long branches are not available and
606 absolute jumps are not acceptable, we don't relax DBcc's. */
608 #define FBRANCH 4 /* Coprocessor branch. */
609 #define DBCCLBR 5 /* DBcc relaxable with a long branch. */
610 #define DBCCABSJ 6 /* DBcc relaxable with an absolute jump. */
612 /* That's all for instruction relaxation. However, we also relax PC-relative
613 operands. Specifically, we have three operand relaxation modes. On the
614 68000 PC-relative operands can only be 16-bit, but on 68020 and higher and
615 on CPU32 they may be 16-bit or 32-bit. For the latter we relax between the
616 two. Also PC+displacement+index operands in their simple form (with a non-
617 suppressed index without memory indirection) are supported on all CPUs, but
618 on the 68000 the displacement can be 8-bit only, whereas on 68020 and higher
619 and on CPU32 we relax it to SHORT and LONG forms as well using the extended
620 form of the PC+displacement+index operand. Finally, some absolute operands
621 can be relaxed down to 16-bit PC-relative. */
623 #define PCREL1632 7 /* 16-bit or 32-bit PC-relative. */
624 #define PCINDEX 8 /* PC + displacement + index. */
625 #define ABSTOPCREL 9 /* Absolute relax down to 16-bit PC-relative. */
627 /* Note that calls to frag_var need to specify the maximum expansion
628 needed; this is currently 10 bytes for DBCC. */
631 How far Forward this mode will reach:
632 How far Backward this mode will reach:
633 How many bytes this mode will add to the size of the frag
634 Which mode to go to if the offset won't fit in this one
636 Please check tc-m68k.h:md_prepare_relax_scan if changing this table. */
637 relax_typeS md_relax_table
[] =
639 { 127, -128, 0, TAB (BRANCHBWL
, SHORT
) },
640 { 32767, -32768, 2, TAB (BRANCHBWL
, LONG
) },
644 { 127, -128, 0, TAB (BRABSJUNC
, SHORT
) },
645 { 32767, -32768, 2, TAB (BRABSJUNC
, LONG
) },
649 { 127, -128, 0, TAB (BRABSJCOND
, SHORT
) },
650 { 32767, -32768, 2, TAB (BRABSJCOND
, LONG
) },
654 { 127, -128, 0, TAB (BRANCHBW
, SHORT
) },
659 { 1, 1, 0, 0 }, /* FBRANCH doesn't come BYTE. */
660 { 32767, -32768, 2, TAB (FBRANCH
, LONG
) },
664 { 1, 1, 0, 0 }, /* DBCC doesn't come BYTE. */
665 { 32767, -32768, 2, TAB (DBCCLBR
, LONG
) },
669 { 1, 1, 0, 0 }, /* DBCC doesn't come BYTE. */
670 { 32767, -32768, 2, TAB (DBCCABSJ
, LONG
) },
674 { 1, 1, 0, 0 }, /* PCREL1632 doesn't come BYTE. */
675 { 32767, -32768, 2, TAB (PCREL1632
, LONG
) },
679 { 125, -130, 0, TAB (PCINDEX
, SHORT
) },
680 { 32765, -32770, 2, TAB (PCINDEX
, LONG
) },
684 { 1, 1, 0, 0 }, /* ABSTOPCREL doesn't come BYTE. */
685 { 32767, -32768, 2, TAB (ABSTOPCREL
, LONG
) },
690 /* These are the machine dependent pseudo-ops. These are included so
691 the assembler can work on the output from the SUN C compiler, which
694 /* This table describes all the machine specific pseudo-ops the assembler
695 has to support. The fields are:
696 pseudo-op name without dot
697 function to call to execute this pseudo-op
698 Integer arg to pass to the function. */
699 const pseudo_typeS md_pseudo_table
[] =
701 {"data1", s_data1
, 0},
702 {"data2", s_data2
, 0},
705 {"skip", s_space
, 0},
707 #if defined (TE_SUN3) || defined (OBJ_ELF)
708 {"align", s_align_bytes
, 0},
711 {"swbeg", s_ignore
, 0},
713 {"extend", float_cons
, 'x'},
714 {"ldouble", float_cons
, 'x'},
716 {"arch", s_m68k_arch
, 0},
717 {"cpu", s_m68k_cpu
, 0},
719 /* The following pseudo-ops are supported for MRI compatibility. */
721 {"comline", s_space
, 1},
723 {"mask2", s_ignore
, 0},
726 {"restore", s_restore
, 0},
730 {"if.b", s_mri_if
, 'b'},
731 {"if.w", s_mri_if
, 'w'},
732 {"if.l", s_mri_if
, 'l'},
733 {"else", s_mri_else
, 0},
734 {"else.s", s_mri_else
, 's'},
735 {"else.l", s_mri_else
, 'l'},
736 {"endi", s_mri_endi
, 0},
737 {"break", s_mri_break
, 0},
738 {"break.s", s_mri_break
, 's'},
739 {"break.l", s_mri_break
, 'l'},
740 {"next", s_mri_next
, 0},
741 {"next.s", s_mri_next
, 's'},
742 {"next.l", s_mri_next
, 'l'},
743 {"for", s_mri_for
, 0},
744 {"for.b", s_mri_for
, 'b'},
745 {"for.w", s_mri_for
, 'w'},
746 {"for.l", s_mri_for
, 'l'},
747 {"endf", s_mri_endf
, 0},
748 {"repeat", s_mri_repeat
, 0},
749 {"until", s_mri_until
, 0},
750 {"until.b", s_mri_until
, 'b'},
751 {"until.w", s_mri_until
, 'w'},
752 {"until.l", s_mri_until
, 'l'},
753 {"while", s_mri_while
, 0},
754 {"while.b", s_mri_while
, 'b'},
755 {"while.w", s_mri_while
, 'w'},
756 {"while.l", s_mri_while
, 'l'},
757 {"endw", s_mri_endw
, 0},
762 /* The mote pseudo ops are put into the opcode table, since they
763 don't start with a . they look like opcodes to gas. */
765 const pseudo_typeS mote_pseudo_table
[] =
778 {"xdef", s_globl
, 0},
780 {"align", s_align_bytes
, 0},
782 {"align", s_align_ptwo
, 0},
785 {"sect", obj_coff_section
, 0},
786 {"section", obj_coff_section
, 0},
791 /* Truncate and sign-extend at 32 bits, so that building on a 64-bit host
792 gives identical results to a 32-bit host. */
793 #define TRUNC(X) ((valueT) (X) & 0xffffffff)
794 #define SEXT(X) ((TRUNC (X) ^ 0x80000000) - 0x80000000)
796 #define issbyte(x) ((valueT) SEXT (x) + 0x80 < 0x100)
797 #define isubyte(x) ((valueT) TRUNC (x) < 0x100)
798 #define issword(x) ((valueT) SEXT (x) + 0x8000 < 0x10000)
799 #define isuword(x) ((valueT) TRUNC (x) < 0x10000)
801 #define isbyte(x) ((valueT) SEXT (x) + 0xff < 0x1ff)
802 #define isword(x) ((valueT) SEXT (x) + 0xffff < 0x1ffff)
803 #define islong(x) (1)
805 static char notend_table
[256];
806 static char alt_notend_table
[256];
808 (! (notend_table[(unsigned char) *s] \
810 && alt_notend_table[(unsigned char) s[1]])))
814 /* Return zero if the reference to SYMBOL from within the same segment may
817 /* On an ELF system, we can't relax an externally visible symbol,
818 because it may be overridden by a shared library. However, if
819 TARGET_OS is "elf", then we presume that we are assembling for an
820 embedded system, in which case we don't have to worry about shared
821 libraries, and we can relax any external sym. */
823 #define relaxable_symbol(symbol) \
824 (!((S_IS_EXTERNAL (symbol) && EXTERN_FORCE_RELOC) \
825 || S_IS_WEAK (symbol)))
827 /* Compute the relocation code for a fixup of SIZE bytes, using pc
828 relative relocation if PCREL is non-zero. PIC says whether a special
829 pic relocation was requested. */
831 static bfd_reloc_code_real_type
832 get_reloc_code (int size
, int pcrel
, enum pic_relocation pic
)
840 return BFD_RELOC_8_GOT_PCREL
;
842 return BFD_RELOC_16_GOT_PCREL
;
844 return BFD_RELOC_32_GOT_PCREL
;
852 return BFD_RELOC_8_GOTOFF
;
854 return BFD_RELOC_16_GOTOFF
;
856 return BFD_RELOC_32_GOTOFF
;
864 return BFD_RELOC_8_PLT_PCREL
;
866 return BFD_RELOC_16_PLT_PCREL
;
868 return BFD_RELOC_32_PLT_PCREL
;
876 return BFD_RELOC_8_PLTOFF
;
878 return BFD_RELOC_16_PLTOFF
;
880 return BFD_RELOC_32_PLTOFF
;
890 return BFD_RELOC_8_PCREL
;
892 return BFD_RELOC_16_PCREL
;
894 return BFD_RELOC_32_PCREL
;
914 as_bad (_("Can not do %d byte pc-relative relocation"), size
);
916 as_bad (_("Can not do %d byte pc-relative pic relocation"), size
);
921 as_bad (_("Can not do %d byte relocation"), size
);
923 as_bad (_("Can not do %d byte pic relocation"), size
);
926 return BFD_RELOC_NONE
;
929 /* Here we decide which fixups can be adjusted to make them relative
930 to the beginning of the section instead of the symbol. Basically
931 we need to make sure that the dynamic relocations are done
932 correctly, so in some cases we force the original symbol to be
935 tc_m68k_fix_adjustable (fixS
*fixP
)
937 /* Adjust_reloc_syms doesn't know about the GOT. */
938 switch (fixP
->fx_r_type
)
940 case BFD_RELOC_8_GOT_PCREL
:
941 case BFD_RELOC_16_GOT_PCREL
:
942 case BFD_RELOC_32_GOT_PCREL
:
943 case BFD_RELOC_8_GOTOFF
:
944 case BFD_RELOC_16_GOTOFF
:
945 case BFD_RELOC_32_GOTOFF
:
946 case BFD_RELOC_8_PLT_PCREL
:
947 case BFD_RELOC_16_PLT_PCREL
:
948 case BFD_RELOC_32_PLT_PCREL
:
949 case BFD_RELOC_8_PLTOFF
:
950 case BFD_RELOC_16_PLTOFF
:
951 case BFD_RELOC_32_PLTOFF
:
954 case BFD_RELOC_VTABLE_INHERIT
:
955 case BFD_RELOC_VTABLE_ENTRY
:
965 #define get_reloc_code(SIZE,PCREL,OTHER) NO_RELOC
967 #define relaxable_symbol(symbol) 1
972 tc_gen_reloc (asection
*section ATTRIBUTE_UNUSED
, fixS
*fixp
)
975 bfd_reloc_code_real_type code
;
977 /* If the tcbit is set, then this was a fixup of a negative value
978 that was never resolved. We do not have a reloc to handle this,
979 so just return. We assume that other code will have detected this
980 situation and produced a helpful error message, so we just tell the
981 user that the reloc cannot be produced. */
985 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
986 _("Unable to produce reloc against symbol '%s'"),
987 S_GET_NAME (fixp
->fx_addsy
));
991 if (fixp
->fx_r_type
!= BFD_RELOC_NONE
)
993 code
= fixp
->fx_r_type
;
995 /* Since DIFF_EXPR_OK is defined in tc-m68k.h, it is possible
996 that fixup_segment converted a non-PC relative reloc into a
997 PC relative reloc. In such a case, we need to convert the
1004 code
= BFD_RELOC_8_PCREL
;
1007 code
= BFD_RELOC_16_PCREL
;
1010 code
= BFD_RELOC_32_PCREL
;
1012 case BFD_RELOC_8_PCREL
:
1013 case BFD_RELOC_16_PCREL
:
1014 case BFD_RELOC_32_PCREL
:
1015 case BFD_RELOC_8_GOT_PCREL
:
1016 case BFD_RELOC_16_GOT_PCREL
:
1017 case BFD_RELOC_32_GOT_PCREL
:
1018 case BFD_RELOC_8_GOTOFF
:
1019 case BFD_RELOC_16_GOTOFF
:
1020 case BFD_RELOC_32_GOTOFF
:
1021 case BFD_RELOC_8_PLT_PCREL
:
1022 case BFD_RELOC_16_PLT_PCREL
:
1023 case BFD_RELOC_32_PLT_PCREL
:
1024 case BFD_RELOC_8_PLTOFF
:
1025 case BFD_RELOC_16_PLTOFF
:
1026 case BFD_RELOC_32_PLTOFF
:
1029 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1030 _("Cannot make %s relocation PC relative"),
1031 bfd_get_reloc_code_name (code
));
1037 #define F(SZ,PCREL) (((SZ) << 1) + (PCREL))
1038 switch (F (fixp
->fx_size
, fixp
->fx_pcrel
))
1040 #define MAP(SZ,PCREL,TYPE) case F(SZ,PCREL): code = (TYPE); break
1041 MAP (1, 0, BFD_RELOC_8
);
1042 MAP (2, 0, BFD_RELOC_16
);
1043 MAP (4, 0, BFD_RELOC_32
);
1044 MAP (1, 1, BFD_RELOC_8_PCREL
);
1045 MAP (2, 1, BFD_RELOC_16_PCREL
);
1046 MAP (4, 1, BFD_RELOC_32_PCREL
);
1054 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
1055 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
1056 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
1057 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
1060 reloc
->addend
= fixp
->fx_addnumber
;
1064 if (!fixp
->fx_pcrel
)
1065 reloc
->addend
= fixp
->fx_addnumber
;
1067 reloc
->addend
= (section
->vma
1068 /* Explicit sign extension in case char is
1070 + ((fixp
->fx_pcrel_adjust
& 0xff) ^ 0x80) - 0x80
1071 + fixp
->fx_addnumber
1072 + md_pcrel_from (fixp
));
1075 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
1076 assert (reloc
->howto
!= 0);
1081 /* Handle of the OPCODE hash table. NULL means any use before
1082 m68k_ip_begin() will crash. */
1083 static struct hash_control
*op_hash
;
1085 /* Assemble an m68k instruction. */
1088 m68k_ip (char *instring
)
1091 register struct m68k_op
*opP
;
1092 register const struct m68k_incant
*opcode
;
1093 register const char *s
;
1094 register int tmpreg
= 0, baseo
= 0, outro
= 0, nextword
;
1095 char *pdot
, *pdotmove
;
1096 enum m68k_size siz1
, siz2
;
1100 struct m68k_op operands_backup
[6];
1101 LITTLENUM_TYPE words
[6];
1102 LITTLENUM_TYPE
*wordp
;
1103 unsigned long ok_arch
= 0;
1105 if (*instring
== ' ')
1106 instring
++; /* Skip leading whitespace. */
1108 /* Scan up to end of operation-code, which MUST end in end-of-string
1109 or exactly 1 space. */
1111 for (p
= instring
; *p
!= '\0'; p
++)
1121 the_ins
.error
= _("No operator");
1125 /* p now points to the end of the opcode name, probably whitespace.
1126 Make sure the name is null terminated by clobbering the
1127 whitespace, look it up in the hash table, then fix it back.
1128 Remove a dot, first, since the opcode tables have none. */
1131 for (pdotmove
= pdot
; pdotmove
< p
; pdotmove
++)
1132 *pdotmove
= pdotmove
[1];
1138 opcode
= (const struct m68k_incant
*) hash_find (op_hash
, instring
);
1143 for (pdotmove
= p
; pdotmove
> pdot
; pdotmove
--)
1144 *pdotmove
= pdotmove
[-1];
1151 the_ins
.error
= _("Unknown operator");
1155 /* Found a legitimate opcode, start matching operands. */
1159 if (opcode
->m_operands
== 0)
1161 char *old
= input_line_pointer
;
1163 input_line_pointer
= p
;
1164 /* Ahh - it's a motorola style psuedo op. */
1165 mote_pseudo_table
[opcode
->m_opnum
].poc_handler
1166 (mote_pseudo_table
[opcode
->m_opnum
].poc_val
);
1167 input_line_pointer
= old
;
1173 if (flag_mri
&& opcode
->m_opnum
== 0)
1175 /* In MRI mode, random garbage is allowed after an instruction
1176 which accepts no operands. */
1177 the_ins
.args
= opcode
->m_operands
;
1178 the_ins
.numargs
= opcode
->m_opnum
;
1179 the_ins
.numo
= opcode
->m_codenum
;
1180 the_ins
.opcode
[0] = getone (opcode
);
1181 the_ins
.opcode
[1] = gettwo (opcode
);
1185 for (opP
= &the_ins
.operands
[0]; *p
; opP
++)
1187 p
= crack_operand (p
, opP
);
1191 the_ins
.error
= opP
->error
;
1196 opsfound
= opP
- &the_ins
.operands
[0];
1198 /* This ugly hack is to support the floating pt opcodes in their
1199 standard form. Essentially, we fake a first enty of type COP#1 */
1200 if (opcode
->m_operands
[0] == 'I')
1204 for (n
= opsfound
; n
> 0; --n
)
1205 the_ins
.operands
[n
] = the_ins
.operands
[n
- 1];
1207 memset (&the_ins
.operands
[0], '\0', sizeof (the_ins
.operands
[0]));
1208 the_ins
.operands
[0].mode
= CONTROL
;
1209 the_ins
.operands
[0].reg
= m68k_float_copnum
;
1213 /* We've got the operands. Find an opcode that'll accept them. */
1216 /* If we didn't get the right number of ops, or we have no
1217 common model with this pattern then reject this pattern. */
1219 ok_arch
|= opcode
->m_arch
;
1220 if (opsfound
!= opcode
->m_opnum
1221 || ((opcode
->m_arch
& current_architecture
) == 0))
1227 /* Make a copy of the operands of this insn so that
1228 we can modify them safely, should we want to. */
1229 assert (opsfound
<= (int) ARRAY_SIZE (operands_backup
));
1230 for (i
= 0; i
< opsfound
; i
++)
1231 operands_backup
[i
] = the_ins
.operands
[i
];
1233 for (s
= opcode
->m_operands
, opP
= &operands_backup
[0];
1237 /* Warning: this switch is huge! */
1238 /* I've tried to organize the cases into this order:
1239 non-alpha first, then alpha by letter. Lower-case
1240 goes directly before uppercase counterpart. */
1241 /* Code with multiple case ...: gets sorted by the lowest
1242 case ... it belongs to. I hope this makes sense. */
1348 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
1365 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
1384 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
1394 if (opP
->mode
!= IMMED
)
1396 else if (s
[1] == 'b'
1397 && ! isvar (&opP
->disp
)
1398 && (opP
->disp
.exp
.X_op
!= O_constant
1399 || ! isbyte (opP
->disp
.exp
.X_add_number
)))
1401 else if (s
[1] == 'B'
1402 && ! isvar (&opP
->disp
)
1403 && (opP
->disp
.exp
.X_op
!= O_constant
1404 || ! issbyte (opP
->disp
.exp
.X_add_number
)))
1406 else if (s
[1] == 'w'
1407 && ! isvar (&opP
->disp
)
1408 && (opP
->disp
.exp
.X_op
!= O_constant
1409 || ! isword (opP
->disp
.exp
.X_add_number
)))
1411 else if (s
[1] == 'W'
1412 && ! isvar (&opP
->disp
)
1413 && (opP
->disp
.exp
.X_op
!= O_constant
1414 || ! issword (opP
->disp
.exp
.X_add_number
)))
1420 if (opP
->mode
!= IMMED
)
1425 if (opP
->mode
== AREG
1426 || opP
->mode
== CONTROL
1427 || opP
->mode
== FPREG
1428 || opP
->mode
== IMMED
1429 || opP
->mode
== REGLST
1430 || (opP
->mode
!= ABSL
1432 || opP
->reg
== ZPC
)))
1437 if (opP
->mode
== CONTROL
1438 || opP
->mode
== FPREG
1439 || opP
->mode
== REGLST
1440 || opP
->mode
== IMMED
1441 || (opP
->mode
!= ABSL
1443 || opP
->reg
== ZPC
)))
1471 if (opP
->mode
== CONTROL
1472 || opP
->mode
== FPREG
1473 || opP
->mode
== REGLST
)
1478 if (opP
->mode
!= AINC
)
1483 if (opP
->mode
!= ADEC
)
1533 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
1554 case '~': /* For now! (JF FOO is this right?) */
1576 if (opP
->mode
!= CONTROL
1577 || (opP
->reg
!= TT0
&& opP
->reg
!= TT1
))
1582 if (opP
->mode
!= AREG
)
1587 if (opP
->mode
!= AINDR
)
1592 if (opP
->mode
!= AINDR
&& opP
->mode
!= AINC
&& opP
->mode
!= ADEC
1593 && (opP
->mode
!= DISP
1595 || opP
->reg
> ADDR7
))
1600 if (opP
->mode
!= ABSL
1602 && strncmp (instring
, "jbsr", 4) == 0))
1625 if (opP
->mode
!= CONTROL
|| opP
->reg
!= CCR
)
1630 if (opP
->mode
!= DISP
1632 || opP
->reg
> ADDR7
)
1637 if (opP
->mode
!= DREG
)
1642 if (opP
->reg
!= ACC
)
1647 if (opP
->reg
!= ACC
&& opP
->reg
!= ACC1
1648 && opP
->reg
!= ACC2
&& opP
->reg
!= ACC3
)
1653 if (opP
->mode
!= FPREG
)
1658 if (opP
->reg
!= MACSR
)
1663 if (opP
->reg
!= ACCEXT01
&& opP
->reg
!= ACCEXT23
)
1668 if (opP
->reg
!= MASK
)
1673 if (opP
->mode
!= CONTROL
1680 if (opP
->mode
!= LSH
&& opP
->mode
!= RSH
)
1685 if (opP
->mode
!= CONTROL
1687 || opP
->reg
> last_movec_reg
1692 const enum m68k_register
*rp
;
1694 for (rp
= control_regs
; *rp
; rp
++)
1695 if (*rp
== opP
->reg
)
1703 if (opP
->mode
!= IMMED
)
1709 if (opP
->mode
== DREG
1710 || opP
->mode
== AREG
1711 || opP
->mode
== FPREG
)
1720 opP
->mask
= 1 << (opP
->reg
- DATA0
);
1723 opP
->mask
= 1 << (opP
->reg
- ADDR0
+ 8);
1726 opP
->mask
= 1 << (opP
->reg
- FP0
+ 16);
1734 else if (opP
->mode
== CONTROL
)
1743 opP
->mask
= 1 << 24;
1746 opP
->mask
= 1 << 25;
1749 opP
->mask
= 1 << 26;
1758 else if (opP
->mode
!= REGLST
)
1760 else if (s
[1] == '8' && (opP
->mask
& 0x0ffffff) != 0)
1762 else if (s
[1] == '3' && (opP
->mask
& 0x7000000) != 0)
1767 if (opP
->mode
!= IMMED
)
1769 else if (opP
->disp
.exp
.X_op
!= O_constant
1770 || ! issbyte (opP
->disp
.exp
.X_add_number
))
1772 else if (! m68k_quick
1773 && instring
[3] != 'q'
1774 && instring
[4] != 'q')
1779 if (opP
->mode
!= DREG
1780 && opP
->mode
!= IMMED
1781 && opP
->mode
!= ABSL
)
1786 if (opP
->mode
!= IMMED
)
1788 else if (opP
->disp
.exp
.X_op
!= O_constant
1789 || TRUNC (opP
->disp
.exp
.X_add_number
) - 1 > 7)
1791 else if (! m68k_quick
1792 && (strncmp (instring
, "add", 3) == 0
1793 || strncmp (instring
, "sub", 3) == 0)
1794 && instring
[3] != 'q')
1799 if (opP
->mode
!= DREG
&& opP
->mode
!= AREG
)
1804 if (opP
->mode
!= AINDR
1805 && (opP
->mode
!= BASE
1807 && opP
->reg
!= ZADDR0
)
1808 || opP
->disp
.exp
.X_op
!= O_absent
1809 || ((opP
->index
.reg
< DATA0
1810 || opP
->index
.reg
> DATA7
)
1811 && (opP
->index
.reg
< ADDR0
1812 || opP
->index
.reg
> ADDR7
))
1813 || opP
->index
.size
!= SIZE_UNSPEC
1814 || opP
->index
.scale
!= 1))
1819 if (opP
->mode
!= CONTROL
1820 || ! (opP
->reg
== FPI
1822 || opP
->reg
== FPC
))
1827 if (opP
->mode
!= CONTROL
|| opP
->reg
!= SR
)
1832 if (opP
->mode
!= IMMED
)
1834 else if (opP
->disp
.exp
.X_op
!= O_constant
1835 || TRUNC (opP
->disp
.exp
.X_add_number
) > 7)
1840 if (opP
->mode
!= CONTROL
|| opP
->reg
!= USP
)
1845 if (opP
->mode
!= IMMED
)
1847 else if (opP
->disp
.exp
.X_op
!= O_constant
1848 || (TRUNC (opP
->disp
.exp
.X_add_number
) != 0xffffffff
1849 && TRUNC (opP
->disp
.exp
.X_add_number
) - 1 > 6))
1853 /* JF these are out of order. We could put them
1854 in order if we were willing to put up with
1855 bunches of #ifdef m68851s in the code.
1857 Don't forget that you need these operands
1858 to use 68030 MMU instructions. */
1860 /* Memory addressing mode used by pflushr. */
1862 if (opP
->mode
== CONTROL
1863 || opP
->mode
== FPREG
1864 || opP
->mode
== DREG
1865 || opP
->mode
== AREG
1866 || opP
->mode
== REGLST
)
1868 /* We should accept immediate operands, but they
1869 supposedly have to be quad word, and we don't
1870 handle that. I would like to see what a Motorola
1871 assembler does before doing something here. */
1872 if (opP
->mode
== IMMED
)
1877 if (opP
->mode
!= CONTROL
1878 || (opP
->reg
!= SFC
&& opP
->reg
!= DFC
))
1883 if (opP
->mode
!= CONTROL
|| opP
->reg
!= TC
)
1888 if (opP
->mode
!= CONTROL
|| opP
->reg
!= AC
)
1893 if (opP
->mode
!= CONTROL
1896 && opP
->reg
!= SCC
))
1901 if (opP
->mode
!= CONTROL
1907 if (opP
->mode
!= CONTROL
1910 && opP
->reg
!= CRP
))
1934 if (opP
->mode
!= CONTROL
1935 || (!(opP
->reg
>= BAD
&& opP
->reg
<= BAD
+ 7)
1936 && !(opP
->reg
>= BAC
&& opP
->reg
<= BAC
+ 7)))
1941 if (opP
->mode
!= CONTROL
|| opP
->reg
!= PSR
)
1946 if (opP
->mode
!= CONTROL
|| opP
->reg
!= PCSR
)
1951 if (opP
->mode
!= CONTROL
1960 if (opP
->mode
!= ABSL
)
1965 if (opP
->reg
< DATA0L
|| opP
->reg
> ADDR7U
)
1967 /* FIXME: kludge instead of fixing parser:
1968 upper/lower registers are *not* CONTROL
1969 registers, but ordinary ones. */
1970 if ((opP
->reg
>= DATA0L
&& opP
->reg
<= DATA7L
)
1971 || (opP
->reg
>= DATA0U
&& opP
->reg
<= DATA7U
))
1978 if (!(opP
->mode
== AINDR
1979 || (opP
->mode
== DISP
1980 && !(opP
->reg
== PC
|| opP
->reg
== ZPC
))))
1985 if (!(opP
->mode
== AINDR
|| opP
->mode
== DISP
))
1997 /* Since we have found the correct instruction, copy
1998 in the modifications that we may have made. */
2000 for (i
= 0; i
< opsfound
; i
++)
2001 the_ins
.operands
[i
] = operands_backup
[i
];
2007 opcode
= opcode
->m_next
;
2012 && !(ok_arch
& current_architecture
))
2014 const struct m68k_cpu
*cpu
;
2017 char *buf
= xmalloc (space
+ 1);
2021 the_ins
.error
= buf
;
2022 /* Make sure there's a NUL at the end of the buffer -- strncpy
2023 won't write one when it runs out of buffer */
2025 #define APPEND(STRING) \
2026 (strncpy (buf, STRING, space), len = strlen (buf), buf += len, space -= len)
2028 APPEND (_("invalid instruction for this architecture; needs "));
2032 APPEND (_("ColdFire ISA_A"));
2035 APPEND (_("ColdFire hardware divide"));
2038 APPEND (_("ColdFire ISA_A+"));
2041 APPEND (_("ColdFire ISA_B"));
2044 APPEND (_("ColdFire fpu"));
2047 APPEND (_("M68K fpu"));
2050 APPEND (_("M68K mmu"));
2053 APPEND (_("68020 or higher"));
2056 APPEND (_("68000 or higher"));
2059 APPEND (_("68010 or higher"));
2067 for (cpu
= m68k_cpus
; cpu
->name
; cpu
++)
2068 if (!cpu
->alias
&& (cpu
->arch
& ok_arch
))
2070 const struct m68k_cpu
*alias
;
2071 int seen_master
= 0;
2077 for (alias
= cpu
; alias
!= m68k_cpus
; alias
--)
2078 if (alias
[-1].alias
>= 0)
2080 for (; !seen_master
|| alias
->alias
> 0; alias
++)
2090 APPEND (alias
->name
);
2103 /* we ran out of space, so replace the end of the list
2108 strcpy (buf
, " ...");
2112 the_ins
.error
= _("operands mismatch");
2119 /* Now assemble it. */
2120 the_ins
.args
= opcode
->m_operands
;
2121 the_ins
.numargs
= opcode
->m_opnum
;
2122 the_ins
.numo
= opcode
->m_codenum
;
2123 the_ins
.opcode
[0] = getone (opcode
);
2124 the_ins
.opcode
[1] = gettwo (opcode
);
2126 for (s
= the_ins
.args
, opP
= &the_ins
.operands
[0]; *s
; s
+= 2, opP
++)
2128 /* This switch is a doozy.
2129 Watch the first step; its a big one! */
2162 tmpreg
= 0x3c; /* 7.4 */
2163 if (strchr ("bwl", s
[1]))
2164 nextword
= get_num (&opP
->disp
, 90);
2166 nextword
= get_num (&opP
->disp
, 0);
2167 if (isvar (&opP
->disp
))
2168 add_fix (s
[1], &opP
->disp
, 0, 0);
2172 if (!isbyte (nextword
))
2173 opP
->error
= _("operand out of range");
2178 if (!isword (nextword
))
2179 opP
->error
= _("operand out of range");
2184 if (!issword (nextword
))
2185 opP
->error
= _("operand out of range");
2190 addword (nextword
>> 16);
2217 /* We gotta put out some float. */
2218 if (op (&opP
->disp
) != O_big
)
2223 /* Can other cases happen here? */
2224 if (op (&opP
->disp
) != O_constant
)
2227 val
= (valueT
) offs (&opP
->disp
);
2231 generic_bignum
[gencnt
] = (LITTLENUM_TYPE
) val
;
2232 val
>>= LITTLENUM_NUMBER_OF_BITS
;
2236 offs (&opP
->disp
) = gencnt
;
2238 if (offs (&opP
->disp
) > 0)
2240 if (offs (&opP
->disp
) > baseo
)
2242 as_warn (_("Bignum too big for %c format; truncated"),
2244 offs (&opP
->disp
) = baseo
;
2246 baseo
-= offs (&opP
->disp
);
2249 for (wordp
= generic_bignum
+ offs (&opP
->disp
) - 1;
2250 offs (&opP
->disp
)--;
2255 gen_to_words (words
, baseo
, (long) outro
);
2256 for (wordp
= words
; baseo
--; wordp
++)
2260 tmpreg
= opP
->reg
- DATA
; /* 0.dreg */
2263 tmpreg
= 0x08 + opP
->reg
- ADDR
; /* 1.areg */
2266 tmpreg
= 0x10 + opP
->reg
- ADDR
; /* 2.areg */
2269 tmpreg
= 0x20 + opP
->reg
- ADDR
; /* 4.areg */
2272 tmpreg
= 0x18 + opP
->reg
- ADDR
; /* 3.areg */
2276 nextword
= get_num (&opP
->disp
, 90);
2278 /* Convert mode 5 addressing with a zero offset into
2279 mode 2 addressing to reduce the instruction size by a
2281 if (! isvar (&opP
->disp
)
2283 && (opP
->disp
.size
== SIZE_UNSPEC
)
2284 && (opP
->reg
>= ADDR0
)
2285 && (opP
->reg
<= ADDR7
))
2287 tmpreg
= 0x10 + opP
->reg
- ADDR
; /* 2.areg */
2292 && ! isvar (&opP
->disp
)
2295 opP
->disp
.exp
.X_op
= O_symbol
;
2296 opP
->disp
.exp
.X_add_symbol
=
2297 section_symbol (absolute_section
);
2300 /* Force into index mode. Hope this works. */
2302 /* We do the first bit for 32-bit displacements, and the
2303 second bit for 16 bit ones. It is possible that we
2304 should make the default be WORD instead of LONG, but
2305 I think that'd break GCC, so we put up with a little
2306 inefficiency for the sake of working output. */
2308 if (!issword (nextword
)
2309 || (isvar (&opP
->disp
)
2310 && ((opP
->disp
.size
== SIZE_UNSPEC
2311 && flag_short_refs
== 0
2312 && cpu_of_arch (current_architecture
) >= m68020
2313 && ! arch_coldfire_p (current_architecture
))
2314 || opP
->disp
.size
== SIZE_LONG
)))
2316 if (cpu_of_arch (current_architecture
) < m68020
2317 || arch_coldfire_p (current_architecture
))
2319 _("displacement too large for this architecture; needs 68020 or higher");
2321 tmpreg
= 0x3B; /* 7.3 */
2323 tmpreg
= 0x30 + opP
->reg
- ADDR
; /* 6.areg */
2324 if (isvar (&opP
->disp
))
2328 if (opP
->disp
.size
== SIZE_LONG
2330 /* If the displacement needs pic
2331 relocation it cannot be relaxed. */
2332 || opP
->disp
.pic_reloc
!= pic_none
2337 add_fix ('l', &opP
->disp
, 1, 2);
2341 add_frag (adds (&opP
->disp
),
2342 SEXT (offs (&opP
->disp
)),
2343 TAB (PCREL1632
, SZ_UNDEF
));
2350 add_fix ('l', &opP
->disp
, 0, 0);
2355 addword (nextword
>> 16);
2360 tmpreg
= 0x3A; /* 7.2 */
2362 tmpreg
= 0x28 + opP
->reg
- ADDR
; /* 5.areg */
2364 if (isvar (&opP
->disp
))
2368 add_fix ('w', &opP
->disp
, 1, 0);
2371 add_fix ('w', &opP
->disp
, 0, 0);
2381 baseo
= get_num (&opP
->disp
, 90);
2382 if (opP
->mode
== POST
|| opP
->mode
== PRE
)
2383 outro
= get_num (&opP
->odisp
, 90);
2384 /* Figure out the `addressing mode'.
2385 Also turn on the BASE_DISABLE bit, if needed. */
2386 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
2388 tmpreg
= 0x3b; /* 7.3 */
2389 if (opP
->reg
== ZPC
)
2392 else if (opP
->reg
== 0)
2395 tmpreg
= 0x30; /* 6.garbage */
2397 else if (opP
->reg
>= ZADDR0
&& opP
->reg
<= ZADDR7
)
2400 tmpreg
= 0x30 + opP
->reg
- ZADDR0
;
2403 tmpreg
= 0x30 + opP
->reg
- ADDR
; /* 6.areg */
2405 siz1
= opP
->disp
.size
;
2406 if (opP
->mode
== POST
|| opP
->mode
== PRE
)
2407 siz2
= opP
->odisp
.size
;
2411 /* Index register stuff. */
2412 if (opP
->index
.reg
!= 0
2413 && opP
->index
.reg
>= DATA
2414 && opP
->index
.reg
<= ADDR7
)
2416 nextword
|= (opP
->index
.reg
- DATA
) << 12;
2418 if (opP
->index
.size
== SIZE_LONG
2419 || (opP
->index
.size
== SIZE_UNSPEC
2420 && m68k_index_width_default
== SIZE_LONG
))
2423 if ((opP
->index
.scale
!= 1
2424 && cpu_of_arch (current_architecture
) < m68020
)
2425 || (opP
->index
.scale
== 8
2426 && (arch_coldfire_p (current_architecture
)
2427 && !arch_coldfire_fpu (current_architecture
))))
2430 _("scale factor invalid on this architecture; needs cpu32 or 68020 or higher");
2433 if (arch_coldfire_p (current_architecture
)
2434 && opP
->index
.size
== SIZE_WORD
)
2435 opP
->error
= _("invalid index size for coldfire");
2437 switch (opP
->index
.scale
)
2454 GET US OUT OF HERE! */
2456 /* Must be INDEX, with an index register. Address
2457 register cannot be ZERO-PC, and either :b was
2458 forced, or we know it will fit. For a 68000 or
2459 68010, force this mode anyways, because the
2460 larger modes aren't supported. */
2461 if (opP
->mode
== BASE
2462 && ((opP
->reg
>= ADDR0
2463 && opP
->reg
<= ADDR7
)
2466 if (siz1
== SIZE_BYTE
2467 || cpu_of_arch (current_architecture
) < m68020
2468 || arch_coldfire_p (current_architecture
)
2469 || (siz1
== SIZE_UNSPEC
2470 && ! isvar (&opP
->disp
)
2471 && issbyte (baseo
)))
2473 nextword
+= baseo
& 0xff;
2475 if (isvar (&opP
->disp
))
2477 /* Do a byte relocation. If it doesn't
2478 fit (possible on m68000) let the
2479 fixup processing complain later. */
2481 add_fix ('B', &opP
->disp
, 1, 1);
2483 add_fix ('B', &opP
->disp
, 0, 0);
2485 else if (siz1
!= SIZE_BYTE
)
2487 if (siz1
!= SIZE_UNSPEC
)
2488 as_warn (_("Forcing byte displacement"));
2489 if (! issbyte (baseo
))
2490 opP
->error
= _("byte displacement out of range");
2495 else if (siz1
== SIZE_UNSPEC
2497 && isvar (&opP
->disp
)
2498 && subs (&opP
->disp
) == NULL
2500 /* If the displacement needs pic
2501 relocation it cannot be relaxed. */
2502 && opP
->disp
.pic_reloc
== pic_none
2506 /* The code in md_convert_frag_1 needs to be
2507 able to adjust nextword. Call frag_grow
2508 to ensure that we have enough space in
2509 the frag obstack to make all the bytes
2512 nextword
+= baseo
& 0xff;
2514 add_frag (adds (&opP
->disp
),
2515 SEXT (offs (&opP
->disp
)),
2516 TAB (PCINDEX
, SZ_UNDEF
));
2524 nextword
|= 0x40; /* No index reg. */
2525 if (opP
->index
.reg
>= ZDATA0
2526 && opP
->index
.reg
<= ZDATA7
)
2527 nextword
|= (opP
->index
.reg
- ZDATA0
) << 12;
2528 else if (opP
->index
.reg
>= ZADDR0
2529 || opP
->index
.reg
<= ZADDR7
)
2530 nextword
|= (opP
->index
.reg
- ZADDR0
+ 8) << 12;
2533 /* It isn't simple. */
2535 if (cpu_of_arch (current_architecture
) < m68020
2536 || arch_coldfire_p (current_architecture
))
2538 _("invalid operand mode for this architecture; needs 68020 or higher");
2541 /* If the guy specified a width, we assume that it is
2542 wide enough. Maybe it isn't. If so, we lose. */
2546 if (isvar (&opP
->disp
)
2548 : ! issword (baseo
))
2553 else if (! isvar (&opP
->disp
) && baseo
== 0)
2562 as_warn (_(":b not permitted; defaulting to :w"));
2572 /* Figure out inner displacement stuff. */
2573 if (opP
->mode
== POST
|| opP
->mode
== PRE
)
2575 if (cpu_of_arch (current_architecture
) & cpu32
)
2576 opP
->error
= _("invalid operand mode for this architecture; needs 68020 or higher");
2580 if (isvar (&opP
->odisp
)
2582 : ! issword (outro
))
2587 else if (! isvar (&opP
->odisp
) && outro
== 0)
2596 as_warn (_(":b not permitted; defaulting to :w"));
2605 if (opP
->mode
== POST
2606 && (nextword
& 0x40) == 0)
2611 if (siz1
!= SIZE_UNSPEC
&& isvar (&opP
->disp
))
2613 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
2614 add_fix (siz1
== SIZE_LONG
? 'l' : 'w', &opP
->disp
, 1, 2);
2616 add_fix (siz1
== SIZE_LONG
? 'l' : 'w', &opP
->disp
, 0, 0);
2618 if (siz1
== SIZE_LONG
)
2619 addword (baseo
>> 16);
2620 if (siz1
!= SIZE_UNSPEC
)
2623 if (siz2
!= SIZE_UNSPEC
&& isvar (&opP
->odisp
))
2624 add_fix (siz2
== SIZE_LONG
? 'l' : 'w', &opP
->odisp
, 0, 0);
2625 if (siz2
== SIZE_LONG
)
2626 addword (outro
>> 16);
2627 if (siz2
!= SIZE_UNSPEC
)
2633 nextword
= get_num (&opP
->disp
, 90);
2634 switch (opP
->disp
.size
)
2639 if (!isvar (&opP
->disp
) && issword (offs (&opP
->disp
)))
2641 tmpreg
= 0x38; /* 7.0 */
2645 if (isvar (&opP
->disp
)
2646 && !subs (&opP
->disp
)
2647 && adds (&opP
->disp
)
2649 /* If the displacement needs pic relocation it
2650 cannot be relaxed. */
2651 && opP
->disp
.pic_reloc
== pic_none
2654 && !strchr ("~%&$?", s
[0]))
2656 tmpreg
= 0x3A; /* 7.2 */
2657 add_frag (adds (&opP
->disp
),
2658 SEXT (offs (&opP
->disp
)),
2659 TAB (ABSTOPCREL
, SZ_UNDEF
));
2662 /* Fall through into long. */
2664 if (isvar (&opP
->disp
))
2665 add_fix ('l', &opP
->disp
, 0, 0);
2667 tmpreg
= 0x39;/* 7.1 mode */
2668 addword (nextword
>> 16);
2673 as_bad (_("unsupported byte value; use a different suffix"));
2677 if (isvar (&opP
->disp
))
2678 add_fix ('w', &opP
->disp
, 0, 0);
2680 tmpreg
= 0x38;/* 7.0 mode */
2688 as_bad (_("unknown/incorrect operand"));
2692 /* If s[0] is '4', then this is for the mac instructions
2693 that can have a trailing_ampersand set. If so, set 0x100
2694 bit on tmpreg so install_gen_operand can check for it and
2695 set the appropriate bit (word2, bit 5). */
2698 if (opP
->trailing_ampersand
)
2701 install_gen_operand (s
[1], tmpreg
);
2707 { /* JF: I hate floating point! */
2722 tmpreg
= get_num (&opP
->disp
, tmpreg
);
2723 if (isvar (&opP
->disp
))
2724 add_fix (s
[1], &opP
->disp
, 0, 0);
2727 case 'b': /* Danger: These do no check for
2728 certain types of overflow.
2730 if (!isbyte (tmpreg
))
2731 opP
->error
= _("out of range");
2732 insop (tmpreg
, opcode
);
2733 if (isvar (&opP
->disp
))
2734 the_ins
.reloc
[the_ins
.nrel
- 1].n
=
2735 (opcode
->m_codenum
) * 2 + 1;
2738 if (!issbyte (tmpreg
))
2739 opP
->error
= _("out of range");
2740 the_ins
.opcode
[the_ins
.numo
- 1] |= tmpreg
& 0xff;
2741 if (isvar (&opP
->disp
))
2742 the_ins
.reloc
[the_ins
.nrel
- 1].n
= opcode
->m_codenum
* 2 - 1;
2745 if (!isword (tmpreg
))
2746 opP
->error
= _("out of range");
2747 insop (tmpreg
, opcode
);
2748 if (isvar (&opP
->disp
))
2749 the_ins
.reloc
[the_ins
.nrel
- 1].n
= (opcode
->m_codenum
) * 2;
2752 if (!issword (tmpreg
))
2753 opP
->error
= _("out of range");
2754 insop (tmpreg
, opcode
);
2755 if (isvar (&opP
->disp
))
2756 the_ins
.reloc
[the_ins
.nrel
- 1].n
= (opcode
->m_codenum
) * 2;
2759 /* Because of the way insop works, we put these two out
2761 insop (tmpreg
, opcode
);
2762 insop (tmpreg
>> 16, opcode
);
2763 if (isvar (&opP
->disp
))
2764 the_ins
.reloc
[the_ins
.nrel
- 1].n
= (opcode
->m_codenum
) * 2;
2771 install_operand (s
[1], tmpreg
);
2782 install_operand (s
[1], opP
->reg
- ADDR
);
2786 tmpreg
= get_num (&opP
->disp
, 90);
2790 add_fix ('B', &opP
->disp
, 1, -1);
2793 add_fix ('w', &opP
->disp
, 1, 0);
2798 if (! HAVE_LONG_BRANCH (current_architecture
))
2799 as_warn (_("Can't use long branches on 68000/68010/5200"));
2800 the_ins
.opcode
[0] |= 0xff;
2801 add_fix ('l', &opP
->disp
, 1, 0);
2806 if (subs (&opP
->disp
)) /* We can't relax it. */
2810 /* If the displacement needs pic relocation it cannot be
2812 if (opP
->disp
.pic_reloc
!= pic_none
)
2815 /* This could either be a symbol, or an absolute
2816 address. If it's an absolute address, turn it into
2817 an absolute jump right here and keep it out of the
2819 if (adds (&opP
->disp
) == 0)
2821 if (the_ins
.opcode
[0] == 0x6000) /* jbra */
2822 the_ins
.opcode
[0] = 0x4EF9;
2823 else if (the_ins
.opcode
[0] == 0x6100) /* jbsr */
2824 the_ins
.opcode
[0] = 0x4EB9;
2827 the_ins
.opcode
[0] ^= 0x0100;
2828 the_ins
.opcode
[0] |= 0x0006;
2831 add_fix ('l', &opP
->disp
, 0, 0);
2837 /* Now we know it's going into the relaxer. Now figure
2838 out which mode. We try in this order of preference:
2839 long branch, absolute jump, byte/word branches only. */
2840 if (HAVE_LONG_BRANCH (current_architecture
))
2841 add_frag (adds (&opP
->disp
),
2842 SEXT (offs (&opP
->disp
)),
2843 TAB (BRANCHBWL
, SZ_UNDEF
));
2844 else if (! flag_keep_pcrel
)
2846 if ((the_ins
.opcode
[0] == 0x6000)
2847 || (the_ins
.opcode
[0] == 0x6100))
2848 add_frag (adds (&opP
->disp
),
2849 SEXT (offs (&opP
->disp
)),
2850 TAB (BRABSJUNC
, SZ_UNDEF
));
2852 add_frag (adds (&opP
->disp
),
2853 SEXT (offs (&opP
->disp
)),
2854 TAB (BRABSJCOND
, SZ_UNDEF
));
2857 add_frag (adds (&opP
->disp
),
2858 SEXT (offs (&opP
->disp
)),
2859 TAB (BRANCHBW
, SZ_UNDEF
));
2862 if (isvar (&opP
->disp
))
2864 /* Check for DBcc instructions. We can relax them,
2865 but only if we have long branches and/or absolute
2867 if (((the_ins
.opcode
[0] & 0xf0f8) == 0x50c8)
2868 && (HAVE_LONG_BRANCH (current_architecture
)
2869 || (! flag_keep_pcrel
)))
2871 if (HAVE_LONG_BRANCH (current_architecture
))
2872 add_frag (adds (&opP
->disp
),
2873 SEXT (offs (&opP
->disp
)),
2874 TAB (DBCCLBR
, SZ_UNDEF
));
2876 add_frag (adds (&opP
->disp
),
2877 SEXT (offs (&opP
->disp
)),
2878 TAB (DBCCABSJ
, SZ_UNDEF
));
2881 add_fix ('w', &opP
->disp
, 1, 0);
2885 case 'C': /* Fixed size LONG coproc branches. */
2886 add_fix ('l', &opP
->disp
, 1, 0);
2890 case 'c': /* Var size Coprocesssor branches. */
2891 if (subs (&opP
->disp
) || (adds (&opP
->disp
) == 0))
2893 the_ins
.opcode
[the_ins
.numo
- 1] |= 0x40;
2894 add_fix ('l', &opP
->disp
, 1, 0);
2899 add_frag (adds (&opP
->disp
),
2900 SEXT (offs (&opP
->disp
)),
2901 TAB (FBRANCH
, SZ_UNDEF
));
2908 case 'C': /* Ignore it. */
2911 case 'd': /* JF this is a kludge. */
2912 install_operand ('s', opP
->reg
- ADDR
);
2913 tmpreg
= get_num (&opP
->disp
, 90);
2914 if (!issword (tmpreg
))
2916 as_warn (_("Expression out of range, using 0"));
2923 install_operand (s
[1], opP
->reg
- DATA
);
2926 case 'e': /* EMAC ACCx, reg/reg. */
2927 install_operand (s
[1], opP
->reg
- ACC
);
2930 case 'E': /* Ignore it. */
2934 install_operand (s
[1], opP
->reg
- FP0
);
2937 case 'g': /* EMAC ACCEXTx. */
2938 install_operand (s
[1], opP
->reg
- ACCEXT01
);
2941 case 'G': /* Ignore it. */
2946 tmpreg
= opP
->reg
- COP0
;
2947 install_operand (s
[1], tmpreg
);
2950 case 'i': /* MAC/EMAC scale factor. */
2951 install_operand (s
[1], opP
->mode
== LSH
? 0x1 : 0x3);
2954 case 'J': /* JF foo. */
3090 install_operand (s
[1], tmpreg
);
3094 tmpreg
= get_num (&opP
->disp
, 55);
3095 install_operand (s
[1], tmpreg
& 0x7f);
3102 if (tmpreg
& 0x7FF0000)
3103 as_bad (_("Floating point register in register list"));
3104 insop (reverse_16_bits (tmpreg
), opcode
);
3108 if (tmpreg
& 0x700FFFF)
3109 as_bad (_("Wrong register in floating-point reglist"));
3110 install_operand (s
[1], reverse_8_bits (tmpreg
>> 16));
3118 if (tmpreg
& 0x7FF0000)
3119 as_bad (_("Floating point register in register list"));
3120 insop (tmpreg
, opcode
);
3122 else if (s
[1] == '8')
3124 if (tmpreg
& 0x0FFFFFF)
3125 as_bad (_("incorrect register in reglist"));
3126 install_operand (s
[1], tmpreg
>> 24);
3130 if (tmpreg
& 0x700FFFF)
3131 as_bad (_("wrong register in floating-point reglist"));
3133 install_operand (s
[1], tmpreg
>> 16);
3138 install_operand (s
[1], get_num (&opP
->disp
, 60));
3142 tmpreg
= ((opP
->mode
== DREG
)
3143 ? 0x20 + (int) (opP
->reg
- DATA
)
3144 : (get_num (&opP
->disp
, 40) & 0x1F));
3145 install_operand (s
[1], tmpreg
);
3149 tmpreg
= get_num (&opP
->disp
, 10);
3152 install_operand (s
[1], tmpreg
);
3156 /* This depends on the fact that ADDR registers are eight
3157 more than their corresponding DATA regs, so the result
3158 will have the ADDR_REG bit set. */
3159 install_operand (s
[1], opP
->reg
- DATA
);
3163 if (opP
->mode
== AINDR
)
3164 install_operand (s
[1], opP
->reg
- DATA
);
3166 install_operand (s
[1], opP
->index
.reg
- DATA
);
3170 if (opP
->reg
== FPI
)
3172 else if (opP
->reg
== FPS
)
3174 else if (opP
->reg
== FPC
)
3178 install_operand (s
[1], tmpreg
);
3181 case 'S': /* Ignore it. */
3185 install_operand (s
[1], get_num (&opP
->disp
, 30));
3188 case 'U': /* Ignore it. */
3207 as_fatal (_("failed sanity check"));
3208 } /* switch on cache token. */
3209 install_operand (s
[1], tmpreg
);
3212 /* JF: These are out of order, I fear. */
3225 install_operand (s
[1], tmpreg
);
3251 install_operand (s
[1], tmpreg
);
3255 if (opP
->reg
== VAL
)
3274 install_operand (s
[1], tmpreg
);
3288 tmpreg
= (4 << 10) | ((opP
->reg
- BAD
) << 2);
3299 tmpreg
= (5 << 10) | ((opP
->reg
- BAC
) << 2);
3305 install_operand (s
[1], tmpreg
);
3308 know (opP
->reg
== PSR
);
3311 know (opP
->reg
== PCSR
);
3326 install_operand (s
[1], tmpreg
);
3329 tmpreg
= get_num (&opP
->disp
, 20);
3330 install_operand (s
[1], tmpreg
);
3332 case '_': /* used only for move16 absolute 32-bit address. */
3333 if (isvar (&opP
->disp
))
3334 add_fix ('l', &opP
->disp
, 0, 0);
3335 tmpreg
= get_num (&opP
->disp
, 90);
3336 addword (tmpreg
>> 16);
3337 addword (tmpreg
& 0xFFFF);
3340 install_operand (s
[1], opP
->reg
- DATA0L
);
3341 opP
->reg
-= (DATA0L
);
3342 opP
->reg
&= 0x0F; /* remove upper/lower bit. */
3345 tmpreg
= get_num (&opP
->disp
, 80);
3348 install_operand (s
[1], tmpreg
);
3355 /* By the time whe get here (FINALLY) the_ins contains the complete
3356 instruction, ready to be emitted. . . */
3360 reverse_16_bits (int in
)
3365 static int mask
[16] =
3367 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
3368 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000
3370 for (n
= 0; n
< 16; n
++)
3373 out
|= mask
[15 - n
];
3376 } /* reverse_16_bits() */
3379 reverse_8_bits (int in
)
3384 static int mask
[8] =
3386 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
3389 for (n
= 0; n
< 8; n
++)
3395 } /* reverse_8_bits() */
3397 /* Cause an extra frag to be generated here, inserting up to 10 bytes
3398 (that value is chosen in the frag_var call in md_assemble). TYPE
3399 is the subtype of the frag to be generated; its primary type is
3400 rs_machine_dependent.
3402 The TYPE parameter is also used by md_convert_frag_1 and
3403 md_estimate_size_before_relax. The appropriate type of fixup will
3404 be emitted by md_convert_frag_1.
3406 ADD becomes the FR_SYMBOL field of the frag, and OFF the FR_OFFSET. */
3408 install_operand (int mode
, int val
)
3413 the_ins
.opcode
[0] |= val
& 0xFF; /* JF FF is for M kludge. */
3416 the_ins
.opcode
[0] |= val
<< 9;
3419 the_ins
.opcode
[1] |= val
<< 12;
3422 the_ins
.opcode
[1] |= val
<< 6;
3425 the_ins
.opcode
[1] |= val
;
3428 the_ins
.opcode
[2] |= val
<< 12;
3431 the_ins
.opcode
[2] |= val
<< 6;
3434 /* DANGER! This is a hack to force cas2l and cas2w cmds to be
3435 three words long! */
3437 the_ins
.opcode
[2] |= val
;
3440 the_ins
.opcode
[1] |= val
<< 7;
3443 the_ins
.opcode
[1] |= val
<< 10;
3447 the_ins
.opcode
[1] |= val
<< 5;
3452 the_ins
.opcode
[1] |= (val
<< 10) | (val
<< 7);
3455 the_ins
.opcode
[1] |= (val
<< 12) | val
;
3458 the_ins
.opcode
[0] |= val
= 0xff;
3461 the_ins
.opcode
[0] |= val
<< 9;
3464 the_ins
.opcode
[1] |= val
;
3467 the_ins
.opcode
[1] |= val
;
3468 the_ins
.numo
++; /* What a hack. */
3471 the_ins
.opcode
[1] |= val
<< 4;
3479 the_ins
.opcode
[0] |= (val
<< 6);
3482 the_ins
.opcode
[1] = (val
>> 16);
3483 the_ins
.opcode
[2] = val
& 0xffff;
3486 the_ins
.opcode
[0] |= ((val
& 0x8) << (6 - 3));
3487 the_ins
.opcode
[0] |= ((val
& 0x7) << 9);
3488 the_ins
.opcode
[1] |= ((val
& 0x10) << (7 - 4));
3490 case 'n': /* MAC/EMAC Rx on !load. */
3491 the_ins
.opcode
[0] |= ((val
& 0x8) << (6 - 3));
3492 the_ins
.opcode
[0] |= ((val
& 0x7) << 9);
3493 the_ins
.opcode
[1] |= ((val
& 0x10) << (7 - 4));
3495 case 'o': /* MAC/EMAC Rx on load. */
3496 the_ins
.opcode
[1] |= val
<< 12;
3497 the_ins
.opcode
[1] |= ((val
& 0x10) << (7 - 4));
3499 case 'M': /* MAC/EMAC Ry on !load. */
3500 the_ins
.opcode
[0] |= (val
& 0xF);
3501 the_ins
.opcode
[1] |= ((val
& 0x10) << (6 - 4));
3503 case 'N': /* MAC/EMAC Ry on load. */
3504 the_ins
.opcode
[1] |= (val
& 0xF);
3505 the_ins
.opcode
[1] |= ((val
& 0x10) << (6 - 4));
3508 the_ins
.opcode
[1] |= ((val
!= 1) << 10);
3511 the_ins
.opcode
[0] |= ((val
& 0x3) << 9);
3514 the_ins
.opcode
[0] |= ((val
& 0x3) << 0);
3516 case 'G': /* EMAC accumulator in a EMAC load instruction. */
3517 the_ins
.opcode
[0] |= ((~val
& 0x1) << 7);
3518 the_ins
.opcode
[1] |= ((val
& 0x2) << (4 - 1));
3520 case 'H': /* EMAC accumulator in a EMAC non-load instruction. */
3521 the_ins
.opcode
[0] |= ((val
& 0x1) << 7);
3522 the_ins
.opcode
[1] |= ((val
& 0x2) << (4 - 1));
3525 the_ins
.opcode
[1] |= ((val
& 0x3) << 9);
3528 the_ins
.opcode
[0] |= (val
& 0x1) <<10;
3532 as_fatal (_("failed sanity check."));
3537 install_gen_operand (int mode
, int val
)
3541 case '/': /* Special for mask loads for mac/msac insns with
3542 possible mask; trailing_ampersend set in bit 8. */
3543 the_ins
.opcode
[0] |= (val
& 0x3f);
3544 the_ins
.opcode
[1] |= (((val
& 0x100) >> 8) << 5);
3547 the_ins
.opcode
[0] |= val
;
3550 /* This is a kludge!!! */
3551 the_ins
.opcode
[0] |= (val
& 0x07) << 9 | (val
& 0x38) << 3;
3560 the_ins
.opcode
[0] |= val
;
3562 /* more stuff goes here. */
3564 as_fatal (_("failed sanity check."));
3568 /* Verify that we have some number of paren pairs, do m68k_ip_op(), and
3569 then deal with the bitfield hack. */
3572 crack_operand (char *str
, struct m68k_op
*opP
)
3574 register int parens
;
3576 register char *beg_str
;
3584 for (parens
= 0; *str
&& (parens
> 0 || inquote
|| notend (str
)); str
++)
3590 else if (*str
== ')')
3594 opP
->error
= _("Extra )");
3600 if (flag_mri
&& *str
== '\'')
3601 inquote
= ! inquote
;
3603 if (!*str
&& parens
)
3605 opP
->error
= _("Missing )");
3610 if (m68k_ip_op (beg_str
, opP
) != 0)
3617 c
= *++str
; /* JF bitfield hack. */
3622 as_bad (_("Missing operand"));
3625 /* Detect MRI REG symbols and convert them to REGLSTs. */
3626 if (opP
->mode
== CONTROL
&& (int)opP
->reg
< 0)
3629 opP
->mask
= ~(int)opP
->reg
;
3636 /* This is the guts of the machine-dependent assembler. STR points to a
3637 machine dependent instruction. This function is supposed to emit
3638 the frags/bytes it assembles to.
3642 insert_reg (const char *regname
, int regnum
)
3647 #ifdef REGISTER_PREFIX
3648 if (!flag_reg_prefix_optional
)
3650 buf
[0] = REGISTER_PREFIX
;
3651 strcpy (buf
+ 1, regname
);
3656 symbol_table_insert (symbol_new (regname
, reg_section
, regnum
,
3657 &zero_address_frag
));
3659 for (i
= 0; regname
[i
]; i
++)
3660 buf
[i
] = TOUPPER (regname
[i
]);
3663 symbol_table_insert (symbol_new (buf
, reg_section
, regnum
,
3664 &zero_address_frag
));
3673 static const struct init_entry init_table
[] =
3733 { "accext01", ACCEXT01
},
3734 { "accext23", ACCEXT23
},
3738 /* Control registers. */
3739 { "sfc", SFC
}, /* Source Function Code. */
3741 { "dfc", DFC
}, /* Destination Function Code. */
3743 { "cacr", CACR
}, /* Cache Control Register. */
3744 { "caar", CAAR
}, /* Cache Address Register. */
3746 { "usp", USP
}, /* User Stack Pointer. */
3747 { "vbr", VBR
}, /* Vector Base Register. */
3748 { "msp", MSP
}, /* Master Stack Pointer. */
3749 { "isp", ISP
}, /* Interrupt Stack Pointer. */
3751 { "itt0", ITT0
}, /* Instruction Transparent Translation Reg 0. */
3752 { "itt1", ITT1
}, /* Instruction Transparent Translation Reg 1. */
3753 { "dtt0", DTT0
}, /* Data Transparent Translation Register 0. */
3754 { "dtt1", DTT1
}, /* Data Transparent Translation Register 1. */
3756 /* 68ec040 versions of same */
3757 { "iacr0", ITT0
}, /* Instruction Access Control Register 0. */
3758 { "iacr1", ITT1
}, /* Instruction Access Control Register 0. */
3759 { "dacr0", DTT0
}, /* Data Access Control Register 0. */
3760 { "dacr1", DTT1
}, /* Data Access Control Register 0. */
3762 /* mcf5200 versions of same. The ColdFire programmer's reference
3763 manual indicated that the order is 2,3,0,1, but Ken Rose
3764 <rose@netcom.com> says that 0,1,2,3 is the correct order. */
3765 { "acr0", ACR0
}, /* Access Control Unit 0. */
3766 { "acr1", ACR1
}, /* Access Control Unit 1. */
3767 { "acr2", ACR2
}, /* Access Control Unit 2. */
3768 { "acr3", ACR3
}, /* Access Control Unit 3. */
3770 { "tc", TC
}, /* MMU Translation Control Register. */
3773 { "mmusr", MMUSR
}, /* MMU Status Register. */
3774 { "srp", SRP
}, /* User Root Pointer. */
3775 { "urp", URP
}, /* Supervisor Root Pointer. */
3780 { "rombar", ROMBAR
}, /* ROM Base Address Register. */
3781 { "rambar0", RAMBAR0
}, /* ROM Base Address Register. */
3782 { "rambar1", RAMBAR1
}, /* ROM Base Address Register. */
3783 { "mbar", MBAR
}, /* Module Base Address Register. */
3785 { "mbar0", MBAR0
}, /* mcfv4e registers. */
3786 { "mbar1", MBAR1
}, /* mcfv4e registers. */
3787 { "rombar0", ROMBAR
}, /* mcfv4e registers. */
3788 { "rombar1", ROMBAR1
}, /* mcfv4e registers. */
3789 { "mpcr", MPCR
}, /* mcfv4e registers. */
3790 { "edrambar", EDRAMBAR
}, /* mcfv4e registers. */
3791 { "secmbar", SECMBAR
}, /* mcfv4e registers. */
3792 { "asid", TC
}, /* mcfv4e registers. */
3793 { "mmubar", BUSCR
}, /* mcfv4e registers. */
3794 { "pcr1u0", PCR1U0
}, /* mcfv4e registers. */
3795 { "pcr1l0", PCR1L0
}, /* mcfv4e registers. */
3796 { "pcr2u0", PCR2U0
}, /* mcfv4e registers. */
3797 { "pcr2l0", PCR2L0
}, /* mcfv4e registers. */
3798 { "pcr3u0", PCR3U0
}, /* mcfv4e registers. */
3799 { "pcr3l0", PCR3L0
}, /* mcfv4e registers. */
3800 { "pcr1u1", PCR1U1
}, /* mcfv4e registers. */
3801 { "pcr1l1", PCR1L1
}, /* mcfv4e registers. */
3802 { "pcr2u1", PCR2U1
}, /* mcfv4e registers. */
3803 { "pcr2l1", PCR2L1
}, /* mcfv4e registers. */
3804 { "pcr3u1", PCR3U1
}, /* mcfv4e registers. */
3805 { "pcr3l1", PCR3L1
}, /* mcfv4e registers. */
3807 { "flashbar", FLASHBAR
}, /* mcf528x registers. */
3808 { "rambar", RAMBAR
}, /* mcf528x registers. */
3810 { "mbar2", MBAR2
}, /* mcf5249 registers. */
3812 { "cac", CAC
}, /* fido registers. */
3813 { "mbb", MBB
}, /* fido registers. */
3814 /* End of control registers. */
3848 /* 68ec030 versions of same. */
3851 /* 68ec030 access control unit, identical to 030 MMU status reg. */
3854 /* Suppressed data and address registers. */
3872 /* Upper and lower data and address registers, used by macw and msacw. */
3913 init_regtable (void)
3916 for (i
= 0; init_table
[i
].name
; i
++)
3917 insert_reg (init_table
[i
].name
, init_table
[i
].number
);
3921 md_assemble (char *str
)
3928 int shorts_this_frag
;
3931 if (!selected_cpu
&& !selected_arch
)
3933 /* We've not selected an architecture yet. Set the default
3934 now. We do this lazily so that an initial .cpu or .arch directive
3936 if (!m68k_set_cpu (TARGET_CPU
, 1, 1))
3937 as_bad (_("unrecognized default cpu `%s'"), TARGET_CPU
);
3942 /* In MRI mode, the instruction and operands are separated by a
3943 space. Anything following the operands is a comment. The label
3944 has already been removed. */
3952 for (s
= str
; *s
!= '\0'; s
++)
3954 if ((*s
== ' ' || *s
== '\t') && ! inquote
)
3972 inquote
= ! inquote
;
3977 memset (&the_ins
, '\0', sizeof (the_ins
));
3982 for (n
= 0; n
< the_ins
.numargs
; n
++)
3983 if (the_ins
.operands
[n
].error
)
3985 er
= the_ins
.operands
[n
].error
;
3991 as_bad (_("%s -- statement `%s' ignored"), er
, str
);
3995 /* If there is a current label, record that it marks an instruction. */
3996 if (current_label
!= NULL
)
3998 current_label
->text
= 1;
3999 current_label
= NULL
;
4003 /* Tie dwarf2 debug info to the address at the start of the insn. */
4004 dwarf2_emit_insn (0);
4007 if (the_ins
.nfrag
== 0)
4009 /* No frag hacking involved; just put it out. */
4010 toP
= frag_more (2 * the_ins
.numo
);
4011 fromP
= &the_ins
.opcode
[0];
4012 for (m
= the_ins
.numo
; m
; --m
)
4014 md_number_to_chars (toP
, (long) (*fromP
), 2);
4018 /* Put out symbol-dependent info. */
4019 for (m
= 0; m
< the_ins
.nrel
; m
++)
4021 switch (the_ins
.reloc
[m
].wid
)
4040 as_fatal (_("Don't know how to figure width of %c in md_assemble()"),
4041 the_ins
.reloc
[m
].wid
);
4044 fixP
= fix_new_exp (frag_now
,
4045 ((toP
- frag_now
->fr_literal
)
4046 - the_ins
.numo
* 2 + the_ins
.reloc
[m
].n
),
4048 &the_ins
.reloc
[m
].exp
,
4049 the_ins
.reloc
[m
].pcrel
,
4050 get_reloc_code (n
, the_ins
.reloc
[m
].pcrel
,
4051 the_ins
.reloc
[m
].pic_reloc
));
4052 fixP
->fx_pcrel_adjust
= the_ins
.reloc
[m
].pcrel_fix
;
4053 if (the_ins
.reloc
[m
].wid
== 'B')
4054 fixP
->fx_signed
= 1;
4059 /* There's some frag hacking. */
4061 /* Calculate the max frag size. */
4064 wid
= 2 * the_ins
.fragb
[0].fragoff
;
4065 for (n
= 1; n
< the_ins
.nfrag
; n
++)
4066 wid
+= 2 * (the_ins
.numo
- the_ins
.fragb
[n
- 1].fragoff
);
4067 /* frag_var part. */
4069 /* Make sure the whole insn fits in one chunk, in particular that
4070 the var part is attached, as we access one byte before the
4071 variable frag for byte branches. */
4075 for (n
= 0, fromP
= &the_ins
.opcode
[0]; n
< the_ins
.nfrag
; n
++)
4080 wid
= 2 * the_ins
.fragb
[n
].fragoff
;
4082 wid
= 2 * (the_ins
.numo
- the_ins
.fragb
[n
- 1].fragoff
);
4083 toP
= frag_more (wid
);
4085 shorts_this_frag
= 0;
4086 for (m
= wid
/ 2; m
; --m
)
4088 md_number_to_chars (toP
, (long) (*fromP
), 2);
4093 for (m
= 0; m
< the_ins
.nrel
; m
++)
4095 if ((the_ins
.reloc
[m
].n
) >= 2 * shorts_this_frag
)
4097 the_ins
.reloc
[m
].n
-= 2 * shorts_this_frag
;
4100 wid
= the_ins
.reloc
[m
].wid
;
4103 the_ins
.reloc
[m
].wid
= 0;
4104 wid
= (wid
== 'b') ? 1 : (wid
== 'w') ? 2 : (wid
== 'l') ? 4 : 4000;
4106 fixP
= fix_new_exp (frag_now
,
4107 ((toP
- frag_now
->fr_literal
)
4108 - the_ins
.numo
* 2 + the_ins
.reloc
[m
].n
),
4110 &the_ins
.reloc
[m
].exp
,
4111 the_ins
.reloc
[m
].pcrel
,
4112 get_reloc_code (wid
, the_ins
.reloc
[m
].pcrel
,
4113 the_ins
.reloc
[m
].pic_reloc
));
4114 fixP
->fx_pcrel_adjust
= the_ins
.reloc
[m
].pcrel_fix
;
4116 (void) frag_var (rs_machine_dependent
, 10, 0,
4117 (relax_substateT
) (the_ins
.fragb
[n
].fragty
),
4118 the_ins
.fragb
[n
].fadd
, the_ins
.fragb
[n
].foff
, to_beg_P
);
4120 n
= (the_ins
.numo
- the_ins
.fragb
[n
- 1].fragoff
);
4121 shorts_this_frag
= 0;
4124 toP
= frag_more (n
* 2);
4127 md_number_to_chars (toP
, (long) (*fromP
), 2);
4133 for (m
= 0; m
< the_ins
.nrel
; m
++)
4137 wid
= the_ins
.reloc
[m
].wid
;
4140 the_ins
.reloc
[m
].wid
= 0;
4141 wid
= (wid
== 'b') ? 1 : (wid
== 'w') ? 2 : (wid
== 'l') ? 4 : 4000;
4143 fixP
= fix_new_exp (frag_now
,
4144 ((the_ins
.reloc
[m
].n
+ toP
- frag_now
->fr_literal
)
4145 - shorts_this_frag
* 2),
4147 &the_ins
.reloc
[m
].exp
,
4148 the_ins
.reloc
[m
].pcrel
,
4149 get_reloc_code (wid
, the_ins
.reloc
[m
].pcrel
,
4150 the_ins
.reloc
[m
].pic_reloc
));
4151 fixP
->fx_pcrel_adjust
= the_ins
.reloc
[m
].pcrel_fix
;
4155 /* Comparison function used by qsort to rank the opcode entries by name. */
4158 m68k_compare_opcode (const void * v1
, const void * v2
)
4160 struct m68k_opcode
* op1
, * op2
;
4166 op1
= *(struct m68k_opcode
**) v1
;
4167 op2
= *(struct m68k_opcode
**) v2
;
4169 /* Compare the two names. If different, return the comparison.
4170 If the same, return the order they are in the opcode table. */
4171 ret
= strcmp (op1
->name
, op2
->name
);
4182 const struct m68k_opcode
*ins
;
4183 struct m68k_incant
*hack
, *slak
;
4184 const char *retval
= 0; /* Empty string, or error msg text. */
4187 /* Set up hash tables with 68000 instructions.
4188 similar to what the vax assembler does. */
4189 /* RMS claims the thing to do is take the m68k-opcode.h table, and make
4190 a copy of it at runtime, adding in the information we want but isn't
4191 there. I think it'd be better to have an awk script hack the table
4192 at compile time. Or even just xstr the table and use it as-is. But
4193 my lord ghod hath spoken, so we do it this way. Excuse the ugly var
4198 flag_reg_prefix_optional
= 1;
4200 if (! m68k_rel32_from_cmdline
)
4204 /* First sort the opcode table into alphabetical order to seperate
4205 the order that the assembler wants to see the opcodes from the
4206 order that the disassembler wants to see them. */
4207 m68k_sorted_opcodes
= xmalloc (m68k_numopcodes
* sizeof (* m68k_sorted_opcodes
));
4208 if (!m68k_sorted_opcodes
)
4209 as_fatal (_("Internal Error: Can't allocate m68k_sorted_opcodes of size %d"),
4210 m68k_numopcodes
* ((int) sizeof (* m68k_sorted_opcodes
)));
4212 for (i
= m68k_numopcodes
; i
--;)
4213 m68k_sorted_opcodes
[i
] = m68k_opcodes
+ i
;
4215 qsort (m68k_sorted_opcodes
, m68k_numopcodes
,
4216 sizeof (m68k_sorted_opcodes
[0]), m68k_compare_opcode
);
4218 op_hash
= hash_new ();
4220 obstack_begin (&robyn
, 4000);
4221 for (i
= 0; i
< m68k_numopcodes
; i
++)
4223 hack
= slak
= (struct m68k_incant
*) obstack_alloc (&robyn
, sizeof (struct m68k_incant
));
4226 ins
= m68k_sorted_opcodes
[i
];
4228 /* We *could* ignore insns that don't match our
4229 arch here by just leaving them out of the hash. */
4230 slak
->m_operands
= ins
->args
;
4231 slak
->m_opnum
= strlen (slak
->m_operands
) / 2;
4232 slak
->m_arch
= ins
->arch
;
4233 slak
->m_opcode
= ins
->opcode
;
4234 /* This is kludgey. */
4235 slak
->m_codenum
= ((ins
->match
) & 0xffffL
) ? 2 : 1;
4236 if (i
+ 1 != m68k_numopcodes
4237 && !strcmp (ins
->name
, m68k_sorted_opcodes
[i
+ 1]->name
))
4239 slak
->m_next
= obstack_alloc (&robyn
, sizeof (struct m68k_incant
));
4244 slak
= slak
->m_next
;
4248 retval
= hash_insert (op_hash
, ins
->name
, (char *) hack
);
4250 as_fatal (_("Internal Error: Can't hash %s: %s"), ins
->name
, retval
);
4253 for (i
= 0; i
< m68k_numaliases
; i
++)
4255 const char *name
= m68k_opcode_aliases
[i
].primary
;
4256 const char *alias
= m68k_opcode_aliases
[i
].alias
;
4257 PTR val
= hash_find (op_hash
, name
);
4260 as_fatal (_("Internal Error: Can't find %s in hash table"), name
);
4261 retval
= hash_insert (op_hash
, alias
, val
);
4263 as_fatal (_("Internal Error: Can't hash %s: %s"), alias
, retval
);
4266 /* In MRI mode, all unsized branches are variable sized. Normally,
4267 they are word sized. */
4270 static struct m68k_opcode_alias mri_aliases
[] =
4291 i
< (int) (sizeof mri_aliases
/ sizeof mri_aliases
[0]);
4294 const char *name
= mri_aliases
[i
].primary
;
4295 const char *alias
= mri_aliases
[i
].alias
;
4296 PTR val
= hash_find (op_hash
, name
);
4299 as_fatal (_("Internal Error: Can't find %s in hash table"), name
);
4300 retval
= hash_jam (op_hash
, alias
, val
);
4302 as_fatal (_("Internal Error: Can't hash %s: %s"), alias
, retval
);
4306 for (i
= 0; i
< (int) sizeof (notend_table
); i
++)
4308 notend_table
[i
] = 0;
4309 alt_notend_table
[i
] = 0;
4312 notend_table
[','] = 1;
4313 notend_table
['{'] = 1;
4314 notend_table
['}'] = 1;
4315 alt_notend_table
['a'] = 1;
4316 alt_notend_table
['A'] = 1;
4317 alt_notend_table
['d'] = 1;
4318 alt_notend_table
['D'] = 1;
4319 alt_notend_table
['#'] = 1;
4320 alt_notend_table
['&'] = 1;
4321 alt_notend_table
['f'] = 1;
4322 alt_notend_table
['F'] = 1;
4323 #ifdef REGISTER_PREFIX
4324 alt_notend_table
[REGISTER_PREFIX
] = 1;
4327 /* We need to put '(' in alt_notend_table to handle
4328 cas2 %d0:%d2,%d3:%d4,(%a0):(%a1) */
4329 alt_notend_table
['('] = 1;
4331 /* We need to put '@' in alt_notend_table to handle
4332 cas2 %d0:%d2,%d3:%d4,@(%d0):@(%d1) */
4333 alt_notend_table
['@'] = 1;
4335 /* We need to put digits in alt_notend_table to handle
4336 bfextu %d0{24:1},%d0 */
4337 alt_notend_table
['0'] = 1;
4338 alt_notend_table
['1'] = 1;
4339 alt_notend_table
['2'] = 1;
4340 alt_notend_table
['3'] = 1;
4341 alt_notend_table
['4'] = 1;
4342 alt_notend_table
['5'] = 1;
4343 alt_notend_table
['6'] = 1;
4344 alt_notend_table
['7'] = 1;
4345 alt_notend_table
['8'] = 1;
4346 alt_notend_table
['9'] = 1;
4348 #ifndef MIT_SYNTAX_ONLY
4349 /* Insert pseudo ops, these have to go into the opcode table since
4350 gas expects pseudo ops to start with a dot. */
4354 while (mote_pseudo_table
[n
].poc_name
)
4356 hack
= obstack_alloc (&robyn
, sizeof (struct m68k_incant
));
4357 hash_insert (op_hash
,
4358 mote_pseudo_table
[n
].poc_name
, (char *) hack
);
4359 hack
->m_operands
= 0;
4369 record_alignment (text_section
, 2);
4370 record_alignment (data_section
, 2);
4371 record_alignment (bss_section
, 2);
4376 /* This is called when a label is defined. */
4379 m68k_frob_label (symbolS
*sym
)
4381 struct label_line
*n
;
4383 n
= (struct label_line
*) xmalloc (sizeof *n
);
4386 as_where (&n
->file
, &n
->line
);
4392 dwarf2_emit_label (sym
);
4396 /* This is called when a value that is not an instruction is emitted. */
4399 m68k_flush_pending_output (void)
4401 current_label
= NULL
;
4404 /* This is called at the end of the assembly, when the final value of
4405 the label is known. We warn if this is a text symbol aligned at an
4409 m68k_frob_symbol (symbolS
*sym
)
4411 if (S_GET_SEGMENT (sym
) == reg_section
4412 && (int) S_GET_VALUE (sym
) < 0)
4414 S_SET_SEGMENT (sym
, absolute_section
);
4415 S_SET_VALUE (sym
, ~(int)S_GET_VALUE (sym
));
4417 else if ((S_GET_VALUE (sym
) & 1) != 0)
4419 struct label_line
*l
;
4421 for (l
= labels
; l
!= NULL
; l
= l
->next
)
4423 if (l
->label
== sym
)
4426 as_warn_where (l
->file
, l
->line
,
4427 _("text label `%s' aligned to odd boundary"),
4435 /* This is called if we go in or out of MRI mode because of the .mri
4439 m68k_mri_mode_change (int on
)
4443 if (! flag_reg_prefix_optional
)
4445 flag_reg_prefix_optional
= 1;
4446 #ifdef REGISTER_PREFIX
4451 if (! m68k_rel32_from_cmdline
)
4456 if (! reg_prefix_optional_seen
)
4458 #ifdef REGISTER_PREFIX_OPTIONAL
4459 flag_reg_prefix_optional
= REGISTER_PREFIX_OPTIONAL
;
4461 flag_reg_prefix_optional
= 0;
4463 #ifdef REGISTER_PREFIX
4468 if (! m68k_rel32_from_cmdline
)
4473 /* Equal to MAX_PRECISION in atof-ieee.c. */
4474 #define MAX_LITTLENUMS 6
4476 /* Turn a string in input_line_pointer into a floating point constant
4477 of type TYPE, and store the appropriate bytes in *LITP. The number
4478 of LITTLENUMS emitted is stored in *SIZEP. An error message is
4479 returned, or NULL on OK. */
4482 md_atof (int type
, char *litP
, int *sizeP
)
4485 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
4486 LITTLENUM_TYPE
*wordP
;
4517 return _("Bad call to MD_ATOF()");
4519 t
= atof_ieee (input_line_pointer
, type
, words
);
4521 input_line_pointer
= t
;
4523 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
4524 for (wordP
= words
; prec
--;)
4526 md_number_to_chars (litP
, (long) (*wordP
++), sizeof (LITTLENUM_TYPE
));
4527 litP
+= sizeof (LITTLENUM_TYPE
);
4533 md_number_to_chars (char *buf
, valueT val
, int n
)
4535 number_to_chars_bigendian (buf
, val
, n
);
4539 md_apply_fix (fixS
*fixP
, valueT
*valP
, segT seg ATTRIBUTE_UNUSED
)
4541 offsetT val
= *valP
;
4542 addressT upper_limit
;
4543 offsetT lower_limit
;
4545 /* This is unnecessary but it convinces the native rs6000 compiler
4546 to generate the code we want. */
4547 char *buf
= fixP
->fx_frag
->fr_literal
;
4548 buf
+= fixP
->fx_where
;
4549 /* End ibm compiler workaround. */
4553 if (fixP
->fx_addsy
== NULL
&& fixP
->fx_pcrel
== 0)
4559 memset (buf
, 0, fixP
->fx_size
);
4560 fixP
->fx_addnumber
= val
; /* Remember value for emit_reloc. */
4562 if (fixP
->fx_r_type
== BFD_RELOC_VTABLE_INHERIT
4563 && !S_IS_DEFINED (fixP
->fx_addsy
)
4564 && !S_IS_WEAK (fixP
->fx_addsy
))
4565 S_SET_WEAK (fixP
->fx_addsy
);
4570 if (fixP
->fx_r_type
== BFD_RELOC_VTABLE_INHERIT
4571 || fixP
->fx_r_type
== BFD_RELOC_VTABLE_ENTRY
)
4574 switch (fixP
->fx_size
)
4576 /* The cast to offsetT below are necessary to make code
4577 correct for machines where ints are smaller than offsetT. */
4581 lower_limit
= - (offsetT
) 0x80;
4584 *buf
++ = (val
>> 8);
4586 upper_limit
= 0x7fff;
4587 lower_limit
= - (offsetT
) 0x8000;
4590 *buf
++ = (val
>> 24);
4591 *buf
++ = (val
>> 16);
4592 *buf
++ = (val
>> 8);
4594 upper_limit
= 0x7fffffff;
4595 lower_limit
= - (offsetT
) 0x7fffffff - 1; /* Avoid constant overflow. */
4598 BAD_CASE (fixP
->fx_size
);
4601 /* Fix up a negative reloc. */
4602 if (fixP
->fx_addsy
== NULL
&& fixP
->fx_subsy
!= NULL
)
4604 fixP
->fx_addsy
= fixP
->fx_subsy
;
4605 fixP
->fx_subsy
= NULL
;
4609 /* For non-pc-relative values, it's conceivable we might get something
4610 like "0xff" for a byte field. So extend the upper part of the range
4611 to accept such numbers. We arbitrarily disallow "-0xff" or "0xff+0xff",
4612 so that we can do any range checking at all. */
4613 if (! fixP
->fx_pcrel
&& ! fixP
->fx_signed
)
4614 upper_limit
= upper_limit
* 2 + 1;
4616 if ((addressT
) val
> upper_limit
4617 && (val
> 0 || val
< lower_limit
))
4618 as_bad_where (fixP
->fx_file
, fixP
->fx_line
, _("value out of range"));
4620 /* A one byte PC-relative reloc means a short branch. We can't use
4621 a short branch with a value of 0 or -1, because those indicate
4622 different opcodes (branches with longer offsets). fixup_segment
4623 in write.c may have clobbered fx_pcrel, so we need to examine the
4626 || fixP
->fx_r_type
== BFD_RELOC_8_PCREL
)
4627 && fixP
->fx_size
== 1
4628 && (fixP
->fx_addsy
== NULL
4629 || S_IS_DEFINED (fixP
->fx_addsy
))
4630 && (val
== 0 || val
== -1))
4631 as_bad_where (fixP
->fx_file
, fixP
->fx_line
, _("invalid byte branch offset"));
4634 /* *fragP has been relaxed to its final size, and now needs to have
4635 the bytes inside it modified to conform to the new size There is UGLY
4639 md_convert_frag_1 (fragS
*fragP
)
4644 /* Address in object code of the displacement. */
4645 register int object_address
= fragP
->fr_fix
+ fragP
->fr_address
;
4647 /* Address in gas core of the place to store the displacement. */
4648 /* This convinces the native rs6000 compiler to generate the code we
4650 register char *buffer_address
= fragP
->fr_literal
;
4651 buffer_address
+= fragP
->fr_fix
;
4652 /* End ibm compiler workaround. */
4654 /* The displacement of the address, from current location. */
4655 disp
= fragP
->fr_symbol
? S_GET_VALUE (fragP
->fr_symbol
) : 0;
4656 disp
= (disp
+ fragP
->fr_offset
) - object_address
;
4658 switch (fragP
->fr_subtype
)
4660 case TAB (BRANCHBWL
, BYTE
):
4661 case TAB (BRABSJUNC
, BYTE
):
4662 case TAB (BRABSJCOND
, BYTE
):
4663 case TAB (BRANCHBW
, BYTE
):
4664 know (issbyte (disp
));
4666 as_bad_where (fragP
->fr_file
, fragP
->fr_line
,
4667 _("short branch with zero offset: use :w"));
4668 fixP
= fix_new (fragP
, fragP
->fr_fix
- 1, 1, fragP
->fr_symbol
,
4669 fragP
->fr_offset
, 1, RELAX_RELOC_PC8
);
4670 fixP
->fx_pcrel_adjust
= -1;
4672 case TAB (BRANCHBWL
, SHORT
):
4673 case TAB (BRABSJUNC
, SHORT
):
4674 case TAB (BRABSJCOND
, SHORT
):
4675 case TAB (BRANCHBW
, SHORT
):
4676 fragP
->fr_opcode
[1] = 0x00;
4677 fix_new (fragP
, fragP
->fr_fix
, 2, fragP
->fr_symbol
, fragP
->fr_offset
,
4678 1, RELAX_RELOC_PC16
);
4681 case TAB (BRANCHBWL
, LONG
):
4682 fragP
->fr_opcode
[1] = (char) 0xFF;
4683 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4684 1, RELAX_RELOC_PC32
);
4687 case TAB (BRABSJUNC
, LONG
):
4688 if (fragP
->fr_opcode
[0] == 0x61) /* jbsr */
4690 if (flag_keep_pcrel
)
4691 as_fatal (_("Tried to convert PC relative BSR to absolute JSR"));
4692 fragP
->fr_opcode
[0] = 0x4E;
4693 fragP
->fr_opcode
[1] = (char) 0xB9; /* JSR with ABSL LONG operand. */
4694 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4695 0, RELAX_RELOC_ABS32
);
4698 else if (fragP
->fr_opcode
[0] == 0x60) /* jbra */
4700 if (flag_keep_pcrel
)
4701 as_fatal (_("Tried to convert PC relative branch to absolute jump"));
4702 fragP
->fr_opcode
[0] = 0x4E;
4703 fragP
->fr_opcode
[1] = (char) 0xF9; /* JMP with ABSL LONG operand. */
4704 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4705 0, RELAX_RELOC_ABS32
);
4710 /* This cannot happen, because jbsr and jbra are the only two
4711 unconditional branches. */
4715 case TAB (BRABSJCOND
, LONG
):
4716 if (flag_keep_pcrel
)
4717 as_fatal (_("Tried to convert PC relative conditional branch to absolute jump"));
4719 /* Only Bcc 68000 instructions can come here
4720 Change bcc into b!cc/jmp absl long. */
4721 fragP
->fr_opcode
[0] ^= 0x01; /* Invert bcc. */
4722 fragP
->fr_opcode
[1] = 0x06; /* Branch offset = 6. */
4724 /* JF: these used to be fr_opcode[2,3], but they may be in a
4725 different frag, in which case referring to them is a no-no.
4726 Only fr_opcode[0,1] are guaranteed to work. */
4727 *buffer_address
++ = 0x4e; /* put in jmp long (0x4ef9) */
4728 *buffer_address
++ = (char) 0xf9;
4729 fragP
->fr_fix
+= 2; /* Account for jmp instruction. */
4730 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
,
4731 fragP
->fr_offset
, 0, RELAX_RELOC_ABS32
);
4734 case TAB (FBRANCH
, SHORT
):
4735 know ((fragP
->fr_opcode
[1] & 0x40) == 0);
4736 fix_new (fragP
, fragP
->fr_fix
, 2, fragP
->fr_symbol
, fragP
->fr_offset
,
4737 1, RELAX_RELOC_PC16
);
4740 case TAB (FBRANCH
, LONG
):
4741 fragP
->fr_opcode
[1] |= 0x40; /* Turn on LONG bit. */
4742 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4743 1, RELAX_RELOC_PC32
);
4746 case TAB (DBCCLBR
, SHORT
):
4747 case TAB (DBCCABSJ
, SHORT
):
4748 fix_new (fragP
, fragP
->fr_fix
, 2, fragP
->fr_symbol
, fragP
->fr_offset
,
4749 1, RELAX_RELOC_PC16
);
4752 case TAB (DBCCLBR
, LONG
):
4753 /* Only DBcc instructions can come here.
4754 Change dbcc into dbcc/bral.
4755 JF: these used to be fr_opcode[2-7], but that's wrong. */
4756 if (flag_keep_pcrel
)
4757 as_fatal (_("Tried to convert DBcc to absolute jump"));
4759 *buffer_address
++ = 0x00; /* Branch offset = 4. */
4760 *buffer_address
++ = 0x04;
4761 *buffer_address
++ = 0x60; /* Put in bra pc+6. */
4762 *buffer_address
++ = 0x06;
4763 *buffer_address
++ = 0x60; /* Put in bral (0x60ff). */
4764 *buffer_address
++ = (char) 0xff;
4766 fragP
->fr_fix
+= 6; /* Account for bra/jmp instructions. */
4767 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
, 1,
4771 case TAB (DBCCABSJ
, LONG
):
4772 /* Only DBcc instructions can come here.
4773 Change dbcc into dbcc/jmp.
4774 JF: these used to be fr_opcode[2-7], but that's wrong. */
4775 if (flag_keep_pcrel
)
4776 as_fatal (_("Tried to convert PC relative conditional branch to absolute jump"));
4778 *buffer_address
++ = 0x00; /* Branch offset = 4. */
4779 *buffer_address
++ = 0x04;
4780 *buffer_address
++ = 0x60; /* Put in bra pc + 6. */
4781 *buffer_address
++ = 0x06;
4782 *buffer_address
++ = 0x4e; /* Put in jmp long (0x4ef9). */
4783 *buffer_address
++ = (char) 0xf9;
4785 fragP
->fr_fix
+= 6; /* Account for bra/jmp instructions. */
4786 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
, 0,
4790 case TAB (PCREL1632
, SHORT
):
4791 fragP
->fr_opcode
[1] &= ~0x3F;
4792 fragP
->fr_opcode
[1] |= 0x3A; /* 072 - mode 7.2 */
4793 fix_new (fragP
, (int) (fragP
->fr_fix
), 2, fragP
->fr_symbol
,
4794 fragP
->fr_offset
, 1, RELAX_RELOC_PC16
);
4797 case TAB (PCREL1632
, LONG
):
4798 /* Already set to mode 7.3; this indicates: PC indirect with
4799 suppressed index, 32-bit displacement. */
4800 *buffer_address
++ = 0x01;
4801 *buffer_address
++ = 0x70;
4803 fixP
= fix_new (fragP
, (int) (fragP
->fr_fix
), 4, fragP
->fr_symbol
,
4804 fragP
->fr_offset
, 1, RELAX_RELOC_PC32
);
4805 fixP
->fx_pcrel_adjust
= 2;
4808 case TAB (PCINDEX
, BYTE
):
4809 assert (fragP
->fr_fix
>= 2);
4810 buffer_address
[-2] &= ~1;
4811 fixP
= fix_new (fragP
, fragP
->fr_fix
- 1, 1, fragP
->fr_symbol
,
4812 fragP
->fr_offset
, 1, RELAX_RELOC_PC8
);
4813 fixP
->fx_pcrel_adjust
= 1;
4815 case TAB (PCINDEX
, SHORT
):
4816 assert (fragP
->fr_fix
>= 2);
4817 buffer_address
[-2] |= 0x1;
4818 buffer_address
[-1] = 0x20;
4819 fixP
= fix_new (fragP
, (int) (fragP
->fr_fix
), 2, fragP
->fr_symbol
,
4820 fragP
->fr_offset
, 1, RELAX_RELOC_PC16
);
4821 fixP
->fx_pcrel_adjust
= 2;
4824 case TAB (PCINDEX
, LONG
):
4825 assert (fragP
->fr_fix
>= 2);
4826 buffer_address
[-2] |= 0x1;
4827 buffer_address
[-1] = 0x30;
4828 fixP
= fix_new (fragP
, (int) (fragP
->fr_fix
), 4, fragP
->fr_symbol
,
4829 fragP
->fr_offset
, 1, RELAX_RELOC_PC32
);
4830 fixP
->fx_pcrel_adjust
= 2;
4833 case TAB (ABSTOPCREL
, SHORT
):
4834 fix_new (fragP
, fragP
->fr_fix
, 2, fragP
->fr_symbol
, fragP
->fr_offset
,
4835 1, RELAX_RELOC_PC16
);
4838 case TAB (ABSTOPCREL
, LONG
):
4839 if (flag_keep_pcrel
)
4840 as_fatal (_("Tried to convert PC relative conditional branch to absolute jump"));
4841 /* The thing to do here is force it to ABSOLUTE LONG, since
4842 ABSTOPCREL is really trying to shorten an ABSOLUTE address anyway. */
4843 if ((fragP
->fr_opcode
[1] & 0x3F) != 0x3A)
4845 fragP
->fr_opcode
[1] &= ~0x3F;
4846 fragP
->fr_opcode
[1] |= 0x39; /* Mode 7.1 */
4847 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4848 0, RELAX_RELOC_ABS32
);
4855 md_convert_frag (bfd
*abfd ATTRIBUTE_UNUSED
,
4856 segT sec ATTRIBUTE_UNUSED
,
4859 md_convert_frag_1 (fragP
);
4862 /* Force truly undefined symbols to their maximum size, and generally set up
4863 the frag list to be relaxed
4866 md_estimate_size_before_relax (fragS
*fragP
, segT segment
)
4868 /* Handle SZ_UNDEF first, it can be changed to BYTE or SHORT. */
4869 switch (fragP
->fr_subtype
)
4871 case TAB (BRANCHBWL
, SZ_UNDEF
):
4872 case TAB (BRABSJUNC
, SZ_UNDEF
):
4873 case TAB (BRABSJCOND
, SZ_UNDEF
):
4875 if (S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4876 && relaxable_symbol (fragP
->fr_symbol
))
4878 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), BYTE
);
4880 else if (flag_short_refs
)
4882 /* Symbol is undefined and we want short ref. */
4883 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), SHORT
);
4887 /* Symbol is still undefined. Make it LONG. */
4888 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), LONG
);
4893 case TAB (BRANCHBW
, SZ_UNDEF
):
4895 if (S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4896 && relaxable_symbol (fragP
->fr_symbol
))
4898 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), BYTE
);
4902 /* Symbol is undefined and we don't have long branches. */
4903 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), SHORT
);
4908 case TAB (FBRANCH
, SZ_UNDEF
):
4909 case TAB (DBCCLBR
, SZ_UNDEF
):
4910 case TAB (DBCCABSJ
, SZ_UNDEF
):
4911 case TAB (PCREL1632
, SZ_UNDEF
):
4913 if ((S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4914 && relaxable_symbol (fragP
->fr_symbol
))
4917 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), SHORT
);
4921 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), LONG
);
4926 case TAB (PCINDEX
, SZ_UNDEF
):
4927 if ((S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4928 && relaxable_symbol (fragP
->fr_symbol
)))
4930 fragP
->fr_subtype
= TAB (PCINDEX
, BYTE
);
4934 fragP
->fr_subtype
= TAB (PCINDEX
, LONG
);
4938 case TAB (ABSTOPCREL
, SZ_UNDEF
):
4940 if ((S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4941 && relaxable_symbol (fragP
->fr_symbol
)))
4943 fragP
->fr_subtype
= TAB (ABSTOPCREL
, SHORT
);
4947 fragP
->fr_subtype
= TAB (ABSTOPCREL
, LONG
);
4956 /* Now that SZ_UNDEF are taken care of, check others. */
4957 switch (fragP
->fr_subtype
)
4959 case TAB (BRANCHBWL
, BYTE
):
4960 case TAB (BRABSJUNC
, BYTE
):
4961 case TAB (BRABSJCOND
, BYTE
):
4962 case TAB (BRANCHBW
, BYTE
):
4963 /* We can't do a short jump to the next instruction, so in that
4964 case we force word mode. If the symbol is at the start of a
4965 frag, and it is the next frag with any data in it (usually
4966 this is just the next frag, but assembler listings may
4967 introduce empty frags), we must use word mode. */
4968 if (fragP
->fr_symbol
)
4972 sym_frag
= symbol_get_frag (fragP
->fr_symbol
);
4973 if (S_GET_VALUE (fragP
->fr_symbol
) == sym_frag
->fr_address
)
4977 for (l
= fragP
->fr_next
; l
&& l
!= sym_frag
; l
= l
->fr_next
)
4981 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), SHORT
);
4988 return md_relax_table
[fragP
->fr_subtype
].rlx_length
;
4991 #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
4992 /* the bit-field entries in the relocation_info struct plays hell
4993 with the byte-order problems of cross-assembly. So as a hack,
4994 I added this mach. dependent ri twiddler. Ugly, but it gets
4996 /* on m68k: first 4 bytes are normal unsigned long, next three bytes
4997 are symbolnum, most sig. byte first. Last byte is broken up with
4998 bit 7 as pcrel, bits 6 & 5 as length, bit 4 as pcrel, and the lower
4999 nibble as nuthin. (on Sun 3 at least) */
5000 /* Translate the internal relocation information into target-specific
5004 md_ri_to_chars (char *the_bytes
, struct reloc_info_generic
*ri
)
5007 md_number_to_chars (the_bytes
, ri
->r_address
, 4);
5008 /* Now the fun stuff. */
5009 the_bytes
[4] = (ri
->r_symbolnum
>> 16) & 0x0ff;
5010 the_bytes
[5] = (ri
->r_symbolnum
>> 8) & 0x0ff;
5011 the_bytes
[6] = ri
->r_symbolnum
& 0x0ff;
5012 the_bytes
[7] = (((ri
->r_pcrel
<< 7) & 0x80)
5013 | ((ri
->r_length
<< 5) & 0x60)
5014 | ((ri
->r_extern
<< 4) & 0x10));
5019 #endif /* OBJ_AOUT or OBJ_BOUT */
5021 #ifndef WORKING_DOT_WORD
5022 int md_short_jump_size
= 4;
5023 int md_long_jump_size
= 6;
5026 md_create_short_jump (char *ptr
, addressT from_addr
, addressT to_addr
,
5027 fragS
*frag ATTRIBUTE_UNUSED
,
5028 symbolS
*to_symbol ATTRIBUTE_UNUSED
)
5032 offset
= to_addr
- (from_addr
+ 2);
5034 md_number_to_chars (ptr
, (valueT
) 0x6000, 2);
5035 md_number_to_chars (ptr
+ 2, (valueT
) offset
, 2);
5039 md_create_long_jump (char *ptr
, addressT from_addr
, addressT to_addr
,
5040 fragS
*frag
, symbolS
*to_symbol
)
5044 if (!HAVE_LONG_BRANCH (current_architecture
))
5046 if (flag_keep_pcrel
)
5047 as_fatal (_("Tried to convert PC relative branch to absolute jump"));
5048 offset
= to_addr
- S_GET_VALUE (to_symbol
);
5049 md_number_to_chars (ptr
, (valueT
) 0x4EF9, 2);
5050 md_number_to_chars (ptr
+ 2, (valueT
) offset
, 4);
5051 fix_new (frag
, (ptr
+ 2) - frag
->fr_literal
, 4, to_symbol
, (offsetT
) 0,
5056 offset
= to_addr
- (from_addr
+ 2);
5057 md_number_to_chars (ptr
, (valueT
) 0x60ff, 2);
5058 md_number_to_chars (ptr
+ 2, (valueT
) offset
, 4);
5064 /* Different values of OK tell what its OK to return. Things that
5065 aren't OK are an error (what a shock, no?)
5068 10: Absolute 1:8 only
5069 20: Absolute 0:7 only
5070 30: absolute 0:15 only
5071 40: Absolute 0:31 only
5072 50: absolute 0:127 only
5073 55: absolute -64:63 only
5074 60: absolute -128:127 only
5075 70: absolute 0:4095 only
5076 80: absolute -1, 1:7 only
5080 get_num (struct m68k_exp
*exp
, int ok
)
5082 if (exp
->exp
.X_op
== O_absent
)
5084 /* Do the same thing the VAX asm does. */
5085 op (exp
) = O_constant
;
5091 as_warn (_("expression out of range: defaulting to 1"));
5095 else if (exp
->exp
.X_op
== O_constant
)
5100 if ((valueT
) TRUNC (offs (exp
)) - 1 > 7)
5102 as_warn (_("expression out of range: defaulting to 1"));
5107 if ((valueT
) TRUNC (offs (exp
)) > 7)
5111 if ((valueT
) TRUNC (offs (exp
)) > 15)
5115 if ((valueT
) TRUNC (offs (exp
)) > 32)
5119 if ((valueT
) TRUNC (offs (exp
)) > 127)
5123 if ((valueT
) SEXT (offs (exp
)) + 64 > 127)
5127 if ((valueT
) SEXT (offs (exp
)) + 128 > 255)
5131 if ((valueT
) TRUNC (offs (exp
)) > 4095)
5134 as_warn (_("expression out of range: defaulting to 0"));
5139 if ((valueT
) TRUNC (offs (exp
)) != 0xffffffff
5140 && (valueT
) TRUNC (offs (exp
)) - 1 > 6)
5142 as_warn (_("expression out of range: defaulting to 1"));
5150 else if (exp
->exp
.X_op
== O_big
)
5152 if (offs (exp
) <= 0 /* flonum. */
5153 && (ok
== 90 /* no bignums */
5154 || (ok
> 10 /* Small-int ranges including 0 ok. */
5155 /* If we have a flonum zero, a zero integer should
5156 do as well (e.g., in moveq). */
5157 && generic_floating_point_number
.exponent
== 0
5158 && generic_floating_point_number
.low
[0] == 0)))
5160 /* HACK! Turn it into a long. */
5161 LITTLENUM_TYPE words
[6];
5163 gen_to_words (words
, 2, 8L); /* These numbers are magic! */
5164 op (exp
) = O_constant
;
5167 offs (exp
) = words
[1] | (words
[0] << 16);
5171 op (exp
) = O_constant
;
5174 offs (exp
) = (ok
== 10) ? 1 : 0;
5175 as_warn (_("Can't deal with expression; defaulting to %ld"),
5181 if (ok
>= 10 && ok
<= 80)
5183 op (exp
) = O_constant
;
5186 offs (exp
) = (ok
== 10) ? 1 : 0;
5187 as_warn (_("Can't deal with expression; defaulting to %ld"),
5192 if (exp
->size
!= SIZE_UNSPEC
)
5200 if (!isbyte (offs (exp
)))
5201 as_warn (_("expression doesn't fit in BYTE"));
5204 if (!isword (offs (exp
)))
5205 as_warn (_("expression doesn't fit in WORD"));
5213 /* These are the back-ends for the various machine dependent pseudo-ops. */
5216 s_data1 (int ignore ATTRIBUTE_UNUSED
)
5218 subseg_set (data_section
, 1);
5219 demand_empty_rest_of_line ();
5223 s_data2 (int ignore ATTRIBUTE_UNUSED
)
5225 subseg_set (data_section
, 2);
5226 demand_empty_rest_of_line ();
5230 s_bss (int ignore ATTRIBUTE_UNUSED
)
5232 /* We don't support putting frags in the BSS segment, we fake it
5233 by marking in_bss, then looking at s_skip for clues. */
5235 subseg_set (bss_section
, 0);
5236 demand_empty_rest_of_line ();
5240 s_even (int ignore ATTRIBUTE_UNUSED
)
5243 register long temp_fill
;
5245 temp
= 1; /* JF should be 2? */
5246 temp_fill
= get_absolute_expression ();
5247 if (!need_pass_2
) /* Never make frag if expect extra pass. */
5248 frag_align (temp
, (int) temp_fill
, 0);
5249 demand_empty_rest_of_line ();
5250 record_alignment (now_seg
, temp
);
5254 s_proc (int ignore ATTRIBUTE_UNUSED
)
5256 demand_empty_rest_of_line ();
5259 /* Pseudo-ops handled for MRI compatibility. */
5261 /* This function returns non-zero if the argument is a conditional
5262 pseudo-op. This is called when checking whether a pending
5263 alignment is needed. */
5266 m68k_conditional_pseudoop (pseudo_typeS
*pop
)
5268 return (pop
->poc_handler
== s_mri_if
5269 || pop
->poc_handler
== s_mri_else
);
5272 /* Handle an MRI style chip specification. */
5281 s
= input_line_pointer
;
5282 /* We can't use get_symbol_end since the processor names are not proper
5284 while (is_part_of_name (c
= *input_line_pointer
++))
5286 *--input_line_pointer
= 0;
5287 for (i
= 0; m68k_cpus
[i
].name
; i
++)
5288 if (strcasecmp (s
, m68k_cpus
[i
].name
) == 0)
5290 if (!m68k_cpus
[i
].name
)
5292 as_bad (_("%s: unrecognized processor name"), s
);
5293 *input_line_pointer
= c
;
5294 ignore_rest_of_line ();
5297 *input_line_pointer
= c
;
5299 if (*input_line_pointer
== '/')
5300 current_architecture
= 0;
5302 current_architecture
&= m68881
| m68851
;
5303 current_architecture
|= m68k_cpus
[i
].arch
& ~(m68881
| m68851
);
5304 control_regs
= m68k_cpus
[i
].control_regs
;
5306 while (*input_line_pointer
== '/')
5308 ++input_line_pointer
;
5309 s
= input_line_pointer
;
5310 /* We can't use get_symbol_end since the processor names are not
5312 while (is_part_of_name (c
= *input_line_pointer
++))
5314 *--input_line_pointer
= 0;
5315 if (strcmp (s
, "68881") == 0)
5316 current_architecture
|= m68881
;
5317 else if (strcmp (s
, "68851") == 0)
5318 current_architecture
|= m68851
;
5319 *input_line_pointer
= c
;
5323 /* The MRI CHIP pseudo-op. */
5326 s_chip (int ignore ATTRIBUTE_UNUSED
)
5332 stop
= mri_comment_field (&stopc
);
5335 mri_comment_end (stop
, stopc
);
5336 demand_empty_rest_of_line ();
5339 /* The MRI FOPT pseudo-op. */
5342 s_fopt (int ignore ATTRIBUTE_UNUSED
)
5346 if (strncasecmp (input_line_pointer
, "ID=", 3) == 0)
5350 input_line_pointer
+= 3;
5351 temp
= get_absolute_expression ();
5352 if (temp
< 0 || temp
> 7)
5353 as_bad (_("bad coprocessor id"));
5355 m68k_float_copnum
= COP0
+ temp
;
5359 as_bad (_("unrecognized fopt option"));
5360 ignore_rest_of_line ();
5364 demand_empty_rest_of_line ();
5367 /* The structure used to handle the MRI OPT pseudo-op. */
5371 /* The name of the option. */
5374 /* If this is not NULL, just call this function. The first argument
5375 is the ARG field of this structure, the second argument is
5376 whether the option was negated. */
5377 void (*pfn
) (int arg
, int on
);
5379 /* If this is not NULL, and the PFN field is NULL, set the variable
5380 this points to. Set it to the ARG field if the option was not
5381 negated, and the NOTARG field otherwise. */
5384 /* The value to pass to PFN or to assign to *PVAR. */
5387 /* The value to assign to *PVAR if the option is negated. If PFN is
5388 NULL, and PVAR is not NULL, and ARG and NOTARG are the same, then
5389 the option may not be negated. */
5393 /* The table used to handle the MRI OPT pseudo-op. */
5395 static void skip_to_comma (int, int);
5396 static void opt_nest (int, int);
5397 static void opt_chip (int, int);
5398 static void opt_list (int, int);
5399 static void opt_list_symbols (int, int);
5401 static const struct opt_action opt_table
[] =
5403 { "abspcadd", 0, &m68k_abspcadd
, 1, 0 },
5405 /* We do relaxing, so there is little use for these options. */
5406 { "b", 0, 0, 0, 0 },
5407 { "brs", 0, 0, 0, 0 },
5408 { "brb", 0, 0, 0, 0 },
5409 { "brl", 0, 0, 0, 0 },
5410 { "brw", 0, 0, 0, 0 },
5412 { "c", 0, 0, 0, 0 },
5413 { "cex", 0, 0, 0, 0 },
5414 { "case", 0, &symbols_case_sensitive
, 1, 0 },
5415 { "cl", 0, 0, 0, 0 },
5416 { "cre", 0, 0, 0, 0 },
5417 { "d", 0, &flag_keep_locals
, 1, 0 },
5418 { "e", 0, 0, 0, 0 },
5419 { "f", 0, &flag_short_refs
, 1, 0 },
5420 { "frs", 0, &flag_short_refs
, 1, 0 },
5421 { "frl", 0, &flag_short_refs
, 0, 1 },
5422 { "g", 0, 0, 0, 0 },
5423 { "i", 0, 0, 0, 0 },
5424 { "m", 0, 0, 0, 0 },
5425 { "mex", 0, 0, 0, 0 },
5426 { "mc", 0, 0, 0, 0 },
5427 { "md", 0, 0, 0, 0 },
5428 { "nest", opt_nest
, 0, 0, 0 },
5429 { "next", skip_to_comma
, 0, 0, 0 },
5430 { "o", 0, 0, 0, 0 },
5431 { "old", 0, 0, 0, 0 },
5432 { "op", skip_to_comma
, 0, 0, 0 },
5433 { "pco", 0, 0, 0, 0 },
5434 { "p", opt_chip
, 0, 0, 0 },
5435 { "pcr", 0, 0, 0, 0 },
5436 { "pcs", 0, 0, 0, 0 },
5437 { "r", 0, 0, 0, 0 },
5438 { "quick", 0, &m68k_quick
, 1, 0 },
5439 { "rel32", 0, &m68k_rel32
, 1, 0 },
5440 { "s", opt_list
, 0, 0, 0 },
5441 { "t", opt_list_symbols
, 0, 0, 0 },
5442 { "w", 0, &flag_no_warnings
, 0, 1 },
5446 #define OPTCOUNT ((int) (sizeof opt_table / sizeof opt_table[0]))
5448 /* The MRI OPT pseudo-op. */
5451 s_opt (int ignore ATTRIBUTE_UNUSED
)
5459 const struct opt_action
*o
;
5464 if (*input_line_pointer
== '-')
5466 ++input_line_pointer
;
5469 else if (strncasecmp (input_line_pointer
, "NO", 2) == 0)
5471 input_line_pointer
+= 2;
5475 s
= input_line_pointer
;
5476 c
= get_symbol_end ();
5478 for (i
= 0, o
= opt_table
; i
< OPTCOUNT
; i
++, o
++)
5480 if (strcasecmp (s
, o
->name
) == 0)
5484 /* Restore input_line_pointer now in case the option
5486 *input_line_pointer
= c
;
5487 (*o
->pfn
) (o
->arg
, t
);
5489 else if (o
->pvar
!= NULL
)
5491 if (! t
&& o
->arg
== o
->notarg
)
5492 as_bad (_("option `%s' may not be negated"), s
);
5493 *input_line_pointer
= c
;
5494 *o
->pvar
= t
? o
->arg
: o
->notarg
;
5497 *input_line_pointer
= c
;
5503 as_bad (_("option `%s' not recognized"), s
);
5504 *input_line_pointer
= c
;
5507 while (*input_line_pointer
++ == ',');
5509 /* Move back to terminating character. */
5510 --input_line_pointer
;
5511 demand_empty_rest_of_line ();
5514 /* Skip ahead to a comma. This is used for OPT options which we do
5515 not support and which take arguments. */
5518 skip_to_comma (int arg ATTRIBUTE_UNUSED
, int on ATTRIBUTE_UNUSED
)
5520 while (*input_line_pointer
!= ','
5521 && ! is_end_of_line
[(unsigned char) *input_line_pointer
])
5522 ++input_line_pointer
;
5525 /* Handle the OPT NEST=depth option. */
5528 opt_nest (int arg ATTRIBUTE_UNUSED
, int on ATTRIBUTE_UNUSED
)
5530 if (*input_line_pointer
!= '=')
5532 as_bad (_("bad format of OPT NEST=depth"));
5536 ++input_line_pointer
;
5537 max_macro_nest
= get_absolute_expression ();
5540 /* Handle the OPT P=chip option. */
5543 opt_chip (int arg ATTRIBUTE_UNUSED
, int on ATTRIBUTE_UNUSED
)
5545 if (*input_line_pointer
!= '=')
5547 /* This is just OPT P, which we do not support. */
5551 ++input_line_pointer
;
5555 /* Handle the OPT S option. */
5558 opt_list (int arg ATTRIBUTE_UNUSED
, int on
)
5563 /* Handle the OPT T option. */
5566 opt_list_symbols (int arg ATTRIBUTE_UNUSED
, int on
)
5569 listing
|= LISTING_SYMBOLS
;
5571 listing
&= ~LISTING_SYMBOLS
;
5574 /* Handle the MRI REG pseudo-op. */
5577 s_reg (int ignore ATTRIBUTE_UNUSED
)
5586 if (line_label
== NULL
)
5588 as_bad (_("missing label"));
5589 ignore_rest_of_line ();
5594 stop
= mri_comment_field (&stopc
);
5598 s
= input_line_pointer
;
5599 while (ISALNUM (*input_line_pointer
)
5600 #ifdef REGISTER_PREFIX
5601 || *input_line_pointer
== REGISTER_PREFIX
5603 || *input_line_pointer
== '/'
5604 || *input_line_pointer
== '-')
5605 ++input_line_pointer
;
5606 c
= *input_line_pointer
;
5607 *input_line_pointer
= '\0';
5609 if (m68k_ip_op (s
, &rop
) != 0)
5611 if (rop
.error
== NULL
)
5612 as_bad (_("bad register list"));
5614 as_bad (_("bad register list: %s"), rop
.error
);
5615 *input_line_pointer
= c
;
5616 ignore_rest_of_line ();
5620 *input_line_pointer
= c
;
5622 if (rop
.mode
== REGLST
)
5624 else if (rop
.mode
== DREG
)
5625 mask
= 1 << (rop
.reg
- DATA0
);
5626 else if (rop
.mode
== AREG
)
5627 mask
= 1 << (rop
.reg
- ADDR0
+ 8);
5628 else if (rop
.mode
== FPREG
)
5629 mask
= 1 << (rop
.reg
- FP0
+ 16);
5630 else if (rop
.mode
== CONTROL
5633 else if (rop
.mode
== CONTROL
5636 else if (rop
.mode
== CONTROL
5641 as_bad (_("bad register list"));
5642 ignore_rest_of_line ();
5646 S_SET_SEGMENT (line_label
, reg_section
);
5647 S_SET_VALUE (line_label
, ~mask
);
5648 symbol_set_frag (line_label
, &zero_address_frag
);
5651 mri_comment_end (stop
, stopc
);
5653 demand_empty_rest_of_line ();
5656 /* This structure is used for the MRI SAVE and RESTORE pseudo-ops. */
5660 struct save_opts
*next
;
5662 int symbols_case_sensitive
;
5666 const enum m68k_register
*control_regs
;
5671 /* FIXME: We don't save OPT S. */
5674 /* This variable holds the stack of saved options. */
5676 static struct save_opts
*save_stack
;
5678 /* The MRI SAVE pseudo-op. */
5681 s_save (int ignore ATTRIBUTE_UNUSED
)
5683 struct save_opts
*s
;
5685 s
= (struct save_opts
*) xmalloc (sizeof (struct save_opts
));
5686 s
->abspcadd
= m68k_abspcadd
;
5687 s
->symbols_case_sensitive
= symbols_case_sensitive
;
5688 s
->keep_locals
= flag_keep_locals
;
5689 s
->short_refs
= flag_short_refs
;
5690 s
->architecture
= current_architecture
;
5691 s
->control_regs
= control_regs
;
5692 s
->quick
= m68k_quick
;
5693 s
->rel32
= m68k_rel32
;
5694 s
->listing
= listing
;
5695 s
->no_warnings
= flag_no_warnings
;
5697 s
->next
= save_stack
;
5700 demand_empty_rest_of_line ();
5703 /* The MRI RESTORE pseudo-op. */
5706 s_restore (int ignore ATTRIBUTE_UNUSED
)
5708 struct save_opts
*s
;
5710 if (save_stack
== NULL
)
5712 as_bad (_("restore without save"));
5713 ignore_rest_of_line ();
5718 save_stack
= s
->next
;
5720 m68k_abspcadd
= s
->abspcadd
;
5721 symbols_case_sensitive
= s
->symbols_case_sensitive
;
5722 flag_keep_locals
= s
->keep_locals
;
5723 flag_short_refs
= s
->short_refs
;
5724 current_architecture
= s
->architecture
;
5725 control_regs
= s
->control_regs
;
5726 m68k_quick
= s
->quick
;
5727 m68k_rel32
= s
->rel32
;
5728 listing
= s
->listing
;
5729 flag_no_warnings
= s
->no_warnings
;
5733 demand_empty_rest_of_line ();
5736 /* Types of MRI structured control directives. */
5738 enum mri_control_type
5746 /* This structure is used to stack the MRI structured control
5749 struct mri_control_info
5751 /* The directive within which this one is enclosed. */
5752 struct mri_control_info
*outer
;
5754 /* The type of directive. */
5755 enum mri_control_type type
;
5757 /* Whether an ELSE has been in an IF. */
5760 /* The add or sub statement at the end of a FOR. */
5763 /* The label of the top of a FOR or REPEAT loop. */
5766 /* The label to jump to for the next iteration, or the else
5767 expression of a conditional. */
5770 /* The label to jump to to break out of the loop, or the label past
5771 the end of a conditional. */
5775 /* The stack of MRI structured control directives. */
5777 static struct mri_control_info
*mri_control_stack
;
5779 /* The current MRI structured control directive index number, used to
5780 generate label names. */
5782 static int mri_control_index
;
5784 /* Assemble an instruction for an MRI structured control directive. */
5787 mri_assemble (char *str
)
5791 /* md_assemble expects the opcode to be in lower case. */
5792 for (s
= str
; *s
!= ' ' && *s
!= '\0'; s
++)
5798 /* Generate a new MRI label structured control directive label name. */
5801 mri_control_label (void)
5805 n
= (char *) xmalloc (20);
5806 sprintf (n
, "%smc%d", FAKE_LABEL_NAME
, mri_control_index
);
5807 ++mri_control_index
;
5811 /* Create a new MRI structured control directive. */
5813 static struct mri_control_info
*
5814 push_mri_control (enum mri_control_type type
)
5816 struct mri_control_info
*n
;
5818 n
= (struct mri_control_info
*) xmalloc (sizeof (struct mri_control_info
));
5822 if (type
== mri_if
|| type
== mri_while
)
5825 n
->top
= mri_control_label ();
5826 n
->next
= mri_control_label ();
5827 n
->bottom
= mri_control_label ();
5829 n
->outer
= mri_control_stack
;
5830 mri_control_stack
= n
;
5835 /* Pop off the stack of MRI structured control directives. */
5838 pop_mri_control (void)
5840 struct mri_control_info
*n
;
5842 n
= mri_control_stack
;
5843 mri_control_stack
= n
->outer
;
5851 /* Recognize a condition code in an MRI structured control expression. */
5854 parse_mri_condition (int *pcc
)
5858 know (*input_line_pointer
== '<');
5860 ++input_line_pointer
;
5861 c1
= *input_line_pointer
++;
5862 c2
= *input_line_pointer
++;
5864 if (*input_line_pointer
!= '>')
5866 as_bad (_("syntax error in structured control directive"));
5870 ++input_line_pointer
;
5876 *pcc
= (c1
<< 8) | c2
;
5881 /* Parse a single operand in an MRI structured control expression. */
5884 parse_mri_control_operand (int *pcc
, char **leftstart
, char **leftstop
,
5885 char **rightstart
, char **rightstop
)
5897 if (*input_line_pointer
== '<')
5899 /* It's just a condition code. */
5900 return parse_mri_condition (pcc
);
5903 /* Look ahead for the condition code. */
5904 for (s
= input_line_pointer
; *s
!= '\0'; ++s
)
5906 if (*s
== '<' && s
[1] != '\0' && s
[2] != '\0' && s
[3] == '>')
5911 as_bad (_("missing condition code in structured control directive"));
5915 *leftstart
= input_line_pointer
;
5917 if (*leftstop
> *leftstart
5918 && ((*leftstop
)[-1] == ' ' || (*leftstop
)[-1] == '\t'))
5921 input_line_pointer
= s
;
5922 if (! parse_mri_condition (pcc
))
5925 /* Look ahead for AND or OR or end of line. */
5926 for (s
= input_line_pointer
; *s
!= '\0'; ++s
)
5928 /* We must make sure we don't misinterpret AND/OR at the end of labels!
5929 if d0 <eq> #FOOAND and d1 <ne> #BAROR then
5931 if ((s
== input_line_pointer
5934 && ((strncasecmp (s
, "AND", 3) == 0
5935 && (s
[3] == '.' || ! is_part_of_name (s
[3])))
5936 || (strncasecmp (s
, "OR", 2) == 0
5937 && (s
[2] == '.' || ! is_part_of_name (s
[2])))))
5941 *rightstart
= input_line_pointer
;
5943 if (*rightstop
> *rightstart
5944 && ((*rightstop
)[-1] == ' ' || (*rightstop
)[-1] == '\t'))
5947 input_line_pointer
= s
;
5952 #define MCC(b1, b2) (((b1) << 8) | (b2))
5954 /* Swap the sense of a condition. This changes the condition so that
5955 it generates the same result when the operands are swapped. */
5958 swap_mri_condition (int cc
)
5962 case MCC ('h', 'i'): return MCC ('c', 's');
5963 case MCC ('l', 's'): return MCC ('c', 'c');
5964 /* <HS> is an alias for <CC>. */
5965 case MCC ('h', 's'):
5966 case MCC ('c', 'c'): return MCC ('l', 's');
5967 /* <LO> is an alias for <CS>. */
5968 case MCC ('l', 'o'):
5969 case MCC ('c', 's'): return MCC ('h', 'i');
5970 case MCC ('p', 'l'): return MCC ('m', 'i');
5971 case MCC ('m', 'i'): return MCC ('p', 'l');
5972 case MCC ('g', 'e'): return MCC ('l', 'e');
5973 case MCC ('l', 't'): return MCC ('g', 't');
5974 case MCC ('g', 't'): return MCC ('l', 't');
5975 case MCC ('l', 'e'): return MCC ('g', 'e');
5976 /* Issue a warning for conditions we can not swap. */
5977 case MCC ('n', 'e'): return MCC ('n', 'e'); // no problem here
5978 case MCC ('e', 'q'): return MCC ('e', 'q'); // also no problem
5979 case MCC ('v', 'c'):
5980 case MCC ('v', 's'):
5982 as_warn (_("Condition <%c%c> in structured control directive can not be encoded correctly"),
5983 (char) (cc
>> 8), (char) (cc
));
5989 /* Reverse the sense of a condition. */
5992 reverse_mri_condition (int cc
)
5996 case MCC ('h', 'i'): return MCC ('l', 's');
5997 case MCC ('l', 's'): return MCC ('h', 'i');
5998 /* <HS> is an alias for <CC> */
5999 case MCC ('h', 's'): return MCC ('l', 'o');
6000 case MCC ('c', 'c'): return MCC ('c', 's');
6001 /* <LO> is an alias for <CS> */
6002 case MCC ('l', 'o'): return MCC ('h', 's');
6003 case MCC ('c', 's'): return MCC ('c', 'c');
6004 case MCC ('n', 'e'): return MCC ('e', 'q');
6005 case MCC ('e', 'q'): return MCC ('n', 'e');
6006 case MCC ('v', 'c'): return MCC ('v', 's');
6007 case MCC ('v', 's'): return MCC ('v', 'c');
6008 case MCC ('p', 'l'): return MCC ('m', 'i');
6009 case MCC ('m', 'i'): return MCC ('p', 'l');
6010 case MCC ('g', 'e'): return MCC ('l', 't');
6011 case MCC ('l', 't'): return MCC ('g', 'e');
6012 case MCC ('g', 't'): return MCC ('l', 'e');
6013 case MCC ('l', 'e'): return MCC ('g', 't');
6018 /* Build an MRI structured control expression. This generates test
6019 and branch instructions. It goes to TRUELAB if the condition is
6020 true, and to FALSELAB if the condition is false. Exactly one of
6021 TRUELAB and FALSELAB will be NULL, meaning to fall through. QUAL
6022 is the size qualifier for the expression. EXTENT is the size to
6023 use for the branch. */
6026 build_mri_control_operand (int qual
, int cc
, char *leftstart
, char *leftstop
,
6027 char *rightstart
, char *rightstop
,
6028 const char *truelab
, const char *falselab
,
6034 if (leftstart
!= NULL
)
6036 struct m68k_op leftop
, rightop
;
6039 /* Swap the compare operands, if necessary, to produce a legal
6040 m68k compare instruction. Comparing a register operand with
6041 a non-register operand requires the register to be on the
6042 right (cmp, cmpa). Comparing an immediate value with
6043 anything requires the immediate value to be on the left
6048 (void) m68k_ip_op (leftstart
, &leftop
);
6053 (void) m68k_ip_op (rightstart
, &rightop
);
6056 if (rightop
.mode
== IMMED
6057 || ((leftop
.mode
== DREG
|| leftop
.mode
== AREG
)
6058 && (rightop
.mode
!= DREG
&& rightop
.mode
!= AREG
)))
6062 /* Correct conditional handling:
6063 if #1 <lt> d0 then ;means if (1 < d0)
6069 cmp #1,d0 if we do *not* swap the operands
6070 bgt true we need the swapped condition!
6077 leftstart
= rightstart
;
6080 leftstop
= rightstop
;
6085 cc
= swap_mri_condition (cc
);
6089 if (truelab
== NULL
)
6091 cc
= reverse_mri_condition (cc
);
6095 if (leftstart
!= NULL
)
6097 buf
= (char *) xmalloc (20
6098 + (leftstop
- leftstart
)
6099 + (rightstop
- rightstart
));
6105 *s
++ = TOLOWER (qual
);
6107 memcpy (s
, leftstart
, leftstop
- leftstart
);
6108 s
+= leftstop
- leftstart
;
6110 memcpy (s
, rightstart
, rightstop
- rightstart
);
6111 s
+= rightstop
- rightstart
;
6117 buf
= (char *) xmalloc (20 + strlen (truelab
));
6123 *s
++ = TOLOWER (extent
);
6125 strcpy (s
, truelab
);
6130 /* Parse an MRI structured control expression. This generates test
6131 and branch instructions. STOP is where the expression ends. It
6132 goes to TRUELAB if the condition is true, and to FALSELAB if the
6133 condition is false. Exactly one of TRUELAB and FALSELAB will be
6134 NULL, meaning to fall through. QUAL is the size qualifier for the
6135 expression. EXTENT is the size to use for the branch. */
6138 parse_mri_control_expression (char *stop
, int qual
, const char *truelab
,
6139 const char *falselab
, int extent
)
6151 if (! parse_mri_control_operand (&cc
, &leftstart
, &leftstop
,
6152 &rightstart
, &rightstop
))
6158 if (strncasecmp (input_line_pointer
, "AND", 3) == 0)
6162 if (falselab
!= NULL
)
6165 flab
= mri_control_label ();
6167 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6168 rightstop
, (const char *) NULL
, flab
, extent
);
6170 input_line_pointer
+= 3;
6171 if (*input_line_pointer
!= '.'
6172 || input_line_pointer
[1] == '\0')
6176 qual
= input_line_pointer
[1];
6177 input_line_pointer
+= 2;
6180 if (! parse_mri_control_operand (&cc
, &leftstart
, &leftstop
,
6181 &rightstart
, &rightstop
))
6187 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6188 rightstop
, truelab
, falselab
, extent
);
6190 if (falselab
== NULL
)
6193 else if (strncasecmp (input_line_pointer
, "OR", 2) == 0)
6197 if (truelab
!= NULL
)
6200 tlab
= mri_control_label ();
6202 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6203 rightstop
, tlab
, (const char *) NULL
, extent
);
6205 input_line_pointer
+= 2;
6206 if (*input_line_pointer
!= '.'
6207 || input_line_pointer
[1] == '\0')
6211 qual
= input_line_pointer
[1];
6212 input_line_pointer
+= 2;
6215 if (! parse_mri_control_operand (&cc
, &leftstart
, &leftstop
,
6216 &rightstart
, &rightstop
))
6222 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6223 rightstop
, truelab
, falselab
, extent
);
6225 if (truelab
== NULL
)
6230 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6231 rightstop
, truelab
, falselab
, extent
);
6235 if (input_line_pointer
!= stop
)
6236 as_bad (_("syntax error in structured control directive"));
6239 /* Handle the MRI IF pseudo-op. This may be a structured control
6240 directive, or it may be a regular assembler conditional, depending
6248 struct mri_control_info
*n
;
6250 /* A structured control directive must end with THEN with an
6251 optional qualifier. */
6252 s
= input_line_pointer
;
6253 /* We only accept '*' as introduction of comments if preceded by white space
6254 or at first column of a line (I think this can't actually happen here?)
6255 This is important when assembling:
6256 if d0 <ne> 12(a0,d0*2) then
6257 if d0 <ne> #CONST*20 then. */
6258 while (! (is_end_of_line
[(unsigned char) *s
]
6261 && (s
== input_line_pointer
6263 || *(s
-1) == '\t'))))
6266 while (s
> input_line_pointer
&& (*s
== ' ' || *s
== '\t'))
6269 if (s
- input_line_pointer
> 1
6273 if (s
- input_line_pointer
< 3
6274 || strncasecmp (s
- 3, "THEN", 4) != 0)
6278 as_bad (_("missing then"));
6279 ignore_rest_of_line ();
6283 /* It's a conditional. */
6288 /* Since this might be a conditional if, this pseudo-op will be
6289 called even if we are supported to be ignoring input. Double
6290 check now. Clobber *input_line_pointer so that ignore_input
6291 thinks that this is not a special pseudo-op. */
6292 c
= *input_line_pointer
;
6293 *input_line_pointer
= 0;
6294 if (ignore_input ())
6296 *input_line_pointer
= c
;
6297 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6298 ++input_line_pointer
;
6299 demand_empty_rest_of_line ();
6302 *input_line_pointer
= c
;
6304 n
= push_mri_control (mri_if
);
6306 parse_mri_control_expression (s
- 3, qual
, (const char *) NULL
,
6307 n
->next
, s
[1] == '.' ? s
[2] : '\0');
6310 input_line_pointer
= s
+ 3;
6312 input_line_pointer
= s
+ 1;
6316 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6317 ++input_line_pointer
;
6320 demand_empty_rest_of_line ();
6323 /* Handle the MRI else pseudo-op. If we are currently doing an MRI
6324 structured IF, associate the ELSE with the IF. Otherwise, assume
6325 it is a conditional else. */
6328 s_mri_else (int qual
)
6335 && (mri_control_stack
== NULL
6336 || mri_control_stack
->type
!= mri_if
6337 || mri_control_stack
->else_seen
))
6343 c
= *input_line_pointer
;
6344 *input_line_pointer
= 0;
6345 if (ignore_input ())
6347 *input_line_pointer
= c
;
6348 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6349 ++input_line_pointer
;
6350 demand_empty_rest_of_line ();
6353 *input_line_pointer
= c
;
6355 if (mri_control_stack
== NULL
6356 || mri_control_stack
->type
!= mri_if
6357 || mri_control_stack
->else_seen
)
6359 as_bad (_("else without matching if"));
6360 ignore_rest_of_line ();
6364 mri_control_stack
->else_seen
= 1;
6366 buf
= (char *) xmalloc (20 + strlen (mri_control_stack
->bottom
));
6367 q
[0] = TOLOWER (qual
);
6369 sprintf (buf
, "bra%s %s", q
, mri_control_stack
->bottom
);
6373 colon (mri_control_stack
->next
);
6377 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6378 ++input_line_pointer
;
6381 demand_empty_rest_of_line ();
6384 /* Handle the MRI ENDI pseudo-op. */
6387 s_mri_endi (int ignore ATTRIBUTE_UNUSED
)
6389 if (mri_control_stack
== NULL
6390 || mri_control_stack
->type
!= mri_if
)
6392 as_bad (_("endi without matching if"));
6393 ignore_rest_of_line ();
6397 /* ignore_input will not return true for ENDI, so we don't need to
6398 worry about checking it again here. */
6400 if (! mri_control_stack
->else_seen
)
6401 colon (mri_control_stack
->next
);
6402 colon (mri_control_stack
->bottom
);
6408 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6409 ++input_line_pointer
;
6412 demand_empty_rest_of_line ();
6415 /* Handle the MRI BREAK pseudo-op. */
6418 s_mri_break (int extent
)
6420 struct mri_control_info
*n
;
6424 n
= mri_control_stack
;
6426 && n
->type
!= mri_for
6427 && n
->type
!= mri_repeat
6428 && n
->type
!= mri_while
)
6432 as_bad (_("break outside of structured loop"));
6433 ignore_rest_of_line ();
6437 buf
= (char *) xmalloc (20 + strlen (n
->bottom
));
6438 ex
[0] = TOLOWER (extent
);
6440 sprintf (buf
, "bra%s %s", ex
, n
->bottom
);
6446 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6447 ++input_line_pointer
;
6450 demand_empty_rest_of_line ();
6453 /* Handle the MRI NEXT pseudo-op. */
6456 s_mri_next (int extent
)
6458 struct mri_control_info
*n
;
6462 n
= mri_control_stack
;
6464 && n
->type
!= mri_for
6465 && n
->type
!= mri_repeat
6466 && n
->type
!= mri_while
)
6470 as_bad (_("next outside of structured loop"));
6471 ignore_rest_of_line ();
6475 buf
= (char *) xmalloc (20 + strlen (n
->next
));
6476 ex
[0] = TOLOWER (extent
);
6478 sprintf (buf
, "bra%s %s", ex
, n
->next
);
6484 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6485 ++input_line_pointer
;
6488 demand_empty_rest_of_line ();
6491 /* Handle the MRI FOR pseudo-op. */
6494 s_mri_for (int qual
)
6496 const char *varstart
, *varstop
;
6497 const char *initstart
, *initstop
;
6498 const char *endstart
, *endstop
;
6499 const char *bystart
, *bystop
;
6503 struct mri_control_info
*n
;
6509 FOR.q var = init { TO | DOWNTO } end [ BY by ] DO.e
6513 varstart
= input_line_pointer
;
6515 /* Look for the '='. */
6516 while (! is_end_of_line
[(unsigned char) *input_line_pointer
]
6517 && *input_line_pointer
!= '=')
6518 ++input_line_pointer
;
6519 if (*input_line_pointer
!= '=')
6521 as_bad (_("missing ="));
6522 ignore_rest_of_line ();
6526 varstop
= input_line_pointer
;
6527 if (varstop
> varstart
6528 && (varstop
[-1] == ' ' || varstop
[-1] == '\t'))
6531 ++input_line_pointer
;
6533 initstart
= input_line_pointer
;
6535 /* Look for TO or DOWNTO. */
6538 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6540 if (strncasecmp (input_line_pointer
, "TO", 2) == 0
6541 && ! is_part_of_name (input_line_pointer
[2]))
6543 initstop
= input_line_pointer
;
6544 input_line_pointer
+= 2;
6547 if (strncasecmp (input_line_pointer
, "DOWNTO", 6) == 0
6548 && ! is_part_of_name (input_line_pointer
[6]))
6550 initstop
= input_line_pointer
;
6552 input_line_pointer
+= 6;
6555 ++input_line_pointer
;
6557 if (initstop
== NULL
)
6559 as_bad (_("missing to or downto"));
6560 ignore_rest_of_line ();
6563 if (initstop
> initstart
6564 && (initstop
[-1] == ' ' || initstop
[-1] == '\t'))
6568 endstart
= input_line_pointer
;
6570 /* Look for BY or DO. */
6573 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6575 if (strncasecmp (input_line_pointer
, "BY", 2) == 0
6576 && ! is_part_of_name (input_line_pointer
[2]))
6578 endstop
= input_line_pointer
;
6580 input_line_pointer
+= 2;
6583 if (strncasecmp (input_line_pointer
, "DO", 2) == 0
6584 && (input_line_pointer
[2] == '.'
6585 || ! is_part_of_name (input_line_pointer
[2])))
6587 endstop
= input_line_pointer
;
6588 input_line_pointer
+= 2;
6591 ++input_line_pointer
;
6593 if (endstop
== NULL
)
6595 as_bad (_("missing do"));
6596 ignore_rest_of_line ();
6599 if (endstop
> endstart
6600 && (endstop
[-1] == ' ' || endstop
[-1] == '\t'))
6606 bystop
= bystart
+ 2;
6611 bystart
= input_line_pointer
;
6615 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6617 if (strncasecmp (input_line_pointer
, "DO", 2) == 0
6618 && (input_line_pointer
[2] == '.'
6619 || ! is_part_of_name (input_line_pointer
[2])))
6621 bystop
= input_line_pointer
;
6622 input_line_pointer
+= 2;
6625 ++input_line_pointer
;
6629 as_bad (_("missing do"));
6630 ignore_rest_of_line ();
6633 if (bystop
> bystart
6634 && (bystop
[-1] == ' ' || bystop
[-1] == '\t'))
6638 if (*input_line_pointer
!= '.')
6642 extent
= input_line_pointer
[1];
6643 input_line_pointer
+= 2;
6646 /* We have fully parsed the FOR operands. Now build the loop. */
6647 n
= push_mri_control (mri_for
);
6649 buf
= (char *) xmalloc (50 + (input_line_pointer
- varstart
));
6651 /* Move init,var. */
6658 *s
++ = TOLOWER (qual
);
6660 memcpy (s
, initstart
, initstop
- initstart
);
6661 s
+= initstop
- initstart
;
6663 memcpy (s
, varstart
, varstop
- varstart
);
6664 s
+= varstop
- varstart
;
6676 *s
++ = TOLOWER (qual
);
6678 memcpy (s
, endstart
, endstop
- endstart
);
6679 s
+= endstop
- endstart
;
6681 memcpy (s
, varstart
, varstop
- varstart
);
6682 s
+= varstop
- varstart
;
6687 ex
[0] = TOLOWER (extent
);
6690 sprintf (buf
, "blt%s %s", ex
, n
->bottom
);
6692 sprintf (buf
, "bgt%s %s", ex
, n
->bottom
);
6695 /* Put together the add or sub instruction used by ENDF. */
6703 *s
++ = TOLOWER (qual
);
6705 memcpy (s
, bystart
, bystop
- bystart
);
6706 s
+= bystop
- bystart
;
6708 memcpy (s
, varstart
, varstop
- varstart
);
6709 s
+= varstop
- varstart
;
6715 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6716 ++input_line_pointer
;
6719 demand_empty_rest_of_line ();
6722 /* Handle the MRI ENDF pseudo-op. */
6725 s_mri_endf (int ignore ATTRIBUTE_UNUSED
)
6727 if (mri_control_stack
== NULL
6728 || mri_control_stack
->type
!= mri_for
)
6730 as_bad (_("endf without for"));
6731 ignore_rest_of_line ();
6735 colon (mri_control_stack
->next
);
6737 mri_assemble (mri_control_stack
->incr
);
6739 sprintf (mri_control_stack
->incr
, "bra %s", mri_control_stack
->top
);
6740 mri_assemble (mri_control_stack
->incr
);
6742 free (mri_control_stack
->incr
);
6744 colon (mri_control_stack
->bottom
);
6750 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6751 ++input_line_pointer
;
6754 demand_empty_rest_of_line ();
6757 /* Handle the MRI REPEAT pseudo-op. */
6760 s_mri_repeat (int ignore ATTRIBUTE_UNUSED
)
6762 struct mri_control_info
*n
;
6764 n
= push_mri_control (mri_repeat
);
6768 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6769 ++input_line_pointer
;
6771 demand_empty_rest_of_line ();
6774 /* Handle the MRI UNTIL pseudo-op. */
6777 s_mri_until (int qual
)
6781 if (mri_control_stack
== NULL
6782 || mri_control_stack
->type
!= mri_repeat
)
6784 as_bad (_("until without repeat"));
6785 ignore_rest_of_line ();
6789 colon (mri_control_stack
->next
);
6791 for (s
= input_line_pointer
; ! is_end_of_line
[(unsigned char) *s
]; s
++)
6794 parse_mri_control_expression (s
, qual
, (const char *) NULL
,
6795 mri_control_stack
->top
, '\0');
6797 colon (mri_control_stack
->bottom
);
6799 input_line_pointer
= s
;
6805 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6806 ++input_line_pointer
;
6809 demand_empty_rest_of_line ();
6812 /* Handle the MRI WHILE pseudo-op. */
6815 s_mri_while (int qual
)
6819 struct mri_control_info
*n
;
6821 s
= input_line_pointer
;
6822 /* We only accept '*' as introduction of comments if preceded by white space
6823 or at first column of a line (I think this can't actually happen here?)
6824 This is important when assembling:
6825 while d0 <ne> 12(a0,d0*2) do
6826 while d0 <ne> #CONST*20 do. */
6827 while (! (is_end_of_line
[(unsigned char) *s
]
6830 && (s
== input_line_pointer
6832 || *(s
-1) == '\t'))))
6835 while (*s
== ' ' || *s
== '\t')
6837 if (s
- input_line_pointer
> 1
6840 if (s
- input_line_pointer
< 2
6841 || strncasecmp (s
- 1, "DO", 2) != 0)
6843 as_bad (_("missing do"));
6844 ignore_rest_of_line ();
6848 n
= push_mri_control (mri_while
);
6852 parse_mri_control_expression (s
- 1, qual
, (const char *) NULL
, n
->bottom
,
6853 s
[1] == '.' ? s
[2] : '\0');
6855 input_line_pointer
= s
+ 1;
6856 if (*input_line_pointer
== '.')
6857 input_line_pointer
+= 2;
6861 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6862 ++input_line_pointer
;
6865 demand_empty_rest_of_line ();
6868 /* Handle the MRI ENDW pseudo-op. */
6871 s_mri_endw (int ignore ATTRIBUTE_UNUSED
)
6875 if (mri_control_stack
== NULL
6876 || mri_control_stack
->type
!= mri_while
)
6878 as_bad (_("endw without while"));
6879 ignore_rest_of_line ();
6883 buf
= (char *) xmalloc (20 + strlen (mri_control_stack
->next
));
6884 sprintf (buf
, "bra %s", mri_control_stack
->next
);
6888 colon (mri_control_stack
->bottom
);
6894 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6895 ++input_line_pointer
;
6898 demand_empty_rest_of_line ();
6901 /* Parse a .cpu directive. */
6904 s_m68k_cpu (int ignored ATTRIBUTE_UNUSED
)
6911 as_bad (_("already assembled instructions"));
6912 ignore_rest_of_line ();
6916 name
= input_line_pointer
;
6917 while (*input_line_pointer
&& !ISSPACE(*input_line_pointer
))
6918 input_line_pointer
++;
6919 saved_char
= *input_line_pointer
;
6920 *input_line_pointer
= 0;
6922 m68k_set_cpu (name
, 1, 0);
6924 *input_line_pointer
= saved_char
;
6925 demand_empty_rest_of_line ();
6929 /* Parse a .arch directive. */
6932 s_m68k_arch (int ignored ATTRIBUTE_UNUSED
)
6939 as_bad (_("already assembled instructions"));
6940 ignore_rest_of_line ();
6944 name
= input_line_pointer
;
6945 while (*input_line_pointer
&& *input_line_pointer
!= ','
6946 && !ISSPACE (*input_line_pointer
))
6947 input_line_pointer
++;
6948 saved_char
= *input_line_pointer
;
6949 *input_line_pointer
= 0;
6951 if (m68k_set_arch (name
, 1, 0))
6953 /* Scan extensions. */
6956 *input_line_pointer
++ = saved_char
;
6957 if (!*input_line_pointer
|| ISSPACE (*input_line_pointer
))
6959 name
= input_line_pointer
;
6960 while (*input_line_pointer
&& *input_line_pointer
!= ','
6961 && !ISSPACE (*input_line_pointer
))
6962 input_line_pointer
++;
6963 saved_char
= *input_line_pointer
;
6964 *input_line_pointer
= 0;
6966 while (m68k_set_extension (name
, 1, 0));
6969 *input_line_pointer
= saved_char
;
6970 demand_empty_rest_of_line ();
6974 /* Lookup a cpu name in TABLE and return the slot found. Return NULL
6975 if none is found, the caller is responsible for emitting an error
6976 message. If ALLOW_M is non-zero, we allow an initial 'm' on the
6977 cpu name, if it begins with a '6' (possibly skipping an intervening
6978 'c'. We also allow a 'c' in the same place. if NEGATED is
6979 non-zero, we accept a leading 'no-' and *NEGATED is set to true, if
6980 the option is indeed negated. */
6982 static const struct m68k_cpu
*
6983 m68k_lookup_cpu (const char *arg
, const struct m68k_cpu
*table
,
6984 int allow_m
, int *negated
)
6986 /* allow negated value? */
6991 if (arg
[0] == 'n' && arg
[1] == 'o' && arg
[2] == '-')
6998 /* Remove 'm' or 'mc' prefix from 68k variants. */
7005 else if (arg
[1] == 'c' && arg
[2] == '6')
7009 else if (arg
[0] == 'c' && arg
[1] == '6')
7012 for (; table
->name
; table
++)
7013 if (!strcmp (arg
, table
->name
))
7015 if (table
->alias
< -1 || table
->alias
> 1)
7016 as_bad (_("`%s' is deprecated, use `%s'"),
7017 table
->name
, table
[table
->alias
< 0 ? 1 : -1].name
);
7023 /* Set the cpu, issuing errors if it is unrecognized, or invalid */
7026 m68k_set_cpu (char const *name
, int allow_m
, int silent
)
7028 const struct m68k_cpu
*cpu
;
7030 cpu
= m68k_lookup_cpu (name
, m68k_cpus
, allow_m
, NULL
);
7035 as_bad (_("cpu `%s' unrecognized"), name
);
7039 if (selected_cpu
&& selected_cpu
!= cpu
)
7041 as_bad (_("already selected `%s' processor"),
7042 selected_cpu
->name
);
7049 /* Set the architecture, issuing errors if it is unrecognized, or invalid */
7052 m68k_set_arch (char const *name
, int allow_m
, int silent
)
7054 const struct m68k_cpu
*arch
;
7056 arch
= m68k_lookup_cpu (name
, m68k_archs
, allow_m
, NULL
);
7061 as_bad (_("architecture `%s' unrecognized"), name
);
7065 if (selected_arch
&& selected_arch
!= arch
)
7067 as_bad (_("already selected `%s' architecture"),
7068 selected_arch
->name
);
7072 selected_arch
= arch
;
7076 /* Set the architecture extension, issuing errors if it is
7077 unrecognized, or invalid */
7080 m68k_set_extension (char const *name
, int allow_m
, int silent
)
7083 const struct m68k_cpu
*ext
;
7085 ext
= m68k_lookup_cpu (name
, m68k_extensions
, allow_m
, &negated
);
7090 as_bad (_("extension `%s' unrecognized"), name
);
7095 not_current_architecture
|= ext
->arch
;
7097 current_architecture
|= ext
->arch
;
7102 Invocation line includes a switch not recognized by the base assembler.
7106 const char *md_shortopts
= "lSA:m:kQ:V";
7108 const char *md_shortopts
= "lSA:m:k";
7111 struct option md_longopts
[] = {
7112 #define OPTION_PIC (OPTION_MD_BASE)
7113 {"pic", no_argument
, NULL
, OPTION_PIC
},
7114 #define OPTION_REGISTER_PREFIX_OPTIONAL (OPTION_MD_BASE + 1)
7115 {"register-prefix-optional", no_argument
, NULL
,
7116 OPTION_REGISTER_PREFIX_OPTIONAL
},
7117 #define OPTION_BITWISE_OR (OPTION_MD_BASE + 2)
7118 {"bitwise-or", no_argument
, NULL
, OPTION_BITWISE_OR
},
7119 #define OPTION_BASE_SIZE_DEFAULT_16 (OPTION_MD_BASE + 3)
7120 {"base-size-default-16", no_argument
, NULL
, OPTION_BASE_SIZE_DEFAULT_16
},
7121 #define OPTION_BASE_SIZE_DEFAULT_32 (OPTION_MD_BASE + 4)
7122 {"base-size-default-32", no_argument
, NULL
, OPTION_BASE_SIZE_DEFAULT_32
},
7123 #define OPTION_DISP_SIZE_DEFAULT_16 (OPTION_MD_BASE + 5)
7124 {"disp-size-default-16", no_argument
, NULL
, OPTION_DISP_SIZE_DEFAULT_16
},
7125 #define OPTION_DISP_SIZE_DEFAULT_32 (OPTION_MD_BASE + 6)
7126 {"disp-size-default-32", no_argument
, NULL
, OPTION_DISP_SIZE_DEFAULT_32
},
7127 #define OPTION_PCREL (OPTION_MD_BASE + 7)
7128 {"pcrel", no_argument
, NULL
, OPTION_PCREL
},
7129 {NULL
, no_argument
, NULL
, 0}
7131 size_t md_longopts_size
= sizeof (md_longopts
);
7134 md_parse_option (int c
, char *arg
)
7138 case 'l': /* -l means keep external to 2 bit offset
7139 rather than 16 bit one. */
7140 flag_short_refs
= 1;
7143 case 'S': /* -S means that jbsr's always turn into
7145 flag_long_jumps
= 1;
7148 case OPTION_PCREL
: /* --pcrel means never turn PC-relative
7149 branches into absolute jumps. */
7150 flag_keep_pcrel
= 1;
7156 break; /* -pic, Position Independent Code. */
7158 case OPTION_REGISTER_PREFIX_OPTIONAL
:
7159 flag_reg_prefix_optional
= 1;
7160 reg_prefix_optional_seen
= 1;
7163 /* -V: SVR4 argument to print version ID. */
7165 print_version_id ();
7168 /* -Qy, -Qn: SVR4 arguments controlling whether a .comment section
7169 should be emitted or not. FIXME: Not implemented. */
7173 case OPTION_BITWISE_OR
:
7178 n
= (char *) xmalloc (strlen (m68k_comment_chars
) + 1);
7180 for (s
= m68k_comment_chars
; *s
!= '\0'; s
++)
7184 m68k_comment_chars
= n
;
7188 case OPTION_BASE_SIZE_DEFAULT_16
:
7189 m68k_index_width_default
= SIZE_WORD
;
7192 case OPTION_BASE_SIZE_DEFAULT_32
:
7193 m68k_index_width_default
= SIZE_LONG
;
7196 case OPTION_DISP_SIZE_DEFAULT_16
:
7198 m68k_rel32_from_cmdline
= 1;
7201 case OPTION_DISP_SIZE_DEFAULT_32
:
7203 m68k_rel32_from_cmdline
= 1;
7208 as_tsktsk (_ ("option `-A%s' is deprecated: use `-%s'",
7211 /* Intentional fall-through. */
7213 if (!strncmp (arg
, "arch=", 5))
7214 m68k_set_arch (arg
+ 5, 1, 0);
7215 else if (!strncmp (arg
, "cpu=", 4))
7216 m68k_set_cpu (arg
+ 4, 1, 0);
7217 else if (m68k_set_extension (arg
, 0, 1))
7219 else if (m68k_set_arch (arg
, 0, 1))
7221 else if (m68k_set_cpu (arg
, 0, 1))
7234 /* Setup tables from the selected arch and/or cpu */
7237 m68k_init_arch (void)
7239 if (not_current_architecture
& current_architecture
)
7241 as_bad (_("architecture features both enabled and disabled"));
7242 not_current_architecture
&= ~current_architecture
;
7246 current_architecture
|= selected_arch
->arch
;
7247 control_regs
= selected_arch
->control_regs
;
7250 current_architecture
|= selected_cpu
->arch
;
7252 current_architecture
&= ~not_current_architecture
;
7254 if ((current_architecture
& (cfloat
| m68881
)) == (cfloat
| m68881
))
7256 /* Determine which float is really meant. */
7257 if (current_architecture
& (m68k_mask
& ~m68881
))
7258 current_architecture
^= cfloat
;
7260 current_architecture
^= m68881
;
7265 control_regs
= selected_cpu
->control_regs
;
7266 if (current_architecture
& ~selected_cpu
->arch
)
7268 as_bad (_("selected processor does not have all features of selected architecture"));
7269 current_architecture
7270 = selected_cpu
->arch
& ~not_current_architecture
;
7274 if ((current_architecture
& m68k_mask
)
7275 && (current_architecture
& ~m68k_mask
))
7277 as_bad (_ ("m68k and cf features both selected"));
7278 if (current_architecture
& m68k_mask
)
7279 current_architecture
&= m68k_mask
;
7281 current_architecture
&= ~m68k_mask
;
7284 /* Permit m68881 specification with all cpus; those that can't work
7285 with a coprocessor could be doing emulation. */
7286 if (current_architecture
& m68851
)
7288 if (current_architecture
& m68040
)
7289 as_warn (_("68040 and 68851 specified; mmu instructions may assemble incorrectly"));
7291 /* What other incompatibilities could we check for? */
7293 if (cpu_of_arch (current_architecture
) < m68020
7294 || arch_coldfire_p (current_architecture
))
7295 md_relax_table
[TAB (PCINDEX
, BYTE
)].rlx_more
= 0;
7301 md_show_usage (FILE *stream
)
7303 const char *default_cpu
= TARGET_CPU
;
7305 unsigned int default_arch
;
7307 /* Get the canonical name for the default target CPU. */
7308 if (*default_cpu
== 'm')
7310 for (i
= 0; m68k_cpus
[i
].name
; i
++)
7312 if (strcasecmp (default_cpu
, m68k_cpus
[i
].name
) == 0)
7314 default_arch
= m68k_cpus
[i
].arch
;
7315 while (m68k_cpus
[i
].alias
> 0)
7317 while (m68k_cpus
[i
].alias
< 0)
7319 default_cpu
= m68k_cpus
[i
].name
;
7323 fprintf (stream
, _("\
7324 -march=<arch> set architecture\n\
7325 -mcpu=<cpu> set cpu [default %s]\n\
7327 for (i
= 0; m68k_extensions
[i
].name
; i
++)
7328 fprintf (stream
, _("\
7329 -m[no-]%-16s enable/disable%s architecture extension\n\
7330 "), m68k_extensions
[i
].name
,
7331 m68k_extensions
[i
].alias
> 0 ? " ColdFire"
7332 : m68k_extensions
[i
].alias
< 0 ? " m68k" : "");
7334 fprintf (stream
, _("\
7335 -l use 1 word for refs to undefined symbols [default 2]\n\
7336 -pic, -k generate position independent code\n\
7337 -S turn jbsr into jsr\n\
7338 --pcrel never turn PC-relative branches into absolute jumps\n\
7339 --register-prefix-optional\n\
7340 recognize register names without prefix character\n\
7341 --bitwise-or do not treat `|' as a comment character\n\
7342 --base-size-default-16 base reg without size is 16 bits\n\
7343 --base-size-default-32 base reg without size is 32 bits (default)\n\
7344 --disp-size-default-16 displacement with unknown size is 16 bits\n\
7345 --disp-size-default-32 displacement with unknown size is 32 bits (default)\n\
7348 fprintf (stream
, _("Architecture variants are: "));
7349 for (i
= 0; m68k_archs
[i
].name
; i
++)
7352 fprintf (stream
, " | ");
7353 fprintf (stream
, m68k_archs
[i
].name
);
7355 fprintf (stream
, "\n");
7357 fprintf (stream
, _("Processor variants are: "));
7358 for (i
= 0; m68k_cpus
[i
].name
; i
++)
7361 fprintf (stream
, " | ");
7362 fprintf (stream
, m68k_cpus
[i
].name
);
7364 fprintf (stream
, _("\n"));
7369 /* TEST2: Test md_assemble() */
7370 /* Warning, this routine probably doesn't work anymore. */
7374 struct m68k_it the_ins
;
7382 if (!gets (buf
) || !*buf
)
7384 if (buf
[0] == '|' || buf
[1] == '.')
7386 for (cp
= buf
; *cp
; cp
++)
7391 memset (&the_ins
, '\0', sizeof (the_ins
));
7392 m68k_ip (&the_ins
, buf
);
7395 printf (_("Error %s in %s\n"), the_ins
.error
, buf
);
7399 printf (_("Opcode(%d.%s): "), the_ins
.numo
, the_ins
.args
);
7400 for (n
= 0; n
< the_ins
.numo
; n
++)
7401 printf (" 0x%x", the_ins
.opcode
[n
] & 0xffff);
7403 print_the_insn (&the_ins
.opcode
[0], stdout
);
7404 (void) putchar ('\n');
7406 for (n
= 0; n
< strlen (the_ins
.args
) / 2; n
++)
7408 if (the_ins
.operands
[n
].error
)
7410 printf ("op%d Error %s in %s\n", n
, the_ins
.operands
[n
].error
, buf
);
7413 printf ("mode %d, reg %d, ", the_ins
.operands
[n
].mode
,
7414 the_ins
.operands
[n
].reg
);
7415 if (the_ins
.operands
[n
].b_const
)
7416 printf ("Constant: '%.*s', ",
7417 1 + the_ins
.operands
[n
].e_const
- the_ins
.operands
[n
].b_const
,
7418 the_ins
.operands
[n
].b_const
);
7419 printf ("ireg %d, isiz %d, imul %d, ", the_ins
.operands
[n
].ireg
,
7420 the_ins
.operands
[n
].isiz
, the_ins
.operands
[n
].imul
);
7421 if (the_ins
.operands
[n
].b_iadd
)
7422 printf ("Iadd: '%.*s',",
7423 1 + the_ins
.operands
[n
].e_iadd
- the_ins
.operands
[n
].b_iadd
,
7424 the_ins
.operands
[n
].b_iadd
);
7433 is_label (char *str
)
7437 while (*str
&& *str
!= ' ')
7439 if (str
[-1] == ':' || str
[1] == '=')
7446 /* Possible states for relaxation:
7448 0 0 branch offset byte (bra, etc)
7452 1 0 indexed offsets byte a0@(32,d4:w:1) etc
7456 2 0 two-offset index word-word a0@(32,d4)@(45) etc
7463 /* We have no need to default values of symbols. */
7466 md_undefined_symbol (char *name ATTRIBUTE_UNUSED
)
7471 /* Round up a section size to the appropriate boundary. */
7473 md_section_align (segT segment ATTRIBUTE_UNUSED
, valueT size
)
7476 /* For a.out, force the section size to be aligned. If we don't do
7477 this, BFD will align it for us, but it will not write out the
7478 final bytes of the section. This may be a bug in BFD, but it is
7479 easier to fix it here since that is how the other a.out targets
7483 align
= bfd_get_section_alignment (stdoutput
, segment
);
7484 size
= ((size
+ (1 << align
) - 1) & ((valueT
) -1 << align
));
7490 /* Exactly what point is a PC-relative offset relative TO?
7491 On the 68k, it is relative to the address of the first extension
7492 word. The difference between the addresses of the offset and the
7493 first extension word is stored in fx_pcrel_adjust. */
7495 md_pcrel_from (fixS
*fixP
)
7499 /* Because fx_pcrel_adjust is a char, and may be unsigned, we explicitly
7500 sign extend the value here. */
7501 adjust
= ((fixP
->fx_pcrel_adjust
& 0xff) ^ 0x80) - 0x80;
7504 return fixP
->fx_where
+ fixP
->fx_frag
->fr_address
- adjust
;
7509 m68k_elf_final_processing (void)
7513 if (arch_coldfire_fpu (current_architecture
))
7514 flags
|= EF_M68K_CFV4E
;
7515 /* Set file-specific flags if this is a cpu32 processor. */
7516 if (cpu_of_arch (current_architecture
) & cpu32
)
7518 flags
|= EF_M68K_CPU32
;
7519 if (cpu_of_arch (current_architecture
) & fido_a
)
7520 flags
|= EF_M68K_CPU32_FIDO_A
;
7522 else if ((cpu_of_arch (current_architecture
) & m68000up
)
7523 && !(cpu_of_arch (current_architecture
) & m68020up
))
7524 flags
|= EF_M68K_M68000
;
7526 if (current_architecture
& mcfisa_a
)
7528 static const unsigned isa_features
[][2] =
7530 {EF_M68K_CF_ISA_A_NODIV
, mcfisa_a
},
7531 {EF_M68K_CF_ISA_A
, mcfisa_a
|mcfhwdiv
},
7532 {EF_M68K_CF_ISA_A_PLUS
,mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfusp
},
7533 {EF_M68K_CF_ISA_B_NOUSP
,mcfisa_a
|mcfisa_b
|mcfhwdiv
},
7534 {EF_M68K_CF_ISA_B
, mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfusp
},
7537 static const unsigned mac_features
[][2] =
7539 {EF_M68K_CF_MAC
, mcfmac
},
7540 {EF_M68K_CF_EMAC
, mcfemac
},
7546 pattern
= (current_architecture
7547 & (mcfisa_a
|mcfisa_aa
|mcfisa_b
|mcfhwdiv
|mcfusp
));
7548 for (ix
= 0; isa_features
[ix
][1]; ix
++)
7550 if (pattern
== isa_features
[ix
][1])
7552 flags
|= isa_features
[ix
][0];
7556 if (!isa_features
[ix
][1])
7559 as_warn (_("Not a defined coldfire architecture"));
7563 if (current_architecture
& cfloat
)
7564 flags
|= EF_M68K_CF_FLOAT
| EF_M68K_CFV4E
;
7566 pattern
= current_architecture
& (mcfmac
|mcfemac
);
7569 for (ix
= 0; mac_features
[ix
][1]; ix
++)
7571 if (pattern
== mac_features
[ix
][1])
7573 flags
|= mac_features
[ix
][0];
7577 if (!mac_features
[ix
][1])
7582 elf_elfheader (stdoutput
)->e_flags
|= flags
;
7587 tc_m68k_regname_to_dw2regnum (char *regname
)
7589 unsigned int regnum
;
7590 static const char *const regnames
[] =
7592 "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
7593 "a0", "a1", "a2", "a3", "a4", "a5", "a6", "sp",
7594 "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7",
7598 for (regnum
= 0; regnum
< ARRAY_SIZE (regnames
); regnum
++)
7599 if (strcmp (regname
, regnames
[regnum
]) == 0)
7606 tc_m68k_frame_initial_instructions (void)
7608 static int sp_regno
= -1;
7611 sp_regno
= tc_m68k_regname_to_dw2regnum ("sp");
7613 cfi_add_CFA_def_cfa (sp_regno
, -DWARF2_CIE_DATA_ALIGNMENT
);
7614 cfi_add_CFA_offset (DWARF2_DEFAULT_RETURN_COLUMN
, DWARF2_CIE_DATA_ALIGNMENT
);