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 mcf52235_ctrl
[] = {
192 VBR
, FLASHBAR
, RAMBAR
,
195 static const enum m68k_register mcf5225_ctrl
[] = {
196 VBR
, CACR
, ACR0
, ACR1
, FLASHBAR
, RAMBAR
, MBAR
,
199 static const enum m68k_register mcf5235_ctrl
[] = {
200 VBR
, CACR
, ACR0
, ACR1
, RAMBAR
,
203 static const enum m68k_register mcf5249_ctrl
[] = {
204 VBR
, CACR
, ACR0
, ACR1
, RAMBAR0
, RAMBAR1
, MBAR
, MBAR2
,
207 static const enum m68k_register mcf5250_ctrl
[] = {
211 static const enum m68k_register mcf5271_ctrl
[] = {
212 VBR
, CACR
, ACR0
, ACR1
, RAMBAR
,
215 static const enum m68k_register mcf5272_ctrl
[] = {
216 VBR
, CACR
, ACR0
, ACR1
, ROMBAR
, RAMBAR
, MBAR
,
219 static const enum m68k_register mcf5275_ctrl
[] = {
220 VBR
, CACR
, ACR0
, ACR1
, RAMBAR
,
223 static const enum m68k_register mcf5282_ctrl
[] = {
224 VBR
, CACR
, ACR0
, ACR1
, FLASHBAR
, RAMBAR
,
227 static const enum m68k_register mcf5329_ctrl
[] = {
228 VBR
, CACR
, ACR0
, ACR1
, RAMBAR
,
231 static const enum m68k_register mcf5373_ctrl
[] = {
232 VBR
, CACR
, ACR0
, ACR1
, RAMBAR
,
235 static const enum m68k_register mcfv4e_ctrl
[] = {
236 CACR
, TC
, ITT0
, ITT1
, DTT0
, DTT1
, BUSCR
, VBR
, PC
, ROMBAR
,
237 ROMBAR1
, RAMBAR0
, RAMBAR1
, MPCR
, EDRAMBAR
, SECMBAR
, MBAR
, MBAR0
, MBAR1
,
238 PCR1U0
, PCR1L0
, PCR1U1
, PCR1L1
, PCR2U0
, PCR2L0
, PCR2U1
, PCR2L1
,
239 PCR3U0
, PCR3L0
, PCR3U1
, PCR3L1
,
242 #define cpu32_ctrl m68010_ctrl
244 static const enum m68k_register
*control_regs
;
246 /* Internal form of a 68020 instruction. */
250 const char *args
; /* List of opcode info. */
253 int numo
; /* Number of shorts in opcode. */
256 struct m68k_op operands
[6];
258 int nexp
; /* Number of exprs in use. */
259 struct m68k_exp exprs
[4];
261 int nfrag
; /* Number of frags we have to produce. */
264 int fragoff
; /* Where in the current opcode the frag ends. */
271 int nrel
; /* Num of reloc strucs in use. */
278 /* In a pc relative address the difference between the address
279 of the offset and the address that the offset is relative
280 to. This depends on the addressing mode. Basically this
281 is the value to put in the offset field to address the
282 first byte of the offset, without regarding the special
283 significance of some values (in the branch instruction, for
287 /* Whether this expression needs special pic relocation, and if
289 enum pic_relocation pic_reloc
;
292 reloc
[5]; /* Five is enough??? */
295 #define cpu_of_arch(x) ((x) & (m68000up | mcfisa_a))
296 #define float_of_arch(x) ((x) & mfloat)
297 #define mmu_of_arch(x) ((x) & mmmu)
298 #define arch_coldfire_p(x) ((x) & mcfisa_a)
299 #define arch_coldfire_fpu(x) ((x) & cfloat)
301 /* Macros for determining if cpu supports a specific addressing mode. */
302 #define HAVE_LONG_BRANCH(x) ((x) & (m68020|m68030|m68040|m68060|cpu32|mcfisa_b))
304 static struct m68k_it the_ins
; /* The instruction being assembled. */
306 #define op(ex) ((ex)->exp.X_op)
307 #define adds(ex) ((ex)->exp.X_add_symbol)
308 #define subs(ex) ((ex)->exp.X_op_symbol)
309 #define offs(ex) ((ex)->exp.X_add_number)
311 /* Macros for adding things to the m68k_it struct. */
312 #define addword(w) (the_ins.opcode[the_ins.numo++] = (w))
314 /* Like addword, but goes BEFORE general operands. */
317 insop (int w
, const struct m68k_incant
*opcode
)
320 for (z
= the_ins
.numo
; z
> opcode
->m_codenum
; --z
)
321 the_ins
.opcode
[z
] = the_ins
.opcode
[z
- 1];
322 for (z
= 0; z
< the_ins
.nrel
; z
++)
323 the_ins
.reloc
[z
].n
+= 2;
324 for (z
= 0; z
< the_ins
.nfrag
; z
++)
325 the_ins
.fragb
[z
].fragoff
++;
326 the_ins
.opcode
[opcode
->m_codenum
] = w
;
330 /* The numo+1 kludge is so we can hit the low order byte of the prev word.
333 add_fix (int width
, struct m68k_exp
*exp
, int pc_rel
, int pc_fix
)
335 the_ins
.reloc
[the_ins
.nrel
].n
= (width
== 'B' || width
== '3'
336 ? the_ins
.numo
* 2 - 1
338 ? the_ins
.numo
* 2 + 1
339 : the_ins
.numo
* 2));
340 the_ins
.reloc
[the_ins
.nrel
].exp
= exp
->exp
;
341 the_ins
.reloc
[the_ins
.nrel
].wid
= width
;
342 the_ins
.reloc
[the_ins
.nrel
].pcrel_fix
= pc_fix
;
344 the_ins
.reloc
[the_ins
.nrel
].pic_reloc
= exp
->pic_reloc
;
346 the_ins
.reloc
[the_ins
.nrel
++].pcrel
= pc_rel
;
349 /* Cause an extra frag to be generated here, inserting up to 10 bytes
350 (that value is chosen in the frag_var call in md_assemble). TYPE
351 is the subtype of the frag to be generated; its primary type is
352 rs_machine_dependent.
354 The TYPE parameter is also used by md_convert_frag_1 and
355 md_estimate_size_before_relax. The appropriate type of fixup will
356 be emitted by md_convert_frag_1.
358 ADD becomes the FR_SYMBOL field of the frag, and OFF the FR_OFFSET. */
360 add_frag (symbolS
*add
, offsetT off
, int type
)
362 the_ins
.fragb
[the_ins
.nfrag
].fragoff
= the_ins
.numo
;
363 the_ins
.fragb
[the_ins
.nfrag
].fadd
= add
;
364 the_ins
.fragb
[the_ins
.nfrag
].foff
= off
;
365 the_ins
.fragb
[the_ins
.nfrag
++].fragty
= type
;
369 (op (ex) != O_constant && op (ex) != O_big)
371 static char *crack_operand (char *str
, struct m68k_op
*opP
);
372 static int get_num (struct m68k_exp
*exp
, int ok
);
373 static int reverse_16_bits (int in
);
374 static int reverse_8_bits (int in
);
375 static void install_gen_operand (int mode
, int val
);
376 static void install_operand (int mode
, int val
);
377 static void s_bss (int);
378 static void s_data1 (int);
379 static void s_data2 (int);
380 static void s_even (int);
381 static void s_proc (int);
382 static void s_chip (int);
383 static void s_fopt (int);
384 static void s_opt (int);
385 static void s_reg (int);
386 static void s_restore (int);
387 static void s_save (int);
388 static void s_mri_if (int);
389 static void s_mri_else (int);
390 static void s_mri_endi (int);
391 static void s_mri_break (int);
392 static void s_mri_next (int);
393 static void s_mri_for (int);
394 static void s_mri_endf (int);
395 static void s_mri_repeat (int);
396 static void s_mri_until (int);
397 static void s_mri_while (int);
398 static void s_mri_endw (int);
399 static void s_m68k_cpu (int);
400 static void s_m68k_arch (int);
404 unsigned long arch
; /* Architecture features. */
405 const enum m68k_register
*control_regs
; /* Control regs on chip */
406 const char *name
; /* Name */
407 int alias
; /* Alias for a cannonical name. If 1, then
408 succeeds canonical name, if -1 then
409 succeeds canonical name, if <-1 ||>1 this is a
410 deprecated name, and the next/previous name
414 /* We hold flags for features explicitly enabled and explicitly
416 static int current_architecture
;
417 static int not_current_architecture
;
418 static const struct m68k_cpu
*selected_arch
;
419 static const struct m68k_cpu
*selected_cpu
;
420 static int initialized
;
422 /* Architecture models. */
423 static const struct m68k_cpu m68k_archs
[] =
425 {m68000
, m68000_ctrl
, "68000", 0},
426 {m68010
, m68010_ctrl
, "68010", 0},
427 {m68020
|m68881
|m68851
, m68020_ctrl
, "68020", 0},
428 {m68030
|m68881
|m68851
, m68020_ctrl
, "68030", 0},
429 {m68040
, m68040_ctrl
, "68040", 0},
430 {m68060
, m68060_ctrl
, "68060", 0},
431 {cpu32
|m68881
, cpu32_ctrl
, "cpu32", 0},
432 {mcfisa_a
|mcfhwdiv
, NULL
, "isaa", 0},
433 {mcfisa_a
|mcfhwdiv
|mcfisa_aa
|mcfusp
, NULL
, "isaaplus", 0},
434 {mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfusp
, NULL
, "isab", 0},
435 {mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfmac
|mcfusp
, mcf_ctrl
, "cfv4", 0},
436 {mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "cfv4e", 0},
440 /* Architecture extensions, here 'alias' -1 for m68k, +1 for cf and 0
442 static const struct m68k_cpu m68k_extensions
[] =
444 {m68851
, NULL
, "68851", -1},
445 {m68881
, NULL
, "68881", -1},
446 {m68881
, NULL
, "68882", -1},
448 {cfloat
|m68881
, NULL
, "float", 0},
450 {mcfhwdiv
, NULL
, "div", 1},
451 {mcfusp
, NULL
, "usp", 1},
452 {mcfmac
, NULL
, "mac", 1},
453 {mcfemac
, NULL
, "emac", 1},
459 static const struct m68k_cpu m68k_cpus
[] =
461 {m68000
, m68000_ctrl
, "68000", 0},
462 {m68000
, m68000_ctrl
, "68ec000", 1},
463 {m68000
, m68000_ctrl
, "68hc000", 1},
464 {m68000
, m68000_ctrl
, "68hc001", 1},
465 {m68000
, m68000_ctrl
, "68008", 1},
466 {m68000
, m68000_ctrl
, "68302", 1},
467 {m68000
, m68000_ctrl
, "68306", 1},
468 {m68000
, m68000_ctrl
, "68307", 1},
469 {m68000
, m68000_ctrl
, "68322", 1},
470 {m68000
, m68000_ctrl
, "68356", 1},
471 {m68010
, m68010_ctrl
, "68010", 0},
472 {m68020
|m68881
|m68851
, m68020_ctrl
, "68020", 0},
473 {m68020
|m68881
|m68851
, m68020_ctrl
, "68k", 1},
474 {m68020
|m68881
|m68851
, m68020_ctrl
, "68ec020", 1},
475 {m68030
|m68881
|m68851
, m68020_ctrl
, "68030", 0},
476 {m68030
|m68881
|m68851
, m68020_ctrl
, "68ec030", 1},
477 {m68040
, m68040_ctrl
, "68040", 0},
478 {m68040
, m68040_ctrl
, "68ec040", 1},
479 {m68060
, m68060_ctrl
, "68060", 0},
480 {m68060
, m68060_ctrl
, "68ec060", 1},
482 {cpu32
|m68881
, cpu32_ctrl
, "cpu32", 0},
483 {cpu32
|m68881
, cpu32_ctrl
, "68330", 1},
484 {cpu32
|m68881
, cpu32_ctrl
, "68331", 1},
485 {cpu32
|m68881
, cpu32_ctrl
, "68332", 1},
486 {cpu32
|m68881
, cpu32_ctrl
, "68333", 1},
487 {cpu32
|m68881
, cpu32_ctrl
, "68334", 1},
488 {cpu32
|m68881
, cpu32_ctrl
, "68336", 1},
489 {cpu32
|m68881
, cpu32_ctrl
, "68340", 1},
490 {cpu32
|m68881
, cpu32_ctrl
, "68341", 1},
491 {cpu32
|m68881
, cpu32_ctrl
, "68349", 1},
492 {cpu32
|m68881
, cpu32_ctrl
, "68360", 1},
494 {mcfisa_a
, mcf_ctrl
, "5200", 0},
495 {mcfisa_a
, mcf_ctrl
, "5202", 1},
496 {mcfisa_a
, mcf_ctrl
, "5204", 1},
497 {mcfisa_a
, mcf_ctrl
, "5206", 1},
499 {mcfisa_a
|mcfhwdiv
|mcfmac
, mcf_ctrl
, "5206e", 0},
501 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5208_ctrl
, "5207", -1},
502 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5208_ctrl
, "5208", 0},
504 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfmac
|mcfusp
, mcf5213_ctrl
, "5211", -1},
505 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfmac
|mcfusp
, mcf5213_ctrl
, "5212", -1},
506 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfmac
|mcfusp
, mcf5213_ctrl
, "5213", 0},
508 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5216_ctrl
, "5214", -1},
509 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5216_ctrl
, "5216", 0},
510 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5216_ctrl
, "521x", 2},
512 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf52235_ctrl
, "52230", -1},
513 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf52235_ctrl
, "52233", -1},
514 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf52235_ctrl
, "52234", -1},
515 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf52235_ctrl
, "52235", 0},
517 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfmac
|mcfusp
, mcf5225_ctrl
, "5224", -1},
518 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfmac
|mcfusp
, mcf5225_ctrl
, "5225", 0},
520 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5235_ctrl
, "5232", -1},
521 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5235_ctrl
, "5233", -1},
522 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5235_ctrl
, "5234", -1},
523 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5235_ctrl
, "5235", -1},
524 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5235_ctrl
, "523x", 0},
526 {mcfisa_a
|mcfhwdiv
|mcfemac
, mcf5249_ctrl
, "5249", 0},
527 {mcfisa_a
|mcfhwdiv
|mcfemac
, mcf5250_ctrl
, "5250", 0},
529 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5271_ctrl
, "5270", -1},
530 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5271_ctrl
, "5271", 0},
532 {mcfisa_a
|mcfhwdiv
|mcfmac
, mcf5272_ctrl
, "5272", 0},
534 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5275_ctrl
, "5274", -1},
535 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5275_ctrl
, "5275", 0},
537 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5282_ctrl
, "5280", -1},
538 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5282_ctrl
, "5281", -1},
539 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5282_ctrl
, "5282", -1},
540 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5282_ctrl
, "528x", 0},
542 {mcfisa_a
|mcfhwdiv
|mcfmac
, mcf_ctrl
, "5307", 0},
544 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5329_ctrl
, "5327", -1},
545 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5329_ctrl
, "5328", -1},
546 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5329_ctrl
, "5329", -1},
547 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5329_ctrl
, "532x", 0},
549 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5373_ctrl
, "5372", -1},
550 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5373_ctrl
, "5373", -1},
551 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5373_ctrl
, "537x", 0},
553 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfmac
, mcf_ctrl
, "5407",0},
555 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5470", -1},
556 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5471", -1},
557 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5472", -1},
558 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5473", -1},
559 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5474", -1},
560 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5475", -1},
561 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "547x", 0},
563 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5480", -1},
564 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5481", -1},
565 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5482", -1},
566 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5483", -1},
567 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5484", -1},
568 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5485", -1},
569 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "548x", 0},
574 static const struct m68k_cpu
*m68k_lookup_cpu
575 (const char *, const struct m68k_cpu
*, int, int *);
576 static int m68k_set_arch (const char *, int, int);
577 static int m68k_set_cpu (const char *, int, int);
578 static int m68k_set_extension (const char *, int, int);
579 static void m68k_init_arch (void);
581 /* This is the assembler relaxation table for m68k. m68k is a rich CISC
582 architecture and we have a lot of relaxation modes. */
584 /* Macros used in the relaxation code. */
585 #define TAB(x,y) (((x) << 2) + (y))
586 #define TABTYPE(x) ((x) >> 2)
588 /* Relaxation states. */
594 /* Here are all the relaxation modes we support. First we can relax ordinary
595 branches. On 68020 and higher and on CPU32 all branch instructions take
596 three forms, so on these CPUs all branches always remain as such. When we
597 have to expand to the LONG form on a 68000, though, we substitute an
598 absolute jump instead. This is a direct replacement for unconditional
599 branches and a branch over a jump for conditional branches. However, if the
600 user requires PIC and disables this with --pcrel, we can only relax between
601 BYTE and SHORT forms, punting if that isn't enough. This gives us four
602 different relaxation modes for branches: */
604 #define BRANCHBWL 0 /* Branch byte, word, or long. */
605 #define BRABSJUNC 1 /* Absolute jump for LONG, unconditional. */
606 #define BRABSJCOND 2 /* Absolute jump for LONG, conditional. */
607 #define BRANCHBW 3 /* Branch byte or word. */
609 /* We also relax coprocessor branches and DBcc's. All CPUs that support
610 coprocessor branches support them in word and long forms, so we have only
611 one relaxation mode for them. DBcc's are word only on all CPUs. We can
612 relax them to the LONG form with a branch-around sequence. This sequence
613 can use a long branch (if available) or an absolute jump (if acceptable).
614 This gives us two relaxation modes. If long branches are not available and
615 absolute jumps are not acceptable, we don't relax DBcc's. */
617 #define FBRANCH 4 /* Coprocessor branch. */
618 #define DBCCLBR 5 /* DBcc relaxable with a long branch. */
619 #define DBCCABSJ 6 /* DBcc relaxable with an absolute jump. */
621 /* That's all for instruction relaxation. However, we also relax PC-relative
622 operands. Specifically, we have three operand relaxation modes. On the
623 68000 PC-relative operands can only be 16-bit, but on 68020 and higher and
624 on CPU32 they may be 16-bit or 32-bit. For the latter we relax between the
625 two. Also PC+displacement+index operands in their simple form (with a non-
626 suppressed index without memory indirection) are supported on all CPUs, but
627 on the 68000 the displacement can be 8-bit only, whereas on 68020 and higher
628 and on CPU32 we relax it to SHORT and LONG forms as well using the extended
629 form of the PC+displacement+index operand. Finally, some absolute operands
630 can be relaxed down to 16-bit PC-relative. */
632 #define PCREL1632 7 /* 16-bit or 32-bit PC-relative. */
633 #define PCINDEX 8 /* PC + displacement + index. */
634 #define ABSTOPCREL 9 /* Absolute relax down to 16-bit PC-relative. */
636 /* Note that calls to frag_var need to specify the maximum expansion
637 needed; this is currently 10 bytes for DBCC. */
640 How far Forward this mode will reach:
641 How far Backward this mode will reach:
642 How many bytes this mode will add to the size of the frag
643 Which mode to go to if the offset won't fit in this one
645 Please check tc-m68k.h:md_prepare_relax_scan if changing this table. */
646 relax_typeS md_relax_table
[] =
648 { 127, -128, 0, TAB (BRANCHBWL
, SHORT
) },
649 { 32767, -32768, 2, TAB (BRANCHBWL
, LONG
) },
653 { 127, -128, 0, TAB (BRABSJUNC
, SHORT
) },
654 { 32767, -32768, 2, TAB (BRABSJUNC
, LONG
) },
658 { 127, -128, 0, TAB (BRABSJCOND
, SHORT
) },
659 { 32767, -32768, 2, TAB (BRABSJCOND
, LONG
) },
663 { 127, -128, 0, TAB (BRANCHBW
, SHORT
) },
668 { 1, 1, 0, 0 }, /* FBRANCH doesn't come BYTE. */
669 { 32767, -32768, 2, TAB (FBRANCH
, LONG
) },
673 { 1, 1, 0, 0 }, /* DBCC doesn't come BYTE. */
674 { 32767, -32768, 2, TAB (DBCCLBR
, LONG
) },
678 { 1, 1, 0, 0 }, /* DBCC doesn't come BYTE. */
679 { 32767, -32768, 2, TAB (DBCCABSJ
, LONG
) },
683 { 1, 1, 0, 0 }, /* PCREL1632 doesn't come BYTE. */
684 { 32767, -32768, 2, TAB (PCREL1632
, LONG
) },
688 { 125, -130, 0, TAB (PCINDEX
, SHORT
) },
689 { 32765, -32770, 2, TAB (PCINDEX
, LONG
) },
693 { 1, 1, 0, 0 }, /* ABSTOPCREL doesn't come BYTE. */
694 { 32767, -32768, 2, TAB (ABSTOPCREL
, LONG
) },
699 /* These are the machine dependent pseudo-ops. These are included so
700 the assembler can work on the output from the SUN C compiler, which
703 /* This table describes all the machine specific pseudo-ops the assembler
704 has to support. The fields are:
705 pseudo-op name without dot
706 function to call to execute this pseudo-op
707 Integer arg to pass to the function. */
708 const pseudo_typeS md_pseudo_table
[] =
710 {"data1", s_data1
, 0},
711 {"data2", s_data2
, 0},
714 {"skip", s_space
, 0},
716 #if defined (TE_SUN3) || defined (OBJ_ELF)
717 {"align", s_align_bytes
, 0},
720 {"swbeg", s_ignore
, 0},
722 {"extend", float_cons
, 'x'},
723 {"ldouble", float_cons
, 'x'},
725 {"arch", s_m68k_arch
, 0},
726 {"cpu", s_m68k_cpu
, 0},
728 /* The following pseudo-ops are supported for MRI compatibility. */
730 {"comline", s_space
, 1},
732 {"mask2", s_ignore
, 0},
735 {"restore", s_restore
, 0},
739 {"if.b", s_mri_if
, 'b'},
740 {"if.w", s_mri_if
, 'w'},
741 {"if.l", s_mri_if
, 'l'},
742 {"else", s_mri_else
, 0},
743 {"else.s", s_mri_else
, 's'},
744 {"else.l", s_mri_else
, 'l'},
745 {"endi", s_mri_endi
, 0},
746 {"break", s_mri_break
, 0},
747 {"break.s", s_mri_break
, 's'},
748 {"break.l", s_mri_break
, 'l'},
749 {"next", s_mri_next
, 0},
750 {"next.s", s_mri_next
, 's'},
751 {"next.l", s_mri_next
, 'l'},
752 {"for", s_mri_for
, 0},
753 {"for.b", s_mri_for
, 'b'},
754 {"for.w", s_mri_for
, 'w'},
755 {"for.l", s_mri_for
, 'l'},
756 {"endf", s_mri_endf
, 0},
757 {"repeat", s_mri_repeat
, 0},
758 {"until", s_mri_until
, 0},
759 {"until.b", s_mri_until
, 'b'},
760 {"until.w", s_mri_until
, 'w'},
761 {"until.l", s_mri_until
, 'l'},
762 {"while", s_mri_while
, 0},
763 {"while.b", s_mri_while
, 'b'},
764 {"while.w", s_mri_while
, 'w'},
765 {"while.l", s_mri_while
, 'l'},
766 {"endw", s_mri_endw
, 0},
771 /* The mote pseudo ops are put into the opcode table, since they
772 don't start with a . they look like opcodes to gas. */
774 const pseudo_typeS mote_pseudo_table
[] =
787 {"xdef", s_globl
, 0},
789 {"align", s_align_bytes
, 0},
791 {"align", s_align_ptwo
, 0},
794 {"sect", obj_coff_section
, 0},
795 {"section", obj_coff_section
, 0},
800 /* Truncate and sign-extend at 32 bits, so that building on a 64-bit host
801 gives identical results to a 32-bit host. */
802 #define TRUNC(X) ((valueT) (X) & 0xffffffff)
803 #define SEXT(X) ((TRUNC (X) ^ 0x80000000) - 0x80000000)
805 #define issbyte(x) ((valueT) SEXT (x) + 0x80 < 0x100)
806 #define isubyte(x) ((valueT) TRUNC (x) < 0x100)
807 #define issword(x) ((valueT) SEXT (x) + 0x8000 < 0x10000)
808 #define isuword(x) ((valueT) TRUNC (x) < 0x10000)
810 #define isbyte(x) ((valueT) SEXT (x) + 0xff < 0x1ff)
811 #define isword(x) ((valueT) SEXT (x) + 0xffff < 0x1ffff)
812 #define islong(x) (1)
814 static char notend_table
[256];
815 static char alt_notend_table
[256];
817 (! (notend_table[(unsigned char) *s] \
819 && alt_notend_table[(unsigned char) s[1]])))
823 /* Return zero if the reference to SYMBOL from within the same segment may
826 /* On an ELF system, we can't relax an externally visible symbol,
827 because it may be overridden by a shared library. However, if
828 TARGET_OS is "elf", then we presume that we are assembling for an
829 embedded system, in which case we don't have to worry about shared
830 libraries, and we can relax any external sym. */
832 #define relaxable_symbol(symbol) \
833 (!((S_IS_EXTERNAL (symbol) && EXTERN_FORCE_RELOC) \
834 || S_IS_WEAK (symbol)))
836 /* Compute the relocation code for a fixup of SIZE bytes, using pc
837 relative relocation if PCREL is non-zero. PIC says whether a special
838 pic relocation was requested. */
840 static bfd_reloc_code_real_type
841 get_reloc_code (int size
, int pcrel
, enum pic_relocation pic
)
849 return BFD_RELOC_8_GOT_PCREL
;
851 return BFD_RELOC_16_GOT_PCREL
;
853 return BFD_RELOC_32_GOT_PCREL
;
861 return BFD_RELOC_8_GOTOFF
;
863 return BFD_RELOC_16_GOTOFF
;
865 return BFD_RELOC_32_GOTOFF
;
873 return BFD_RELOC_8_PLT_PCREL
;
875 return BFD_RELOC_16_PLT_PCREL
;
877 return BFD_RELOC_32_PLT_PCREL
;
885 return BFD_RELOC_8_PLTOFF
;
887 return BFD_RELOC_16_PLTOFF
;
889 return BFD_RELOC_32_PLTOFF
;
899 return BFD_RELOC_8_PCREL
;
901 return BFD_RELOC_16_PCREL
;
903 return BFD_RELOC_32_PCREL
;
923 as_bad (_("Can not do %d byte pc-relative relocation"), size
);
925 as_bad (_("Can not do %d byte pc-relative pic relocation"), size
);
930 as_bad (_("Can not do %d byte relocation"), size
);
932 as_bad (_("Can not do %d byte pic relocation"), size
);
935 return BFD_RELOC_NONE
;
938 /* Here we decide which fixups can be adjusted to make them relative
939 to the beginning of the section instead of the symbol. Basically
940 we need to make sure that the dynamic relocations are done
941 correctly, so in some cases we force the original symbol to be
944 tc_m68k_fix_adjustable (fixS
*fixP
)
946 /* Adjust_reloc_syms doesn't know about the GOT. */
947 switch (fixP
->fx_r_type
)
949 case BFD_RELOC_8_GOT_PCREL
:
950 case BFD_RELOC_16_GOT_PCREL
:
951 case BFD_RELOC_32_GOT_PCREL
:
952 case BFD_RELOC_8_GOTOFF
:
953 case BFD_RELOC_16_GOTOFF
:
954 case BFD_RELOC_32_GOTOFF
:
955 case BFD_RELOC_8_PLT_PCREL
:
956 case BFD_RELOC_16_PLT_PCREL
:
957 case BFD_RELOC_32_PLT_PCREL
:
958 case BFD_RELOC_8_PLTOFF
:
959 case BFD_RELOC_16_PLTOFF
:
960 case BFD_RELOC_32_PLTOFF
:
963 case BFD_RELOC_VTABLE_INHERIT
:
964 case BFD_RELOC_VTABLE_ENTRY
:
974 #define get_reloc_code(SIZE,PCREL,OTHER) NO_RELOC
976 #define relaxable_symbol(symbol) 1
981 tc_gen_reloc (asection
*section ATTRIBUTE_UNUSED
, fixS
*fixp
)
984 bfd_reloc_code_real_type code
;
986 /* If the tcbit is set, then this was a fixup of a negative value
987 that was never resolved. We do not have a reloc to handle this,
988 so just return. We assume that other code will have detected this
989 situation and produced a helpful error message, so we just tell the
990 user that the reloc cannot be produced. */
994 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
995 _("Unable to produce reloc against symbol '%s'"),
996 S_GET_NAME (fixp
->fx_addsy
));
1000 if (fixp
->fx_r_type
!= BFD_RELOC_NONE
)
1002 code
= fixp
->fx_r_type
;
1004 /* Since DIFF_EXPR_OK is defined in tc-m68k.h, it is possible
1005 that fixup_segment converted a non-PC relative reloc into a
1006 PC relative reloc. In such a case, we need to convert the
1013 code
= BFD_RELOC_8_PCREL
;
1016 code
= BFD_RELOC_16_PCREL
;
1019 code
= BFD_RELOC_32_PCREL
;
1021 case BFD_RELOC_8_PCREL
:
1022 case BFD_RELOC_16_PCREL
:
1023 case BFD_RELOC_32_PCREL
:
1024 case BFD_RELOC_8_GOT_PCREL
:
1025 case BFD_RELOC_16_GOT_PCREL
:
1026 case BFD_RELOC_32_GOT_PCREL
:
1027 case BFD_RELOC_8_GOTOFF
:
1028 case BFD_RELOC_16_GOTOFF
:
1029 case BFD_RELOC_32_GOTOFF
:
1030 case BFD_RELOC_8_PLT_PCREL
:
1031 case BFD_RELOC_16_PLT_PCREL
:
1032 case BFD_RELOC_32_PLT_PCREL
:
1033 case BFD_RELOC_8_PLTOFF
:
1034 case BFD_RELOC_16_PLTOFF
:
1035 case BFD_RELOC_32_PLTOFF
:
1038 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1039 _("Cannot make %s relocation PC relative"),
1040 bfd_get_reloc_code_name (code
));
1046 #define F(SZ,PCREL) (((SZ) << 1) + (PCREL))
1047 switch (F (fixp
->fx_size
, fixp
->fx_pcrel
))
1049 #define MAP(SZ,PCREL,TYPE) case F(SZ,PCREL): code = (TYPE); break
1050 MAP (1, 0, BFD_RELOC_8
);
1051 MAP (2, 0, BFD_RELOC_16
);
1052 MAP (4, 0, BFD_RELOC_32
);
1053 MAP (1, 1, BFD_RELOC_8_PCREL
);
1054 MAP (2, 1, BFD_RELOC_16_PCREL
);
1055 MAP (4, 1, BFD_RELOC_32_PCREL
);
1063 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
1064 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
1065 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
1066 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
1069 reloc
->addend
= fixp
->fx_addnumber
;
1073 if (!fixp
->fx_pcrel
)
1074 reloc
->addend
= fixp
->fx_addnumber
;
1076 reloc
->addend
= (section
->vma
1077 /* Explicit sign extension in case char is
1079 + ((fixp
->fx_pcrel_adjust
& 0xff) ^ 0x80) - 0x80
1080 + fixp
->fx_addnumber
1081 + md_pcrel_from (fixp
));
1084 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
1085 assert (reloc
->howto
!= 0);
1090 /* Handle of the OPCODE hash table. NULL means any use before
1091 m68k_ip_begin() will crash. */
1092 static struct hash_control
*op_hash
;
1094 /* Assemble an m68k instruction. */
1097 m68k_ip (char *instring
)
1100 register struct m68k_op
*opP
;
1101 register const struct m68k_incant
*opcode
;
1102 register const char *s
;
1103 register int tmpreg
= 0, baseo
= 0, outro
= 0, nextword
;
1104 char *pdot
, *pdotmove
;
1105 enum m68k_size siz1
, siz2
;
1109 struct m68k_op operands_backup
[6];
1110 LITTLENUM_TYPE words
[6];
1111 LITTLENUM_TYPE
*wordp
;
1112 unsigned long ok_arch
= 0;
1114 if (*instring
== ' ')
1115 instring
++; /* Skip leading whitespace. */
1117 /* Scan up to end of operation-code, which MUST end in end-of-string
1118 or exactly 1 space. */
1120 for (p
= instring
; *p
!= '\0'; p
++)
1130 the_ins
.error
= _("No operator");
1134 /* p now points to the end of the opcode name, probably whitespace.
1135 Make sure the name is null terminated by clobbering the
1136 whitespace, look it up in the hash table, then fix it back.
1137 Remove a dot, first, since the opcode tables have none. */
1140 for (pdotmove
= pdot
; pdotmove
< p
; pdotmove
++)
1141 *pdotmove
= pdotmove
[1];
1147 opcode
= (const struct m68k_incant
*) hash_find (op_hash
, instring
);
1152 for (pdotmove
= p
; pdotmove
> pdot
; pdotmove
--)
1153 *pdotmove
= pdotmove
[-1];
1160 the_ins
.error
= _("Unknown operator");
1164 /* Found a legitimate opcode, start matching operands. */
1168 if (opcode
->m_operands
== 0)
1170 char *old
= input_line_pointer
;
1172 input_line_pointer
= p
;
1173 /* Ahh - it's a motorola style psuedo op. */
1174 mote_pseudo_table
[opcode
->m_opnum
].poc_handler
1175 (mote_pseudo_table
[opcode
->m_opnum
].poc_val
);
1176 input_line_pointer
= old
;
1182 if (flag_mri
&& opcode
->m_opnum
== 0)
1184 /* In MRI mode, random garbage is allowed after an instruction
1185 which accepts no operands. */
1186 the_ins
.args
= opcode
->m_operands
;
1187 the_ins
.numargs
= opcode
->m_opnum
;
1188 the_ins
.numo
= opcode
->m_codenum
;
1189 the_ins
.opcode
[0] = getone (opcode
);
1190 the_ins
.opcode
[1] = gettwo (opcode
);
1194 for (opP
= &the_ins
.operands
[0]; *p
; opP
++)
1196 p
= crack_operand (p
, opP
);
1200 the_ins
.error
= opP
->error
;
1205 opsfound
= opP
- &the_ins
.operands
[0];
1207 /* This ugly hack is to support the floating pt opcodes in their
1208 standard form. Essentially, we fake a first enty of type COP#1 */
1209 if (opcode
->m_operands
[0] == 'I')
1213 for (n
= opsfound
; n
> 0; --n
)
1214 the_ins
.operands
[n
] = the_ins
.operands
[n
- 1];
1216 memset (&the_ins
.operands
[0], '\0', sizeof (the_ins
.operands
[0]));
1217 the_ins
.operands
[0].mode
= CONTROL
;
1218 the_ins
.operands
[0].reg
= m68k_float_copnum
;
1222 /* We've got the operands. Find an opcode that'll accept them. */
1225 /* If we didn't get the right number of ops, or we have no
1226 common model with this pattern then reject this pattern. */
1228 ok_arch
|= opcode
->m_arch
;
1229 if (opsfound
!= opcode
->m_opnum
1230 || ((opcode
->m_arch
& current_architecture
) == 0))
1236 /* Make a copy of the operands of this insn so that
1237 we can modify them safely, should we want to. */
1238 assert (opsfound
<= (int) ARRAY_SIZE (operands_backup
));
1239 for (i
= 0; i
< opsfound
; i
++)
1240 operands_backup
[i
] = the_ins
.operands
[i
];
1242 for (s
= opcode
->m_operands
, opP
= &operands_backup
[0];
1246 /* Warning: this switch is huge! */
1247 /* I've tried to organize the cases into this order:
1248 non-alpha first, then alpha by letter. Lower-case
1249 goes directly before uppercase counterpart. */
1250 /* Code with multiple case ...: gets sorted by the lowest
1251 case ... it belongs to. I hope this makes sense. */
1357 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
1374 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
1393 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
1403 if (opP
->mode
!= IMMED
)
1405 else if (s
[1] == 'b'
1406 && ! isvar (&opP
->disp
)
1407 && (opP
->disp
.exp
.X_op
!= O_constant
1408 || ! isbyte (opP
->disp
.exp
.X_add_number
)))
1410 else if (s
[1] == 'B'
1411 && ! isvar (&opP
->disp
)
1412 && (opP
->disp
.exp
.X_op
!= O_constant
1413 || ! issbyte (opP
->disp
.exp
.X_add_number
)))
1415 else if (s
[1] == 'w'
1416 && ! isvar (&opP
->disp
)
1417 && (opP
->disp
.exp
.X_op
!= O_constant
1418 || ! isword (opP
->disp
.exp
.X_add_number
)))
1420 else if (s
[1] == 'W'
1421 && ! isvar (&opP
->disp
)
1422 && (opP
->disp
.exp
.X_op
!= O_constant
1423 || ! issword (opP
->disp
.exp
.X_add_number
)))
1429 if (opP
->mode
!= IMMED
)
1434 if (opP
->mode
== AREG
1435 || opP
->mode
== CONTROL
1436 || opP
->mode
== FPREG
1437 || opP
->mode
== IMMED
1438 || opP
->mode
== REGLST
1439 || (opP
->mode
!= ABSL
1441 || opP
->reg
== ZPC
)))
1446 if (opP
->mode
== CONTROL
1447 || opP
->mode
== FPREG
1448 || opP
->mode
== REGLST
1449 || opP
->mode
== IMMED
1450 || (opP
->mode
!= ABSL
1452 || opP
->reg
== ZPC
)))
1480 if (opP
->mode
== CONTROL
1481 || opP
->mode
== FPREG
1482 || opP
->mode
== REGLST
)
1487 if (opP
->mode
!= AINC
)
1492 if (opP
->mode
!= ADEC
)
1542 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
1563 case '~': /* For now! (JF FOO is this right?) */
1585 if (opP
->mode
!= CONTROL
1586 || (opP
->reg
!= TT0
&& opP
->reg
!= TT1
))
1591 if (opP
->mode
!= AREG
)
1596 if (opP
->mode
!= AINDR
)
1601 if (opP
->mode
!= AINDR
&& opP
->mode
!= AINC
&& opP
->mode
!= ADEC
1602 && (opP
->mode
!= DISP
1604 || opP
->reg
> ADDR7
))
1609 if (opP
->mode
!= ABSL
1611 && strncmp (instring
, "jbsr", 4) == 0))
1634 if (opP
->mode
!= CONTROL
|| opP
->reg
!= CCR
)
1639 if (opP
->mode
!= DISP
1641 || opP
->reg
> ADDR7
)
1646 if (opP
->mode
!= DREG
)
1651 if (opP
->reg
!= ACC
)
1656 if (opP
->reg
!= ACC
&& opP
->reg
!= ACC1
1657 && opP
->reg
!= ACC2
&& opP
->reg
!= ACC3
)
1662 if (opP
->mode
!= FPREG
)
1667 if (opP
->reg
!= MACSR
)
1672 if (opP
->reg
!= ACCEXT01
&& opP
->reg
!= ACCEXT23
)
1677 if (opP
->reg
!= MASK
)
1682 if (opP
->mode
!= CONTROL
1689 if (opP
->mode
!= LSH
&& opP
->mode
!= RSH
)
1694 if (opP
->mode
!= CONTROL
1696 || opP
->reg
> last_movec_reg
1701 const enum m68k_register
*rp
;
1703 for (rp
= control_regs
; *rp
; rp
++)
1704 if (*rp
== opP
->reg
)
1712 if (opP
->mode
!= IMMED
)
1718 if (opP
->mode
== DREG
1719 || opP
->mode
== AREG
1720 || opP
->mode
== FPREG
)
1729 opP
->mask
= 1 << (opP
->reg
- DATA0
);
1732 opP
->mask
= 1 << (opP
->reg
- ADDR0
+ 8);
1735 opP
->mask
= 1 << (opP
->reg
- FP0
+ 16);
1743 else if (opP
->mode
== CONTROL
)
1752 opP
->mask
= 1 << 24;
1755 opP
->mask
= 1 << 25;
1758 opP
->mask
= 1 << 26;
1767 else if (opP
->mode
!= REGLST
)
1769 else if (s
[1] == '8' && (opP
->mask
& 0x0ffffff) != 0)
1771 else if (s
[1] == '3' && (opP
->mask
& 0x7000000) != 0)
1776 if (opP
->mode
!= IMMED
)
1778 else if (opP
->disp
.exp
.X_op
!= O_constant
1779 || ! issbyte (opP
->disp
.exp
.X_add_number
))
1781 else if (! m68k_quick
1782 && instring
[3] != 'q'
1783 && instring
[4] != 'q')
1788 if (opP
->mode
!= DREG
1789 && opP
->mode
!= IMMED
1790 && opP
->mode
!= ABSL
)
1795 if (opP
->mode
!= IMMED
)
1797 else if (opP
->disp
.exp
.X_op
!= O_constant
1798 || TRUNC (opP
->disp
.exp
.X_add_number
) - 1 > 7)
1800 else if (! m68k_quick
1801 && (strncmp (instring
, "add", 3) == 0
1802 || strncmp (instring
, "sub", 3) == 0)
1803 && instring
[3] != 'q')
1808 if (opP
->mode
!= DREG
&& opP
->mode
!= AREG
)
1813 if (opP
->mode
!= AINDR
1814 && (opP
->mode
!= BASE
1816 && opP
->reg
!= ZADDR0
)
1817 || opP
->disp
.exp
.X_op
!= O_absent
1818 || ((opP
->index
.reg
< DATA0
1819 || opP
->index
.reg
> DATA7
)
1820 && (opP
->index
.reg
< ADDR0
1821 || opP
->index
.reg
> ADDR7
))
1822 || opP
->index
.size
!= SIZE_UNSPEC
1823 || opP
->index
.scale
!= 1))
1828 if (opP
->mode
!= CONTROL
1829 || ! (opP
->reg
== FPI
1831 || opP
->reg
== FPC
))
1836 if (opP
->mode
!= CONTROL
|| opP
->reg
!= SR
)
1841 if (opP
->mode
!= IMMED
)
1843 else if (opP
->disp
.exp
.X_op
!= O_constant
1844 || TRUNC (opP
->disp
.exp
.X_add_number
) > 7)
1849 if (opP
->mode
!= CONTROL
|| opP
->reg
!= USP
)
1854 if (opP
->mode
!= IMMED
)
1856 else if (opP
->disp
.exp
.X_op
!= O_constant
1857 || (TRUNC (opP
->disp
.exp
.X_add_number
) != 0xffffffff
1858 && TRUNC (opP
->disp
.exp
.X_add_number
) - 1 > 6))
1862 /* JF these are out of order. We could put them
1863 in order if we were willing to put up with
1864 bunches of #ifdef m68851s in the code.
1866 Don't forget that you need these operands
1867 to use 68030 MMU instructions. */
1869 /* Memory addressing mode used by pflushr. */
1871 if (opP
->mode
== CONTROL
1872 || opP
->mode
== FPREG
1873 || opP
->mode
== DREG
1874 || opP
->mode
== AREG
1875 || opP
->mode
== REGLST
)
1877 /* We should accept immediate operands, but they
1878 supposedly have to be quad word, and we don't
1879 handle that. I would like to see what a Motorola
1880 assembler does before doing something here. */
1881 if (opP
->mode
== IMMED
)
1886 if (opP
->mode
!= CONTROL
1887 || (opP
->reg
!= SFC
&& opP
->reg
!= DFC
))
1892 if (opP
->mode
!= CONTROL
|| opP
->reg
!= TC
)
1897 if (opP
->mode
!= CONTROL
|| opP
->reg
!= AC
)
1902 if (opP
->mode
!= CONTROL
1905 && opP
->reg
!= SCC
))
1910 if (opP
->mode
!= CONTROL
1916 if (opP
->mode
!= CONTROL
1919 && opP
->reg
!= CRP
))
1943 if (opP
->mode
!= CONTROL
1944 || (!(opP
->reg
>= BAD
&& opP
->reg
<= BAD
+ 7)
1945 && !(opP
->reg
>= BAC
&& opP
->reg
<= BAC
+ 7)))
1950 if (opP
->mode
!= CONTROL
|| opP
->reg
!= PSR
)
1955 if (opP
->mode
!= CONTROL
|| opP
->reg
!= PCSR
)
1960 if (opP
->mode
!= CONTROL
1969 if (opP
->mode
!= ABSL
)
1974 if (opP
->reg
< DATA0L
|| opP
->reg
> ADDR7U
)
1976 /* FIXME: kludge instead of fixing parser:
1977 upper/lower registers are *not* CONTROL
1978 registers, but ordinary ones. */
1979 if ((opP
->reg
>= DATA0L
&& opP
->reg
<= DATA7L
)
1980 || (opP
->reg
>= DATA0U
&& opP
->reg
<= DATA7U
))
1987 if (!(opP
->mode
== AINDR
1988 || (opP
->mode
== DISP
1989 && !(opP
->reg
== PC
|| opP
->reg
== ZPC
))))
1994 if (!(opP
->mode
== AINDR
|| opP
->mode
== DISP
))
2006 /* Since we have found the correct instruction, copy
2007 in the modifications that we may have made. */
2009 for (i
= 0; i
< opsfound
; i
++)
2010 the_ins
.operands
[i
] = operands_backup
[i
];
2016 opcode
= opcode
->m_next
;
2021 && !(ok_arch
& current_architecture
))
2023 const struct m68k_cpu
*cpu
;
2026 char *buf
= xmalloc (space
+ 1);
2030 the_ins
.error
= buf
;
2031 /* Make sure there's a NUL at the end of the buffer -- strncpy
2032 won't write one when it runs out of buffer */
2034 #define APPEND(STRING) \
2035 (strncpy (buf, STRING, space), len = strlen (buf), buf += len, space -= len)
2037 APPEND (_("invalid instruction for this architecture; needs "));
2041 APPEND (_("ColdFire ISA_A"));
2044 APPEND (_("ColdFire hardware divide"));
2047 APPEND (_("ColdFire ISA_A+"));
2050 APPEND (_("ColdFire ISA_B"));
2053 APPEND (_("ColdFire fpu"));
2056 APPEND (_("M68K fpu"));
2059 APPEND (_("M68K mmu"));
2062 APPEND (_("68020 or higher"));
2065 APPEND (_("68000 or higher"));
2068 APPEND (_("68010 or higher"));
2076 for (cpu
= m68k_cpus
; cpu
->name
; cpu
++)
2077 if (!cpu
->alias
&& (cpu
->arch
& ok_arch
))
2079 const struct m68k_cpu
*alias
;
2086 if (cpu
!= m68k_cpus
)
2087 for (alias
= cpu
- 1; alias
->alias
; alias
--)
2091 APPEND (alias
->name
);
2094 for (alias
= cpu
+ 1; alias
->alias
; alias
++)
2098 APPEND (alias
->name
);
2110 /* we ran out of space, so replace the end of the list
2115 strcpy (buf
, " ...");
2119 the_ins
.error
= _("operands mismatch");
2126 /* Now assemble it. */
2127 the_ins
.args
= opcode
->m_operands
;
2128 the_ins
.numargs
= opcode
->m_opnum
;
2129 the_ins
.numo
= opcode
->m_codenum
;
2130 the_ins
.opcode
[0] = getone (opcode
);
2131 the_ins
.opcode
[1] = gettwo (opcode
);
2133 for (s
= the_ins
.args
, opP
= &the_ins
.operands
[0]; *s
; s
+= 2, opP
++)
2135 /* This switch is a doozy.
2136 Watch the first step; its a big one! */
2169 tmpreg
= 0x3c; /* 7.4 */
2170 if (strchr ("bwl", s
[1]))
2171 nextword
= get_num (&opP
->disp
, 90);
2173 nextword
= get_num (&opP
->disp
, 0);
2174 if (isvar (&opP
->disp
))
2175 add_fix (s
[1], &opP
->disp
, 0, 0);
2179 if (!isbyte (nextword
))
2180 opP
->error
= _("operand out of range");
2185 if (!isword (nextword
))
2186 opP
->error
= _("operand out of range");
2191 if (!issword (nextword
))
2192 opP
->error
= _("operand out of range");
2197 addword (nextword
>> 16);
2224 /* We gotta put out some float. */
2225 if (op (&opP
->disp
) != O_big
)
2230 /* Can other cases happen here? */
2231 if (op (&opP
->disp
) != O_constant
)
2234 val
= (valueT
) offs (&opP
->disp
);
2238 generic_bignum
[gencnt
] = (LITTLENUM_TYPE
) val
;
2239 val
>>= LITTLENUM_NUMBER_OF_BITS
;
2243 offs (&opP
->disp
) = gencnt
;
2245 if (offs (&opP
->disp
) > 0)
2247 if (offs (&opP
->disp
) > baseo
)
2249 as_warn (_("Bignum too big for %c format; truncated"),
2251 offs (&opP
->disp
) = baseo
;
2253 baseo
-= offs (&opP
->disp
);
2256 for (wordp
= generic_bignum
+ offs (&opP
->disp
) - 1;
2257 offs (&opP
->disp
)--;
2262 gen_to_words (words
, baseo
, (long) outro
);
2263 for (wordp
= words
; baseo
--; wordp
++)
2267 tmpreg
= opP
->reg
- DATA
; /* 0.dreg */
2270 tmpreg
= 0x08 + opP
->reg
- ADDR
; /* 1.areg */
2273 tmpreg
= 0x10 + opP
->reg
- ADDR
; /* 2.areg */
2276 tmpreg
= 0x20 + opP
->reg
- ADDR
; /* 4.areg */
2279 tmpreg
= 0x18 + opP
->reg
- ADDR
; /* 3.areg */
2283 nextword
= get_num (&opP
->disp
, 90);
2285 /* Convert mode 5 addressing with a zero offset into
2286 mode 2 addressing to reduce the instruction size by a
2288 if (! isvar (&opP
->disp
)
2290 && (opP
->disp
.size
== SIZE_UNSPEC
)
2291 && (opP
->reg
>= ADDR0
)
2292 && (opP
->reg
<= ADDR7
))
2294 tmpreg
= 0x10 + opP
->reg
- ADDR
; /* 2.areg */
2299 && ! isvar (&opP
->disp
)
2302 opP
->disp
.exp
.X_op
= O_symbol
;
2303 opP
->disp
.exp
.X_add_symbol
=
2304 section_symbol (absolute_section
);
2307 /* Force into index mode. Hope this works. */
2309 /* We do the first bit for 32-bit displacements, and the
2310 second bit for 16 bit ones. It is possible that we
2311 should make the default be WORD instead of LONG, but
2312 I think that'd break GCC, so we put up with a little
2313 inefficiency for the sake of working output. */
2315 if (!issword (nextword
)
2316 || (isvar (&opP
->disp
)
2317 && ((opP
->disp
.size
== SIZE_UNSPEC
2318 && flag_short_refs
== 0
2319 && cpu_of_arch (current_architecture
) >= m68020
2320 && ! arch_coldfire_p (current_architecture
))
2321 || opP
->disp
.size
== SIZE_LONG
)))
2323 if (cpu_of_arch (current_architecture
) < m68020
2324 || arch_coldfire_p (current_architecture
))
2326 _("displacement too large for this architecture; needs 68020 or higher");
2328 tmpreg
= 0x3B; /* 7.3 */
2330 tmpreg
= 0x30 + opP
->reg
- ADDR
; /* 6.areg */
2331 if (isvar (&opP
->disp
))
2335 if (opP
->disp
.size
== SIZE_LONG
2337 /* If the displacement needs pic
2338 relocation it cannot be relaxed. */
2339 || opP
->disp
.pic_reloc
!= pic_none
2344 add_fix ('l', &opP
->disp
, 1, 2);
2348 add_frag (adds (&opP
->disp
),
2349 SEXT (offs (&opP
->disp
)),
2350 TAB (PCREL1632
, SZ_UNDEF
));
2357 add_fix ('l', &opP
->disp
, 0, 0);
2362 addword (nextword
>> 16);
2367 tmpreg
= 0x3A; /* 7.2 */
2369 tmpreg
= 0x28 + opP
->reg
- ADDR
; /* 5.areg */
2371 if (isvar (&opP
->disp
))
2375 add_fix ('w', &opP
->disp
, 1, 0);
2378 add_fix ('w', &opP
->disp
, 0, 0);
2388 baseo
= get_num (&opP
->disp
, 90);
2389 if (opP
->mode
== POST
|| opP
->mode
== PRE
)
2390 outro
= get_num (&opP
->odisp
, 90);
2391 /* Figure out the `addressing mode'.
2392 Also turn on the BASE_DISABLE bit, if needed. */
2393 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
2395 tmpreg
= 0x3b; /* 7.3 */
2396 if (opP
->reg
== ZPC
)
2399 else if (opP
->reg
== 0)
2402 tmpreg
= 0x30; /* 6.garbage */
2404 else if (opP
->reg
>= ZADDR0
&& opP
->reg
<= ZADDR7
)
2407 tmpreg
= 0x30 + opP
->reg
- ZADDR0
;
2410 tmpreg
= 0x30 + opP
->reg
- ADDR
; /* 6.areg */
2412 siz1
= opP
->disp
.size
;
2413 if (opP
->mode
== POST
|| opP
->mode
== PRE
)
2414 siz2
= opP
->odisp
.size
;
2418 /* Index register stuff. */
2419 if (opP
->index
.reg
!= 0
2420 && opP
->index
.reg
>= DATA
2421 && opP
->index
.reg
<= ADDR7
)
2423 nextword
|= (opP
->index
.reg
- DATA
) << 12;
2425 if (opP
->index
.size
== SIZE_LONG
2426 || (opP
->index
.size
== SIZE_UNSPEC
2427 && m68k_index_width_default
== SIZE_LONG
))
2430 if ((opP
->index
.scale
!= 1
2431 && cpu_of_arch (current_architecture
) < m68020
)
2432 || (opP
->index
.scale
== 8
2433 && (arch_coldfire_p (current_architecture
)
2434 && !arch_coldfire_fpu (current_architecture
))))
2437 _("scale factor invalid on this architecture; needs cpu32 or 68020 or higher");
2440 if (arch_coldfire_p (current_architecture
)
2441 && opP
->index
.size
== SIZE_WORD
)
2442 opP
->error
= _("invalid index size for coldfire");
2444 switch (opP
->index
.scale
)
2461 GET US OUT OF HERE! */
2463 /* Must be INDEX, with an index register. Address
2464 register cannot be ZERO-PC, and either :b was
2465 forced, or we know it will fit. For a 68000 or
2466 68010, force this mode anyways, because the
2467 larger modes aren't supported. */
2468 if (opP
->mode
== BASE
2469 && ((opP
->reg
>= ADDR0
2470 && opP
->reg
<= ADDR7
)
2473 if (siz1
== SIZE_BYTE
2474 || cpu_of_arch (current_architecture
) < m68020
2475 || arch_coldfire_p (current_architecture
)
2476 || (siz1
== SIZE_UNSPEC
2477 && ! isvar (&opP
->disp
)
2478 && issbyte (baseo
)))
2480 nextword
+= baseo
& 0xff;
2482 if (isvar (&opP
->disp
))
2484 /* Do a byte relocation. If it doesn't
2485 fit (possible on m68000) let the
2486 fixup processing complain later. */
2488 add_fix ('B', &opP
->disp
, 1, 1);
2490 add_fix ('B', &opP
->disp
, 0, 0);
2492 else if (siz1
!= SIZE_BYTE
)
2494 if (siz1
!= SIZE_UNSPEC
)
2495 as_warn (_("Forcing byte displacement"));
2496 if (! issbyte (baseo
))
2497 opP
->error
= _("byte displacement out of range");
2502 else if (siz1
== SIZE_UNSPEC
2504 && isvar (&opP
->disp
)
2505 && subs (&opP
->disp
) == NULL
2507 /* If the displacement needs pic
2508 relocation it cannot be relaxed. */
2509 && opP
->disp
.pic_reloc
== pic_none
2513 /* The code in md_convert_frag_1 needs to be
2514 able to adjust nextword. Call frag_grow
2515 to ensure that we have enough space in
2516 the frag obstack to make all the bytes
2519 nextword
+= baseo
& 0xff;
2521 add_frag (adds (&opP
->disp
),
2522 SEXT (offs (&opP
->disp
)),
2523 TAB (PCINDEX
, SZ_UNDEF
));
2531 nextword
|= 0x40; /* No index reg. */
2532 if (opP
->index
.reg
>= ZDATA0
2533 && opP
->index
.reg
<= ZDATA7
)
2534 nextword
|= (opP
->index
.reg
- ZDATA0
) << 12;
2535 else if (opP
->index
.reg
>= ZADDR0
2536 || opP
->index
.reg
<= ZADDR7
)
2537 nextword
|= (opP
->index
.reg
- ZADDR0
+ 8) << 12;
2540 /* It isn't simple. */
2542 if (cpu_of_arch (current_architecture
) < m68020
2543 || arch_coldfire_p (current_architecture
))
2545 _("invalid operand mode for this architecture; needs 68020 or higher");
2548 /* If the guy specified a width, we assume that it is
2549 wide enough. Maybe it isn't. If so, we lose. */
2553 if (isvar (&opP
->disp
)
2555 : ! issword (baseo
))
2560 else if (! isvar (&opP
->disp
) && baseo
== 0)
2569 as_warn (_(":b not permitted; defaulting to :w"));
2579 /* Figure out inner displacement stuff. */
2580 if (opP
->mode
== POST
|| opP
->mode
== PRE
)
2582 if (cpu_of_arch (current_architecture
) & cpu32
)
2583 opP
->error
= _("invalid operand mode for this architecture; needs 68020 or higher");
2587 if (isvar (&opP
->odisp
)
2589 : ! issword (outro
))
2594 else if (! isvar (&opP
->odisp
) && outro
== 0)
2603 as_warn (_(":b not permitted; defaulting to :w"));
2612 if (opP
->mode
== POST
2613 && (nextword
& 0x40) == 0)
2618 if (siz1
!= SIZE_UNSPEC
&& isvar (&opP
->disp
))
2620 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
2621 add_fix (siz1
== SIZE_LONG
? 'l' : 'w', &opP
->disp
, 1, 2);
2623 add_fix (siz1
== SIZE_LONG
? 'l' : 'w', &opP
->disp
, 0, 0);
2625 if (siz1
== SIZE_LONG
)
2626 addword (baseo
>> 16);
2627 if (siz1
!= SIZE_UNSPEC
)
2630 if (siz2
!= SIZE_UNSPEC
&& isvar (&opP
->odisp
))
2631 add_fix (siz2
== SIZE_LONG
? 'l' : 'w', &opP
->odisp
, 0, 0);
2632 if (siz2
== SIZE_LONG
)
2633 addword (outro
>> 16);
2634 if (siz2
!= SIZE_UNSPEC
)
2640 nextword
= get_num (&opP
->disp
, 90);
2641 switch (opP
->disp
.size
)
2646 if (!isvar (&opP
->disp
) && issword (offs (&opP
->disp
)))
2648 tmpreg
= 0x38; /* 7.0 */
2652 if (isvar (&opP
->disp
)
2653 && !subs (&opP
->disp
)
2654 && adds (&opP
->disp
)
2656 /* If the displacement needs pic relocation it
2657 cannot be relaxed. */
2658 && opP
->disp
.pic_reloc
== pic_none
2661 && !strchr ("~%&$?", s
[0]))
2663 tmpreg
= 0x3A; /* 7.2 */
2664 add_frag (adds (&opP
->disp
),
2665 SEXT (offs (&opP
->disp
)),
2666 TAB (ABSTOPCREL
, SZ_UNDEF
));
2669 /* Fall through into long. */
2671 if (isvar (&opP
->disp
))
2672 add_fix ('l', &opP
->disp
, 0, 0);
2674 tmpreg
= 0x39;/* 7.1 mode */
2675 addword (nextword
>> 16);
2680 as_bad (_("unsupported byte value; use a different suffix"));
2684 if (isvar (&opP
->disp
))
2685 add_fix ('w', &opP
->disp
, 0, 0);
2687 tmpreg
= 0x38;/* 7.0 mode */
2695 as_bad (_("unknown/incorrect operand"));
2699 /* If s[0] is '4', then this is for the mac instructions
2700 that can have a trailing_ampersand set. If so, set 0x100
2701 bit on tmpreg so install_gen_operand can check for it and
2702 set the appropriate bit (word2, bit 5). */
2705 if (opP
->trailing_ampersand
)
2708 install_gen_operand (s
[1], tmpreg
);
2714 { /* JF: I hate floating point! */
2729 tmpreg
= get_num (&opP
->disp
, tmpreg
);
2730 if (isvar (&opP
->disp
))
2731 add_fix (s
[1], &opP
->disp
, 0, 0);
2734 case 'b': /* Danger: These do no check for
2735 certain types of overflow.
2737 if (!isbyte (tmpreg
))
2738 opP
->error
= _("out of range");
2739 insop (tmpreg
, opcode
);
2740 if (isvar (&opP
->disp
))
2741 the_ins
.reloc
[the_ins
.nrel
- 1].n
=
2742 (opcode
->m_codenum
) * 2 + 1;
2745 if (!issbyte (tmpreg
))
2746 opP
->error
= _("out of range");
2747 the_ins
.opcode
[the_ins
.numo
- 1] |= tmpreg
& 0xff;
2748 if (isvar (&opP
->disp
))
2749 the_ins
.reloc
[the_ins
.nrel
- 1].n
= opcode
->m_codenum
* 2 - 1;
2752 if (!isword (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 if (!issword (tmpreg
))
2760 opP
->error
= _("out of range");
2761 insop (tmpreg
, opcode
);
2762 if (isvar (&opP
->disp
))
2763 the_ins
.reloc
[the_ins
.nrel
- 1].n
= (opcode
->m_codenum
) * 2;
2766 /* Because of the way insop works, we put these two out
2768 insop (tmpreg
, opcode
);
2769 insop (tmpreg
>> 16, opcode
);
2770 if (isvar (&opP
->disp
))
2771 the_ins
.reloc
[the_ins
.nrel
- 1].n
= (opcode
->m_codenum
) * 2;
2778 install_operand (s
[1], tmpreg
);
2789 install_operand (s
[1], opP
->reg
- ADDR
);
2793 tmpreg
= get_num (&opP
->disp
, 90);
2797 add_fix ('B', &opP
->disp
, 1, -1);
2800 add_fix ('w', &opP
->disp
, 1, 0);
2805 if (! HAVE_LONG_BRANCH (current_architecture
))
2806 as_warn (_("Can't use long branches on 68000/68010/5200"));
2807 the_ins
.opcode
[0] |= 0xff;
2808 add_fix ('l', &opP
->disp
, 1, 0);
2813 if (subs (&opP
->disp
)) /* We can't relax it. */
2817 /* If the displacement needs pic relocation it cannot be
2819 if (opP
->disp
.pic_reloc
!= pic_none
)
2822 /* This could either be a symbol, or an absolute
2823 address. If it's an absolute address, turn it into
2824 an absolute jump right here and keep it out of the
2826 if (adds (&opP
->disp
) == 0)
2828 if (the_ins
.opcode
[0] == 0x6000) /* jbra */
2829 the_ins
.opcode
[0] = 0x4EF9;
2830 else if (the_ins
.opcode
[0] == 0x6100) /* jbsr */
2831 the_ins
.opcode
[0] = 0x4EB9;
2834 the_ins
.opcode
[0] ^= 0x0100;
2835 the_ins
.opcode
[0] |= 0x0006;
2838 add_fix ('l', &opP
->disp
, 0, 0);
2844 /* Now we know it's going into the relaxer. Now figure
2845 out which mode. We try in this order of preference:
2846 long branch, absolute jump, byte/word branches only. */
2847 if (HAVE_LONG_BRANCH (current_architecture
))
2848 add_frag (adds (&opP
->disp
),
2849 SEXT (offs (&opP
->disp
)),
2850 TAB (BRANCHBWL
, SZ_UNDEF
));
2851 else if (! flag_keep_pcrel
)
2853 if ((the_ins
.opcode
[0] == 0x6000)
2854 || (the_ins
.opcode
[0] == 0x6100))
2855 add_frag (adds (&opP
->disp
),
2856 SEXT (offs (&opP
->disp
)),
2857 TAB (BRABSJUNC
, SZ_UNDEF
));
2859 add_frag (adds (&opP
->disp
),
2860 SEXT (offs (&opP
->disp
)),
2861 TAB (BRABSJCOND
, SZ_UNDEF
));
2864 add_frag (adds (&opP
->disp
),
2865 SEXT (offs (&opP
->disp
)),
2866 TAB (BRANCHBW
, SZ_UNDEF
));
2869 if (isvar (&opP
->disp
))
2871 /* Check for DBcc instructions. We can relax them,
2872 but only if we have long branches and/or absolute
2874 if (((the_ins
.opcode
[0] & 0xf0f8) == 0x50c8)
2875 && (HAVE_LONG_BRANCH (current_architecture
)
2876 || (! flag_keep_pcrel
)))
2878 if (HAVE_LONG_BRANCH (current_architecture
))
2879 add_frag (adds (&opP
->disp
),
2880 SEXT (offs (&opP
->disp
)),
2881 TAB (DBCCLBR
, SZ_UNDEF
));
2883 add_frag (adds (&opP
->disp
),
2884 SEXT (offs (&opP
->disp
)),
2885 TAB (DBCCABSJ
, SZ_UNDEF
));
2888 add_fix ('w', &opP
->disp
, 1, 0);
2892 case 'C': /* Fixed size LONG coproc branches. */
2893 add_fix ('l', &opP
->disp
, 1, 0);
2897 case 'c': /* Var size Coprocesssor branches. */
2898 if (subs (&opP
->disp
) || (adds (&opP
->disp
) == 0))
2900 the_ins
.opcode
[the_ins
.numo
- 1] |= 0x40;
2901 add_fix ('l', &opP
->disp
, 1, 0);
2906 add_frag (adds (&opP
->disp
),
2907 SEXT (offs (&opP
->disp
)),
2908 TAB (FBRANCH
, SZ_UNDEF
));
2915 case 'C': /* Ignore it. */
2918 case 'd': /* JF this is a kludge. */
2919 install_operand ('s', opP
->reg
- ADDR
);
2920 tmpreg
= get_num (&opP
->disp
, 90);
2921 if (!issword (tmpreg
))
2923 as_warn (_("Expression out of range, using 0"));
2930 install_operand (s
[1], opP
->reg
- DATA
);
2933 case 'e': /* EMAC ACCx, reg/reg. */
2934 install_operand (s
[1], opP
->reg
- ACC
);
2937 case 'E': /* Ignore it. */
2941 install_operand (s
[1], opP
->reg
- FP0
);
2944 case 'g': /* EMAC ACCEXTx. */
2945 install_operand (s
[1], opP
->reg
- ACCEXT01
);
2948 case 'G': /* Ignore it. */
2953 tmpreg
= opP
->reg
- COP0
;
2954 install_operand (s
[1], tmpreg
);
2957 case 'i': /* MAC/EMAC scale factor. */
2958 install_operand (s
[1], opP
->mode
== LSH
? 0x1 : 0x3);
2961 case 'J': /* JF foo. */
3091 install_operand (s
[1], tmpreg
);
3095 tmpreg
= get_num (&opP
->disp
, 55);
3096 install_operand (s
[1], tmpreg
& 0x7f);
3103 if (tmpreg
& 0x7FF0000)
3104 as_bad (_("Floating point register in register list"));
3105 insop (reverse_16_bits (tmpreg
), opcode
);
3109 if (tmpreg
& 0x700FFFF)
3110 as_bad (_("Wrong register in floating-point reglist"));
3111 install_operand (s
[1], reverse_8_bits (tmpreg
>> 16));
3119 if (tmpreg
& 0x7FF0000)
3120 as_bad (_("Floating point register in register list"));
3121 insop (tmpreg
, opcode
);
3123 else if (s
[1] == '8')
3125 if (tmpreg
& 0x0FFFFFF)
3126 as_bad (_("incorrect register in reglist"));
3127 install_operand (s
[1], tmpreg
>> 24);
3131 if (tmpreg
& 0x700FFFF)
3132 as_bad (_("wrong register in floating-point reglist"));
3134 install_operand (s
[1], tmpreg
>> 16);
3139 install_operand (s
[1], get_num (&opP
->disp
, 60));
3143 tmpreg
= ((opP
->mode
== DREG
)
3144 ? 0x20 + (int) (opP
->reg
- DATA
)
3145 : (get_num (&opP
->disp
, 40) & 0x1F));
3146 install_operand (s
[1], tmpreg
);
3150 tmpreg
= get_num (&opP
->disp
, 10);
3153 install_operand (s
[1], tmpreg
);
3157 /* This depends on the fact that ADDR registers are eight
3158 more than their corresponding DATA regs, so the result
3159 will have the ADDR_REG bit set. */
3160 install_operand (s
[1], opP
->reg
- DATA
);
3164 if (opP
->mode
== AINDR
)
3165 install_operand (s
[1], opP
->reg
- DATA
);
3167 install_operand (s
[1], opP
->index
.reg
- DATA
);
3171 if (opP
->reg
== FPI
)
3173 else if (opP
->reg
== FPS
)
3175 else if (opP
->reg
== FPC
)
3179 install_operand (s
[1], tmpreg
);
3182 case 'S': /* Ignore it. */
3186 install_operand (s
[1], get_num (&opP
->disp
, 30));
3189 case 'U': /* Ignore it. */
3208 as_fatal (_("failed sanity check"));
3209 } /* switch on cache token. */
3210 install_operand (s
[1], tmpreg
);
3213 /* JF: These are out of order, I fear. */
3226 install_operand (s
[1], tmpreg
);
3252 install_operand (s
[1], tmpreg
);
3256 if (opP
->reg
== VAL
)
3275 install_operand (s
[1], tmpreg
);
3289 tmpreg
= (4 << 10) | ((opP
->reg
- BAD
) << 2);
3300 tmpreg
= (5 << 10) | ((opP
->reg
- BAC
) << 2);
3306 install_operand (s
[1], tmpreg
);
3309 know (opP
->reg
== PSR
);
3312 know (opP
->reg
== PCSR
);
3327 install_operand (s
[1], tmpreg
);
3330 tmpreg
= get_num (&opP
->disp
, 20);
3331 install_operand (s
[1], tmpreg
);
3333 case '_': /* used only for move16 absolute 32-bit address. */
3334 if (isvar (&opP
->disp
))
3335 add_fix ('l', &opP
->disp
, 0, 0);
3336 tmpreg
= get_num (&opP
->disp
, 90);
3337 addword (tmpreg
>> 16);
3338 addword (tmpreg
& 0xFFFF);
3341 install_operand (s
[1], opP
->reg
- DATA0L
);
3342 opP
->reg
-= (DATA0L
);
3343 opP
->reg
&= 0x0F; /* remove upper/lower bit. */
3346 tmpreg
= get_num (&opP
->disp
, 80);
3349 install_operand (s
[1], tmpreg
);
3356 /* By the time whe get here (FINALLY) the_ins contains the complete
3357 instruction, ready to be emitted. . . */
3361 reverse_16_bits (int in
)
3366 static int mask
[16] =
3368 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
3369 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000
3371 for (n
= 0; n
< 16; n
++)
3374 out
|= mask
[15 - n
];
3377 } /* reverse_16_bits() */
3380 reverse_8_bits (int in
)
3385 static int mask
[8] =
3387 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
3390 for (n
= 0; n
< 8; n
++)
3396 } /* reverse_8_bits() */
3398 /* Cause an extra frag to be generated here, inserting up to 10 bytes
3399 (that value is chosen in the frag_var call in md_assemble). TYPE
3400 is the subtype of the frag to be generated; its primary type is
3401 rs_machine_dependent.
3403 The TYPE parameter is also used by md_convert_frag_1 and
3404 md_estimate_size_before_relax. The appropriate type of fixup will
3405 be emitted by md_convert_frag_1.
3407 ADD becomes the FR_SYMBOL field of the frag, and OFF the FR_OFFSET. */
3409 install_operand (int mode
, int val
)
3414 the_ins
.opcode
[0] |= val
& 0xFF; /* JF FF is for M kludge. */
3417 the_ins
.opcode
[0] |= val
<< 9;
3420 the_ins
.opcode
[1] |= val
<< 12;
3423 the_ins
.opcode
[1] |= val
<< 6;
3426 the_ins
.opcode
[1] |= val
;
3429 the_ins
.opcode
[2] |= val
<< 12;
3432 the_ins
.opcode
[2] |= val
<< 6;
3435 /* DANGER! This is a hack to force cas2l and cas2w cmds to be
3436 three words long! */
3438 the_ins
.opcode
[2] |= val
;
3441 the_ins
.opcode
[1] |= val
<< 7;
3444 the_ins
.opcode
[1] |= val
<< 10;
3448 the_ins
.opcode
[1] |= val
<< 5;
3453 the_ins
.opcode
[1] |= (val
<< 10) | (val
<< 7);
3456 the_ins
.opcode
[1] |= (val
<< 12) | val
;
3459 the_ins
.opcode
[0] |= val
= 0xff;
3462 the_ins
.opcode
[0] |= val
<< 9;
3465 the_ins
.opcode
[1] |= val
;
3468 the_ins
.opcode
[1] |= val
;
3469 the_ins
.numo
++; /* What a hack. */
3472 the_ins
.opcode
[1] |= val
<< 4;
3480 the_ins
.opcode
[0] |= (val
<< 6);
3483 the_ins
.opcode
[1] = (val
>> 16);
3484 the_ins
.opcode
[2] = val
& 0xffff;
3487 the_ins
.opcode
[0] |= ((val
& 0x8) << (6 - 3));
3488 the_ins
.opcode
[0] |= ((val
& 0x7) << 9);
3489 the_ins
.opcode
[1] |= ((val
& 0x10) << (7 - 4));
3491 case 'n': /* MAC/EMAC Rx on !load. */
3492 the_ins
.opcode
[0] |= ((val
& 0x8) << (6 - 3));
3493 the_ins
.opcode
[0] |= ((val
& 0x7) << 9);
3494 the_ins
.opcode
[1] |= ((val
& 0x10) << (7 - 4));
3496 case 'o': /* MAC/EMAC Rx on load. */
3497 the_ins
.opcode
[1] |= val
<< 12;
3498 the_ins
.opcode
[1] |= ((val
& 0x10) << (7 - 4));
3500 case 'M': /* MAC/EMAC Ry on !load. */
3501 the_ins
.opcode
[0] |= (val
& 0xF);
3502 the_ins
.opcode
[1] |= ((val
& 0x10) << (6 - 4));
3504 case 'N': /* MAC/EMAC Ry on load. */
3505 the_ins
.opcode
[1] |= (val
& 0xF);
3506 the_ins
.opcode
[1] |= ((val
& 0x10) << (6 - 4));
3509 the_ins
.opcode
[1] |= ((val
!= 1) << 10);
3512 the_ins
.opcode
[0] |= ((val
& 0x3) << 9);
3515 the_ins
.opcode
[0] |= ((val
& 0x3) << 0);
3517 case 'G': /* EMAC accumulator in a EMAC load instruction. */
3518 the_ins
.opcode
[0] |= ((~val
& 0x1) << 7);
3519 the_ins
.opcode
[1] |= ((val
& 0x2) << (4 - 1));
3521 case 'H': /* EMAC accumulator in a EMAC non-load instruction. */
3522 the_ins
.opcode
[0] |= ((val
& 0x1) << 7);
3523 the_ins
.opcode
[1] |= ((val
& 0x2) << (4 - 1));
3526 the_ins
.opcode
[1] |= ((val
& 0x3) << 9);
3529 the_ins
.opcode
[0] |= (val
& 0x1) <<10;
3533 as_fatal (_("failed sanity check."));
3538 install_gen_operand (int mode
, int val
)
3542 case '/': /* Special for mask loads for mac/msac insns with
3543 possible mask; trailing_ampersend set in bit 8. */
3544 the_ins
.opcode
[0] |= (val
& 0x3f);
3545 the_ins
.opcode
[1] |= (((val
& 0x100) >> 8) << 5);
3548 the_ins
.opcode
[0] |= val
;
3551 /* This is a kludge!!! */
3552 the_ins
.opcode
[0] |= (val
& 0x07) << 9 | (val
& 0x38) << 3;
3561 the_ins
.opcode
[0] |= val
;
3563 /* more stuff goes here. */
3565 as_fatal (_("failed sanity check."));
3569 /* Verify that we have some number of paren pairs, do m68k_ip_op(), and
3570 then deal with the bitfield hack. */
3573 crack_operand (char *str
, struct m68k_op
*opP
)
3575 register int parens
;
3577 register char *beg_str
;
3585 for (parens
= 0; *str
&& (parens
> 0 || inquote
|| notend (str
)); str
++)
3591 else if (*str
== ')')
3595 opP
->error
= _("Extra )");
3601 if (flag_mri
&& *str
== '\'')
3602 inquote
= ! inquote
;
3604 if (!*str
&& parens
)
3606 opP
->error
= _("Missing )");
3611 if (m68k_ip_op (beg_str
, opP
) != 0)
3618 c
= *++str
; /* JF bitfield hack. */
3623 as_bad (_("Missing operand"));
3626 /* Detect MRI REG symbols and convert them to REGLSTs. */
3627 if (opP
->mode
== CONTROL
&& (int)opP
->reg
< 0)
3630 opP
->mask
= ~(int)opP
->reg
;
3637 /* This is the guts of the machine-dependent assembler. STR points to a
3638 machine dependent instruction. This function is supposed to emit
3639 the frags/bytes it assembles to.
3643 insert_reg (const char *regname
, int regnum
)
3648 #ifdef REGISTER_PREFIX
3649 if (!flag_reg_prefix_optional
)
3651 buf
[0] = REGISTER_PREFIX
;
3652 strcpy (buf
+ 1, regname
);
3657 symbol_table_insert (symbol_new (regname
, reg_section
, regnum
,
3658 &zero_address_frag
));
3660 for (i
= 0; regname
[i
]; i
++)
3661 buf
[i
] = TOUPPER (regname
[i
]);
3664 symbol_table_insert (symbol_new (buf
, reg_section
, regnum
,
3665 &zero_address_frag
));
3674 static const struct init_entry init_table
[] =
3734 { "accext01", ACCEXT01
},
3735 { "accext23", ACCEXT23
},
3739 /* Control registers. */
3740 { "sfc", SFC
}, /* Source Function Code. */
3742 { "dfc", DFC
}, /* Destination Function Code. */
3744 { "cacr", CACR
}, /* Cache Control Register. */
3745 { "caar", CAAR
}, /* Cache Address Register. */
3747 { "usp", USP
}, /* User Stack Pointer. */
3748 { "vbr", VBR
}, /* Vector Base Register. */
3749 { "msp", MSP
}, /* Master Stack Pointer. */
3750 { "isp", ISP
}, /* Interrupt Stack Pointer. */
3752 { "itt0", ITT0
}, /* Instruction Transparent Translation Reg 0. */
3753 { "itt1", ITT1
}, /* Instruction Transparent Translation Reg 1. */
3754 { "dtt0", DTT0
}, /* Data Transparent Translation Register 0. */
3755 { "dtt1", DTT1
}, /* Data Transparent Translation Register 1. */
3757 /* 68ec040 versions of same */
3758 { "iacr0", ITT0
}, /* Instruction Access Control Register 0. */
3759 { "iacr1", ITT1
}, /* Instruction Access Control Register 0. */
3760 { "dacr0", DTT0
}, /* Data Access Control Register 0. */
3761 { "dacr1", DTT1
}, /* Data Access Control Register 0. */
3763 /* mcf5200 versions of same. The ColdFire programmer's reference
3764 manual indicated that the order is 2,3,0,1, but Ken Rose
3765 <rose@netcom.com> says that 0,1,2,3 is the correct order. */
3766 { "acr0", ACR0
}, /* Access Control Unit 0. */
3767 { "acr1", ACR1
}, /* Access Control Unit 1. */
3768 { "acr2", ACR2
}, /* Access Control Unit 2. */
3769 { "acr3", ACR3
}, /* Access Control Unit 3. */
3771 { "tc", TC
}, /* MMU Translation Control Register. */
3774 { "mmusr", MMUSR
}, /* MMU Status Register. */
3775 { "srp", SRP
}, /* User Root Pointer. */
3776 { "urp", URP
}, /* Supervisor Root Pointer. */
3781 { "rombar", ROMBAR
}, /* ROM Base Address Register. */
3782 { "rambar0", RAMBAR0
}, /* ROM Base Address Register. */
3783 { "rambar1", RAMBAR1
}, /* ROM Base Address Register. */
3784 { "mbar", MBAR
}, /* Module Base Address Register. */
3786 { "mbar0", MBAR0
}, /* mcfv4e registers. */
3787 { "mbar1", MBAR1
}, /* mcfv4e registers. */
3788 { "rombar0", ROMBAR
}, /* mcfv4e registers. */
3789 { "rombar1", ROMBAR1
}, /* mcfv4e registers. */
3790 { "mpcr", MPCR
}, /* mcfv4e registers. */
3791 { "edrambar", EDRAMBAR
}, /* mcfv4e registers. */
3792 { "secmbar", SECMBAR
}, /* mcfv4e registers. */
3793 { "asid", TC
}, /* mcfv4e registers. */
3794 { "mmubar", BUSCR
}, /* mcfv4e registers. */
3795 { "pcr1u0", PCR1U0
}, /* mcfv4e registers. */
3796 { "pcr1l0", PCR1L0
}, /* mcfv4e registers. */
3797 { "pcr2u0", PCR2U0
}, /* mcfv4e registers. */
3798 { "pcr2l0", PCR2L0
}, /* mcfv4e registers. */
3799 { "pcr3u0", PCR3U0
}, /* mcfv4e registers. */
3800 { "pcr3l0", PCR3L0
}, /* mcfv4e registers. */
3801 { "pcr1u1", PCR1U1
}, /* mcfv4e registers. */
3802 { "pcr1l1", PCR1L1
}, /* mcfv4e registers. */
3803 { "pcr2u1", PCR2U1
}, /* mcfv4e registers. */
3804 { "pcr2l1", PCR2L1
}, /* mcfv4e registers. */
3805 { "pcr3u1", PCR3U1
}, /* mcfv4e registers. */
3806 { "pcr3l1", PCR3L1
}, /* mcfv4e registers. */
3808 { "flashbar", FLASHBAR
}, /* mcf528x registers. */
3809 { "rambar", RAMBAR
}, /* mcf528x registers. */
3811 { "mbar2", MBAR2
}, /* mcf5249 registers. */
3812 /* End of control registers. */
3846 /* 68ec030 versions of same. */
3849 /* 68ec030 access control unit, identical to 030 MMU status reg. */
3852 /* Suppressed data and address registers. */
3870 /* Upper and lower data and address registers, used by macw and msacw. */
3911 init_regtable (void)
3914 for (i
= 0; init_table
[i
].name
; i
++)
3915 insert_reg (init_table
[i
].name
, init_table
[i
].number
);
3919 md_assemble (char *str
)
3926 int shorts_this_frag
;
3929 if (!selected_cpu
&& !selected_arch
)
3931 /* We've not selected an architecture yet. Set the default
3932 now. We do this lazily so that an initial .cpu or .arch directive
3934 if (!m68k_set_cpu (TARGET_CPU
, 1, 1))
3935 as_bad (_("unrecognized default cpu `%s'"), TARGET_CPU
);
3940 /* In MRI mode, the instruction and operands are separated by a
3941 space. Anything following the operands is a comment. The label
3942 has already been removed. */
3950 for (s
= str
; *s
!= '\0'; s
++)
3952 if ((*s
== ' ' || *s
== '\t') && ! inquote
)
3970 inquote
= ! inquote
;
3975 memset (&the_ins
, '\0', sizeof (the_ins
));
3980 for (n
= 0; n
< the_ins
.numargs
; n
++)
3981 if (the_ins
.operands
[n
].error
)
3983 er
= the_ins
.operands
[n
].error
;
3989 as_bad (_("%s -- statement `%s' ignored"), er
, str
);
3993 /* If there is a current label, record that it marks an instruction. */
3994 if (current_label
!= NULL
)
3996 current_label
->text
= 1;
3997 current_label
= NULL
;
4001 /* Tie dwarf2 debug info to the address at the start of the insn. */
4002 dwarf2_emit_insn (0);
4005 if (the_ins
.nfrag
== 0)
4007 /* No frag hacking involved; just put it out. */
4008 toP
= frag_more (2 * the_ins
.numo
);
4009 fromP
= &the_ins
.opcode
[0];
4010 for (m
= the_ins
.numo
; m
; --m
)
4012 md_number_to_chars (toP
, (long) (*fromP
), 2);
4016 /* Put out symbol-dependent info. */
4017 for (m
= 0; m
< the_ins
.nrel
; m
++)
4019 switch (the_ins
.reloc
[m
].wid
)
4038 as_fatal (_("Don't know how to figure width of %c in md_assemble()"),
4039 the_ins
.reloc
[m
].wid
);
4042 fixP
= fix_new_exp (frag_now
,
4043 ((toP
- frag_now
->fr_literal
)
4044 - the_ins
.numo
* 2 + the_ins
.reloc
[m
].n
),
4046 &the_ins
.reloc
[m
].exp
,
4047 the_ins
.reloc
[m
].pcrel
,
4048 get_reloc_code (n
, the_ins
.reloc
[m
].pcrel
,
4049 the_ins
.reloc
[m
].pic_reloc
));
4050 fixP
->fx_pcrel_adjust
= the_ins
.reloc
[m
].pcrel_fix
;
4051 if (the_ins
.reloc
[m
].wid
== 'B')
4052 fixP
->fx_signed
= 1;
4057 /* There's some frag hacking. */
4059 /* Calculate the max frag size. */
4062 wid
= 2 * the_ins
.fragb
[0].fragoff
;
4063 for (n
= 1; n
< the_ins
.nfrag
; n
++)
4064 wid
+= 2 * (the_ins
.numo
- the_ins
.fragb
[n
- 1].fragoff
);
4065 /* frag_var part. */
4067 /* Make sure the whole insn fits in one chunk, in particular that
4068 the var part is attached, as we access one byte before the
4069 variable frag for byte branches. */
4073 for (n
= 0, fromP
= &the_ins
.opcode
[0]; n
< the_ins
.nfrag
; n
++)
4078 wid
= 2 * the_ins
.fragb
[n
].fragoff
;
4080 wid
= 2 * (the_ins
.numo
- the_ins
.fragb
[n
- 1].fragoff
);
4081 toP
= frag_more (wid
);
4083 shorts_this_frag
= 0;
4084 for (m
= wid
/ 2; m
; --m
)
4086 md_number_to_chars (toP
, (long) (*fromP
), 2);
4091 for (m
= 0; m
< the_ins
.nrel
; m
++)
4093 if ((the_ins
.reloc
[m
].n
) >= 2 * shorts_this_frag
)
4095 the_ins
.reloc
[m
].n
-= 2 * shorts_this_frag
;
4098 wid
= the_ins
.reloc
[m
].wid
;
4101 the_ins
.reloc
[m
].wid
= 0;
4102 wid
= (wid
== 'b') ? 1 : (wid
== 'w') ? 2 : (wid
== 'l') ? 4 : 4000;
4104 fixP
= fix_new_exp (frag_now
,
4105 ((toP
- frag_now
->fr_literal
)
4106 - the_ins
.numo
* 2 + the_ins
.reloc
[m
].n
),
4108 &the_ins
.reloc
[m
].exp
,
4109 the_ins
.reloc
[m
].pcrel
,
4110 get_reloc_code (wid
, the_ins
.reloc
[m
].pcrel
,
4111 the_ins
.reloc
[m
].pic_reloc
));
4112 fixP
->fx_pcrel_adjust
= the_ins
.reloc
[m
].pcrel_fix
;
4114 (void) frag_var (rs_machine_dependent
, 10, 0,
4115 (relax_substateT
) (the_ins
.fragb
[n
].fragty
),
4116 the_ins
.fragb
[n
].fadd
, the_ins
.fragb
[n
].foff
, to_beg_P
);
4118 n
= (the_ins
.numo
- the_ins
.fragb
[n
- 1].fragoff
);
4119 shorts_this_frag
= 0;
4122 toP
= frag_more (n
* 2);
4125 md_number_to_chars (toP
, (long) (*fromP
), 2);
4131 for (m
= 0; m
< the_ins
.nrel
; m
++)
4135 wid
= the_ins
.reloc
[m
].wid
;
4138 the_ins
.reloc
[m
].wid
= 0;
4139 wid
= (wid
== 'b') ? 1 : (wid
== 'w') ? 2 : (wid
== 'l') ? 4 : 4000;
4141 fixP
= fix_new_exp (frag_now
,
4142 ((the_ins
.reloc
[m
].n
+ toP
- frag_now
->fr_literal
)
4143 - shorts_this_frag
* 2),
4145 &the_ins
.reloc
[m
].exp
,
4146 the_ins
.reloc
[m
].pcrel
,
4147 get_reloc_code (wid
, the_ins
.reloc
[m
].pcrel
,
4148 the_ins
.reloc
[m
].pic_reloc
));
4149 fixP
->fx_pcrel_adjust
= the_ins
.reloc
[m
].pcrel_fix
;
4153 /* Comparison function used by qsort to rank the opcode entries by name. */
4156 m68k_compare_opcode (const void * v1
, const void * v2
)
4158 struct m68k_opcode
* op1
, * op2
;
4164 op1
= *(struct m68k_opcode
**) v1
;
4165 op2
= *(struct m68k_opcode
**) v2
;
4167 /* Compare the two names. If different, return the comparison.
4168 If the same, return the order they are in the opcode table. */
4169 ret
= strcmp (op1
->name
, op2
->name
);
4180 const struct m68k_opcode
*ins
;
4181 struct m68k_incant
*hack
, *slak
;
4182 const char *retval
= 0; /* Empty string, or error msg text. */
4185 /* Set up hash tables with 68000 instructions.
4186 similar to what the vax assembler does. */
4187 /* RMS claims the thing to do is take the m68k-opcode.h table, and make
4188 a copy of it at runtime, adding in the information we want but isn't
4189 there. I think it'd be better to have an awk script hack the table
4190 at compile time. Or even just xstr the table and use it as-is. But
4191 my lord ghod hath spoken, so we do it this way. Excuse the ugly var
4196 flag_reg_prefix_optional
= 1;
4198 if (! m68k_rel32_from_cmdline
)
4202 /* First sort the opcode table into alphabetical order to seperate
4203 the order that the assembler wants to see the opcodes from the
4204 order that the disassembler wants to see them. */
4205 m68k_sorted_opcodes
= xmalloc (m68k_numopcodes
* sizeof (* m68k_sorted_opcodes
));
4206 if (!m68k_sorted_opcodes
)
4207 as_fatal (_("Internal Error: Can't allocate m68k_sorted_opcodes of size %d"),
4208 m68k_numopcodes
* ((int) sizeof (* m68k_sorted_opcodes
)));
4210 for (i
= m68k_numopcodes
; i
--;)
4211 m68k_sorted_opcodes
[i
] = m68k_opcodes
+ i
;
4213 qsort (m68k_sorted_opcodes
, m68k_numopcodes
,
4214 sizeof (m68k_sorted_opcodes
[0]), m68k_compare_opcode
);
4216 op_hash
= hash_new ();
4218 obstack_begin (&robyn
, 4000);
4219 for (i
= 0; i
< m68k_numopcodes
; i
++)
4221 hack
= slak
= (struct m68k_incant
*) obstack_alloc (&robyn
, sizeof (struct m68k_incant
));
4224 ins
= m68k_sorted_opcodes
[i
];
4226 /* We *could* ignore insns that don't match our
4227 arch here by just leaving them out of the hash. */
4228 slak
->m_operands
= ins
->args
;
4229 slak
->m_opnum
= strlen (slak
->m_operands
) / 2;
4230 slak
->m_arch
= ins
->arch
;
4231 slak
->m_opcode
= ins
->opcode
;
4232 /* This is kludgey. */
4233 slak
->m_codenum
= ((ins
->match
) & 0xffffL
) ? 2 : 1;
4234 if (i
+ 1 != m68k_numopcodes
4235 && !strcmp (ins
->name
, m68k_sorted_opcodes
[i
+ 1]->name
))
4237 slak
->m_next
= obstack_alloc (&robyn
, sizeof (struct m68k_incant
));
4242 slak
= slak
->m_next
;
4246 retval
= hash_insert (op_hash
, ins
->name
, (char *) hack
);
4248 as_fatal (_("Internal Error: Can't hash %s: %s"), ins
->name
, retval
);
4251 for (i
= 0; i
< m68k_numaliases
; i
++)
4253 const char *name
= m68k_opcode_aliases
[i
].primary
;
4254 const char *alias
= m68k_opcode_aliases
[i
].alias
;
4255 PTR val
= hash_find (op_hash
, name
);
4258 as_fatal (_("Internal Error: Can't find %s in hash table"), name
);
4259 retval
= hash_insert (op_hash
, alias
, val
);
4261 as_fatal (_("Internal Error: Can't hash %s: %s"), alias
, retval
);
4264 /* In MRI mode, all unsized branches are variable sized. Normally,
4265 they are word sized. */
4268 static struct m68k_opcode_alias mri_aliases
[] =
4289 i
< (int) (sizeof mri_aliases
/ sizeof mri_aliases
[0]);
4292 const char *name
= mri_aliases
[i
].primary
;
4293 const char *alias
= mri_aliases
[i
].alias
;
4294 PTR val
= hash_find (op_hash
, name
);
4297 as_fatal (_("Internal Error: Can't find %s in hash table"), name
);
4298 retval
= hash_jam (op_hash
, alias
, val
);
4300 as_fatal (_("Internal Error: Can't hash %s: %s"), alias
, retval
);
4304 for (i
= 0; i
< (int) sizeof (notend_table
); i
++)
4306 notend_table
[i
] = 0;
4307 alt_notend_table
[i
] = 0;
4310 notend_table
[','] = 1;
4311 notend_table
['{'] = 1;
4312 notend_table
['}'] = 1;
4313 alt_notend_table
['a'] = 1;
4314 alt_notend_table
['A'] = 1;
4315 alt_notend_table
['d'] = 1;
4316 alt_notend_table
['D'] = 1;
4317 alt_notend_table
['#'] = 1;
4318 alt_notend_table
['&'] = 1;
4319 alt_notend_table
['f'] = 1;
4320 alt_notend_table
['F'] = 1;
4321 #ifdef REGISTER_PREFIX
4322 alt_notend_table
[REGISTER_PREFIX
] = 1;
4325 /* We need to put '(' in alt_notend_table to handle
4326 cas2 %d0:%d2,%d3:%d4,(%a0):(%a1) */
4327 alt_notend_table
['('] = 1;
4329 /* We need to put '@' in alt_notend_table to handle
4330 cas2 %d0:%d2,%d3:%d4,@(%d0):@(%d1) */
4331 alt_notend_table
['@'] = 1;
4333 /* We need to put digits in alt_notend_table to handle
4334 bfextu %d0{24:1},%d0 */
4335 alt_notend_table
['0'] = 1;
4336 alt_notend_table
['1'] = 1;
4337 alt_notend_table
['2'] = 1;
4338 alt_notend_table
['3'] = 1;
4339 alt_notend_table
['4'] = 1;
4340 alt_notend_table
['5'] = 1;
4341 alt_notend_table
['6'] = 1;
4342 alt_notend_table
['7'] = 1;
4343 alt_notend_table
['8'] = 1;
4344 alt_notend_table
['9'] = 1;
4346 #ifndef MIT_SYNTAX_ONLY
4347 /* Insert pseudo ops, these have to go into the opcode table since
4348 gas expects pseudo ops to start with a dot. */
4352 while (mote_pseudo_table
[n
].poc_name
)
4354 hack
= obstack_alloc (&robyn
, sizeof (struct m68k_incant
));
4355 hash_insert (op_hash
,
4356 mote_pseudo_table
[n
].poc_name
, (char *) hack
);
4357 hack
->m_operands
= 0;
4367 record_alignment (text_section
, 2);
4368 record_alignment (data_section
, 2);
4369 record_alignment (bss_section
, 2);
4374 /* This is called when a label is defined. */
4377 m68k_frob_label (symbolS
*sym
)
4379 struct label_line
*n
;
4381 n
= (struct label_line
*) xmalloc (sizeof *n
);
4384 as_where (&n
->file
, &n
->line
);
4390 dwarf2_emit_label (sym
);
4394 /* This is called when a value that is not an instruction is emitted. */
4397 m68k_flush_pending_output (void)
4399 current_label
= NULL
;
4402 /* This is called at the end of the assembly, when the final value of
4403 the label is known. We warn if this is a text symbol aligned at an
4407 m68k_frob_symbol (symbolS
*sym
)
4409 if (S_GET_SEGMENT (sym
) == reg_section
4410 && (int) S_GET_VALUE (sym
) < 0)
4412 S_SET_SEGMENT (sym
, absolute_section
);
4413 S_SET_VALUE (sym
, ~(int)S_GET_VALUE (sym
));
4415 else if ((S_GET_VALUE (sym
) & 1) != 0)
4417 struct label_line
*l
;
4419 for (l
= labels
; l
!= NULL
; l
= l
->next
)
4421 if (l
->label
== sym
)
4424 as_warn_where (l
->file
, l
->line
,
4425 _("text label `%s' aligned to odd boundary"),
4433 /* This is called if we go in or out of MRI mode because of the .mri
4437 m68k_mri_mode_change (int on
)
4441 if (! flag_reg_prefix_optional
)
4443 flag_reg_prefix_optional
= 1;
4444 #ifdef REGISTER_PREFIX
4449 if (! m68k_rel32_from_cmdline
)
4454 if (! reg_prefix_optional_seen
)
4456 #ifdef REGISTER_PREFIX_OPTIONAL
4457 flag_reg_prefix_optional
= REGISTER_PREFIX_OPTIONAL
;
4459 flag_reg_prefix_optional
= 0;
4461 #ifdef REGISTER_PREFIX
4466 if (! m68k_rel32_from_cmdline
)
4471 /* Equal to MAX_PRECISION in atof-ieee.c. */
4472 #define MAX_LITTLENUMS 6
4474 /* Turn a string in input_line_pointer into a floating point constant
4475 of type TYPE, and store the appropriate bytes in *LITP. The number
4476 of LITTLENUMS emitted is stored in *SIZEP. An error message is
4477 returned, or NULL on OK. */
4480 md_atof (int type
, char *litP
, int *sizeP
)
4483 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
4484 LITTLENUM_TYPE
*wordP
;
4515 return _("Bad call to MD_ATOF()");
4517 t
= atof_ieee (input_line_pointer
, type
, words
);
4519 input_line_pointer
= t
;
4521 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
4522 for (wordP
= words
; prec
--;)
4524 md_number_to_chars (litP
, (long) (*wordP
++), sizeof (LITTLENUM_TYPE
));
4525 litP
+= sizeof (LITTLENUM_TYPE
);
4531 md_number_to_chars (char *buf
, valueT val
, int n
)
4533 number_to_chars_bigendian (buf
, val
, n
);
4537 md_apply_fix (fixS
*fixP
, valueT
*valP
, segT seg ATTRIBUTE_UNUSED
)
4539 offsetT val
= *valP
;
4540 addressT upper_limit
;
4541 offsetT lower_limit
;
4543 /* This is unnecessary but it convinces the native rs6000 compiler
4544 to generate the code we want. */
4545 char *buf
= fixP
->fx_frag
->fr_literal
;
4546 buf
+= fixP
->fx_where
;
4547 /* End ibm compiler workaround. */
4551 if (fixP
->fx_addsy
== NULL
&& fixP
->fx_pcrel
== 0)
4557 memset (buf
, 0, fixP
->fx_size
);
4558 fixP
->fx_addnumber
= val
; /* Remember value for emit_reloc. */
4560 if (fixP
->fx_r_type
== BFD_RELOC_VTABLE_INHERIT
4561 && !S_IS_DEFINED (fixP
->fx_addsy
)
4562 && !S_IS_WEAK (fixP
->fx_addsy
))
4563 S_SET_WEAK (fixP
->fx_addsy
);
4568 if (fixP
->fx_r_type
== BFD_RELOC_VTABLE_INHERIT
4569 || fixP
->fx_r_type
== BFD_RELOC_VTABLE_ENTRY
)
4572 switch (fixP
->fx_size
)
4574 /* The cast to offsetT below are necessary to make code
4575 correct for machines where ints are smaller than offsetT. */
4579 lower_limit
= - (offsetT
) 0x80;
4582 *buf
++ = (val
>> 8);
4584 upper_limit
= 0x7fff;
4585 lower_limit
= - (offsetT
) 0x8000;
4588 *buf
++ = (val
>> 24);
4589 *buf
++ = (val
>> 16);
4590 *buf
++ = (val
>> 8);
4592 upper_limit
= 0x7fffffff;
4593 lower_limit
= - (offsetT
) 0x7fffffff - 1; /* Avoid constant overflow. */
4596 BAD_CASE (fixP
->fx_size
);
4599 /* Fix up a negative reloc. */
4600 if (fixP
->fx_addsy
== NULL
&& fixP
->fx_subsy
!= NULL
)
4602 fixP
->fx_addsy
= fixP
->fx_subsy
;
4603 fixP
->fx_subsy
= NULL
;
4607 /* For non-pc-relative values, it's conceivable we might get something
4608 like "0xff" for a byte field. So extend the upper part of the range
4609 to accept such numbers. We arbitrarily disallow "-0xff" or "0xff+0xff",
4610 so that we can do any range checking at all. */
4611 if (! fixP
->fx_pcrel
&& ! fixP
->fx_signed
)
4612 upper_limit
= upper_limit
* 2 + 1;
4614 if ((addressT
) val
> upper_limit
4615 && (val
> 0 || val
< lower_limit
))
4616 as_bad_where (fixP
->fx_file
, fixP
->fx_line
, _("value out of range"));
4618 /* A one byte PC-relative reloc means a short branch. We can't use
4619 a short branch with a value of 0 or -1, because those indicate
4620 different opcodes (branches with longer offsets). fixup_segment
4621 in write.c may have clobbered fx_pcrel, so we need to examine the
4624 || fixP
->fx_r_type
== BFD_RELOC_8_PCREL
)
4625 && fixP
->fx_size
== 1
4626 && (fixP
->fx_addsy
== NULL
4627 || S_IS_DEFINED (fixP
->fx_addsy
))
4628 && (val
== 0 || val
== -1))
4629 as_bad_where (fixP
->fx_file
, fixP
->fx_line
, _("invalid byte branch offset"));
4632 /* *fragP has been relaxed to its final size, and now needs to have
4633 the bytes inside it modified to conform to the new size There is UGLY
4637 md_convert_frag_1 (fragS
*fragP
)
4642 /* Address in object code of the displacement. */
4643 register int object_address
= fragP
->fr_fix
+ fragP
->fr_address
;
4645 /* Address in gas core of the place to store the displacement. */
4646 /* This convinces the native rs6000 compiler to generate the code we
4648 register char *buffer_address
= fragP
->fr_literal
;
4649 buffer_address
+= fragP
->fr_fix
;
4650 /* End ibm compiler workaround. */
4652 /* The displacement of the address, from current location. */
4653 disp
= fragP
->fr_symbol
? S_GET_VALUE (fragP
->fr_symbol
) : 0;
4654 disp
= (disp
+ fragP
->fr_offset
) - object_address
;
4656 switch (fragP
->fr_subtype
)
4658 case TAB (BRANCHBWL
, BYTE
):
4659 case TAB (BRABSJUNC
, BYTE
):
4660 case TAB (BRABSJCOND
, BYTE
):
4661 case TAB (BRANCHBW
, BYTE
):
4662 know (issbyte (disp
));
4664 as_bad_where (fragP
->fr_file
, fragP
->fr_line
,
4665 _("short branch with zero offset: use :w"));
4666 fixP
= fix_new (fragP
, fragP
->fr_fix
- 1, 1, fragP
->fr_symbol
,
4667 fragP
->fr_offset
, 1, RELAX_RELOC_PC8
);
4668 fixP
->fx_pcrel_adjust
= -1;
4670 case TAB (BRANCHBWL
, SHORT
):
4671 case TAB (BRABSJUNC
, SHORT
):
4672 case TAB (BRABSJCOND
, SHORT
):
4673 case TAB (BRANCHBW
, SHORT
):
4674 fragP
->fr_opcode
[1] = 0x00;
4675 fix_new (fragP
, fragP
->fr_fix
, 2, fragP
->fr_symbol
, fragP
->fr_offset
,
4676 1, RELAX_RELOC_PC16
);
4679 case TAB (BRANCHBWL
, LONG
):
4680 fragP
->fr_opcode
[1] = (char) 0xFF;
4681 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4682 1, RELAX_RELOC_PC32
);
4685 case TAB (BRABSJUNC
, LONG
):
4686 if (fragP
->fr_opcode
[0] == 0x61) /* jbsr */
4688 if (flag_keep_pcrel
)
4689 as_fatal (_("Tried to convert PC relative BSR to absolute JSR"));
4690 fragP
->fr_opcode
[0] = 0x4E;
4691 fragP
->fr_opcode
[1] = (char) 0xB9; /* JSR with ABSL LONG operand. */
4692 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4693 0, RELAX_RELOC_ABS32
);
4696 else if (fragP
->fr_opcode
[0] == 0x60) /* jbra */
4698 if (flag_keep_pcrel
)
4699 as_fatal (_("Tried to convert PC relative branch to absolute jump"));
4700 fragP
->fr_opcode
[0] = 0x4E;
4701 fragP
->fr_opcode
[1] = (char) 0xF9; /* JMP with ABSL LONG operand. */
4702 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4703 0, RELAX_RELOC_ABS32
);
4708 /* This cannot happen, because jbsr and jbra are the only two
4709 unconditional branches. */
4713 case TAB (BRABSJCOND
, LONG
):
4714 if (flag_keep_pcrel
)
4715 as_fatal (_("Tried to convert PC relative conditional branch to absolute jump"));
4717 /* Only Bcc 68000 instructions can come here
4718 Change bcc into b!cc/jmp absl long. */
4719 fragP
->fr_opcode
[0] ^= 0x01; /* Invert bcc. */
4720 fragP
->fr_opcode
[1] = 0x06; /* Branch offset = 6. */
4722 /* JF: these used to be fr_opcode[2,3], but they may be in a
4723 different frag, in which case referring to them is a no-no.
4724 Only fr_opcode[0,1] are guaranteed to work. */
4725 *buffer_address
++ = 0x4e; /* put in jmp long (0x4ef9) */
4726 *buffer_address
++ = (char) 0xf9;
4727 fragP
->fr_fix
+= 2; /* Account for jmp instruction. */
4728 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
,
4729 fragP
->fr_offset
, 0, RELAX_RELOC_ABS32
);
4732 case TAB (FBRANCH
, SHORT
):
4733 know ((fragP
->fr_opcode
[1] & 0x40) == 0);
4734 fix_new (fragP
, fragP
->fr_fix
, 2, fragP
->fr_symbol
, fragP
->fr_offset
,
4735 1, RELAX_RELOC_PC16
);
4738 case TAB (FBRANCH
, LONG
):
4739 fragP
->fr_opcode
[1] |= 0x40; /* Turn on LONG bit. */
4740 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4741 1, RELAX_RELOC_PC32
);
4744 case TAB (DBCCLBR
, SHORT
):
4745 case TAB (DBCCABSJ
, SHORT
):
4746 fix_new (fragP
, fragP
->fr_fix
, 2, fragP
->fr_symbol
, fragP
->fr_offset
,
4747 1, RELAX_RELOC_PC16
);
4750 case TAB (DBCCLBR
, LONG
):
4751 /* Only DBcc instructions can come here.
4752 Change dbcc into dbcc/bral.
4753 JF: these used to be fr_opcode[2-7], but that's wrong. */
4754 if (flag_keep_pcrel
)
4755 as_fatal (_("Tried to convert DBcc to absolute jump"));
4757 *buffer_address
++ = 0x00; /* Branch offset = 4. */
4758 *buffer_address
++ = 0x04;
4759 *buffer_address
++ = 0x60; /* Put in bra pc+6. */
4760 *buffer_address
++ = 0x06;
4761 *buffer_address
++ = 0x60; /* Put in bral (0x60ff). */
4762 *buffer_address
++ = (char) 0xff;
4764 fragP
->fr_fix
+= 6; /* Account for bra/jmp instructions. */
4765 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
, 1,
4769 case TAB (DBCCABSJ
, LONG
):
4770 /* Only DBcc instructions can come here.
4771 Change dbcc into dbcc/jmp.
4772 JF: these used to be fr_opcode[2-7], but that's wrong. */
4773 if (flag_keep_pcrel
)
4774 as_fatal (_("Tried to convert PC relative conditional branch to absolute jump"));
4776 *buffer_address
++ = 0x00; /* Branch offset = 4. */
4777 *buffer_address
++ = 0x04;
4778 *buffer_address
++ = 0x60; /* Put in bra pc + 6. */
4779 *buffer_address
++ = 0x06;
4780 *buffer_address
++ = 0x4e; /* Put in jmp long (0x4ef9). */
4781 *buffer_address
++ = (char) 0xf9;
4783 fragP
->fr_fix
+= 6; /* Account for bra/jmp instructions. */
4784 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
, 0,
4788 case TAB (PCREL1632
, SHORT
):
4789 fragP
->fr_opcode
[1] &= ~0x3F;
4790 fragP
->fr_opcode
[1] |= 0x3A; /* 072 - mode 7.2 */
4791 fix_new (fragP
, (int) (fragP
->fr_fix
), 2, fragP
->fr_symbol
,
4792 fragP
->fr_offset
, 1, RELAX_RELOC_PC16
);
4795 case TAB (PCREL1632
, LONG
):
4796 /* Already set to mode 7.3; this indicates: PC indirect with
4797 suppressed index, 32-bit displacement. */
4798 *buffer_address
++ = 0x01;
4799 *buffer_address
++ = 0x70;
4801 fixP
= fix_new (fragP
, (int) (fragP
->fr_fix
), 4, fragP
->fr_symbol
,
4802 fragP
->fr_offset
, 1, RELAX_RELOC_PC32
);
4803 fixP
->fx_pcrel_adjust
= 2;
4806 case TAB (PCINDEX
, BYTE
):
4807 assert (fragP
->fr_fix
>= 2);
4808 buffer_address
[-2] &= ~1;
4809 fixP
= fix_new (fragP
, fragP
->fr_fix
- 1, 1, fragP
->fr_symbol
,
4810 fragP
->fr_offset
, 1, RELAX_RELOC_PC8
);
4811 fixP
->fx_pcrel_adjust
= 1;
4813 case TAB (PCINDEX
, SHORT
):
4814 assert (fragP
->fr_fix
>= 2);
4815 buffer_address
[-2] |= 0x1;
4816 buffer_address
[-1] = 0x20;
4817 fixP
= fix_new (fragP
, (int) (fragP
->fr_fix
), 2, fragP
->fr_symbol
,
4818 fragP
->fr_offset
, 1, RELAX_RELOC_PC16
);
4819 fixP
->fx_pcrel_adjust
= 2;
4822 case TAB (PCINDEX
, LONG
):
4823 assert (fragP
->fr_fix
>= 2);
4824 buffer_address
[-2] |= 0x1;
4825 buffer_address
[-1] = 0x30;
4826 fixP
= fix_new (fragP
, (int) (fragP
->fr_fix
), 4, fragP
->fr_symbol
,
4827 fragP
->fr_offset
, 1, RELAX_RELOC_PC32
);
4828 fixP
->fx_pcrel_adjust
= 2;
4831 case TAB (ABSTOPCREL
, SHORT
):
4832 fix_new (fragP
, fragP
->fr_fix
, 2, fragP
->fr_symbol
, fragP
->fr_offset
,
4833 1, RELAX_RELOC_PC16
);
4836 case TAB (ABSTOPCREL
, LONG
):
4837 if (flag_keep_pcrel
)
4838 as_fatal (_("Tried to convert PC relative conditional branch to absolute jump"));
4839 /* The thing to do here is force it to ABSOLUTE LONG, since
4840 ABSTOPCREL is really trying to shorten an ABSOLUTE address anyway. */
4841 if ((fragP
->fr_opcode
[1] & 0x3F) != 0x3A)
4843 fragP
->fr_opcode
[1] &= ~0x3F;
4844 fragP
->fr_opcode
[1] |= 0x39; /* Mode 7.1 */
4845 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4846 0, RELAX_RELOC_ABS32
);
4853 md_convert_frag (bfd
*abfd ATTRIBUTE_UNUSED
,
4854 segT sec ATTRIBUTE_UNUSED
,
4857 md_convert_frag_1 (fragP
);
4860 /* Force truly undefined symbols to their maximum size, and generally set up
4861 the frag list to be relaxed
4864 md_estimate_size_before_relax (fragS
*fragP
, segT segment
)
4866 /* Handle SZ_UNDEF first, it can be changed to BYTE or SHORT. */
4867 switch (fragP
->fr_subtype
)
4869 case TAB (BRANCHBWL
, SZ_UNDEF
):
4870 case TAB (BRABSJUNC
, SZ_UNDEF
):
4871 case TAB (BRABSJCOND
, SZ_UNDEF
):
4873 if (S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4874 && relaxable_symbol (fragP
->fr_symbol
))
4876 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), BYTE
);
4878 else if (flag_short_refs
)
4880 /* Symbol is undefined and we want short ref. */
4881 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), SHORT
);
4885 /* Symbol is still undefined. Make it LONG. */
4886 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), LONG
);
4891 case TAB (BRANCHBW
, SZ_UNDEF
):
4893 if (S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4894 && relaxable_symbol (fragP
->fr_symbol
))
4896 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), BYTE
);
4900 /* Symbol is undefined and we don't have long branches. */
4901 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), SHORT
);
4906 case TAB (FBRANCH
, SZ_UNDEF
):
4907 case TAB (DBCCLBR
, SZ_UNDEF
):
4908 case TAB (DBCCABSJ
, SZ_UNDEF
):
4909 case TAB (PCREL1632
, SZ_UNDEF
):
4911 if ((S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4912 && relaxable_symbol (fragP
->fr_symbol
))
4915 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), SHORT
);
4919 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), LONG
);
4924 case TAB (PCINDEX
, SZ_UNDEF
):
4925 if ((S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4926 && relaxable_symbol (fragP
->fr_symbol
)))
4928 fragP
->fr_subtype
= TAB (PCINDEX
, BYTE
);
4932 fragP
->fr_subtype
= TAB (PCINDEX
, LONG
);
4936 case TAB (ABSTOPCREL
, SZ_UNDEF
):
4938 if ((S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4939 && relaxable_symbol (fragP
->fr_symbol
)))
4941 fragP
->fr_subtype
= TAB (ABSTOPCREL
, SHORT
);
4945 fragP
->fr_subtype
= TAB (ABSTOPCREL
, LONG
);
4954 /* Now that SZ_UNDEF are taken care of, check others. */
4955 switch (fragP
->fr_subtype
)
4957 case TAB (BRANCHBWL
, BYTE
):
4958 case TAB (BRABSJUNC
, BYTE
):
4959 case TAB (BRABSJCOND
, BYTE
):
4960 case TAB (BRANCHBW
, BYTE
):
4961 /* We can't do a short jump to the next instruction, so in that
4962 case we force word mode. If the symbol is at the start of a
4963 frag, and it is the next frag with any data in it (usually
4964 this is just the next frag, but assembler listings may
4965 introduce empty frags), we must use word mode. */
4966 if (fragP
->fr_symbol
)
4970 sym_frag
= symbol_get_frag (fragP
->fr_symbol
);
4971 if (S_GET_VALUE (fragP
->fr_symbol
) == sym_frag
->fr_address
)
4975 for (l
= fragP
->fr_next
; l
&& l
!= sym_frag
; l
= l
->fr_next
)
4979 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), SHORT
);
4986 return md_relax_table
[fragP
->fr_subtype
].rlx_length
;
4989 #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
4990 /* the bit-field entries in the relocation_info struct plays hell
4991 with the byte-order problems of cross-assembly. So as a hack,
4992 I added this mach. dependent ri twiddler. Ugly, but it gets
4994 /* on m68k: first 4 bytes are normal unsigned long, next three bytes
4995 are symbolnum, most sig. byte first. Last byte is broken up with
4996 bit 7 as pcrel, bits 6 & 5 as length, bit 4 as pcrel, and the lower
4997 nibble as nuthin. (on Sun 3 at least) */
4998 /* Translate the internal relocation information into target-specific
5002 md_ri_to_chars (char *the_bytes
, struct reloc_info_generic
*ri
)
5005 md_number_to_chars (the_bytes
, ri
->r_address
, 4);
5006 /* Now the fun stuff. */
5007 the_bytes
[4] = (ri
->r_symbolnum
>> 16) & 0x0ff;
5008 the_bytes
[5] = (ri
->r_symbolnum
>> 8) & 0x0ff;
5009 the_bytes
[6] = ri
->r_symbolnum
& 0x0ff;
5010 the_bytes
[7] = (((ri
->r_pcrel
<< 7) & 0x80)
5011 | ((ri
->r_length
<< 5) & 0x60)
5012 | ((ri
->r_extern
<< 4) & 0x10));
5017 #endif /* OBJ_AOUT or OBJ_BOUT */
5019 #ifndef WORKING_DOT_WORD
5020 int md_short_jump_size
= 4;
5021 int md_long_jump_size
= 6;
5024 md_create_short_jump (char *ptr
, addressT from_addr
, addressT to_addr
,
5025 fragS
*frag ATTRIBUTE_UNUSED
,
5026 symbolS
*to_symbol ATTRIBUTE_UNUSED
)
5030 offset
= to_addr
- (from_addr
+ 2);
5032 md_number_to_chars (ptr
, (valueT
) 0x6000, 2);
5033 md_number_to_chars (ptr
+ 2, (valueT
) offset
, 2);
5037 md_create_long_jump (char *ptr
, addressT from_addr
, addressT to_addr
,
5038 fragS
*frag
, symbolS
*to_symbol
)
5042 if (!HAVE_LONG_BRANCH (current_architecture
))
5044 if (flag_keep_pcrel
)
5045 as_fatal (_("Tried to convert PC relative branch to absolute jump"));
5046 offset
= to_addr
- S_GET_VALUE (to_symbol
);
5047 md_number_to_chars (ptr
, (valueT
) 0x4EF9, 2);
5048 md_number_to_chars (ptr
+ 2, (valueT
) offset
, 4);
5049 fix_new (frag
, (ptr
+ 2) - frag
->fr_literal
, 4, to_symbol
, (offsetT
) 0,
5054 offset
= to_addr
- (from_addr
+ 2);
5055 md_number_to_chars (ptr
, (valueT
) 0x60ff, 2);
5056 md_number_to_chars (ptr
+ 2, (valueT
) offset
, 4);
5062 /* Different values of OK tell what its OK to return. Things that
5063 aren't OK are an error (what a shock, no?)
5066 10: Absolute 1:8 only
5067 20: Absolute 0:7 only
5068 30: absolute 0:15 only
5069 40: Absolute 0:31 only
5070 50: absolute 0:127 only
5071 55: absolute -64:63 only
5072 60: absolute -128:127 only
5073 70: absolute 0:4095 only
5074 80: absolute -1, 1:7 only
5078 get_num (struct m68k_exp
*exp
, int ok
)
5080 if (exp
->exp
.X_op
== O_absent
)
5082 /* Do the same thing the VAX asm does. */
5083 op (exp
) = O_constant
;
5089 as_warn (_("expression out of range: defaulting to 1"));
5093 else if (exp
->exp
.X_op
== O_constant
)
5098 if ((valueT
) TRUNC (offs (exp
)) - 1 > 7)
5100 as_warn (_("expression out of range: defaulting to 1"));
5105 if ((valueT
) TRUNC (offs (exp
)) > 7)
5109 if ((valueT
) TRUNC (offs (exp
)) > 15)
5113 if ((valueT
) TRUNC (offs (exp
)) > 32)
5117 if ((valueT
) TRUNC (offs (exp
)) > 127)
5121 if ((valueT
) SEXT (offs (exp
)) + 64 > 127)
5125 if ((valueT
) SEXT (offs (exp
)) + 128 > 255)
5129 if ((valueT
) TRUNC (offs (exp
)) > 4095)
5132 as_warn (_("expression out of range: defaulting to 0"));
5137 if ((valueT
) TRUNC (offs (exp
)) != 0xffffffff
5138 && (valueT
) TRUNC (offs (exp
)) - 1 > 6)
5140 as_warn (_("expression out of range: defaulting to 1"));
5148 else if (exp
->exp
.X_op
== O_big
)
5150 if (offs (exp
) <= 0 /* flonum. */
5151 && (ok
== 90 /* no bignums */
5152 || (ok
> 10 /* Small-int ranges including 0 ok. */
5153 /* If we have a flonum zero, a zero integer should
5154 do as well (e.g., in moveq). */
5155 && generic_floating_point_number
.exponent
== 0
5156 && generic_floating_point_number
.low
[0] == 0)))
5158 /* HACK! Turn it into a long. */
5159 LITTLENUM_TYPE words
[6];
5161 gen_to_words (words
, 2, 8L); /* These numbers are magic! */
5162 op (exp
) = O_constant
;
5165 offs (exp
) = words
[1] | (words
[0] << 16);
5169 op (exp
) = O_constant
;
5172 offs (exp
) = (ok
== 10) ? 1 : 0;
5173 as_warn (_("Can't deal with expression; defaulting to %ld"),
5179 if (ok
>= 10 && ok
<= 80)
5181 op (exp
) = O_constant
;
5184 offs (exp
) = (ok
== 10) ? 1 : 0;
5185 as_warn (_("Can't deal with expression; defaulting to %ld"),
5190 if (exp
->size
!= SIZE_UNSPEC
)
5198 if (!isbyte (offs (exp
)))
5199 as_warn (_("expression doesn't fit in BYTE"));
5202 if (!isword (offs (exp
)))
5203 as_warn (_("expression doesn't fit in WORD"));
5211 /* These are the back-ends for the various machine dependent pseudo-ops. */
5214 s_data1 (int ignore ATTRIBUTE_UNUSED
)
5216 subseg_set (data_section
, 1);
5217 demand_empty_rest_of_line ();
5221 s_data2 (int ignore ATTRIBUTE_UNUSED
)
5223 subseg_set (data_section
, 2);
5224 demand_empty_rest_of_line ();
5228 s_bss (int ignore ATTRIBUTE_UNUSED
)
5230 /* We don't support putting frags in the BSS segment, we fake it
5231 by marking in_bss, then looking at s_skip for clues. */
5233 subseg_set (bss_section
, 0);
5234 demand_empty_rest_of_line ();
5238 s_even (int ignore ATTRIBUTE_UNUSED
)
5241 register long temp_fill
;
5243 temp
= 1; /* JF should be 2? */
5244 temp_fill
= get_absolute_expression ();
5245 if (!need_pass_2
) /* Never make frag if expect extra pass. */
5246 frag_align (temp
, (int) temp_fill
, 0);
5247 demand_empty_rest_of_line ();
5248 record_alignment (now_seg
, temp
);
5252 s_proc (int ignore ATTRIBUTE_UNUSED
)
5254 demand_empty_rest_of_line ();
5257 /* Pseudo-ops handled for MRI compatibility. */
5259 /* This function returns non-zero if the argument is a conditional
5260 pseudo-op. This is called when checking whether a pending
5261 alignment is needed. */
5264 m68k_conditional_pseudoop (pseudo_typeS
*pop
)
5266 return (pop
->poc_handler
== s_mri_if
5267 || pop
->poc_handler
== s_mri_else
);
5270 /* Handle an MRI style chip specification. */
5279 s
= input_line_pointer
;
5280 /* We can't use get_symbol_end since the processor names are not proper
5282 while (is_part_of_name (c
= *input_line_pointer
++))
5284 *--input_line_pointer
= 0;
5285 for (i
= 0; m68k_cpus
[i
].name
; i
++)
5286 if (strcasecmp (s
, m68k_cpus
[i
].name
) == 0)
5288 if (!m68k_cpus
[i
].name
)
5290 as_bad (_("%s: unrecognized processor name"), s
);
5291 *input_line_pointer
= c
;
5292 ignore_rest_of_line ();
5295 *input_line_pointer
= c
;
5297 if (*input_line_pointer
== '/')
5298 current_architecture
= 0;
5300 current_architecture
&= m68881
| m68851
;
5301 current_architecture
|= m68k_cpus
[i
].arch
& ~(m68881
| m68851
);
5302 control_regs
= m68k_cpus
[i
].control_regs
;
5304 while (*input_line_pointer
== '/')
5306 ++input_line_pointer
;
5307 s
= input_line_pointer
;
5308 /* We can't use get_symbol_end since the processor names are not
5310 while (is_part_of_name (c
= *input_line_pointer
++))
5312 *--input_line_pointer
= 0;
5313 if (strcmp (s
, "68881") == 0)
5314 current_architecture
|= m68881
;
5315 else if (strcmp (s
, "68851") == 0)
5316 current_architecture
|= m68851
;
5317 *input_line_pointer
= c
;
5321 /* The MRI CHIP pseudo-op. */
5324 s_chip (int ignore ATTRIBUTE_UNUSED
)
5330 stop
= mri_comment_field (&stopc
);
5333 mri_comment_end (stop
, stopc
);
5334 demand_empty_rest_of_line ();
5337 /* The MRI FOPT pseudo-op. */
5340 s_fopt (int ignore ATTRIBUTE_UNUSED
)
5344 if (strncasecmp (input_line_pointer
, "ID=", 3) == 0)
5348 input_line_pointer
+= 3;
5349 temp
= get_absolute_expression ();
5350 if (temp
< 0 || temp
> 7)
5351 as_bad (_("bad coprocessor id"));
5353 m68k_float_copnum
= COP0
+ temp
;
5357 as_bad (_("unrecognized fopt option"));
5358 ignore_rest_of_line ();
5362 demand_empty_rest_of_line ();
5365 /* The structure used to handle the MRI OPT pseudo-op. */
5369 /* The name of the option. */
5372 /* If this is not NULL, just call this function. The first argument
5373 is the ARG field of this structure, the second argument is
5374 whether the option was negated. */
5375 void (*pfn
) (int arg
, int on
);
5377 /* If this is not NULL, and the PFN field is NULL, set the variable
5378 this points to. Set it to the ARG field if the option was not
5379 negated, and the NOTARG field otherwise. */
5382 /* The value to pass to PFN or to assign to *PVAR. */
5385 /* The value to assign to *PVAR if the option is negated. If PFN is
5386 NULL, and PVAR is not NULL, and ARG and NOTARG are the same, then
5387 the option may not be negated. */
5391 /* The table used to handle the MRI OPT pseudo-op. */
5393 static void skip_to_comma (int, int);
5394 static void opt_nest (int, int);
5395 static void opt_chip (int, int);
5396 static void opt_list (int, int);
5397 static void opt_list_symbols (int, int);
5399 static const struct opt_action opt_table
[] =
5401 { "abspcadd", 0, &m68k_abspcadd
, 1, 0 },
5403 /* We do relaxing, so there is little use for these options. */
5404 { "b", 0, 0, 0, 0 },
5405 { "brs", 0, 0, 0, 0 },
5406 { "brb", 0, 0, 0, 0 },
5407 { "brl", 0, 0, 0, 0 },
5408 { "brw", 0, 0, 0, 0 },
5410 { "c", 0, 0, 0, 0 },
5411 { "cex", 0, 0, 0, 0 },
5412 { "case", 0, &symbols_case_sensitive
, 1, 0 },
5413 { "cl", 0, 0, 0, 0 },
5414 { "cre", 0, 0, 0, 0 },
5415 { "d", 0, &flag_keep_locals
, 1, 0 },
5416 { "e", 0, 0, 0, 0 },
5417 { "f", 0, &flag_short_refs
, 1, 0 },
5418 { "frs", 0, &flag_short_refs
, 1, 0 },
5419 { "frl", 0, &flag_short_refs
, 0, 1 },
5420 { "g", 0, 0, 0, 0 },
5421 { "i", 0, 0, 0, 0 },
5422 { "m", 0, 0, 0, 0 },
5423 { "mex", 0, 0, 0, 0 },
5424 { "mc", 0, 0, 0, 0 },
5425 { "md", 0, 0, 0, 0 },
5426 { "nest", opt_nest
, 0, 0, 0 },
5427 { "next", skip_to_comma
, 0, 0, 0 },
5428 { "o", 0, 0, 0, 0 },
5429 { "old", 0, 0, 0, 0 },
5430 { "op", skip_to_comma
, 0, 0, 0 },
5431 { "pco", 0, 0, 0, 0 },
5432 { "p", opt_chip
, 0, 0, 0 },
5433 { "pcr", 0, 0, 0, 0 },
5434 { "pcs", 0, 0, 0, 0 },
5435 { "r", 0, 0, 0, 0 },
5436 { "quick", 0, &m68k_quick
, 1, 0 },
5437 { "rel32", 0, &m68k_rel32
, 1, 0 },
5438 { "s", opt_list
, 0, 0, 0 },
5439 { "t", opt_list_symbols
, 0, 0, 0 },
5440 { "w", 0, &flag_no_warnings
, 0, 1 },
5444 #define OPTCOUNT ((int) (sizeof opt_table / sizeof opt_table[0]))
5446 /* The MRI OPT pseudo-op. */
5449 s_opt (int ignore ATTRIBUTE_UNUSED
)
5457 const struct opt_action
*o
;
5462 if (*input_line_pointer
== '-')
5464 ++input_line_pointer
;
5467 else if (strncasecmp (input_line_pointer
, "NO", 2) == 0)
5469 input_line_pointer
+= 2;
5473 s
= input_line_pointer
;
5474 c
= get_symbol_end ();
5476 for (i
= 0, o
= opt_table
; i
< OPTCOUNT
; i
++, o
++)
5478 if (strcasecmp (s
, o
->name
) == 0)
5482 /* Restore input_line_pointer now in case the option
5484 *input_line_pointer
= c
;
5485 (*o
->pfn
) (o
->arg
, t
);
5487 else if (o
->pvar
!= NULL
)
5489 if (! t
&& o
->arg
== o
->notarg
)
5490 as_bad (_("option `%s' may not be negated"), s
);
5491 *input_line_pointer
= c
;
5492 *o
->pvar
= t
? o
->arg
: o
->notarg
;
5495 *input_line_pointer
= c
;
5501 as_bad (_("option `%s' not recognized"), s
);
5502 *input_line_pointer
= c
;
5505 while (*input_line_pointer
++ == ',');
5507 /* Move back to terminating character. */
5508 --input_line_pointer
;
5509 demand_empty_rest_of_line ();
5512 /* Skip ahead to a comma. This is used for OPT options which we do
5513 not support and which take arguments. */
5516 skip_to_comma (int arg ATTRIBUTE_UNUSED
, int on ATTRIBUTE_UNUSED
)
5518 while (*input_line_pointer
!= ','
5519 && ! is_end_of_line
[(unsigned char) *input_line_pointer
])
5520 ++input_line_pointer
;
5523 /* Handle the OPT NEST=depth option. */
5526 opt_nest (int arg ATTRIBUTE_UNUSED
, int on ATTRIBUTE_UNUSED
)
5528 if (*input_line_pointer
!= '=')
5530 as_bad (_("bad format of OPT NEST=depth"));
5534 ++input_line_pointer
;
5535 max_macro_nest
= get_absolute_expression ();
5538 /* Handle the OPT P=chip option. */
5541 opt_chip (int arg ATTRIBUTE_UNUSED
, int on ATTRIBUTE_UNUSED
)
5543 if (*input_line_pointer
!= '=')
5545 /* This is just OPT P, which we do not support. */
5549 ++input_line_pointer
;
5553 /* Handle the OPT S option. */
5556 opt_list (int arg ATTRIBUTE_UNUSED
, int on
)
5561 /* Handle the OPT T option. */
5564 opt_list_symbols (int arg ATTRIBUTE_UNUSED
, int on
)
5567 listing
|= LISTING_SYMBOLS
;
5569 listing
&= ~LISTING_SYMBOLS
;
5572 /* Handle the MRI REG pseudo-op. */
5575 s_reg (int ignore ATTRIBUTE_UNUSED
)
5584 if (line_label
== NULL
)
5586 as_bad (_("missing label"));
5587 ignore_rest_of_line ();
5592 stop
= mri_comment_field (&stopc
);
5596 s
= input_line_pointer
;
5597 while (ISALNUM (*input_line_pointer
)
5598 #ifdef REGISTER_PREFIX
5599 || *input_line_pointer
== REGISTER_PREFIX
5601 || *input_line_pointer
== '/'
5602 || *input_line_pointer
== '-')
5603 ++input_line_pointer
;
5604 c
= *input_line_pointer
;
5605 *input_line_pointer
= '\0';
5607 if (m68k_ip_op (s
, &rop
) != 0)
5609 if (rop
.error
== NULL
)
5610 as_bad (_("bad register list"));
5612 as_bad (_("bad register list: %s"), rop
.error
);
5613 *input_line_pointer
= c
;
5614 ignore_rest_of_line ();
5618 *input_line_pointer
= c
;
5620 if (rop
.mode
== REGLST
)
5622 else if (rop
.mode
== DREG
)
5623 mask
= 1 << (rop
.reg
- DATA0
);
5624 else if (rop
.mode
== AREG
)
5625 mask
= 1 << (rop
.reg
- ADDR0
+ 8);
5626 else if (rop
.mode
== FPREG
)
5627 mask
= 1 << (rop
.reg
- FP0
+ 16);
5628 else if (rop
.mode
== CONTROL
5631 else if (rop
.mode
== CONTROL
5634 else if (rop
.mode
== CONTROL
5639 as_bad (_("bad register list"));
5640 ignore_rest_of_line ();
5644 S_SET_SEGMENT (line_label
, reg_section
);
5645 S_SET_VALUE (line_label
, ~mask
);
5646 symbol_set_frag (line_label
, &zero_address_frag
);
5649 mri_comment_end (stop
, stopc
);
5651 demand_empty_rest_of_line ();
5654 /* This structure is used for the MRI SAVE and RESTORE pseudo-ops. */
5658 struct save_opts
*next
;
5660 int symbols_case_sensitive
;
5664 const enum m68k_register
*control_regs
;
5669 /* FIXME: We don't save OPT S. */
5672 /* This variable holds the stack of saved options. */
5674 static struct save_opts
*save_stack
;
5676 /* The MRI SAVE pseudo-op. */
5679 s_save (int ignore ATTRIBUTE_UNUSED
)
5681 struct save_opts
*s
;
5683 s
= (struct save_opts
*) xmalloc (sizeof (struct save_opts
));
5684 s
->abspcadd
= m68k_abspcadd
;
5685 s
->symbols_case_sensitive
= symbols_case_sensitive
;
5686 s
->keep_locals
= flag_keep_locals
;
5687 s
->short_refs
= flag_short_refs
;
5688 s
->architecture
= current_architecture
;
5689 s
->control_regs
= control_regs
;
5690 s
->quick
= m68k_quick
;
5691 s
->rel32
= m68k_rel32
;
5692 s
->listing
= listing
;
5693 s
->no_warnings
= flag_no_warnings
;
5695 s
->next
= save_stack
;
5698 demand_empty_rest_of_line ();
5701 /* The MRI RESTORE pseudo-op. */
5704 s_restore (int ignore ATTRIBUTE_UNUSED
)
5706 struct save_opts
*s
;
5708 if (save_stack
== NULL
)
5710 as_bad (_("restore without save"));
5711 ignore_rest_of_line ();
5716 save_stack
= s
->next
;
5718 m68k_abspcadd
= s
->abspcadd
;
5719 symbols_case_sensitive
= s
->symbols_case_sensitive
;
5720 flag_keep_locals
= s
->keep_locals
;
5721 flag_short_refs
= s
->short_refs
;
5722 current_architecture
= s
->architecture
;
5723 control_regs
= s
->control_regs
;
5724 m68k_quick
= s
->quick
;
5725 m68k_rel32
= s
->rel32
;
5726 listing
= s
->listing
;
5727 flag_no_warnings
= s
->no_warnings
;
5731 demand_empty_rest_of_line ();
5734 /* Types of MRI structured control directives. */
5736 enum mri_control_type
5744 /* This structure is used to stack the MRI structured control
5747 struct mri_control_info
5749 /* The directive within which this one is enclosed. */
5750 struct mri_control_info
*outer
;
5752 /* The type of directive. */
5753 enum mri_control_type type
;
5755 /* Whether an ELSE has been in an IF. */
5758 /* The add or sub statement at the end of a FOR. */
5761 /* The label of the top of a FOR or REPEAT loop. */
5764 /* The label to jump to for the next iteration, or the else
5765 expression of a conditional. */
5768 /* The label to jump to to break out of the loop, or the label past
5769 the end of a conditional. */
5773 /* The stack of MRI structured control directives. */
5775 static struct mri_control_info
*mri_control_stack
;
5777 /* The current MRI structured control directive index number, used to
5778 generate label names. */
5780 static int mri_control_index
;
5782 /* Assemble an instruction for an MRI structured control directive. */
5785 mri_assemble (char *str
)
5789 /* md_assemble expects the opcode to be in lower case. */
5790 for (s
= str
; *s
!= ' ' && *s
!= '\0'; s
++)
5796 /* Generate a new MRI label structured control directive label name. */
5799 mri_control_label (void)
5803 n
= (char *) xmalloc (20);
5804 sprintf (n
, "%smc%d", FAKE_LABEL_NAME
, mri_control_index
);
5805 ++mri_control_index
;
5809 /* Create a new MRI structured control directive. */
5811 static struct mri_control_info
*
5812 push_mri_control (enum mri_control_type type
)
5814 struct mri_control_info
*n
;
5816 n
= (struct mri_control_info
*) xmalloc (sizeof (struct mri_control_info
));
5820 if (type
== mri_if
|| type
== mri_while
)
5823 n
->top
= mri_control_label ();
5824 n
->next
= mri_control_label ();
5825 n
->bottom
= mri_control_label ();
5827 n
->outer
= mri_control_stack
;
5828 mri_control_stack
= n
;
5833 /* Pop off the stack of MRI structured control directives. */
5836 pop_mri_control (void)
5838 struct mri_control_info
*n
;
5840 n
= mri_control_stack
;
5841 mri_control_stack
= n
->outer
;
5849 /* Recognize a condition code in an MRI structured control expression. */
5852 parse_mri_condition (int *pcc
)
5856 know (*input_line_pointer
== '<');
5858 ++input_line_pointer
;
5859 c1
= *input_line_pointer
++;
5860 c2
= *input_line_pointer
++;
5862 if (*input_line_pointer
!= '>')
5864 as_bad (_("syntax error in structured control directive"));
5868 ++input_line_pointer
;
5874 *pcc
= (c1
<< 8) | c2
;
5879 /* Parse a single operand in an MRI structured control expression. */
5882 parse_mri_control_operand (int *pcc
, char **leftstart
, char **leftstop
,
5883 char **rightstart
, char **rightstop
)
5895 if (*input_line_pointer
== '<')
5897 /* It's just a condition code. */
5898 return parse_mri_condition (pcc
);
5901 /* Look ahead for the condition code. */
5902 for (s
= input_line_pointer
; *s
!= '\0'; ++s
)
5904 if (*s
== '<' && s
[1] != '\0' && s
[2] != '\0' && s
[3] == '>')
5909 as_bad (_("missing condition code in structured control directive"));
5913 *leftstart
= input_line_pointer
;
5915 if (*leftstop
> *leftstart
5916 && ((*leftstop
)[-1] == ' ' || (*leftstop
)[-1] == '\t'))
5919 input_line_pointer
= s
;
5920 if (! parse_mri_condition (pcc
))
5923 /* Look ahead for AND or OR or end of line. */
5924 for (s
= input_line_pointer
; *s
!= '\0'; ++s
)
5926 /* We must make sure we don't misinterpret AND/OR at the end of labels!
5927 if d0 <eq> #FOOAND and d1 <ne> #BAROR then
5929 if ((s
== input_line_pointer
5932 && ((strncasecmp (s
, "AND", 3) == 0
5933 && (s
[3] == '.' || ! is_part_of_name (s
[3])))
5934 || (strncasecmp (s
, "OR", 2) == 0
5935 && (s
[2] == '.' || ! is_part_of_name (s
[2])))))
5939 *rightstart
= input_line_pointer
;
5941 if (*rightstop
> *rightstart
5942 && ((*rightstop
)[-1] == ' ' || (*rightstop
)[-1] == '\t'))
5945 input_line_pointer
= s
;
5950 #define MCC(b1, b2) (((b1) << 8) | (b2))
5952 /* Swap the sense of a condition. This changes the condition so that
5953 it generates the same result when the operands are swapped. */
5956 swap_mri_condition (int cc
)
5960 case MCC ('h', 'i'): return MCC ('c', 's');
5961 case MCC ('l', 's'): return MCC ('c', 'c');
5962 /* <HS> is an alias for <CC>. */
5963 case MCC ('h', 's'):
5964 case MCC ('c', 'c'): return MCC ('l', 's');
5965 /* <LO> is an alias for <CS>. */
5966 case MCC ('l', 'o'):
5967 case MCC ('c', 's'): return MCC ('h', 'i');
5968 case MCC ('p', 'l'): return MCC ('m', 'i');
5969 case MCC ('m', 'i'): return MCC ('p', 'l');
5970 case MCC ('g', 'e'): return MCC ('l', 'e');
5971 case MCC ('l', 't'): return MCC ('g', 't');
5972 case MCC ('g', 't'): return MCC ('l', 't');
5973 case MCC ('l', 'e'): return MCC ('g', 'e');
5974 /* Issue a warning for conditions we can not swap. */
5975 case MCC ('n', 'e'): return MCC ('n', 'e'); // no problem here
5976 case MCC ('e', 'q'): return MCC ('e', 'q'); // also no problem
5977 case MCC ('v', 'c'):
5978 case MCC ('v', 's'):
5980 as_warn (_("Condition <%c%c> in structured control directive can not be encoded correctly"),
5981 (char) (cc
>> 8), (char) (cc
));
5987 /* Reverse the sense of a condition. */
5990 reverse_mri_condition (int cc
)
5994 case MCC ('h', 'i'): return MCC ('l', 's');
5995 case MCC ('l', 's'): return MCC ('h', 'i');
5996 /* <HS> is an alias for <CC> */
5997 case MCC ('h', 's'): return MCC ('l', 'o');
5998 case MCC ('c', 'c'): return MCC ('c', 's');
5999 /* <LO> is an alias for <CS> */
6000 case MCC ('l', 'o'): return MCC ('h', 's');
6001 case MCC ('c', 's'): return MCC ('c', 'c');
6002 case MCC ('n', 'e'): return MCC ('e', 'q');
6003 case MCC ('e', 'q'): return MCC ('n', 'e');
6004 case MCC ('v', 'c'): return MCC ('v', 's');
6005 case MCC ('v', 's'): return MCC ('v', 'c');
6006 case MCC ('p', 'l'): return MCC ('m', 'i');
6007 case MCC ('m', 'i'): return MCC ('p', 'l');
6008 case MCC ('g', 'e'): return MCC ('l', 't');
6009 case MCC ('l', 't'): return MCC ('g', 'e');
6010 case MCC ('g', 't'): return MCC ('l', 'e');
6011 case MCC ('l', 'e'): return MCC ('g', 't');
6016 /* Build an MRI structured control expression. This generates test
6017 and branch instructions. It goes to TRUELAB if the condition is
6018 true, and to FALSELAB if the condition is false. Exactly one of
6019 TRUELAB and FALSELAB will be NULL, meaning to fall through. QUAL
6020 is the size qualifier for the expression. EXTENT is the size to
6021 use for the branch. */
6024 build_mri_control_operand (int qual
, int cc
, char *leftstart
, char *leftstop
,
6025 char *rightstart
, char *rightstop
,
6026 const char *truelab
, const char *falselab
,
6032 if (leftstart
!= NULL
)
6034 struct m68k_op leftop
, rightop
;
6037 /* Swap the compare operands, if necessary, to produce a legal
6038 m68k compare instruction. Comparing a register operand with
6039 a non-register operand requires the register to be on the
6040 right (cmp, cmpa). Comparing an immediate value with
6041 anything requires the immediate value to be on the left
6046 (void) m68k_ip_op (leftstart
, &leftop
);
6051 (void) m68k_ip_op (rightstart
, &rightop
);
6054 if (rightop
.mode
== IMMED
6055 || ((leftop
.mode
== DREG
|| leftop
.mode
== AREG
)
6056 && (rightop
.mode
!= DREG
&& rightop
.mode
!= AREG
)))
6060 /* Correct conditional handling:
6061 if #1 <lt> d0 then ;means if (1 < d0)
6067 cmp #1,d0 if we do *not* swap the operands
6068 bgt true we need the swapped condition!
6075 leftstart
= rightstart
;
6078 leftstop
= rightstop
;
6083 cc
= swap_mri_condition (cc
);
6087 if (truelab
== NULL
)
6089 cc
= reverse_mri_condition (cc
);
6093 if (leftstart
!= NULL
)
6095 buf
= (char *) xmalloc (20
6096 + (leftstop
- leftstart
)
6097 + (rightstop
- rightstart
));
6103 *s
++ = TOLOWER (qual
);
6105 memcpy (s
, leftstart
, leftstop
- leftstart
);
6106 s
+= leftstop
- leftstart
;
6108 memcpy (s
, rightstart
, rightstop
- rightstart
);
6109 s
+= rightstop
- rightstart
;
6115 buf
= (char *) xmalloc (20 + strlen (truelab
));
6121 *s
++ = TOLOWER (extent
);
6123 strcpy (s
, truelab
);
6128 /* Parse an MRI structured control expression. This generates test
6129 and branch instructions. STOP is where the expression ends. It
6130 goes to TRUELAB if the condition is true, and to FALSELAB if the
6131 condition is false. Exactly one of TRUELAB and FALSELAB will be
6132 NULL, meaning to fall through. QUAL is the size qualifier for the
6133 expression. EXTENT is the size to use for the branch. */
6136 parse_mri_control_expression (char *stop
, int qual
, const char *truelab
,
6137 const char *falselab
, int extent
)
6149 if (! parse_mri_control_operand (&cc
, &leftstart
, &leftstop
,
6150 &rightstart
, &rightstop
))
6156 if (strncasecmp (input_line_pointer
, "AND", 3) == 0)
6160 if (falselab
!= NULL
)
6163 flab
= mri_control_label ();
6165 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6166 rightstop
, (const char *) NULL
, flab
, extent
);
6168 input_line_pointer
+= 3;
6169 if (*input_line_pointer
!= '.'
6170 || input_line_pointer
[1] == '\0')
6174 qual
= input_line_pointer
[1];
6175 input_line_pointer
+= 2;
6178 if (! parse_mri_control_operand (&cc
, &leftstart
, &leftstop
,
6179 &rightstart
, &rightstop
))
6185 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6186 rightstop
, truelab
, falselab
, extent
);
6188 if (falselab
== NULL
)
6191 else if (strncasecmp (input_line_pointer
, "OR", 2) == 0)
6195 if (truelab
!= NULL
)
6198 tlab
= mri_control_label ();
6200 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6201 rightstop
, tlab
, (const char *) NULL
, extent
);
6203 input_line_pointer
+= 2;
6204 if (*input_line_pointer
!= '.'
6205 || input_line_pointer
[1] == '\0')
6209 qual
= input_line_pointer
[1];
6210 input_line_pointer
+= 2;
6213 if (! parse_mri_control_operand (&cc
, &leftstart
, &leftstop
,
6214 &rightstart
, &rightstop
))
6220 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6221 rightstop
, truelab
, falselab
, extent
);
6223 if (truelab
== NULL
)
6228 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6229 rightstop
, truelab
, falselab
, extent
);
6233 if (input_line_pointer
!= stop
)
6234 as_bad (_("syntax error in structured control directive"));
6237 /* Handle the MRI IF pseudo-op. This may be a structured control
6238 directive, or it may be a regular assembler conditional, depending
6246 struct mri_control_info
*n
;
6248 /* A structured control directive must end with THEN with an
6249 optional qualifier. */
6250 s
= input_line_pointer
;
6251 /* We only accept '*' as introduction of comments if preceded by white space
6252 or at first column of a line (I think this can't actually happen here?)
6253 This is important when assembling:
6254 if d0 <ne> 12(a0,d0*2) then
6255 if d0 <ne> #CONST*20 then. */
6256 while (! (is_end_of_line
[(unsigned char) *s
]
6259 && (s
== input_line_pointer
6261 || *(s
-1) == '\t'))))
6264 while (s
> input_line_pointer
&& (*s
== ' ' || *s
== '\t'))
6267 if (s
- input_line_pointer
> 1
6271 if (s
- input_line_pointer
< 3
6272 || strncasecmp (s
- 3, "THEN", 4) != 0)
6276 as_bad (_("missing then"));
6277 ignore_rest_of_line ();
6281 /* It's a conditional. */
6286 /* Since this might be a conditional if, this pseudo-op will be
6287 called even if we are supported to be ignoring input. Double
6288 check now. Clobber *input_line_pointer so that ignore_input
6289 thinks that this is not a special pseudo-op. */
6290 c
= *input_line_pointer
;
6291 *input_line_pointer
= 0;
6292 if (ignore_input ())
6294 *input_line_pointer
= c
;
6295 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6296 ++input_line_pointer
;
6297 demand_empty_rest_of_line ();
6300 *input_line_pointer
= c
;
6302 n
= push_mri_control (mri_if
);
6304 parse_mri_control_expression (s
- 3, qual
, (const char *) NULL
,
6305 n
->next
, s
[1] == '.' ? s
[2] : '\0');
6308 input_line_pointer
= s
+ 3;
6310 input_line_pointer
= s
+ 1;
6314 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6315 ++input_line_pointer
;
6318 demand_empty_rest_of_line ();
6321 /* Handle the MRI else pseudo-op. If we are currently doing an MRI
6322 structured IF, associate the ELSE with the IF. Otherwise, assume
6323 it is a conditional else. */
6326 s_mri_else (int qual
)
6333 && (mri_control_stack
== NULL
6334 || mri_control_stack
->type
!= mri_if
6335 || mri_control_stack
->else_seen
))
6341 c
= *input_line_pointer
;
6342 *input_line_pointer
= 0;
6343 if (ignore_input ())
6345 *input_line_pointer
= c
;
6346 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6347 ++input_line_pointer
;
6348 demand_empty_rest_of_line ();
6351 *input_line_pointer
= c
;
6353 if (mri_control_stack
== NULL
6354 || mri_control_stack
->type
!= mri_if
6355 || mri_control_stack
->else_seen
)
6357 as_bad (_("else without matching if"));
6358 ignore_rest_of_line ();
6362 mri_control_stack
->else_seen
= 1;
6364 buf
= (char *) xmalloc (20 + strlen (mri_control_stack
->bottom
));
6365 q
[0] = TOLOWER (qual
);
6367 sprintf (buf
, "bra%s %s", q
, mri_control_stack
->bottom
);
6371 colon (mri_control_stack
->next
);
6375 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6376 ++input_line_pointer
;
6379 demand_empty_rest_of_line ();
6382 /* Handle the MRI ENDI pseudo-op. */
6385 s_mri_endi (int ignore ATTRIBUTE_UNUSED
)
6387 if (mri_control_stack
== NULL
6388 || mri_control_stack
->type
!= mri_if
)
6390 as_bad (_("endi without matching if"));
6391 ignore_rest_of_line ();
6395 /* ignore_input will not return true for ENDI, so we don't need to
6396 worry about checking it again here. */
6398 if (! mri_control_stack
->else_seen
)
6399 colon (mri_control_stack
->next
);
6400 colon (mri_control_stack
->bottom
);
6406 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6407 ++input_line_pointer
;
6410 demand_empty_rest_of_line ();
6413 /* Handle the MRI BREAK pseudo-op. */
6416 s_mri_break (int extent
)
6418 struct mri_control_info
*n
;
6422 n
= mri_control_stack
;
6424 && n
->type
!= mri_for
6425 && n
->type
!= mri_repeat
6426 && n
->type
!= mri_while
)
6430 as_bad (_("break outside of structured loop"));
6431 ignore_rest_of_line ();
6435 buf
= (char *) xmalloc (20 + strlen (n
->bottom
));
6436 ex
[0] = TOLOWER (extent
);
6438 sprintf (buf
, "bra%s %s", ex
, n
->bottom
);
6444 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6445 ++input_line_pointer
;
6448 demand_empty_rest_of_line ();
6451 /* Handle the MRI NEXT pseudo-op. */
6454 s_mri_next (int extent
)
6456 struct mri_control_info
*n
;
6460 n
= mri_control_stack
;
6462 && n
->type
!= mri_for
6463 && n
->type
!= mri_repeat
6464 && n
->type
!= mri_while
)
6468 as_bad (_("next outside of structured loop"));
6469 ignore_rest_of_line ();
6473 buf
= (char *) xmalloc (20 + strlen (n
->next
));
6474 ex
[0] = TOLOWER (extent
);
6476 sprintf (buf
, "bra%s %s", ex
, n
->next
);
6482 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6483 ++input_line_pointer
;
6486 demand_empty_rest_of_line ();
6489 /* Handle the MRI FOR pseudo-op. */
6492 s_mri_for (int qual
)
6494 const char *varstart
, *varstop
;
6495 const char *initstart
, *initstop
;
6496 const char *endstart
, *endstop
;
6497 const char *bystart
, *bystop
;
6501 struct mri_control_info
*n
;
6507 FOR.q var = init { TO | DOWNTO } end [ BY by ] DO.e
6511 varstart
= input_line_pointer
;
6513 /* Look for the '='. */
6514 while (! is_end_of_line
[(unsigned char) *input_line_pointer
]
6515 && *input_line_pointer
!= '=')
6516 ++input_line_pointer
;
6517 if (*input_line_pointer
!= '=')
6519 as_bad (_("missing ="));
6520 ignore_rest_of_line ();
6524 varstop
= input_line_pointer
;
6525 if (varstop
> varstart
6526 && (varstop
[-1] == ' ' || varstop
[-1] == '\t'))
6529 ++input_line_pointer
;
6531 initstart
= input_line_pointer
;
6533 /* Look for TO or DOWNTO. */
6536 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6538 if (strncasecmp (input_line_pointer
, "TO", 2) == 0
6539 && ! is_part_of_name (input_line_pointer
[2]))
6541 initstop
= input_line_pointer
;
6542 input_line_pointer
+= 2;
6545 if (strncasecmp (input_line_pointer
, "DOWNTO", 6) == 0
6546 && ! is_part_of_name (input_line_pointer
[6]))
6548 initstop
= input_line_pointer
;
6550 input_line_pointer
+= 6;
6553 ++input_line_pointer
;
6555 if (initstop
== NULL
)
6557 as_bad (_("missing to or downto"));
6558 ignore_rest_of_line ();
6561 if (initstop
> initstart
6562 && (initstop
[-1] == ' ' || initstop
[-1] == '\t'))
6566 endstart
= input_line_pointer
;
6568 /* Look for BY or DO. */
6571 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6573 if (strncasecmp (input_line_pointer
, "BY", 2) == 0
6574 && ! is_part_of_name (input_line_pointer
[2]))
6576 endstop
= input_line_pointer
;
6578 input_line_pointer
+= 2;
6581 if (strncasecmp (input_line_pointer
, "DO", 2) == 0
6582 && (input_line_pointer
[2] == '.'
6583 || ! is_part_of_name (input_line_pointer
[2])))
6585 endstop
= input_line_pointer
;
6586 input_line_pointer
+= 2;
6589 ++input_line_pointer
;
6591 if (endstop
== NULL
)
6593 as_bad (_("missing do"));
6594 ignore_rest_of_line ();
6597 if (endstop
> endstart
6598 && (endstop
[-1] == ' ' || endstop
[-1] == '\t'))
6604 bystop
= bystart
+ 2;
6609 bystart
= input_line_pointer
;
6613 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6615 if (strncasecmp (input_line_pointer
, "DO", 2) == 0
6616 && (input_line_pointer
[2] == '.'
6617 || ! is_part_of_name (input_line_pointer
[2])))
6619 bystop
= input_line_pointer
;
6620 input_line_pointer
+= 2;
6623 ++input_line_pointer
;
6627 as_bad (_("missing do"));
6628 ignore_rest_of_line ();
6631 if (bystop
> bystart
6632 && (bystop
[-1] == ' ' || bystop
[-1] == '\t'))
6636 if (*input_line_pointer
!= '.')
6640 extent
= input_line_pointer
[1];
6641 input_line_pointer
+= 2;
6644 /* We have fully parsed the FOR operands. Now build the loop. */
6645 n
= push_mri_control (mri_for
);
6647 buf
= (char *) xmalloc (50 + (input_line_pointer
- varstart
));
6649 /* Move init,var. */
6656 *s
++ = TOLOWER (qual
);
6658 memcpy (s
, initstart
, initstop
- initstart
);
6659 s
+= initstop
- initstart
;
6661 memcpy (s
, varstart
, varstop
- varstart
);
6662 s
+= varstop
- varstart
;
6674 *s
++ = TOLOWER (qual
);
6676 memcpy (s
, endstart
, endstop
- endstart
);
6677 s
+= endstop
- endstart
;
6679 memcpy (s
, varstart
, varstop
- varstart
);
6680 s
+= varstop
- varstart
;
6685 ex
[0] = TOLOWER (extent
);
6688 sprintf (buf
, "blt%s %s", ex
, n
->bottom
);
6690 sprintf (buf
, "bgt%s %s", ex
, n
->bottom
);
6693 /* Put together the add or sub instruction used by ENDF. */
6701 *s
++ = TOLOWER (qual
);
6703 memcpy (s
, bystart
, bystop
- bystart
);
6704 s
+= bystop
- bystart
;
6706 memcpy (s
, varstart
, varstop
- varstart
);
6707 s
+= varstop
- varstart
;
6713 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6714 ++input_line_pointer
;
6717 demand_empty_rest_of_line ();
6720 /* Handle the MRI ENDF pseudo-op. */
6723 s_mri_endf (int ignore ATTRIBUTE_UNUSED
)
6725 if (mri_control_stack
== NULL
6726 || mri_control_stack
->type
!= mri_for
)
6728 as_bad (_("endf without for"));
6729 ignore_rest_of_line ();
6733 colon (mri_control_stack
->next
);
6735 mri_assemble (mri_control_stack
->incr
);
6737 sprintf (mri_control_stack
->incr
, "bra %s", mri_control_stack
->top
);
6738 mri_assemble (mri_control_stack
->incr
);
6740 free (mri_control_stack
->incr
);
6742 colon (mri_control_stack
->bottom
);
6748 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6749 ++input_line_pointer
;
6752 demand_empty_rest_of_line ();
6755 /* Handle the MRI REPEAT pseudo-op. */
6758 s_mri_repeat (int ignore ATTRIBUTE_UNUSED
)
6760 struct mri_control_info
*n
;
6762 n
= push_mri_control (mri_repeat
);
6766 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6767 ++input_line_pointer
;
6769 demand_empty_rest_of_line ();
6772 /* Handle the MRI UNTIL pseudo-op. */
6775 s_mri_until (int qual
)
6779 if (mri_control_stack
== NULL
6780 || mri_control_stack
->type
!= mri_repeat
)
6782 as_bad (_("until without repeat"));
6783 ignore_rest_of_line ();
6787 colon (mri_control_stack
->next
);
6789 for (s
= input_line_pointer
; ! is_end_of_line
[(unsigned char) *s
]; s
++)
6792 parse_mri_control_expression (s
, qual
, (const char *) NULL
,
6793 mri_control_stack
->top
, '\0');
6795 colon (mri_control_stack
->bottom
);
6797 input_line_pointer
= s
;
6803 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6804 ++input_line_pointer
;
6807 demand_empty_rest_of_line ();
6810 /* Handle the MRI WHILE pseudo-op. */
6813 s_mri_while (int qual
)
6817 struct mri_control_info
*n
;
6819 s
= input_line_pointer
;
6820 /* We only accept '*' as introduction of comments if preceded by white space
6821 or at first column of a line (I think this can't actually happen here?)
6822 This is important when assembling:
6823 while d0 <ne> 12(a0,d0*2) do
6824 while d0 <ne> #CONST*20 do. */
6825 while (! (is_end_of_line
[(unsigned char) *s
]
6828 && (s
== input_line_pointer
6830 || *(s
-1) == '\t'))))
6833 while (*s
== ' ' || *s
== '\t')
6835 if (s
- input_line_pointer
> 1
6838 if (s
- input_line_pointer
< 2
6839 || strncasecmp (s
- 1, "DO", 2) != 0)
6841 as_bad (_("missing do"));
6842 ignore_rest_of_line ();
6846 n
= push_mri_control (mri_while
);
6850 parse_mri_control_expression (s
- 1, qual
, (const char *) NULL
, n
->bottom
,
6851 s
[1] == '.' ? s
[2] : '\0');
6853 input_line_pointer
= s
+ 1;
6854 if (*input_line_pointer
== '.')
6855 input_line_pointer
+= 2;
6859 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6860 ++input_line_pointer
;
6863 demand_empty_rest_of_line ();
6866 /* Handle the MRI ENDW pseudo-op. */
6869 s_mri_endw (int ignore ATTRIBUTE_UNUSED
)
6873 if (mri_control_stack
== NULL
6874 || mri_control_stack
->type
!= mri_while
)
6876 as_bad (_("endw without while"));
6877 ignore_rest_of_line ();
6881 buf
= (char *) xmalloc (20 + strlen (mri_control_stack
->next
));
6882 sprintf (buf
, "bra %s", mri_control_stack
->next
);
6886 colon (mri_control_stack
->bottom
);
6892 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6893 ++input_line_pointer
;
6896 demand_empty_rest_of_line ();
6899 /* Parse a .cpu directive. */
6902 s_m68k_cpu (int ignored ATTRIBUTE_UNUSED
)
6909 as_bad (_("already assembled instructions"));
6910 ignore_rest_of_line ();
6914 name
= input_line_pointer
;
6915 while (*input_line_pointer
&& !ISSPACE(*input_line_pointer
))
6916 input_line_pointer
++;
6917 saved_char
= *input_line_pointer
;
6918 *input_line_pointer
= 0;
6920 m68k_set_cpu (name
, 1, 0);
6922 *input_line_pointer
= saved_char
;
6923 demand_empty_rest_of_line ();
6927 /* Parse a .arch directive. */
6930 s_m68k_arch (int ignored ATTRIBUTE_UNUSED
)
6937 as_bad (_("already assembled instructions"));
6938 ignore_rest_of_line ();
6942 name
= input_line_pointer
;
6943 while (*input_line_pointer
&& *input_line_pointer
!= ','
6944 && !ISSPACE (*input_line_pointer
))
6945 input_line_pointer
++;
6946 saved_char
= *input_line_pointer
;
6947 *input_line_pointer
= 0;
6949 if (m68k_set_arch (name
, 1, 0))
6951 /* Scan extensions. */
6954 *input_line_pointer
++ = saved_char
;
6955 if (!*input_line_pointer
|| ISSPACE (*input_line_pointer
))
6957 name
= input_line_pointer
;
6958 while (*input_line_pointer
&& *input_line_pointer
!= ','
6959 && !ISSPACE (*input_line_pointer
))
6960 input_line_pointer
++;
6961 saved_char
= *input_line_pointer
;
6962 *input_line_pointer
= 0;
6964 while (m68k_set_extension (name
, 1, 0));
6967 *input_line_pointer
= saved_char
;
6968 demand_empty_rest_of_line ();
6972 /* Lookup a cpu name in TABLE and return the slot found. Return NULL
6973 if none is found, the caller is responsible for emitting an error
6974 message. If ALLOW_M is non-zero, we allow an initial 'm' on the
6975 cpu name, if it begins with a '6' (possibly skipping an intervening
6976 'c'. We also allow a 'c' in the same place. if NEGATED is
6977 non-zero, we accept a leading 'no-' and *NEGATED is set to true, if
6978 the option is indeed negated. */
6980 static const struct m68k_cpu
*
6981 m68k_lookup_cpu (const char *arg
, const struct m68k_cpu
*table
,
6982 int allow_m
, int *negated
)
6984 /* allow negated value? */
6989 if (arg
[0] == 'n' && arg
[1] == 'o' && arg
[2] == '-')
6996 /* Remove 'm' or 'mc' prefix from 68k variants. */
7003 else if (arg
[1] == 'c' && arg
[2] == '6')
7007 else if (arg
[0] == 'c' && arg
[1] == '6')
7010 for (; table
->name
; table
++)
7011 if (!strcmp (arg
, table
->name
))
7013 if (table
->alias
< -1 || table
->alias
> 1)
7014 as_bad (_("`%s' is deprecated, use `%s'"),
7015 table
->name
, table
[table
->alias
< 0 ? 1 : -1].name
);
7021 /* Set the cpu, issuing errors if it is unrecognized, or invalid */
7024 m68k_set_cpu (char const *name
, int allow_m
, int silent
)
7026 const struct m68k_cpu
*cpu
;
7028 cpu
= m68k_lookup_cpu (name
, m68k_cpus
, allow_m
, NULL
);
7033 as_bad (_("cpu `%s' unrecognized"), name
);
7037 if (selected_cpu
&& selected_cpu
!= cpu
)
7039 as_bad (_("already selected `%s' processor"),
7040 selected_cpu
->name
);
7047 /* Set the architecture, issuing errors if it is unrecognized, or invalid */
7050 m68k_set_arch (char const *name
, int allow_m
, int silent
)
7052 const struct m68k_cpu
*arch
;
7054 arch
= m68k_lookup_cpu (name
, m68k_archs
, allow_m
, NULL
);
7059 as_bad (_("architecture `%s' unrecognized"), name
);
7063 if (selected_arch
&& selected_arch
!= arch
)
7065 as_bad (_("already selected `%s' architecture"),
7066 selected_arch
->name
);
7070 selected_arch
= arch
;
7074 /* Set the architecture extension, issuing errors if it is
7075 unrecognized, or invalid */
7078 m68k_set_extension (char const *name
, int allow_m
, int silent
)
7081 const struct m68k_cpu
*ext
;
7083 ext
= m68k_lookup_cpu (name
, m68k_extensions
, allow_m
, &negated
);
7088 as_bad (_("extension `%s' unrecognized"), name
);
7093 not_current_architecture
|= ext
->arch
;
7095 current_architecture
|= ext
->arch
;
7100 Invocation line includes a switch not recognized by the base assembler.
7104 const char *md_shortopts
= "lSA:m:kQ:V";
7106 const char *md_shortopts
= "lSA:m:k";
7109 struct option md_longopts
[] = {
7110 #define OPTION_PIC (OPTION_MD_BASE)
7111 {"pic", no_argument
, NULL
, OPTION_PIC
},
7112 #define OPTION_REGISTER_PREFIX_OPTIONAL (OPTION_MD_BASE + 1)
7113 {"register-prefix-optional", no_argument
, NULL
,
7114 OPTION_REGISTER_PREFIX_OPTIONAL
},
7115 #define OPTION_BITWISE_OR (OPTION_MD_BASE + 2)
7116 {"bitwise-or", no_argument
, NULL
, OPTION_BITWISE_OR
},
7117 #define OPTION_BASE_SIZE_DEFAULT_16 (OPTION_MD_BASE + 3)
7118 {"base-size-default-16", no_argument
, NULL
, OPTION_BASE_SIZE_DEFAULT_16
},
7119 #define OPTION_BASE_SIZE_DEFAULT_32 (OPTION_MD_BASE + 4)
7120 {"base-size-default-32", no_argument
, NULL
, OPTION_BASE_SIZE_DEFAULT_32
},
7121 #define OPTION_DISP_SIZE_DEFAULT_16 (OPTION_MD_BASE + 5)
7122 {"disp-size-default-16", no_argument
, NULL
, OPTION_DISP_SIZE_DEFAULT_16
},
7123 #define OPTION_DISP_SIZE_DEFAULT_32 (OPTION_MD_BASE + 6)
7124 {"disp-size-default-32", no_argument
, NULL
, OPTION_DISP_SIZE_DEFAULT_32
},
7125 #define OPTION_PCREL (OPTION_MD_BASE + 7)
7126 {"pcrel", no_argument
, NULL
, OPTION_PCREL
},
7127 {NULL
, no_argument
, NULL
, 0}
7129 size_t md_longopts_size
= sizeof (md_longopts
);
7132 md_parse_option (int c
, char *arg
)
7136 case 'l': /* -l means keep external to 2 bit offset
7137 rather than 16 bit one. */
7138 flag_short_refs
= 1;
7141 case 'S': /* -S means that jbsr's always turn into
7143 flag_long_jumps
= 1;
7146 case OPTION_PCREL
: /* --pcrel means never turn PC-relative
7147 branches into absolute jumps. */
7148 flag_keep_pcrel
= 1;
7154 break; /* -pic, Position Independent Code. */
7156 case OPTION_REGISTER_PREFIX_OPTIONAL
:
7157 flag_reg_prefix_optional
= 1;
7158 reg_prefix_optional_seen
= 1;
7161 /* -V: SVR4 argument to print version ID. */
7163 print_version_id ();
7166 /* -Qy, -Qn: SVR4 arguments controlling whether a .comment section
7167 should be emitted or not. FIXME: Not implemented. */
7171 case OPTION_BITWISE_OR
:
7176 n
= (char *) xmalloc (strlen (m68k_comment_chars
) + 1);
7178 for (s
= m68k_comment_chars
; *s
!= '\0'; s
++)
7182 m68k_comment_chars
= n
;
7186 case OPTION_BASE_SIZE_DEFAULT_16
:
7187 m68k_index_width_default
= SIZE_WORD
;
7190 case OPTION_BASE_SIZE_DEFAULT_32
:
7191 m68k_index_width_default
= SIZE_LONG
;
7194 case OPTION_DISP_SIZE_DEFAULT_16
:
7196 m68k_rel32_from_cmdline
= 1;
7199 case OPTION_DISP_SIZE_DEFAULT_32
:
7201 m68k_rel32_from_cmdline
= 1;
7206 as_tsktsk (_ ("option `-A%s' is deprecated: use `-%s'",
7209 /* Intentional fall-through. */
7211 if (!strncmp (arg
, "arch=", 5))
7212 m68k_set_arch (arg
+ 5, 1, 0);
7213 else if (!strncmp (arg
, "cpu=", 4))
7214 m68k_set_cpu (arg
+ 4, 1, 0);
7215 else if (m68k_set_extension (arg
, 0, 1))
7217 else if (m68k_set_arch (arg
, 0, 1))
7219 else if (m68k_set_cpu (arg
, 0, 1))
7232 /* Setup tables from the selected arch and/or cpu */
7235 m68k_init_arch (void)
7237 if (not_current_architecture
& current_architecture
)
7239 as_bad (_("architecture features both enabled and disabled"));
7240 not_current_architecture
&= ~current_architecture
;
7244 current_architecture
|= selected_arch
->arch
;
7245 control_regs
= selected_arch
->control_regs
;
7248 current_architecture
|= selected_cpu
->arch
;
7250 current_architecture
&= ~not_current_architecture
;
7252 if ((current_architecture
& (cfloat
| m68881
)) == (cfloat
| m68881
))
7254 /* Determine which float is really meant. */
7255 if (current_architecture
& (m68k_mask
& ~m68881
))
7256 current_architecture
^= cfloat
;
7258 current_architecture
^= m68881
;
7263 control_regs
= selected_cpu
->control_regs
;
7264 if (current_architecture
& ~selected_cpu
->arch
)
7266 as_bad (_("selected processor does not have all features of selected architecture"));
7267 current_architecture
7268 = selected_cpu
->arch
& ~not_current_architecture
;
7272 if ((current_architecture
& m68k_mask
)
7273 && (current_architecture
& ~m68k_mask
))
7275 as_bad (_ ("m68k and cf features both selected"));
7276 if (current_architecture
& m68k_mask
)
7277 current_architecture
&= m68k_mask
;
7279 current_architecture
&= ~m68k_mask
;
7282 /* Permit m68881 specification with all cpus; those that can't work
7283 with a coprocessor could be doing emulation. */
7284 if (current_architecture
& m68851
)
7286 if (current_architecture
& m68040
)
7287 as_warn (_("68040 and 68851 specified; mmu instructions may assemble incorrectly"));
7289 /* What other incompatibilities could we check for? */
7291 if (cpu_of_arch (current_architecture
) < m68020
7292 || arch_coldfire_p (current_architecture
))
7293 md_relax_table
[TAB (PCINDEX
, BYTE
)].rlx_more
= 0;
7299 md_show_usage (FILE *stream
)
7301 const char *default_cpu
= TARGET_CPU
;
7303 unsigned int default_arch
;
7305 /* Get the canonical name for the default target CPU. */
7306 if (*default_cpu
== 'm')
7308 for (i
= 0; m68k_cpus
[i
].name
; i
++)
7310 if (strcasecmp (default_cpu
, m68k_cpus
[i
].name
) == 0)
7312 default_arch
= m68k_cpus
[i
].arch
;
7313 while (m68k_cpus
[i
].alias
> 0)
7315 while (m68k_cpus
[i
].alias
< 0)
7317 default_cpu
= m68k_cpus
[i
].name
;
7321 fprintf (stream
, _("\
7322 -march=<arch> set architecture\n\
7323 -mcpu=<cpu> set cpu [default %s]\n\
7325 for (i
= 0; m68k_extensions
[i
].name
; i
++)
7326 fprintf (stream
, _("\
7327 -m[no-]%-16s enable/disable%s architecture extension\n\
7328 "), m68k_extensions
[i
].name
,
7329 m68k_extensions
[i
].alias
> 0 ? " ColdFire"
7330 : m68k_extensions
[i
].alias
< 0 ? " m68k" : "");
7332 fprintf (stream
, _("\
7333 -l use 1 word for refs to undefined symbols [default 2]\n\
7334 -pic, -k generate position independent code\n\
7335 -S turn jbsr into jsr\n\
7336 --pcrel never turn PC-relative branches into absolute jumps\n\
7337 --register-prefix-optional\n\
7338 recognize register names without prefix character\n\
7339 --bitwise-or do not treat `|' as a comment character\n\
7340 --base-size-default-16 base reg without size is 16 bits\n\
7341 --base-size-default-32 base reg without size is 32 bits (default)\n\
7342 --disp-size-default-16 displacement with unknown size is 16 bits\n\
7343 --disp-size-default-32 displacement with unknown size is 32 bits (default)\n\
7346 fprintf (stream
, _("Architecture variants are: "));
7347 for (i
= 0; m68k_archs
[i
].name
; i
++)
7350 fprintf (stream
, " | ");
7351 fprintf (stream
, m68k_archs
[i
].name
);
7353 fprintf (stream
, "\n");
7355 fprintf (stream
, _("Processor variants are: "));
7356 for (i
= 0; m68k_cpus
[i
].name
; i
++)
7359 fprintf (stream
, " | ");
7360 fprintf (stream
, m68k_cpus
[i
].name
);
7362 fprintf (stream
, _("\n"));
7367 /* TEST2: Test md_assemble() */
7368 /* Warning, this routine probably doesn't work anymore. */
7372 struct m68k_it the_ins
;
7380 if (!gets (buf
) || !*buf
)
7382 if (buf
[0] == '|' || buf
[1] == '.')
7384 for (cp
= buf
; *cp
; cp
++)
7389 memset (&the_ins
, '\0', sizeof (the_ins
));
7390 m68k_ip (&the_ins
, buf
);
7393 printf (_("Error %s in %s\n"), the_ins
.error
, buf
);
7397 printf (_("Opcode(%d.%s): "), the_ins
.numo
, the_ins
.args
);
7398 for (n
= 0; n
< the_ins
.numo
; n
++)
7399 printf (" 0x%x", the_ins
.opcode
[n
] & 0xffff);
7401 print_the_insn (&the_ins
.opcode
[0], stdout
);
7402 (void) putchar ('\n');
7404 for (n
= 0; n
< strlen (the_ins
.args
) / 2; n
++)
7406 if (the_ins
.operands
[n
].error
)
7408 printf ("op%d Error %s in %s\n", n
, the_ins
.operands
[n
].error
, buf
);
7411 printf ("mode %d, reg %d, ", the_ins
.operands
[n
].mode
,
7412 the_ins
.operands
[n
].reg
);
7413 if (the_ins
.operands
[n
].b_const
)
7414 printf ("Constant: '%.*s', ",
7415 1 + the_ins
.operands
[n
].e_const
- the_ins
.operands
[n
].b_const
,
7416 the_ins
.operands
[n
].b_const
);
7417 printf ("ireg %d, isiz %d, imul %d, ", the_ins
.operands
[n
].ireg
,
7418 the_ins
.operands
[n
].isiz
, the_ins
.operands
[n
].imul
);
7419 if (the_ins
.operands
[n
].b_iadd
)
7420 printf ("Iadd: '%.*s',",
7421 1 + the_ins
.operands
[n
].e_iadd
- the_ins
.operands
[n
].b_iadd
,
7422 the_ins
.operands
[n
].b_iadd
);
7431 is_label (char *str
)
7435 while (*str
&& *str
!= ' ')
7437 if (str
[-1] == ':' || str
[1] == '=')
7444 /* Possible states for relaxation:
7446 0 0 branch offset byte (bra, etc)
7450 1 0 indexed offsets byte a0@(32,d4:w:1) etc
7454 2 0 two-offset index word-word a0@(32,d4)@(45) etc
7461 /* We have no need to default values of symbols. */
7464 md_undefined_symbol (char *name ATTRIBUTE_UNUSED
)
7469 /* Round up a section size to the appropriate boundary. */
7471 md_section_align (segT segment ATTRIBUTE_UNUSED
, valueT size
)
7474 /* For a.out, force the section size to be aligned. If we don't do
7475 this, BFD will align it for us, but it will not write out the
7476 final bytes of the section. This may be a bug in BFD, but it is
7477 easier to fix it here since that is how the other a.out targets
7481 align
= bfd_get_section_alignment (stdoutput
, segment
);
7482 size
= ((size
+ (1 << align
) - 1) & ((valueT
) -1 << align
));
7488 /* Exactly what point is a PC-relative offset relative TO?
7489 On the 68k, it is relative to the address of the first extension
7490 word. The difference between the addresses of the offset and the
7491 first extension word is stored in fx_pcrel_adjust. */
7493 md_pcrel_from (fixS
*fixP
)
7497 /* Because fx_pcrel_adjust is a char, and may be unsigned, we explicitly
7498 sign extend the value here. */
7499 adjust
= ((fixP
->fx_pcrel_adjust
& 0xff) ^ 0x80) - 0x80;
7502 return fixP
->fx_where
+ fixP
->fx_frag
->fr_address
- adjust
;
7507 m68k_elf_final_processing (void)
7511 if (arch_coldfire_fpu (current_architecture
))
7512 flags
|= EF_M68K_CFV4E
;
7513 /* Set file-specific flags if this is a cpu32 processor. */
7514 if (cpu_of_arch (current_architecture
) & cpu32
)
7515 flags
|= EF_M68K_CPU32
;
7516 else if ((cpu_of_arch (current_architecture
) & m68000up
)
7517 && !(cpu_of_arch (current_architecture
) & m68020up
))
7518 flags
|= EF_M68K_M68000
;
7520 if (current_architecture
& mcfisa_a
)
7522 static const unsigned isa_features
[][2] =
7524 {EF_M68K_ISA_A_NODIV
, mcfisa_a
},
7525 {EF_M68K_ISA_A
, mcfisa_a
|mcfhwdiv
},
7526 {EF_M68K_ISA_A_PLUS
,mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfusp
},
7527 {EF_M68K_ISA_B_NOUSP
,mcfisa_a
|mcfisa_b
|mcfhwdiv
},
7528 {EF_M68K_ISA_B
, mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfusp
},
7531 static const unsigned mac_features
[][2] =
7533 {EF_M68K_MAC
, mcfmac
},
7534 {EF_M68K_EMAC
, mcfemac
},
7540 pattern
= (current_architecture
7541 & (mcfisa_a
|mcfisa_aa
|mcfisa_b
|mcfhwdiv
|mcfusp
));
7542 for (ix
= 0; isa_features
[ix
][1]; ix
++)
7544 if (pattern
== isa_features
[ix
][1])
7546 flags
|= isa_features
[ix
][0];
7550 if (!isa_features
[ix
][1])
7553 as_warn (_("Not a defined coldfire architecture"));
7557 if (current_architecture
& cfloat
)
7558 flags
|= EF_M68K_FLOAT
| EF_M68K_CFV4E
;
7560 pattern
= current_architecture
& (mcfmac
|mcfemac
);
7563 for (ix
= 0; mac_features
[ix
][1]; ix
++)
7565 if (pattern
== mac_features
[ix
][1])
7567 flags
|= mac_features
[ix
][0];
7571 if (!mac_features
[ix
][1])
7576 elf_elfheader (stdoutput
)->e_flags
|= flags
;
7581 tc_m68k_regname_to_dw2regnum (const char *regname
)
7583 unsigned int regnum
;
7584 static const char *const regnames
[] =
7586 "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
7587 "a0", "a1", "a2", "a3", "a4", "a5", "a6", "sp",
7588 "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7",
7592 for (regnum
= 0; regnum
< ARRAY_SIZE (regnames
); regnum
++)
7593 if (strcmp (regname
, regnames
[regnum
]) == 0)
7600 tc_m68k_frame_initial_instructions (void)
7602 static int sp_regno
= -1;
7605 sp_regno
= tc_m68k_regname_to_dw2regnum ("sp");
7607 cfi_add_CFA_def_cfa (sp_regno
, -DWARF2_CIE_DATA_ALIGNMENT
);
7608 cfi_add_CFA_offset (DWARF2_DEFAULT_RETURN_COLUMN
, DWARF2_CIE_DATA_ALIGNMENT
);