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 mcf5210a_ctrl
[] = {
184 VBR
, CACR
, ACR0
, ACR1
, ROMBAR
, RAMBAR
, MBAR
,
187 static const enum m68k_register mcf5213_ctrl
[] = {
188 VBR
, RAMBAR
, FLASHBAR
,
191 static const enum m68k_register mcf5216_ctrl
[] = {
192 VBR
, CACR
, ACR0
, ACR1
, FLASHBAR
, RAMBAR
,
195 static const enum m68k_register mcf52235_ctrl
[] = {
196 VBR
, FLASHBAR
, RAMBAR
,
199 static const enum m68k_register mcf5225_ctrl
[] = {
200 VBR
, CACR
, ACR0
, ACR1
, FLASHBAR
, RAMBAR
, MBAR
,
203 static const enum m68k_register mcf5235_ctrl
[] = {
204 VBR
, CACR
, ACR0
, ACR1
, RAMBAR
,
207 static const enum m68k_register mcf5249_ctrl
[] = {
208 VBR
, CACR
, ACR0
, ACR1
, RAMBAR0
, RAMBAR1
, MBAR
, MBAR2
,
211 static const enum m68k_register mcf5250_ctrl
[] = {
215 static const enum m68k_register mcf5271_ctrl
[] = {
216 VBR
, CACR
, ACR0
, ACR1
, RAMBAR
,
219 static const enum m68k_register mcf5272_ctrl
[] = {
220 VBR
, CACR
, ACR0
, ACR1
, ROMBAR
, RAMBAR
, MBAR
,
223 static const enum m68k_register mcf5275_ctrl
[] = {
224 VBR
, CACR
, ACR0
, ACR1
, RAMBAR
,
227 static const enum m68k_register mcf5282_ctrl
[] = {
228 VBR
, CACR
, ACR0
, ACR1
, FLASHBAR
, RAMBAR
,
231 static const enum m68k_register mcf5329_ctrl
[] = {
232 VBR
, CACR
, ACR0
, ACR1
, RAMBAR
,
235 static const enum m68k_register mcf5373_ctrl
[] = {
236 VBR
, CACR
, ACR0
, ACR1
, RAMBAR
,
239 static const enum m68k_register mcfv4e_ctrl
[] = {
240 CACR
, TC
, ITT0
, ITT1
, DTT0
, DTT1
, BUSCR
, VBR
, PC
, ROMBAR
,
241 ROMBAR1
, RAMBAR0
, RAMBAR1
, MPCR
, EDRAMBAR
, SECMBAR
, MBAR
, MBAR0
, MBAR1
,
242 PCR1U0
, PCR1L0
, PCR1U1
, PCR1L1
, PCR2U0
, PCR2L0
, PCR2U1
, PCR2L1
,
243 PCR3U0
, PCR3L0
, PCR3U1
, PCR3L1
,
246 #define cpu32_ctrl m68010_ctrl
248 static const enum m68k_register
*control_regs
;
250 /* Internal form of a 68020 instruction. */
254 const char *args
; /* List of opcode info. */
257 int numo
; /* Number of shorts in opcode. */
260 struct m68k_op operands
[6];
262 int nexp
; /* Number of exprs in use. */
263 struct m68k_exp exprs
[4];
265 int nfrag
; /* Number of frags we have to produce. */
268 int fragoff
; /* Where in the current opcode the frag ends. */
275 int nrel
; /* Num of reloc strucs in use. */
282 /* In a pc relative address the difference between the address
283 of the offset and the address that the offset is relative
284 to. This depends on the addressing mode. Basically this
285 is the value to put in the offset field to address the
286 first byte of the offset, without regarding the special
287 significance of some values (in the branch instruction, for
291 /* Whether this expression needs special pic relocation, and if
293 enum pic_relocation pic_reloc
;
296 reloc
[5]; /* Five is enough??? */
299 #define cpu_of_arch(x) ((x) & (m68000up | mcfisa_a))
300 #define float_of_arch(x) ((x) & mfloat)
301 #define mmu_of_arch(x) ((x) & mmmu)
302 #define arch_coldfire_p(x) ((x) & mcfisa_a)
303 #define arch_coldfire_fpu(x) ((x) & cfloat)
305 /* Macros for determining if cpu supports a specific addressing mode. */
306 #define HAVE_LONG_BRANCH(x) ((x) & (m68020|m68030|m68040|m68060|cpu32|mcfisa_b))
308 static struct m68k_it the_ins
; /* The instruction being assembled. */
310 #define op(ex) ((ex)->exp.X_op)
311 #define adds(ex) ((ex)->exp.X_add_symbol)
312 #define subs(ex) ((ex)->exp.X_op_symbol)
313 #define offs(ex) ((ex)->exp.X_add_number)
315 /* Macros for adding things to the m68k_it struct. */
316 #define addword(w) (the_ins.opcode[the_ins.numo++] = (w))
318 /* Like addword, but goes BEFORE general operands. */
321 insop (int w
, const struct m68k_incant
*opcode
)
324 for (z
= the_ins
.numo
; z
> opcode
->m_codenum
; --z
)
325 the_ins
.opcode
[z
] = the_ins
.opcode
[z
- 1];
326 for (z
= 0; z
< the_ins
.nrel
; z
++)
327 the_ins
.reloc
[z
].n
+= 2;
328 for (z
= 0; z
< the_ins
.nfrag
; z
++)
329 the_ins
.fragb
[z
].fragoff
++;
330 the_ins
.opcode
[opcode
->m_codenum
] = w
;
334 /* The numo+1 kludge is so we can hit the low order byte of the prev word.
337 add_fix (int width
, struct m68k_exp
*exp
, int pc_rel
, int pc_fix
)
339 the_ins
.reloc
[the_ins
.nrel
].n
= (width
== 'B' || width
== '3'
340 ? the_ins
.numo
* 2 - 1
342 ? the_ins
.numo
* 2 + 1
343 : the_ins
.numo
* 2));
344 the_ins
.reloc
[the_ins
.nrel
].exp
= exp
->exp
;
345 the_ins
.reloc
[the_ins
.nrel
].wid
= width
;
346 the_ins
.reloc
[the_ins
.nrel
].pcrel_fix
= pc_fix
;
348 the_ins
.reloc
[the_ins
.nrel
].pic_reloc
= exp
->pic_reloc
;
350 the_ins
.reloc
[the_ins
.nrel
++].pcrel
= pc_rel
;
353 /* Cause an extra frag to be generated here, inserting up to 10 bytes
354 (that value is chosen in the frag_var call in md_assemble). TYPE
355 is the subtype of the frag to be generated; its primary type is
356 rs_machine_dependent.
358 The TYPE parameter is also used by md_convert_frag_1 and
359 md_estimate_size_before_relax. The appropriate type of fixup will
360 be emitted by md_convert_frag_1.
362 ADD becomes the FR_SYMBOL field of the frag, and OFF the FR_OFFSET. */
364 add_frag (symbolS
*add
, offsetT off
, int type
)
366 the_ins
.fragb
[the_ins
.nfrag
].fragoff
= the_ins
.numo
;
367 the_ins
.fragb
[the_ins
.nfrag
].fadd
= add
;
368 the_ins
.fragb
[the_ins
.nfrag
].foff
= off
;
369 the_ins
.fragb
[the_ins
.nfrag
++].fragty
= type
;
373 (op (ex) != O_constant && op (ex) != O_big)
375 static char *crack_operand (char *str
, struct m68k_op
*opP
);
376 static int get_num (struct m68k_exp
*exp
, int ok
);
377 static int reverse_16_bits (int in
);
378 static int reverse_8_bits (int in
);
379 static void install_gen_operand (int mode
, int val
);
380 static void install_operand (int mode
, int val
);
381 static void s_bss (int);
382 static void s_data1 (int);
383 static void s_data2 (int);
384 static void s_even (int);
385 static void s_proc (int);
386 static void s_chip (int);
387 static void s_fopt (int);
388 static void s_opt (int);
389 static void s_reg (int);
390 static void s_restore (int);
391 static void s_save (int);
392 static void s_mri_if (int);
393 static void s_mri_else (int);
394 static void s_mri_endi (int);
395 static void s_mri_break (int);
396 static void s_mri_next (int);
397 static void s_mri_for (int);
398 static void s_mri_endf (int);
399 static void s_mri_repeat (int);
400 static void s_mri_until (int);
401 static void s_mri_while (int);
402 static void s_mri_endw (int);
403 static void s_m68k_cpu (int);
404 static void s_m68k_arch (int);
408 unsigned long arch
; /* Architecture features. */
409 const enum m68k_register
*control_regs
; /* Control regs on chip */
410 const char *name
; /* Name */
411 int alias
; /* Alias for a cannonical name. If 1, then
412 succeeds canonical name, if -1 then
413 succeeds canonical name, if <-1 ||>1 this is a
414 deprecated name, and the next/previous name
418 /* We hold flags for features explicitly enabled and explicitly
420 static int current_architecture
;
421 static int not_current_architecture
;
422 static const struct m68k_cpu
*selected_arch
;
423 static const struct m68k_cpu
*selected_cpu
;
424 static int initialized
;
426 /* Architecture models. */
427 static const struct m68k_cpu m68k_archs
[] =
429 {m68000
, m68000_ctrl
, "68000", 0},
430 {m68010
, m68010_ctrl
, "68010", 0},
431 {m68020
|m68881
|m68851
, m68020_ctrl
, "68020", 0},
432 {m68030
|m68881
|m68851
, m68020_ctrl
, "68030", 0},
433 {m68040
, m68040_ctrl
, "68040", 0},
434 {m68060
, m68060_ctrl
, "68060", 0},
435 {cpu32
|m68881
, cpu32_ctrl
, "cpu32", 0},
436 {mcfisa_a
|mcfhwdiv
, NULL
, "isaa", 0},
437 {mcfisa_a
|mcfhwdiv
|mcfisa_aa
|mcfusp
, NULL
, "isaaplus", 0},
438 {mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfusp
, NULL
, "isab", 0},
439 {mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfmac
|mcfusp
, mcf_ctrl
, "cfv4", 0},
440 {mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "cfv4e", 0},
444 /* Architecture extensions, here 'alias' -1 for m68k, +1 for cf and 0
446 static const struct m68k_cpu m68k_extensions
[] =
448 {m68851
, NULL
, "68851", -1},
449 {m68881
, NULL
, "68881", -1},
450 {m68881
, NULL
, "68882", -1},
452 {cfloat
|m68881
, NULL
, "float", 0},
454 {mcfhwdiv
, NULL
, "div", 1},
455 {mcfusp
, NULL
, "usp", 1},
456 {mcfmac
, NULL
, "mac", 1},
457 {mcfemac
, NULL
, "emac", 1},
463 static const struct m68k_cpu m68k_cpus
[] =
465 {m68000
, m68000_ctrl
, "68000", 0},
466 {m68000
, m68000_ctrl
, "68ec000", 1},
467 {m68000
, m68000_ctrl
, "68hc000", 1},
468 {m68000
, m68000_ctrl
, "68hc001", 1},
469 {m68000
, m68000_ctrl
, "68008", 1},
470 {m68000
, m68000_ctrl
, "68302", 1},
471 {m68000
, m68000_ctrl
, "68306", 1},
472 {m68000
, m68000_ctrl
, "68307", 1},
473 {m68000
, m68000_ctrl
, "68322", 1},
474 {m68000
, m68000_ctrl
, "68356", 1},
475 {m68010
, m68010_ctrl
, "68010", 0},
476 {m68020
|m68881
|m68851
, m68020_ctrl
, "68020", 0},
477 {m68020
|m68881
|m68851
, m68020_ctrl
, "68k", 1},
478 {m68020
|m68881
|m68851
, m68020_ctrl
, "68ec020", 1},
479 {m68030
|m68881
|m68851
, m68020_ctrl
, "68030", 0},
480 {m68030
|m68881
|m68851
, m68020_ctrl
, "68ec030", 1},
481 {m68040
, m68040_ctrl
, "68040", 0},
482 {m68040
, m68040_ctrl
, "68ec040", 1},
483 {m68060
, m68060_ctrl
, "68060", 0},
484 {m68060
, m68060_ctrl
, "68ec060", 1},
486 {cpu32
|m68881
, cpu32_ctrl
, "cpu32", 0},
487 {cpu32
|m68881
, cpu32_ctrl
, "68330", 1},
488 {cpu32
|m68881
, cpu32_ctrl
, "68331", 1},
489 {cpu32
|m68881
, cpu32_ctrl
, "68332", 1},
490 {cpu32
|m68881
, cpu32_ctrl
, "68333", 1},
491 {cpu32
|m68881
, cpu32_ctrl
, "68334", 1},
492 {cpu32
|m68881
, cpu32_ctrl
, "68336", 1},
493 {cpu32
|m68881
, cpu32_ctrl
, "68340", 1},
494 {cpu32
|m68881
, cpu32_ctrl
, "68341", 1},
495 {cpu32
|m68881
, cpu32_ctrl
, "68349", 1},
496 {cpu32
|m68881
, cpu32_ctrl
, "68360", 1},
498 {mcfisa_a
, mcf_ctrl
, "5200", 0},
499 {mcfisa_a
, mcf_ctrl
, "5202", 1},
500 {mcfisa_a
, mcf_ctrl
, "5204", 1},
501 {mcfisa_a
, mcf_ctrl
, "5206", 1},
503 {mcfisa_a
|mcfhwdiv
|mcfmac
, mcf_ctrl
, "5206e", 0},
505 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5208_ctrl
, "5207", -1},
506 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5208_ctrl
, "5208", 0},
508 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfmac
|mcfusp
, mcf5210a_ctrl
, "5210a", 0},
509 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfmac
|mcfusp
, mcf5210a_ctrl
, "5211a", 1},
511 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfmac
|mcfusp
, mcf5213_ctrl
, "5211", -1},
512 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfmac
|mcfusp
, mcf5213_ctrl
, "5212", -1},
513 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfmac
|mcfusp
, mcf5213_ctrl
, "5213", 0},
515 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5216_ctrl
, "5214", -1},
516 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5216_ctrl
, "5216", 0},
517 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5216_ctrl
, "521x", 2},
519 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf52235_ctrl
, "52230", -1},
520 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf52235_ctrl
, "52233", -1},
521 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf52235_ctrl
, "52234", -1},
522 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf52235_ctrl
, "52235", 0},
524 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfmac
|mcfusp
, mcf5225_ctrl
, "5224", -1},
525 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfmac
|mcfusp
, mcf5225_ctrl
, "5225", 0},
527 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5235_ctrl
, "5232", -1},
528 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5235_ctrl
, "5233", -1},
529 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5235_ctrl
, "5234", -1},
530 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5235_ctrl
, "5235", -1},
531 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5235_ctrl
, "523x", 0},
533 {mcfisa_a
|mcfhwdiv
|mcfemac
, mcf5249_ctrl
, "5249", 0},
534 {mcfisa_a
|mcfhwdiv
|mcfemac
, mcf5250_ctrl
, "5250", 0},
536 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5271_ctrl
, "5270", -1},
537 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5271_ctrl
, "5271", 0},
539 {mcfisa_a
|mcfhwdiv
|mcfmac
, mcf5272_ctrl
, "5272", 0},
541 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5275_ctrl
, "5274", -1},
542 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5275_ctrl
, "5275", 0},
544 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5282_ctrl
, "5280", -1},
545 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5282_ctrl
, "5281", -1},
546 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5282_ctrl
, "5282", -1},
547 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5282_ctrl
, "528x", 0},
549 {mcfisa_a
|mcfhwdiv
|mcfmac
, mcf_ctrl
, "5307", 0},
551 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5329_ctrl
, "5327", -1},
552 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5329_ctrl
, "5328", -1},
553 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5329_ctrl
, "5329", -1},
554 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5329_ctrl
, "532x", 0},
556 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5373_ctrl
, "5372", -1},
557 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5373_ctrl
, "5373", -1},
558 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5373_ctrl
, "537x", 0},
560 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfmac
, mcf_ctrl
, "5407",0},
562 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5470", -1},
563 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5471", -1},
564 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5472", -1},
565 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5473", -1},
566 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5474", -1},
567 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5475", -1},
568 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "547x", 0},
570 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5480", -1},
571 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5481", -1},
572 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5482", -1},
573 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5483", -1},
574 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5484", -1},
575 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5485", -1},
576 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "548x", 0},
581 static const struct m68k_cpu
*m68k_lookup_cpu
582 (const char *, const struct m68k_cpu
*, int, int *);
583 static int m68k_set_arch (const char *, int, int);
584 static int m68k_set_cpu (const char *, int, int);
585 static int m68k_set_extension (const char *, int, int);
586 static void m68k_init_arch (void);
588 /* This is the assembler relaxation table for m68k. m68k is a rich CISC
589 architecture and we have a lot of relaxation modes. */
591 /* Macros used in the relaxation code. */
592 #define TAB(x,y) (((x) << 2) + (y))
593 #define TABTYPE(x) ((x) >> 2)
595 /* Relaxation states. */
601 /* Here are all the relaxation modes we support. First we can relax ordinary
602 branches. On 68020 and higher and on CPU32 all branch instructions take
603 three forms, so on these CPUs all branches always remain as such. When we
604 have to expand to the LONG form on a 68000, though, we substitute an
605 absolute jump instead. This is a direct replacement for unconditional
606 branches and a branch over a jump for conditional branches. However, if the
607 user requires PIC and disables this with --pcrel, we can only relax between
608 BYTE and SHORT forms, punting if that isn't enough. This gives us four
609 different relaxation modes for branches: */
611 #define BRANCHBWL 0 /* Branch byte, word, or long. */
612 #define BRABSJUNC 1 /* Absolute jump for LONG, unconditional. */
613 #define BRABSJCOND 2 /* Absolute jump for LONG, conditional. */
614 #define BRANCHBW 3 /* Branch byte or word. */
616 /* We also relax coprocessor branches and DBcc's. All CPUs that support
617 coprocessor branches support them in word and long forms, so we have only
618 one relaxation mode for them. DBcc's are word only on all CPUs. We can
619 relax them to the LONG form with a branch-around sequence. This sequence
620 can use a long branch (if available) or an absolute jump (if acceptable).
621 This gives us two relaxation modes. If long branches are not available and
622 absolute jumps are not acceptable, we don't relax DBcc's. */
624 #define FBRANCH 4 /* Coprocessor branch. */
625 #define DBCCLBR 5 /* DBcc relaxable with a long branch. */
626 #define DBCCABSJ 6 /* DBcc relaxable with an absolute jump. */
628 /* That's all for instruction relaxation. However, we also relax PC-relative
629 operands. Specifically, we have three operand relaxation modes. On the
630 68000 PC-relative operands can only be 16-bit, but on 68020 and higher and
631 on CPU32 they may be 16-bit or 32-bit. For the latter we relax between the
632 two. Also PC+displacement+index operands in their simple form (with a non-
633 suppressed index without memory indirection) are supported on all CPUs, but
634 on the 68000 the displacement can be 8-bit only, whereas on 68020 and higher
635 and on CPU32 we relax it to SHORT and LONG forms as well using the extended
636 form of the PC+displacement+index operand. Finally, some absolute operands
637 can be relaxed down to 16-bit PC-relative. */
639 #define PCREL1632 7 /* 16-bit or 32-bit PC-relative. */
640 #define PCINDEX 8 /* PC + displacement + index. */
641 #define ABSTOPCREL 9 /* Absolute relax down to 16-bit PC-relative. */
643 /* Note that calls to frag_var need to specify the maximum expansion
644 needed; this is currently 10 bytes for DBCC. */
647 How far Forward this mode will reach:
648 How far Backward this mode will reach:
649 How many bytes this mode will add to the size of the frag
650 Which mode to go to if the offset won't fit in this one
652 Please check tc-m68k.h:md_prepare_relax_scan if changing this table. */
653 relax_typeS md_relax_table
[] =
655 { 127, -128, 0, TAB (BRANCHBWL
, SHORT
) },
656 { 32767, -32768, 2, TAB (BRANCHBWL
, LONG
) },
660 { 127, -128, 0, TAB (BRABSJUNC
, SHORT
) },
661 { 32767, -32768, 2, TAB (BRABSJUNC
, LONG
) },
665 { 127, -128, 0, TAB (BRABSJCOND
, SHORT
) },
666 { 32767, -32768, 2, TAB (BRABSJCOND
, LONG
) },
670 { 127, -128, 0, TAB (BRANCHBW
, SHORT
) },
675 { 1, 1, 0, 0 }, /* FBRANCH doesn't come BYTE. */
676 { 32767, -32768, 2, TAB (FBRANCH
, LONG
) },
680 { 1, 1, 0, 0 }, /* DBCC doesn't come BYTE. */
681 { 32767, -32768, 2, TAB (DBCCLBR
, LONG
) },
685 { 1, 1, 0, 0 }, /* DBCC doesn't come BYTE. */
686 { 32767, -32768, 2, TAB (DBCCABSJ
, LONG
) },
690 { 1, 1, 0, 0 }, /* PCREL1632 doesn't come BYTE. */
691 { 32767, -32768, 2, TAB (PCREL1632
, LONG
) },
695 { 125, -130, 0, TAB (PCINDEX
, SHORT
) },
696 { 32765, -32770, 2, TAB (PCINDEX
, LONG
) },
700 { 1, 1, 0, 0 }, /* ABSTOPCREL doesn't come BYTE. */
701 { 32767, -32768, 2, TAB (ABSTOPCREL
, LONG
) },
706 /* These are the machine dependent pseudo-ops. These are included so
707 the assembler can work on the output from the SUN C compiler, which
710 /* This table describes all the machine specific pseudo-ops the assembler
711 has to support. The fields are:
712 pseudo-op name without dot
713 function to call to execute this pseudo-op
714 Integer arg to pass to the function. */
715 const pseudo_typeS md_pseudo_table
[] =
717 {"data1", s_data1
, 0},
718 {"data2", s_data2
, 0},
721 {"skip", s_space
, 0},
723 #if defined (TE_SUN3) || defined (OBJ_ELF)
724 {"align", s_align_bytes
, 0},
727 {"swbeg", s_ignore
, 0},
729 {"extend", float_cons
, 'x'},
730 {"ldouble", float_cons
, 'x'},
732 {"arch", s_m68k_arch
, 0},
733 {"cpu", s_m68k_cpu
, 0},
735 /* The following pseudo-ops are supported for MRI compatibility. */
737 {"comline", s_space
, 1},
739 {"mask2", s_ignore
, 0},
742 {"restore", s_restore
, 0},
746 {"if.b", s_mri_if
, 'b'},
747 {"if.w", s_mri_if
, 'w'},
748 {"if.l", s_mri_if
, 'l'},
749 {"else", s_mri_else
, 0},
750 {"else.s", s_mri_else
, 's'},
751 {"else.l", s_mri_else
, 'l'},
752 {"endi", s_mri_endi
, 0},
753 {"break", s_mri_break
, 0},
754 {"break.s", s_mri_break
, 's'},
755 {"break.l", s_mri_break
, 'l'},
756 {"next", s_mri_next
, 0},
757 {"next.s", s_mri_next
, 's'},
758 {"next.l", s_mri_next
, 'l'},
759 {"for", s_mri_for
, 0},
760 {"for.b", s_mri_for
, 'b'},
761 {"for.w", s_mri_for
, 'w'},
762 {"for.l", s_mri_for
, 'l'},
763 {"endf", s_mri_endf
, 0},
764 {"repeat", s_mri_repeat
, 0},
765 {"until", s_mri_until
, 0},
766 {"until.b", s_mri_until
, 'b'},
767 {"until.w", s_mri_until
, 'w'},
768 {"until.l", s_mri_until
, 'l'},
769 {"while", s_mri_while
, 0},
770 {"while.b", s_mri_while
, 'b'},
771 {"while.w", s_mri_while
, 'w'},
772 {"while.l", s_mri_while
, 'l'},
773 {"endw", s_mri_endw
, 0},
778 /* The mote pseudo ops are put into the opcode table, since they
779 don't start with a . they look like opcodes to gas. */
781 const pseudo_typeS mote_pseudo_table
[] =
794 {"xdef", s_globl
, 0},
796 {"align", s_align_bytes
, 0},
798 {"align", s_align_ptwo
, 0},
801 {"sect", obj_coff_section
, 0},
802 {"section", obj_coff_section
, 0},
807 /* Truncate and sign-extend at 32 bits, so that building on a 64-bit host
808 gives identical results to a 32-bit host. */
809 #define TRUNC(X) ((valueT) (X) & 0xffffffff)
810 #define SEXT(X) ((TRUNC (X) ^ 0x80000000) - 0x80000000)
812 #define issbyte(x) ((valueT) SEXT (x) + 0x80 < 0x100)
813 #define isubyte(x) ((valueT) TRUNC (x) < 0x100)
814 #define issword(x) ((valueT) SEXT (x) + 0x8000 < 0x10000)
815 #define isuword(x) ((valueT) TRUNC (x) < 0x10000)
817 #define isbyte(x) ((valueT) SEXT (x) + 0xff < 0x1ff)
818 #define isword(x) ((valueT) SEXT (x) + 0xffff < 0x1ffff)
819 #define islong(x) (1)
821 static char notend_table
[256];
822 static char alt_notend_table
[256];
824 (! (notend_table[(unsigned char) *s] \
826 && alt_notend_table[(unsigned char) s[1]])))
830 /* Return zero if the reference to SYMBOL from within the same segment may
833 /* On an ELF system, we can't relax an externally visible symbol,
834 because it may be overridden by a shared library. However, if
835 TARGET_OS is "elf", then we presume that we are assembling for an
836 embedded system, in which case we don't have to worry about shared
837 libraries, and we can relax any external sym. */
839 #define relaxable_symbol(symbol) \
840 (!((S_IS_EXTERNAL (symbol) && EXTERN_FORCE_RELOC) \
841 || S_IS_WEAK (symbol)))
843 /* Compute the relocation code for a fixup of SIZE bytes, using pc
844 relative relocation if PCREL is non-zero. PIC says whether a special
845 pic relocation was requested. */
847 static bfd_reloc_code_real_type
848 get_reloc_code (int size
, int pcrel
, enum pic_relocation pic
)
856 return BFD_RELOC_8_GOT_PCREL
;
858 return BFD_RELOC_16_GOT_PCREL
;
860 return BFD_RELOC_32_GOT_PCREL
;
868 return BFD_RELOC_8_GOTOFF
;
870 return BFD_RELOC_16_GOTOFF
;
872 return BFD_RELOC_32_GOTOFF
;
880 return BFD_RELOC_8_PLT_PCREL
;
882 return BFD_RELOC_16_PLT_PCREL
;
884 return BFD_RELOC_32_PLT_PCREL
;
892 return BFD_RELOC_8_PLTOFF
;
894 return BFD_RELOC_16_PLTOFF
;
896 return BFD_RELOC_32_PLTOFF
;
906 return BFD_RELOC_8_PCREL
;
908 return BFD_RELOC_16_PCREL
;
910 return BFD_RELOC_32_PCREL
;
930 as_bad (_("Can not do %d byte pc-relative relocation"), size
);
932 as_bad (_("Can not do %d byte pc-relative pic relocation"), size
);
937 as_bad (_("Can not do %d byte relocation"), size
);
939 as_bad (_("Can not do %d byte pic relocation"), size
);
942 return BFD_RELOC_NONE
;
945 /* Here we decide which fixups can be adjusted to make them relative
946 to the beginning of the section instead of the symbol. Basically
947 we need to make sure that the dynamic relocations are done
948 correctly, so in some cases we force the original symbol to be
951 tc_m68k_fix_adjustable (fixS
*fixP
)
953 /* Adjust_reloc_syms doesn't know about the GOT. */
954 switch (fixP
->fx_r_type
)
956 case BFD_RELOC_8_GOT_PCREL
:
957 case BFD_RELOC_16_GOT_PCREL
:
958 case BFD_RELOC_32_GOT_PCREL
:
959 case BFD_RELOC_8_GOTOFF
:
960 case BFD_RELOC_16_GOTOFF
:
961 case BFD_RELOC_32_GOTOFF
:
962 case BFD_RELOC_8_PLT_PCREL
:
963 case BFD_RELOC_16_PLT_PCREL
:
964 case BFD_RELOC_32_PLT_PCREL
:
965 case BFD_RELOC_8_PLTOFF
:
966 case BFD_RELOC_16_PLTOFF
:
967 case BFD_RELOC_32_PLTOFF
:
970 case BFD_RELOC_VTABLE_INHERIT
:
971 case BFD_RELOC_VTABLE_ENTRY
:
981 #define get_reloc_code(SIZE,PCREL,OTHER) NO_RELOC
983 #define relaxable_symbol(symbol) 1
988 tc_gen_reloc (asection
*section ATTRIBUTE_UNUSED
, fixS
*fixp
)
991 bfd_reloc_code_real_type code
;
993 /* If the tcbit is set, then this was a fixup of a negative value
994 that was never resolved. We do not have a reloc to handle this,
995 so just return. We assume that other code will have detected this
996 situation and produced a helpful error message, so we just tell the
997 user that the reloc cannot be produced. */
1001 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1002 _("Unable to produce reloc against symbol '%s'"),
1003 S_GET_NAME (fixp
->fx_addsy
));
1007 if (fixp
->fx_r_type
!= BFD_RELOC_NONE
)
1009 code
= fixp
->fx_r_type
;
1011 /* Since DIFF_EXPR_OK is defined in tc-m68k.h, it is possible
1012 that fixup_segment converted a non-PC relative reloc into a
1013 PC relative reloc. In such a case, we need to convert the
1020 code
= BFD_RELOC_8_PCREL
;
1023 code
= BFD_RELOC_16_PCREL
;
1026 code
= BFD_RELOC_32_PCREL
;
1028 case BFD_RELOC_8_PCREL
:
1029 case BFD_RELOC_16_PCREL
:
1030 case BFD_RELOC_32_PCREL
:
1031 case BFD_RELOC_8_GOT_PCREL
:
1032 case BFD_RELOC_16_GOT_PCREL
:
1033 case BFD_RELOC_32_GOT_PCREL
:
1034 case BFD_RELOC_8_GOTOFF
:
1035 case BFD_RELOC_16_GOTOFF
:
1036 case BFD_RELOC_32_GOTOFF
:
1037 case BFD_RELOC_8_PLT_PCREL
:
1038 case BFD_RELOC_16_PLT_PCREL
:
1039 case BFD_RELOC_32_PLT_PCREL
:
1040 case BFD_RELOC_8_PLTOFF
:
1041 case BFD_RELOC_16_PLTOFF
:
1042 case BFD_RELOC_32_PLTOFF
:
1045 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1046 _("Cannot make %s relocation PC relative"),
1047 bfd_get_reloc_code_name (code
));
1053 #define F(SZ,PCREL) (((SZ) << 1) + (PCREL))
1054 switch (F (fixp
->fx_size
, fixp
->fx_pcrel
))
1056 #define MAP(SZ,PCREL,TYPE) case F(SZ,PCREL): code = (TYPE); break
1057 MAP (1, 0, BFD_RELOC_8
);
1058 MAP (2, 0, BFD_RELOC_16
);
1059 MAP (4, 0, BFD_RELOC_32
);
1060 MAP (1, 1, BFD_RELOC_8_PCREL
);
1061 MAP (2, 1, BFD_RELOC_16_PCREL
);
1062 MAP (4, 1, BFD_RELOC_32_PCREL
);
1070 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
1071 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
1072 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
1073 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
1076 reloc
->addend
= fixp
->fx_addnumber
;
1080 if (!fixp
->fx_pcrel
)
1081 reloc
->addend
= fixp
->fx_addnumber
;
1083 reloc
->addend
= (section
->vma
1084 /* Explicit sign extension in case char is
1086 + ((fixp
->fx_pcrel_adjust
& 0xff) ^ 0x80) - 0x80
1087 + fixp
->fx_addnumber
1088 + md_pcrel_from (fixp
));
1091 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
1092 assert (reloc
->howto
!= 0);
1097 /* Handle of the OPCODE hash table. NULL means any use before
1098 m68k_ip_begin() will crash. */
1099 static struct hash_control
*op_hash
;
1101 /* Assemble an m68k instruction. */
1104 m68k_ip (char *instring
)
1107 register struct m68k_op
*opP
;
1108 register const struct m68k_incant
*opcode
;
1109 register const char *s
;
1110 register int tmpreg
= 0, baseo
= 0, outro
= 0, nextword
;
1111 char *pdot
, *pdotmove
;
1112 enum m68k_size siz1
, siz2
;
1116 struct m68k_op operands_backup
[6];
1117 LITTLENUM_TYPE words
[6];
1118 LITTLENUM_TYPE
*wordp
;
1119 unsigned long ok_arch
= 0;
1121 if (*instring
== ' ')
1122 instring
++; /* Skip leading whitespace. */
1124 /* Scan up to end of operation-code, which MUST end in end-of-string
1125 or exactly 1 space. */
1127 for (p
= instring
; *p
!= '\0'; p
++)
1137 the_ins
.error
= _("No operator");
1141 /* p now points to the end of the opcode name, probably whitespace.
1142 Make sure the name is null terminated by clobbering the
1143 whitespace, look it up in the hash table, then fix it back.
1144 Remove a dot, first, since the opcode tables have none. */
1147 for (pdotmove
= pdot
; pdotmove
< p
; pdotmove
++)
1148 *pdotmove
= pdotmove
[1];
1154 opcode
= (const struct m68k_incant
*) hash_find (op_hash
, instring
);
1159 for (pdotmove
= p
; pdotmove
> pdot
; pdotmove
--)
1160 *pdotmove
= pdotmove
[-1];
1167 the_ins
.error
= _("Unknown operator");
1171 /* Found a legitimate opcode, start matching operands. */
1175 if (opcode
->m_operands
== 0)
1177 char *old
= input_line_pointer
;
1179 input_line_pointer
= p
;
1180 /* Ahh - it's a motorola style psuedo op. */
1181 mote_pseudo_table
[opcode
->m_opnum
].poc_handler
1182 (mote_pseudo_table
[opcode
->m_opnum
].poc_val
);
1183 input_line_pointer
= old
;
1189 if (flag_mri
&& opcode
->m_opnum
== 0)
1191 /* In MRI mode, random garbage is allowed after an instruction
1192 which accepts no operands. */
1193 the_ins
.args
= opcode
->m_operands
;
1194 the_ins
.numargs
= opcode
->m_opnum
;
1195 the_ins
.numo
= opcode
->m_codenum
;
1196 the_ins
.opcode
[0] = getone (opcode
);
1197 the_ins
.opcode
[1] = gettwo (opcode
);
1201 for (opP
= &the_ins
.operands
[0]; *p
; opP
++)
1203 p
= crack_operand (p
, opP
);
1207 the_ins
.error
= opP
->error
;
1212 opsfound
= opP
- &the_ins
.operands
[0];
1214 /* This ugly hack is to support the floating pt opcodes in their
1215 standard form. Essentially, we fake a first enty of type COP#1 */
1216 if (opcode
->m_operands
[0] == 'I')
1220 for (n
= opsfound
; n
> 0; --n
)
1221 the_ins
.operands
[n
] = the_ins
.operands
[n
- 1];
1223 memset (&the_ins
.operands
[0], '\0', sizeof (the_ins
.operands
[0]));
1224 the_ins
.operands
[0].mode
= CONTROL
;
1225 the_ins
.operands
[0].reg
= m68k_float_copnum
;
1229 /* We've got the operands. Find an opcode that'll accept them. */
1232 /* If we didn't get the right number of ops, or we have no
1233 common model with this pattern then reject this pattern. */
1235 ok_arch
|= opcode
->m_arch
;
1236 if (opsfound
!= opcode
->m_opnum
1237 || ((opcode
->m_arch
& current_architecture
) == 0))
1243 /* Make a copy of the operands of this insn so that
1244 we can modify them safely, should we want to. */
1245 assert (opsfound
<= (int) ARRAY_SIZE (operands_backup
));
1246 for (i
= 0; i
< opsfound
; i
++)
1247 operands_backup
[i
] = the_ins
.operands
[i
];
1249 for (s
= opcode
->m_operands
, opP
= &operands_backup
[0];
1253 /* Warning: this switch is huge! */
1254 /* I've tried to organize the cases into this order:
1255 non-alpha first, then alpha by letter. Lower-case
1256 goes directly before uppercase counterpart. */
1257 /* Code with multiple case ...: gets sorted by the lowest
1258 case ... it belongs to. I hope this makes sense. */
1364 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
1381 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
1400 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
1410 if (opP
->mode
!= IMMED
)
1412 else if (s
[1] == 'b'
1413 && ! isvar (&opP
->disp
)
1414 && (opP
->disp
.exp
.X_op
!= O_constant
1415 || ! isbyte (opP
->disp
.exp
.X_add_number
)))
1417 else if (s
[1] == 'B'
1418 && ! isvar (&opP
->disp
)
1419 && (opP
->disp
.exp
.X_op
!= O_constant
1420 || ! issbyte (opP
->disp
.exp
.X_add_number
)))
1422 else if (s
[1] == 'w'
1423 && ! isvar (&opP
->disp
)
1424 && (opP
->disp
.exp
.X_op
!= O_constant
1425 || ! isword (opP
->disp
.exp
.X_add_number
)))
1427 else if (s
[1] == 'W'
1428 && ! isvar (&opP
->disp
)
1429 && (opP
->disp
.exp
.X_op
!= O_constant
1430 || ! issword (opP
->disp
.exp
.X_add_number
)))
1436 if (opP
->mode
!= IMMED
)
1441 if (opP
->mode
== AREG
1442 || opP
->mode
== CONTROL
1443 || opP
->mode
== FPREG
1444 || opP
->mode
== IMMED
1445 || opP
->mode
== REGLST
1446 || (opP
->mode
!= ABSL
1448 || opP
->reg
== ZPC
)))
1453 if (opP
->mode
== CONTROL
1454 || opP
->mode
== FPREG
1455 || opP
->mode
== REGLST
1456 || opP
->mode
== IMMED
1457 || (opP
->mode
!= ABSL
1459 || opP
->reg
== ZPC
)))
1487 if (opP
->mode
== CONTROL
1488 || opP
->mode
== FPREG
1489 || opP
->mode
== REGLST
)
1494 if (opP
->mode
!= AINC
)
1499 if (opP
->mode
!= ADEC
)
1549 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
1570 case '~': /* For now! (JF FOO is this right?) */
1592 if (opP
->mode
!= CONTROL
1593 || (opP
->reg
!= TT0
&& opP
->reg
!= TT1
))
1598 if (opP
->mode
!= AREG
)
1603 if (opP
->mode
!= AINDR
)
1608 if (opP
->mode
!= AINDR
&& opP
->mode
!= AINC
&& opP
->mode
!= ADEC
1609 && (opP
->mode
!= DISP
1611 || opP
->reg
> ADDR7
))
1616 if (opP
->mode
!= ABSL
1618 && strncmp (instring
, "jbsr", 4) == 0))
1641 if (opP
->mode
!= CONTROL
|| opP
->reg
!= CCR
)
1646 if (opP
->mode
!= DISP
1648 || opP
->reg
> ADDR7
)
1653 if (opP
->mode
!= DREG
)
1658 if (opP
->reg
!= ACC
)
1663 if (opP
->reg
!= ACC
&& opP
->reg
!= ACC1
1664 && opP
->reg
!= ACC2
&& opP
->reg
!= ACC3
)
1669 if (opP
->mode
!= FPREG
)
1674 if (opP
->reg
!= MACSR
)
1679 if (opP
->reg
!= ACCEXT01
&& opP
->reg
!= ACCEXT23
)
1684 if (opP
->reg
!= MASK
)
1689 if (opP
->mode
!= CONTROL
1696 if (opP
->mode
!= LSH
&& opP
->mode
!= RSH
)
1701 if (opP
->mode
!= CONTROL
1703 || opP
->reg
> last_movec_reg
1708 const enum m68k_register
*rp
;
1710 for (rp
= control_regs
; *rp
; rp
++)
1711 if (*rp
== opP
->reg
)
1719 if (opP
->mode
!= IMMED
)
1725 if (opP
->mode
== DREG
1726 || opP
->mode
== AREG
1727 || opP
->mode
== FPREG
)
1736 opP
->mask
= 1 << (opP
->reg
- DATA0
);
1739 opP
->mask
= 1 << (opP
->reg
- ADDR0
+ 8);
1742 opP
->mask
= 1 << (opP
->reg
- FP0
+ 16);
1750 else if (opP
->mode
== CONTROL
)
1759 opP
->mask
= 1 << 24;
1762 opP
->mask
= 1 << 25;
1765 opP
->mask
= 1 << 26;
1774 else if (opP
->mode
!= REGLST
)
1776 else if (s
[1] == '8' && (opP
->mask
& 0x0ffffff) != 0)
1778 else if (s
[1] == '3' && (opP
->mask
& 0x7000000) != 0)
1783 if (opP
->mode
!= IMMED
)
1785 else if (opP
->disp
.exp
.X_op
!= O_constant
1786 || ! issbyte (opP
->disp
.exp
.X_add_number
))
1788 else if (! m68k_quick
1789 && instring
[3] != 'q'
1790 && instring
[4] != 'q')
1795 if (opP
->mode
!= DREG
1796 && opP
->mode
!= IMMED
1797 && opP
->mode
!= ABSL
)
1802 if (opP
->mode
!= IMMED
)
1804 else if (opP
->disp
.exp
.X_op
!= O_constant
1805 || TRUNC (opP
->disp
.exp
.X_add_number
) - 1 > 7)
1807 else if (! m68k_quick
1808 && (strncmp (instring
, "add", 3) == 0
1809 || strncmp (instring
, "sub", 3) == 0)
1810 && instring
[3] != 'q')
1815 if (opP
->mode
!= DREG
&& opP
->mode
!= AREG
)
1820 if (opP
->mode
!= AINDR
1821 && (opP
->mode
!= BASE
1823 && opP
->reg
!= ZADDR0
)
1824 || opP
->disp
.exp
.X_op
!= O_absent
1825 || ((opP
->index
.reg
< DATA0
1826 || opP
->index
.reg
> DATA7
)
1827 && (opP
->index
.reg
< ADDR0
1828 || opP
->index
.reg
> ADDR7
))
1829 || opP
->index
.size
!= SIZE_UNSPEC
1830 || opP
->index
.scale
!= 1))
1835 if (opP
->mode
!= CONTROL
1836 || ! (opP
->reg
== FPI
1838 || opP
->reg
== FPC
))
1843 if (opP
->mode
!= CONTROL
|| opP
->reg
!= SR
)
1848 if (opP
->mode
!= IMMED
)
1850 else if (opP
->disp
.exp
.X_op
!= O_constant
1851 || TRUNC (opP
->disp
.exp
.X_add_number
) > 7)
1856 if (opP
->mode
!= CONTROL
|| opP
->reg
!= USP
)
1861 if (opP
->mode
!= IMMED
)
1863 else if (opP
->disp
.exp
.X_op
!= O_constant
1864 || (TRUNC (opP
->disp
.exp
.X_add_number
) != 0xffffffff
1865 && TRUNC (opP
->disp
.exp
.X_add_number
) - 1 > 6))
1869 /* JF these are out of order. We could put them
1870 in order if we were willing to put up with
1871 bunches of #ifdef m68851s in the code.
1873 Don't forget that you need these operands
1874 to use 68030 MMU instructions. */
1876 /* Memory addressing mode used by pflushr. */
1878 if (opP
->mode
== CONTROL
1879 || opP
->mode
== FPREG
1880 || opP
->mode
== DREG
1881 || opP
->mode
== AREG
1882 || opP
->mode
== REGLST
)
1884 /* We should accept immediate operands, but they
1885 supposedly have to be quad word, and we don't
1886 handle that. I would like to see what a Motorola
1887 assembler does before doing something here. */
1888 if (opP
->mode
== IMMED
)
1893 if (opP
->mode
!= CONTROL
1894 || (opP
->reg
!= SFC
&& opP
->reg
!= DFC
))
1899 if (opP
->mode
!= CONTROL
|| opP
->reg
!= TC
)
1904 if (opP
->mode
!= CONTROL
|| opP
->reg
!= AC
)
1909 if (opP
->mode
!= CONTROL
1912 && opP
->reg
!= SCC
))
1917 if (opP
->mode
!= CONTROL
1923 if (opP
->mode
!= CONTROL
1926 && opP
->reg
!= CRP
))
1950 if (opP
->mode
!= CONTROL
1951 || (!(opP
->reg
>= BAD
&& opP
->reg
<= BAD
+ 7)
1952 && !(opP
->reg
>= BAC
&& opP
->reg
<= BAC
+ 7)))
1957 if (opP
->mode
!= CONTROL
|| opP
->reg
!= PSR
)
1962 if (opP
->mode
!= CONTROL
|| opP
->reg
!= PCSR
)
1967 if (opP
->mode
!= CONTROL
1976 if (opP
->mode
!= ABSL
)
1981 if (opP
->reg
< DATA0L
|| opP
->reg
> ADDR7U
)
1983 /* FIXME: kludge instead of fixing parser:
1984 upper/lower registers are *not* CONTROL
1985 registers, but ordinary ones. */
1986 if ((opP
->reg
>= DATA0L
&& opP
->reg
<= DATA7L
)
1987 || (opP
->reg
>= DATA0U
&& opP
->reg
<= DATA7U
))
1994 if (!(opP
->mode
== AINDR
1995 || (opP
->mode
== DISP
1996 && !(opP
->reg
== PC
|| opP
->reg
== ZPC
))))
2001 if (!(opP
->mode
== AINDR
|| opP
->mode
== DISP
))
2013 /* Since we have found the correct instruction, copy
2014 in the modifications that we may have made. */
2016 for (i
= 0; i
< opsfound
; i
++)
2017 the_ins
.operands
[i
] = operands_backup
[i
];
2023 opcode
= opcode
->m_next
;
2028 && !(ok_arch
& current_architecture
))
2030 const struct m68k_cpu
*cpu
;
2033 char *buf
= xmalloc (space
+ 1);
2037 the_ins
.error
= buf
;
2038 /* Make sure there's a NUL at the end of the buffer -- strncpy
2039 won't write one when it runs out of buffer */
2041 #define APPEND(STRING) \
2042 (strncpy (buf, STRING, space), len = strlen (buf), buf += len, space -= len)
2044 APPEND (_("invalid instruction for this architecture; needs "));
2048 APPEND (_("ColdFire ISA_A"));
2051 APPEND (_("ColdFire hardware divide"));
2054 APPEND (_("ColdFire ISA_A+"));
2057 APPEND (_("ColdFire ISA_B"));
2060 APPEND (_("ColdFire fpu"));
2063 APPEND (_("M68K fpu"));
2066 APPEND (_("M68K mmu"));
2069 APPEND (_("68020 or higher"));
2072 APPEND (_("68000 or higher"));
2075 APPEND (_("68010 or higher"));
2083 for (cpu
= m68k_cpus
; cpu
->name
; cpu
++)
2084 if (!cpu
->alias
&& (cpu
->arch
& ok_arch
))
2086 const struct m68k_cpu
*alias
;
2093 if (cpu
!= m68k_cpus
)
2094 for (alias
= cpu
- 1; alias
->alias
; alias
--)
2098 APPEND (alias
->name
);
2101 for (alias
= cpu
+ 1; alias
->alias
; alias
++)
2105 APPEND (alias
->name
);
2117 /* we ran out of space, so replace the end of the list
2122 strcpy (buf
, " ...");
2126 the_ins
.error
= _("operands mismatch");
2133 /* Now assemble it. */
2134 the_ins
.args
= opcode
->m_operands
;
2135 the_ins
.numargs
= opcode
->m_opnum
;
2136 the_ins
.numo
= opcode
->m_codenum
;
2137 the_ins
.opcode
[0] = getone (opcode
);
2138 the_ins
.opcode
[1] = gettwo (opcode
);
2140 for (s
= the_ins
.args
, opP
= &the_ins
.operands
[0]; *s
; s
+= 2, opP
++)
2142 /* This switch is a doozy.
2143 Watch the first step; its a big one! */
2176 tmpreg
= 0x3c; /* 7.4 */
2177 if (strchr ("bwl", s
[1]))
2178 nextword
= get_num (&opP
->disp
, 90);
2180 nextword
= get_num (&opP
->disp
, 0);
2181 if (isvar (&opP
->disp
))
2182 add_fix (s
[1], &opP
->disp
, 0, 0);
2186 if (!isbyte (nextword
))
2187 opP
->error
= _("operand out of range");
2192 if (!isword (nextword
))
2193 opP
->error
= _("operand out of range");
2198 if (!issword (nextword
))
2199 opP
->error
= _("operand out of range");
2204 addword (nextword
>> 16);
2231 /* We gotta put out some float. */
2232 if (op (&opP
->disp
) != O_big
)
2237 /* Can other cases happen here? */
2238 if (op (&opP
->disp
) != O_constant
)
2241 val
= (valueT
) offs (&opP
->disp
);
2245 generic_bignum
[gencnt
] = (LITTLENUM_TYPE
) val
;
2246 val
>>= LITTLENUM_NUMBER_OF_BITS
;
2250 offs (&opP
->disp
) = gencnt
;
2252 if (offs (&opP
->disp
) > 0)
2254 if (offs (&opP
->disp
) > baseo
)
2256 as_warn (_("Bignum too big for %c format; truncated"),
2258 offs (&opP
->disp
) = baseo
;
2260 baseo
-= offs (&opP
->disp
);
2263 for (wordp
= generic_bignum
+ offs (&opP
->disp
) - 1;
2264 offs (&opP
->disp
)--;
2269 gen_to_words (words
, baseo
, (long) outro
);
2270 for (wordp
= words
; baseo
--; wordp
++)
2274 tmpreg
= opP
->reg
- DATA
; /* 0.dreg */
2277 tmpreg
= 0x08 + opP
->reg
- ADDR
; /* 1.areg */
2280 tmpreg
= 0x10 + opP
->reg
- ADDR
; /* 2.areg */
2283 tmpreg
= 0x20 + opP
->reg
- ADDR
; /* 4.areg */
2286 tmpreg
= 0x18 + opP
->reg
- ADDR
; /* 3.areg */
2290 nextword
= get_num (&opP
->disp
, 90);
2292 /* Convert mode 5 addressing with a zero offset into
2293 mode 2 addressing to reduce the instruction size by a
2295 if (! isvar (&opP
->disp
)
2297 && (opP
->disp
.size
== SIZE_UNSPEC
)
2298 && (opP
->reg
>= ADDR0
)
2299 && (opP
->reg
<= ADDR7
))
2301 tmpreg
= 0x10 + opP
->reg
- ADDR
; /* 2.areg */
2306 && ! isvar (&opP
->disp
)
2309 opP
->disp
.exp
.X_op
= O_symbol
;
2310 opP
->disp
.exp
.X_add_symbol
=
2311 section_symbol (absolute_section
);
2314 /* Force into index mode. Hope this works. */
2316 /* We do the first bit for 32-bit displacements, and the
2317 second bit for 16 bit ones. It is possible that we
2318 should make the default be WORD instead of LONG, but
2319 I think that'd break GCC, so we put up with a little
2320 inefficiency for the sake of working output. */
2322 if (!issword (nextword
)
2323 || (isvar (&opP
->disp
)
2324 && ((opP
->disp
.size
== SIZE_UNSPEC
2325 && flag_short_refs
== 0
2326 && cpu_of_arch (current_architecture
) >= m68020
2327 && ! arch_coldfire_p (current_architecture
))
2328 || opP
->disp
.size
== SIZE_LONG
)))
2330 if (cpu_of_arch (current_architecture
) < m68020
2331 || arch_coldfire_p (current_architecture
))
2333 _("displacement too large for this architecture; needs 68020 or higher");
2335 tmpreg
= 0x3B; /* 7.3 */
2337 tmpreg
= 0x30 + opP
->reg
- ADDR
; /* 6.areg */
2338 if (isvar (&opP
->disp
))
2342 if (opP
->disp
.size
== SIZE_LONG
2344 /* If the displacement needs pic
2345 relocation it cannot be relaxed. */
2346 || opP
->disp
.pic_reloc
!= pic_none
2351 add_fix ('l', &opP
->disp
, 1, 2);
2355 add_frag (adds (&opP
->disp
),
2356 SEXT (offs (&opP
->disp
)),
2357 TAB (PCREL1632
, SZ_UNDEF
));
2364 add_fix ('l', &opP
->disp
, 0, 0);
2369 addword (nextword
>> 16);
2374 tmpreg
= 0x3A; /* 7.2 */
2376 tmpreg
= 0x28 + opP
->reg
- ADDR
; /* 5.areg */
2378 if (isvar (&opP
->disp
))
2382 add_fix ('w', &opP
->disp
, 1, 0);
2385 add_fix ('w', &opP
->disp
, 0, 0);
2395 baseo
= get_num (&opP
->disp
, 90);
2396 if (opP
->mode
== POST
|| opP
->mode
== PRE
)
2397 outro
= get_num (&opP
->odisp
, 90);
2398 /* Figure out the `addressing mode'.
2399 Also turn on the BASE_DISABLE bit, if needed. */
2400 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
2402 tmpreg
= 0x3b; /* 7.3 */
2403 if (opP
->reg
== ZPC
)
2406 else if (opP
->reg
== 0)
2409 tmpreg
= 0x30; /* 6.garbage */
2411 else if (opP
->reg
>= ZADDR0
&& opP
->reg
<= ZADDR7
)
2414 tmpreg
= 0x30 + opP
->reg
- ZADDR0
;
2417 tmpreg
= 0x30 + opP
->reg
- ADDR
; /* 6.areg */
2419 siz1
= opP
->disp
.size
;
2420 if (opP
->mode
== POST
|| opP
->mode
== PRE
)
2421 siz2
= opP
->odisp
.size
;
2425 /* Index register stuff. */
2426 if (opP
->index
.reg
!= 0
2427 && opP
->index
.reg
>= DATA
2428 && opP
->index
.reg
<= ADDR7
)
2430 nextword
|= (opP
->index
.reg
- DATA
) << 12;
2432 if (opP
->index
.size
== SIZE_LONG
2433 || (opP
->index
.size
== SIZE_UNSPEC
2434 && m68k_index_width_default
== SIZE_LONG
))
2437 if ((opP
->index
.scale
!= 1
2438 && cpu_of_arch (current_architecture
) < m68020
)
2439 || (opP
->index
.scale
== 8
2440 && (arch_coldfire_p (current_architecture
)
2441 && !arch_coldfire_fpu (current_architecture
))))
2444 _("scale factor invalid on this architecture; needs cpu32 or 68020 or higher");
2447 if (arch_coldfire_p (current_architecture
)
2448 && opP
->index
.size
== SIZE_WORD
)
2449 opP
->error
= _("invalid index size for coldfire");
2451 switch (opP
->index
.scale
)
2468 GET US OUT OF HERE! */
2470 /* Must be INDEX, with an index register. Address
2471 register cannot be ZERO-PC, and either :b was
2472 forced, or we know it will fit. For a 68000 or
2473 68010, force this mode anyways, because the
2474 larger modes aren't supported. */
2475 if (opP
->mode
== BASE
2476 && ((opP
->reg
>= ADDR0
2477 && opP
->reg
<= ADDR7
)
2480 if (siz1
== SIZE_BYTE
2481 || cpu_of_arch (current_architecture
) < m68020
2482 || arch_coldfire_p (current_architecture
)
2483 || (siz1
== SIZE_UNSPEC
2484 && ! isvar (&opP
->disp
)
2485 && issbyte (baseo
)))
2487 nextword
+= baseo
& 0xff;
2489 if (isvar (&opP
->disp
))
2491 /* Do a byte relocation. If it doesn't
2492 fit (possible on m68000) let the
2493 fixup processing complain later. */
2495 add_fix ('B', &opP
->disp
, 1, 1);
2497 add_fix ('B', &opP
->disp
, 0, 0);
2499 else if (siz1
!= SIZE_BYTE
)
2501 if (siz1
!= SIZE_UNSPEC
)
2502 as_warn (_("Forcing byte displacement"));
2503 if (! issbyte (baseo
))
2504 opP
->error
= _("byte displacement out of range");
2509 else if (siz1
== SIZE_UNSPEC
2511 && isvar (&opP
->disp
)
2512 && subs (&opP
->disp
) == NULL
2514 /* If the displacement needs pic
2515 relocation it cannot be relaxed. */
2516 && opP
->disp
.pic_reloc
== pic_none
2520 /* The code in md_convert_frag_1 needs to be
2521 able to adjust nextword. Call frag_grow
2522 to ensure that we have enough space in
2523 the frag obstack to make all the bytes
2526 nextword
+= baseo
& 0xff;
2528 add_frag (adds (&opP
->disp
),
2529 SEXT (offs (&opP
->disp
)),
2530 TAB (PCINDEX
, SZ_UNDEF
));
2538 nextword
|= 0x40; /* No index reg. */
2539 if (opP
->index
.reg
>= ZDATA0
2540 && opP
->index
.reg
<= ZDATA7
)
2541 nextword
|= (opP
->index
.reg
- ZDATA0
) << 12;
2542 else if (opP
->index
.reg
>= ZADDR0
2543 || opP
->index
.reg
<= ZADDR7
)
2544 nextword
|= (opP
->index
.reg
- ZADDR0
+ 8) << 12;
2547 /* It isn't simple. */
2549 if (cpu_of_arch (current_architecture
) < m68020
2550 || arch_coldfire_p (current_architecture
))
2552 _("invalid operand mode for this architecture; needs 68020 or higher");
2555 /* If the guy specified a width, we assume that it is
2556 wide enough. Maybe it isn't. If so, we lose. */
2560 if (isvar (&opP
->disp
)
2562 : ! issword (baseo
))
2567 else if (! isvar (&opP
->disp
) && baseo
== 0)
2576 as_warn (_(":b not permitted; defaulting to :w"));
2586 /* Figure out inner displacement stuff. */
2587 if (opP
->mode
== POST
|| opP
->mode
== PRE
)
2589 if (cpu_of_arch (current_architecture
) & cpu32
)
2590 opP
->error
= _("invalid operand mode for this architecture; needs 68020 or higher");
2594 if (isvar (&opP
->odisp
)
2596 : ! issword (outro
))
2601 else if (! isvar (&opP
->odisp
) && outro
== 0)
2610 as_warn (_(":b not permitted; defaulting to :w"));
2619 if (opP
->mode
== POST
2620 && (nextword
& 0x40) == 0)
2625 if (siz1
!= SIZE_UNSPEC
&& isvar (&opP
->disp
))
2627 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
2628 add_fix (siz1
== SIZE_LONG
? 'l' : 'w', &opP
->disp
, 1, 2);
2630 add_fix (siz1
== SIZE_LONG
? 'l' : 'w', &opP
->disp
, 0, 0);
2632 if (siz1
== SIZE_LONG
)
2633 addword (baseo
>> 16);
2634 if (siz1
!= SIZE_UNSPEC
)
2637 if (siz2
!= SIZE_UNSPEC
&& isvar (&opP
->odisp
))
2638 add_fix (siz2
== SIZE_LONG
? 'l' : 'w', &opP
->odisp
, 0, 0);
2639 if (siz2
== SIZE_LONG
)
2640 addword (outro
>> 16);
2641 if (siz2
!= SIZE_UNSPEC
)
2647 nextword
= get_num (&opP
->disp
, 90);
2648 switch (opP
->disp
.size
)
2653 if (!isvar (&opP
->disp
) && issword (offs (&opP
->disp
)))
2655 tmpreg
= 0x38; /* 7.0 */
2659 if (isvar (&opP
->disp
)
2660 && !subs (&opP
->disp
)
2661 && adds (&opP
->disp
)
2663 /* If the displacement needs pic relocation it
2664 cannot be relaxed. */
2665 && opP
->disp
.pic_reloc
== pic_none
2668 && !strchr ("~%&$?", s
[0]))
2670 tmpreg
= 0x3A; /* 7.2 */
2671 add_frag (adds (&opP
->disp
),
2672 SEXT (offs (&opP
->disp
)),
2673 TAB (ABSTOPCREL
, SZ_UNDEF
));
2676 /* Fall through into long. */
2678 if (isvar (&opP
->disp
))
2679 add_fix ('l', &opP
->disp
, 0, 0);
2681 tmpreg
= 0x39;/* 7.1 mode */
2682 addword (nextword
>> 16);
2687 as_bad (_("unsupported byte value; use a different suffix"));
2691 if (isvar (&opP
->disp
))
2692 add_fix ('w', &opP
->disp
, 0, 0);
2694 tmpreg
= 0x38;/* 7.0 mode */
2702 as_bad (_("unknown/incorrect operand"));
2706 /* If s[0] is '4', then this is for the mac instructions
2707 that can have a trailing_ampersand set. If so, set 0x100
2708 bit on tmpreg so install_gen_operand can check for it and
2709 set the appropriate bit (word2, bit 5). */
2712 if (opP
->trailing_ampersand
)
2715 install_gen_operand (s
[1], tmpreg
);
2721 { /* JF: I hate floating point! */
2736 tmpreg
= get_num (&opP
->disp
, tmpreg
);
2737 if (isvar (&opP
->disp
))
2738 add_fix (s
[1], &opP
->disp
, 0, 0);
2741 case 'b': /* Danger: These do no check for
2742 certain types of overflow.
2744 if (!isbyte (tmpreg
))
2745 opP
->error
= _("out of range");
2746 insop (tmpreg
, opcode
);
2747 if (isvar (&opP
->disp
))
2748 the_ins
.reloc
[the_ins
.nrel
- 1].n
=
2749 (opcode
->m_codenum
) * 2 + 1;
2752 if (!issbyte (tmpreg
))
2753 opP
->error
= _("out of range");
2754 the_ins
.opcode
[the_ins
.numo
- 1] |= tmpreg
& 0xff;
2755 if (isvar (&opP
->disp
))
2756 the_ins
.reloc
[the_ins
.nrel
- 1].n
= opcode
->m_codenum
* 2 - 1;
2759 if (!isword (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 if (!issword (tmpreg
))
2767 opP
->error
= _("out of range");
2768 insop (tmpreg
, opcode
);
2769 if (isvar (&opP
->disp
))
2770 the_ins
.reloc
[the_ins
.nrel
- 1].n
= (opcode
->m_codenum
) * 2;
2773 /* Because of the way insop works, we put these two out
2775 insop (tmpreg
, opcode
);
2776 insop (tmpreg
>> 16, opcode
);
2777 if (isvar (&opP
->disp
))
2778 the_ins
.reloc
[the_ins
.nrel
- 1].n
= (opcode
->m_codenum
) * 2;
2785 install_operand (s
[1], tmpreg
);
2796 install_operand (s
[1], opP
->reg
- ADDR
);
2800 tmpreg
= get_num (&opP
->disp
, 90);
2804 add_fix ('B', &opP
->disp
, 1, -1);
2807 add_fix ('w', &opP
->disp
, 1, 0);
2812 if (! HAVE_LONG_BRANCH (current_architecture
))
2813 as_warn (_("Can't use long branches on 68000/68010/5200"));
2814 the_ins
.opcode
[0] |= 0xff;
2815 add_fix ('l', &opP
->disp
, 1, 0);
2820 if (subs (&opP
->disp
)) /* We can't relax it. */
2824 /* If the displacement needs pic relocation it cannot be
2826 if (opP
->disp
.pic_reloc
!= pic_none
)
2829 /* This could either be a symbol, or an absolute
2830 address. If it's an absolute address, turn it into
2831 an absolute jump right here and keep it out of the
2833 if (adds (&opP
->disp
) == 0)
2835 if (the_ins
.opcode
[0] == 0x6000) /* jbra */
2836 the_ins
.opcode
[0] = 0x4EF9;
2837 else if (the_ins
.opcode
[0] == 0x6100) /* jbsr */
2838 the_ins
.opcode
[0] = 0x4EB9;
2841 the_ins
.opcode
[0] ^= 0x0100;
2842 the_ins
.opcode
[0] |= 0x0006;
2845 add_fix ('l', &opP
->disp
, 0, 0);
2851 /* Now we know it's going into the relaxer. Now figure
2852 out which mode. We try in this order of preference:
2853 long branch, absolute jump, byte/word branches only. */
2854 if (HAVE_LONG_BRANCH (current_architecture
))
2855 add_frag (adds (&opP
->disp
),
2856 SEXT (offs (&opP
->disp
)),
2857 TAB (BRANCHBWL
, SZ_UNDEF
));
2858 else if (! flag_keep_pcrel
)
2860 if ((the_ins
.opcode
[0] == 0x6000)
2861 || (the_ins
.opcode
[0] == 0x6100))
2862 add_frag (adds (&opP
->disp
),
2863 SEXT (offs (&opP
->disp
)),
2864 TAB (BRABSJUNC
, SZ_UNDEF
));
2866 add_frag (adds (&opP
->disp
),
2867 SEXT (offs (&opP
->disp
)),
2868 TAB (BRABSJCOND
, SZ_UNDEF
));
2871 add_frag (adds (&opP
->disp
),
2872 SEXT (offs (&opP
->disp
)),
2873 TAB (BRANCHBW
, SZ_UNDEF
));
2876 if (isvar (&opP
->disp
))
2878 /* Check for DBcc instructions. We can relax them,
2879 but only if we have long branches and/or absolute
2881 if (((the_ins
.opcode
[0] & 0xf0f8) == 0x50c8)
2882 && (HAVE_LONG_BRANCH (current_architecture
)
2883 || (! flag_keep_pcrel
)))
2885 if (HAVE_LONG_BRANCH (current_architecture
))
2886 add_frag (adds (&opP
->disp
),
2887 SEXT (offs (&opP
->disp
)),
2888 TAB (DBCCLBR
, SZ_UNDEF
));
2890 add_frag (adds (&opP
->disp
),
2891 SEXT (offs (&opP
->disp
)),
2892 TAB (DBCCABSJ
, SZ_UNDEF
));
2895 add_fix ('w', &opP
->disp
, 1, 0);
2899 case 'C': /* Fixed size LONG coproc branches. */
2900 add_fix ('l', &opP
->disp
, 1, 0);
2904 case 'c': /* Var size Coprocesssor branches. */
2905 if (subs (&opP
->disp
) || (adds (&opP
->disp
) == 0))
2907 the_ins
.opcode
[the_ins
.numo
- 1] |= 0x40;
2908 add_fix ('l', &opP
->disp
, 1, 0);
2913 add_frag (adds (&opP
->disp
),
2914 SEXT (offs (&opP
->disp
)),
2915 TAB (FBRANCH
, SZ_UNDEF
));
2922 case 'C': /* Ignore it. */
2925 case 'd': /* JF this is a kludge. */
2926 install_operand ('s', opP
->reg
- ADDR
);
2927 tmpreg
= get_num (&opP
->disp
, 90);
2928 if (!issword (tmpreg
))
2930 as_warn (_("Expression out of range, using 0"));
2937 install_operand (s
[1], opP
->reg
- DATA
);
2940 case 'e': /* EMAC ACCx, reg/reg. */
2941 install_operand (s
[1], opP
->reg
- ACC
);
2944 case 'E': /* Ignore it. */
2948 install_operand (s
[1], opP
->reg
- FP0
);
2951 case 'g': /* EMAC ACCEXTx. */
2952 install_operand (s
[1], opP
->reg
- ACCEXT01
);
2955 case 'G': /* Ignore it. */
2960 tmpreg
= opP
->reg
- COP0
;
2961 install_operand (s
[1], tmpreg
);
2964 case 'i': /* MAC/EMAC scale factor. */
2965 install_operand (s
[1], opP
->mode
== LSH
? 0x1 : 0x3);
2968 case 'J': /* JF foo. */
3098 install_operand (s
[1], tmpreg
);
3102 tmpreg
= get_num (&opP
->disp
, 55);
3103 install_operand (s
[1], tmpreg
& 0x7f);
3110 if (tmpreg
& 0x7FF0000)
3111 as_bad (_("Floating point register in register list"));
3112 insop (reverse_16_bits (tmpreg
), opcode
);
3116 if (tmpreg
& 0x700FFFF)
3117 as_bad (_("Wrong register in floating-point reglist"));
3118 install_operand (s
[1], reverse_8_bits (tmpreg
>> 16));
3126 if (tmpreg
& 0x7FF0000)
3127 as_bad (_("Floating point register in register list"));
3128 insop (tmpreg
, opcode
);
3130 else if (s
[1] == '8')
3132 if (tmpreg
& 0x0FFFFFF)
3133 as_bad (_("incorrect register in reglist"));
3134 install_operand (s
[1], tmpreg
>> 24);
3138 if (tmpreg
& 0x700FFFF)
3139 as_bad (_("wrong register in floating-point reglist"));
3141 install_operand (s
[1], tmpreg
>> 16);
3146 install_operand (s
[1], get_num (&opP
->disp
, 60));
3150 tmpreg
= ((opP
->mode
== DREG
)
3151 ? 0x20 + (int) (opP
->reg
- DATA
)
3152 : (get_num (&opP
->disp
, 40) & 0x1F));
3153 install_operand (s
[1], tmpreg
);
3157 tmpreg
= get_num (&opP
->disp
, 10);
3160 install_operand (s
[1], tmpreg
);
3164 /* This depends on the fact that ADDR registers are eight
3165 more than their corresponding DATA regs, so the result
3166 will have the ADDR_REG bit set. */
3167 install_operand (s
[1], opP
->reg
- DATA
);
3171 if (opP
->mode
== AINDR
)
3172 install_operand (s
[1], opP
->reg
- DATA
);
3174 install_operand (s
[1], opP
->index
.reg
- DATA
);
3178 if (opP
->reg
== FPI
)
3180 else if (opP
->reg
== FPS
)
3182 else if (opP
->reg
== FPC
)
3186 install_operand (s
[1], tmpreg
);
3189 case 'S': /* Ignore it. */
3193 install_operand (s
[1], get_num (&opP
->disp
, 30));
3196 case 'U': /* Ignore it. */
3215 as_fatal (_("failed sanity check"));
3216 } /* switch on cache token. */
3217 install_operand (s
[1], tmpreg
);
3220 /* JF: These are out of order, I fear. */
3233 install_operand (s
[1], tmpreg
);
3259 install_operand (s
[1], tmpreg
);
3263 if (opP
->reg
== VAL
)
3282 install_operand (s
[1], tmpreg
);
3296 tmpreg
= (4 << 10) | ((opP
->reg
- BAD
) << 2);
3307 tmpreg
= (5 << 10) | ((opP
->reg
- BAC
) << 2);
3313 install_operand (s
[1], tmpreg
);
3316 know (opP
->reg
== PSR
);
3319 know (opP
->reg
== PCSR
);
3334 install_operand (s
[1], tmpreg
);
3337 tmpreg
= get_num (&opP
->disp
, 20);
3338 install_operand (s
[1], tmpreg
);
3340 case '_': /* used only for move16 absolute 32-bit address. */
3341 if (isvar (&opP
->disp
))
3342 add_fix ('l', &opP
->disp
, 0, 0);
3343 tmpreg
= get_num (&opP
->disp
, 90);
3344 addword (tmpreg
>> 16);
3345 addword (tmpreg
& 0xFFFF);
3348 install_operand (s
[1], opP
->reg
- DATA0L
);
3349 opP
->reg
-= (DATA0L
);
3350 opP
->reg
&= 0x0F; /* remove upper/lower bit. */
3353 tmpreg
= get_num (&opP
->disp
, 80);
3356 install_operand (s
[1], tmpreg
);
3363 /* By the time whe get here (FINALLY) the_ins contains the complete
3364 instruction, ready to be emitted. . . */
3368 reverse_16_bits (int in
)
3373 static int mask
[16] =
3375 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
3376 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000
3378 for (n
= 0; n
< 16; n
++)
3381 out
|= mask
[15 - n
];
3384 } /* reverse_16_bits() */
3387 reverse_8_bits (int in
)
3392 static int mask
[8] =
3394 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
3397 for (n
= 0; n
< 8; n
++)
3403 } /* reverse_8_bits() */
3405 /* Cause an extra frag to be generated here, inserting up to 10 bytes
3406 (that value is chosen in the frag_var call in md_assemble). TYPE
3407 is the subtype of the frag to be generated; its primary type is
3408 rs_machine_dependent.
3410 The TYPE parameter is also used by md_convert_frag_1 and
3411 md_estimate_size_before_relax. The appropriate type of fixup will
3412 be emitted by md_convert_frag_1.
3414 ADD becomes the FR_SYMBOL field of the frag, and OFF the FR_OFFSET. */
3416 install_operand (int mode
, int val
)
3421 the_ins
.opcode
[0] |= val
& 0xFF; /* JF FF is for M kludge. */
3424 the_ins
.opcode
[0] |= val
<< 9;
3427 the_ins
.opcode
[1] |= val
<< 12;
3430 the_ins
.opcode
[1] |= val
<< 6;
3433 the_ins
.opcode
[1] |= val
;
3436 the_ins
.opcode
[2] |= val
<< 12;
3439 the_ins
.opcode
[2] |= val
<< 6;
3442 /* DANGER! This is a hack to force cas2l and cas2w cmds to be
3443 three words long! */
3445 the_ins
.opcode
[2] |= val
;
3448 the_ins
.opcode
[1] |= val
<< 7;
3451 the_ins
.opcode
[1] |= val
<< 10;
3455 the_ins
.opcode
[1] |= val
<< 5;
3460 the_ins
.opcode
[1] |= (val
<< 10) | (val
<< 7);
3463 the_ins
.opcode
[1] |= (val
<< 12) | val
;
3466 the_ins
.opcode
[0] |= val
= 0xff;
3469 the_ins
.opcode
[0] |= val
<< 9;
3472 the_ins
.opcode
[1] |= val
;
3475 the_ins
.opcode
[1] |= val
;
3476 the_ins
.numo
++; /* What a hack. */
3479 the_ins
.opcode
[1] |= val
<< 4;
3487 the_ins
.opcode
[0] |= (val
<< 6);
3490 the_ins
.opcode
[1] = (val
>> 16);
3491 the_ins
.opcode
[2] = val
& 0xffff;
3494 the_ins
.opcode
[0] |= ((val
& 0x8) << (6 - 3));
3495 the_ins
.opcode
[0] |= ((val
& 0x7) << 9);
3496 the_ins
.opcode
[1] |= ((val
& 0x10) << (7 - 4));
3498 case 'n': /* MAC/EMAC Rx on !load. */
3499 the_ins
.opcode
[0] |= ((val
& 0x8) << (6 - 3));
3500 the_ins
.opcode
[0] |= ((val
& 0x7) << 9);
3501 the_ins
.opcode
[1] |= ((val
& 0x10) << (7 - 4));
3503 case 'o': /* MAC/EMAC Rx on load. */
3504 the_ins
.opcode
[1] |= val
<< 12;
3505 the_ins
.opcode
[1] |= ((val
& 0x10) << (7 - 4));
3507 case 'M': /* MAC/EMAC Ry on !load. */
3508 the_ins
.opcode
[0] |= (val
& 0xF);
3509 the_ins
.opcode
[1] |= ((val
& 0x10) << (6 - 4));
3511 case 'N': /* MAC/EMAC Ry on load. */
3512 the_ins
.opcode
[1] |= (val
& 0xF);
3513 the_ins
.opcode
[1] |= ((val
& 0x10) << (6 - 4));
3516 the_ins
.opcode
[1] |= ((val
!= 1) << 10);
3519 the_ins
.opcode
[0] |= ((val
& 0x3) << 9);
3522 the_ins
.opcode
[0] |= ((val
& 0x3) << 0);
3524 case 'G': /* EMAC accumulator in a EMAC load instruction. */
3525 the_ins
.opcode
[0] |= ((~val
& 0x1) << 7);
3526 the_ins
.opcode
[1] |= ((val
& 0x2) << (4 - 1));
3528 case 'H': /* EMAC accumulator in a EMAC non-load instruction. */
3529 the_ins
.opcode
[0] |= ((val
& 0x1) << 7);
3530 the_ins
.opcode
[1] |= ((val
& 0x2) << (4 - 1));
3533 the_ins
.opcode
[1] |= ((val
& 0x3) << 9);
3536 the_ins
.opcode
[0] |= (val
& 0x1) <<10;
3540 as_fatal (_("failed sanity check."));
3545 install_gen_operand (int mode
, int val
)
3549 case '/': /* Special for mask loads for mac/msac insns with
3550 possible mask; trailing_ampersend set in bit 8. */
3551 the_ins
.opcode
[0] |= (val
& 0x3f);
3552 the_ins
.opcode
[1] |= (((val
& 0x100) >> 8) << 5);
3555 the_ins
.opcode
[0] |= val
;
3558 /* This is a kludge!!! */
3559 the_ins
.opcode
[0] |= (val
& 0x07) << 9 | (val
& 0x38) << 3;
3568 the_ins
.opcode
[0] |= val
;
3570 /* more stuff goes here. */
3572 as_fatal (_("failed sanity check."));
3576 /* Verify that we have some number of paren pairs, do m68k_ip_op(), and
3577 then deal with the bitfield hack. */
3580 crack_operand (char *str
, struct m68k_op
*opP
)
3582 register int parens
;
3584 register char *beg_str
;
3592 for (parens
= 0; *str
&& (parens
> 0 || inquote
|| notend (str
)); str
++)
3598 else if (*str
== ')')
3602 opP
->error
= _("Extra )");
3608 if (flag_mri
&& *str
== '\'')
3609 inquote
= ! inquote
;
3611 if (!*str
&& parens
)
3613 opP
->error
= _("Missing )");
3618 if (m68k_ip_op (beg_str
, opP
) != 0)
3625 c
= *++str
; /* JF bitfield hack. */
3630 as_bad (_("Missing operand"));
3633 /* Detect MRI REG symbols and convert them to REGLSTs. */
3634 if (opP
->mode
== CONTROL
&& (int)opP
->reg
< 0)
3637 opP
->mask
= ~(int)opP
->reg
;
3644 /* This is the guts of the machine-dependent assembler. STR points to a
3645 machine dependent instruction. This function is supposed to emit
3646 the frags/bytes it assembles to.
3650 insert_reg (const char *regname
, int regnum
)
3655 #ifdef REGISTER_PREFIX
3656 if (!flag_reg_prefix_optional
)
3658 buf
[0] = REGISTER_PREFIX
;
3659 strcpy (buf
+ 1, regname
);
3664 symbol_table_insert (symbol_new (regname
, reg_section
, regnum
,
3665 &zero_address_frag
));
3667 for (i
= 0; regname
[i
]; i
++)
3668 buf
[i
] = TOUPPER (regname
[i
]);
3671 symbol_table_insert (symbol_new (buf
, reg_section
, regnum
,
3672 &zero_address_frag
));
3681 static const struct init_entry init_table
[] =
3741 { "accext01", ACCEXT01
},
3742 { "accext23", ACCEXT23
},
3746 /* Control registers. */
3747 { "sfc", SFC
}, /* Source Function Code. */
3749 { "dfc", DFC
}, /* Destination Function Code. */
3751 { "cacr", CACR
}, /* Cache Control Register. */
3752 { "caar", CAAR
}, /* Cache Address Register. */
3754 { "usp", USP
}, /* User Stack Pointer. */
3755 { "vbr", VBR
}, /* Vector Base Register. */
3756 { "msp", MSP
}, /* Master Stack Pointer. */
3757 { "isp", ISP
}, /* Interrupt Stack Pointer. */
3759 { "itt0", ITT0
}, /* Instruction Transparent Translation Reg 0. */
3760 { "itt1", ITT1
}, /* Instruction Transparent Translation Reg 1. */
3761 { "dtt0", DTT0
}, /* Data Transparent Translation Register 0. */
3762 { "dtt1", DTT1
}, /* Data Transparent Translation Register 1. */
3764 /* 68ec040 versions of same */
3765 { "iacr0", ITT0
}, /* Instruction Access Control Register 0. */
3766 { "iacr1", ITT1
}, /* Instruction Access Control Register 0. */
3767 { "dacr0", DTT0
}, /* Data Access Control Register 0. */
3768 { "dacr1", DTT1
}, /* Data Access Control Register 0. */
3770 /* mcf5200 versions of same. The ColdFire programmer's reference
3771 manual indicated that the order is 2,3,0,1, but Ken Rose
3772 <rose@netcom.com> says that 0,1,2,3 is the correct order. */
3773 { "acr0", ACR0
}, /* Access Control Unit 0. */
3774 { "acr1", ACR1
}, /* Access Control Unit 1. */
3775 { "acr2", ACR2
}, /* Access Control Unit 2. */
3776 { "acr3", ACR3
}, /* Access Control Unit 3. */
3778 { "tc", TC
}, /* MMU Translation Control Register. */
3781 { "mmusr", MMUSR
}, /* MMU Status Register. */
3782 { "srp", SRP
}, /* User Root Pointer. */
3783 { "urp", URP
}, /* Supervisor Root Pointer. */
3788 { "rombar", ROMBAR
}, /* ROM Base Address Register. */
3789 { "rambar0", RAMBAR0
}, /* ROM Base Address Register. */
3790 { "rambar1", RAMBAR1
}, /* ROM Base Address Register. */
3791 { "mbar", MBAR
}, /* Module Base Address Register. */
3793 { "mbar0", MBAR0
}, /* mcfv4e registers. */
3794 { "mbar1", MBAR1
}, /* mcfv4e registers. */
3795 { "rombar0", ROMBAR
}, /* mcfv4e registers. */
3796 { "rombar1", ROMBAR1
}, /* mcfv4e registers. */
3797 { "mpcr", MPCR
}, /* mcfv4e registers. */
3798 { "edrambar", EDRAMBAR
}, /* mcfv4e registers. */
3799 { "secmbar", SECMBAR
}, /* mcfv4e registers. */
3800 { "asid", TC
}, /* mcfv4e registers. */
3801 { "mmubar", BUSCR
}, /* mcfv4e registers. */
3802 { "pcr1u0", PCR1U0
}, /* mcfv4e registers. */
3803 { "pcr1l0", PCR1L0
}, /* mcfv4e registers. */
3804 { "pcr2u0", PCR2U0
}, /* mcfv4e registers. */
3805 { "pcr2l0", PCR2L0
}, /* mcfv4e registers. */
3806 { "pcr3u0", PCR3U0
}, /* mcfv4e registers. */
3807 { "pcr3l0", PCR3L0
}, /* mcfv4e registers. */
3808 { "pcr1u1", PCR1U1
}, /* mcfv4e registers. */
3809 { "pcr1l1", PCR1L1
}, /* mcfv4e registers. */
3810 { "pcr2u1", PCR2U1
}, /* mcfv4e registers. */
3811 { "pcr2l1", PCR2L1
}, /* mcfv4e registers. */
3812 { "pcr3u1", PCR3U1
}, /* mcfv4e registers. */
3813 { "pcr3l1", PCR3L1
}, /* mcfv4e registers. */
3815 { "flashbar", FLASHBAR
}, /* mcf528x registers. */
3816 { "rambar", RAMBAR
}, /* mcf528x registers. */
3818 { "mbar2", MBAR2
}, /* mcf5249 registers. */
3819 /* End of control registers. */
3853 /* 68ec030 versions of same. */
3856 /* 68ec030 access control unit, identical to 030 MMU status reg. */
3859 /* Suppressed data and address registers. */
3877 /* Upper and lower data and address registers, used by macw and msacw. */
3918 init_regtable (void)
3921 for (i
= 0; init_table
[i
].name
; i
++)
3922 insert_reg (init_table
[i
].name
, init_table
[i
].number
);
3926 md_assemble (char *str
)
3933 int shorts_this_frag
;
3936 if (!selected_cpu
&& !selected_arch
)
3938 /* We've not selected an architecture yet. Set the default
3939 now. We do this lazily so that an initial .cpu or .arch directive
3941 if (!m68k_set_cpu (TARGET_CPU
, 1, 1))
3942 as_bad (_("unrecognized default cpu `%s'"), TARGET_CPU
);
3947 /* In MRI mode, the instruction and operands are separated by a
3948 space. Anything following the operands is a comment. The label
3949 has already been removed. */
3957 for (s
= str
; *s
!= '\0'; s
++)
3959 if ((*s
== ' ' || *s
== '\t') && ! inquote
)
3977 inquote
= ! inquote
;
3982 memset (&the_ins
, '\0', sizeof (the_ins
));
3987 for (n
= 0; n
< the_ins
.numargs
; n
++)
3988 if (the_ins
.operands
[n
].error
)
3990 er
= the_ins
.operands
[n
].error
;
3996 as_bad (_("%s -- statement `%s' ignored"), er
, str
);
4000 /* If there is a current label, record that it marks an instruction. */
4001 if (current_label
!= NULL
)
4003 current_label
->text
= 1;
4004 current_label
= NULL
;
4008 /* Tie dwarf2 debug info to the address at the start of the insn. */
4009 dwarf2_emit_insn (0);
4012 if (the_ins
.nfrag
== 0)
4014 /* No frag hacking involved; just put it out. */
4015 toP
= frag_more (2 * the_ins
.numo
);
4016 fromP
= &the_ins
.opcode
[0];
4017 for (m
= the_ins
.numo
; m
; --m
)
4019 md_number_to_chars (toP
, (long) (*fromP
), 2);
4023 /* Put out symbol-dependent info. */
4024 for (m
= 0; m
< the_ins
.nrel
; m
++)
4026 switch (the_ins
.reloc
[m
].wid
)
4045 as_fatal (_("Don't know how to figure width of %c in md_assemble()"),
4046 the_ins
.reloc
[m
].wid
);
4049 fixP
= fix_new_exp (frag_now
,
4050 ((toP
- frag_now
->fr_literal
)
4051 - the_ins
.numo
* 2 + the_ins
.reloc
[m
].n
),
4053 &the_ins
.reloc
[m
].exp
,
4054 the_ins
.reloc
[m
].pcrel
,
4055 get_reloc_code (n
, the_ins
.reloc
[m
].pcrel
,
4056 the_ins
.reloc
[m
].pic_reloc
));
4057 fixP
->fx_pcrel_adjust
= the_ins
.reloc
[m
].pcrel_fix
;
4058 if (the_ins
.reloc
[m
].wid
== 'B')
4059 fixP
->fx_signed
= 1;
4064 /* There's some frag hacking. */
4066 /* Calculate the max frag size. */
4069 wid
= 2 * the_ins
.fragb
[0].fragoff
;
4070 for (n
= 1; n
< the_ins
.nfrag
; n
++)
4071 wid
+= 2 * (the_ins
.numo
- the_ins
.fragb
[n
- 1].fragoff
);
4072 /* frag_var part. */
4074 /* Make sure the whole insn fits in one chunk, in particular that
4075 the var part is attached, as we access one byte before the
4076 variable frag for byte branches. */
4080 for (n
= 0, fromP
= &the_ins
.opcode
[0]; n
< the_ins
.nfrag
; n
++)
4085 wid
= 2 * the_ins
.fragb
[n
].fragoff
;
4087 wid
= 2 * (the_ins
.numo
- the_ins
.fragb
[n
- 1].fragoff
);
4088 toP
= frag_more (wid
);
4090 shorts_this_frag
= 0;
4091 for (m
= wid
/ 2; m
; --m
)
4093 md_number_to_chars (toP
, (long) (*fromP
), 2);
4098 for (m
= 0; m
< the_ins
.nrel
; m
++)
4100 if ((the_ins
.reloc
[m
].n
) >= 2 * shorts_this_frag
)
4102 the_ins
.reloc
[m
].n
-= 2 * shorts_this_frag
;
4105 wid
= the_ins
.reloc
[m
].wid
;
4108 the_ins
.reloc
[m
].wid
= 0;
4109 wid
= (wid
== 'b') ? 1 : (wid
== 'w') ? 2 : (wid
== 'l') ? 4 : 4000;
4111 fixP
= fix_new_exp (frag_now
,
4112 ((toP
- frag_now
->fr_literal
)
4113 - the_ins
.numo
* 2 + the_ins
.reloc
[m
].n
),
4115 &the_ins
.reloc
[m
].exp
,
4116 the_ins
.reloc
[m
].pcrel
,
4117 get_reloc_code (wid
, the_ins
.reloc
[m
].pcrel
,
4118 the_ins
.reloc
[m
].pic_reloc
));
4119 fixP
->fx_pcrel_adjust
= the_ins
.reloc
[m
].pcrel_fix
;
4121 (void) frag_var (rs_machine_dependent
, 10, 0,
4122 (relax_substateT
) (the_ins
.fragb
[n
].fragty
),
4123 the_ins
.fragb
[n
].fadd
, the_ins
.fragb
[n
].foff
, to_beg_P
);
4125 n
= (the_ins
.numo
- the_ins
.fragb
[n
- 1].fragoff
);
4126 shorts_this_frag
= 0;
4129 toP
= frag_more (n
* 2);
4132 md_number_to_chars (toP
, (long) (*fromP
), 2);
4138 for (m
= 0; m
< the_ins
.nrel
; m
++)
4142 wid
= the_ins
.reloc
[m
].wid
;
4145 the_ins
.reloc
[m
].wid
= 0;
4146 wid
= (wid
== 'b') ? 1 : (wid
== 'w') ? 2 : (wid
== 'l') ? 4 : 4000;
4148 fixP
= fix_new_exp (frag_now
,
4149 ((the_ins
.reloc
[m
].n
+ toP
- frag_now
->fr_literal
)
4150 - shorts_this_frag
* 2),
4152 &the_ins
.reloc
[m
].exp
,
4153 the_ins
.reloc
[m
].pcrel
,
4154 get_reloc_code (wid
, the_ins
.reloc
[m
].pcrel
,
4155 the_ins
.reloc
[m
].pic_reloc
));
4156 fixP
->fx_pcrel_adjust
= the_ins
.reloc
[m
].pcrel_fix
;
4160 /* Comparison function used by qsort to rank the opcode entries by name. */
4163 m68k_compare_opcode (const void * v1
, const void * v2
)
4165 struct m68k_opcode
* op1
, * op2
;
4171 op1
= *(struct m68k_opcode
**) v1
;
4172 op2
= *(struct m68k_opcode
**) v2
;
4174 /* Compare the two names. If different, return the comparison.
4175 If the same, return the order they are in the opcode table. */
4176 ret
= strcmp (op1
->name
, op2
->name
);
4187 const struct m68k_opcode
*ins
;
4188 struct m68k_incant
*hack
, *slak
;
4189 const char *retval
= 0; /* Empty string, or error msg text. */
4192 /* Set up hash tables with 68000 instructions.
4193 similar to what the vax assembler does. */
4194 /* RMS claims the thing to do is take the m68k-opcode.h table, and make
4195 a copy of it at runtime, adding in the information we want but isn't
4196 there. I think it'd be better to have an awk script hack the table
4197 at compile time. Or even just xstr the table and use it as-is. But
4198 my lord ghod hath spoken, so we do it this way. Excuse the ugly var
4203 flag_reg_prefix_optional
= 1;
4205 if (! m68k_rel32_from_cmdline
)
4209 /* First sort the opcode table into alphabetical order to seperate
4210 the order that the assembler wants to see the opcodes from the
4211 order that the disassembler wants to see them. */
4212 m68k_sorted_opcodes
= xmalloc (m68k_numopcodes
* sizeof (* m68k_sorted_opcodes
));
4213 if (!m68k_sorted_opcodes
)
4214 as_fatal (_("Internal Error: Can't allocate m68k_sorted_opcodes of size %d"),
4215 m68k_numopcodes
* ((int) sizeof (* m68k_sorted_opcodes
)));
4217 for (i
= m68k_numopcodes
; i
--;)
4218 m68k_sorted_opcodes
[i
] = m68k_opcodes
+ i
;
4220 qsort (m68k_sorted_opcodes
, m68k_numopcodes
,
4221 sizeof (m68k_sorted_opcodes
[0]), m68k_compare_opcode
);
4223 op_hash
= hash_new ();
4225 obstack_begin (&robyn
, 4000);
4226 for (i
= 0; i
< m68k_numopcodes
; i
++)
4228 hack
= slak
= (struct m68k_incant
*) obstack_alloc (&robyn
, sizeof (struct m68k_incant
));
4231 ins
= m68k_sorted_opcodes
[i
];
4233 /* We *could* ignore insns that don't match our
4234 arch here by just leaving them out of the hash. */
4235 slak
->m_operands
= ins
->args
;
4236 slak
->m_opnum
= strlen (slak
->m_operands
) / 2;
4237 slak
->m_arch
= ins
->arch
;
4238 slak
->m_opcode
= ins
->opcode
;
4239 /* This is kludgey. */
4240 slak
->m_codenum
= ((ins
->match
) & 0xffffL
) ? 2 : 1;
4241 if (i
+ 1 != m68k_numopcodes
4242 && !strcmp (ins
->name
, m68k_sorted_opcodes
[i
+ 1]->name
))
4244 slak
->m_next
= obstack_alloc (&robyn
, sizeof (struct m68k_incant
));
4249 slak
= slak
->m_next
;
4253 retval
= hash_insert (op_hash
, ins
->name
, (char *) hack
);
4255 as_fatal (_("Internal Error: Can't hash %s: %s"), ins
->name
, retval
);
4258 for (i
= 0; i
< m68k_numaliases
; i
++)
4260 const char *name
= m68k_opcode_aliases
[i
].primary
;
4261 const char *alias
= m68k_opcode_aliases
[i
].alias
;
4262 PTR val
= hash_find (op_hash
, name
);
4265 as_fatal (_("Internal Error: Can't find %s in hash table"), name
);
4266 retval
= hash_insert (op_hash
, alias
, val
);
4268 as_fatal (_("Internal Error: Can't hash %s: %s"), alias
, retval
);
4271 /* In MRI mode, all unsized branches are variable sized. Normally,
4272 they are word sized. */
4275 static struct m68k_opcode_alias mri_aliases
[] =
4296 i
< (int) (sizeof mri_aliases
/ sizeof mri_aliases
[0]);
4299 const char *name
= mri_aliases
[i
].primary
;
4300 const char *alias
= mri_aliases
[i
].alias
;
4301 PTR val
= hash_find (op_hash
, name
);
4304 as_fatal (_("Internal Error: Can't find %s in hash table"), name
);
4305 retval
= hash_jam (op_hash
, alias
, val
);
4307 as_fatal (_("Internal Error: Can't hash %s: %s"), alias
, retval
);
4311 for (i
= 0; i
< (int) sizeof (notend_table
); i
++)
4313 notend_table
[i
] = 0;
4314 alt_notend_table
[i
] = 0;
4317 notend_table
[','] = 1;
4318 notend_table
['{'] = 1;
4319 notend_table
['}'] = 1;
4320 alt_notend_table
['a'] = 1;
4321 alt_notend_table
['A'] = 1;
4322 alt_notend_table
['d'] = 1;
4323 alt_notend_table
['D'] = 1;
4324 alt_notend_table
['#'] = 1;
4325 alt_notend_table
['&'] = 1;
4326 alt_notend_table
['f'] = 1;
4327 alt_notend_table
['F'] = 1;
4328 #ifdef REGISTER_PREFIX
4329 alt_notend_table
[REGISTER_PREFIX
] = 1;
4332 /* We need to put '(' in alt_notend_table to handle
4333 cas2 %d0:%d2,%d3:%d4,(%a0):(%a1) */
4334 alt_notend_table
['('] = 1;
4336 /* We need to put '@' in alt_notend_table to handle
4337 cas2 %d0:%d2,%d3:%d4,@(%d0):@(%d1) */
4338 alt_notend_table
['@'] = 1;
4340 /* We need to put digits in alt_notend_table to handle
4341 bfextu %d0{24:1},%d0 */
4342 alt_notend_table
['0'] = 1;
4343 alt_notend_table
['1'] = 1;
4344 alt_notend_table
['2'] = 1;
4345 alt_notend_table
['3'] = 1;
4346 alt_notend_table
['4'] = 1;
4347 alt_notend_table
['5'] = 1;
4348 alt_notend_table
['6'] = 1;
4349 alt_notend_table
['7'] = 1;
4350 alt_notend_table
['8'] = 1;
4351 alt_notend_table
['9'] = 1;
4353 #ifndef MIT_SYNTAX_ONLY
4354 /* Insert pseudo ops, these have to go into the opcode table since
4355 gas expects pseudo ops to start with a dot. */
4359 while (mote_pseudo_table
[n
].poc_name
)
4361 hack
= obstack_alloc (&robyn
, sizeof (struct m68k_incant
));
4362 hash_insert (op_hash
,
4363 mote_pseudo_table
[n
].poc_name
, (char *) hack
);
4364 hack
->m_operands
= 0;
4374 record_alignment (text_section
, 2);
4375 record_alignment (data_section
, 2);
4376 record_alignment (bss_section
, 2);
4381 /* This is called when a label is defined. */
4384 m68k_frob_label (symbolS
*sym
)
4386 struct label_line
*n
;
4388 n
= (struct label_line
*) xmalloc (sizeof *n
);
4391 as_where (&n
->file
, &n
->line
);
4397 dwarf2_emit_label (sym
);
4401 /* This is called when a value that is not an instruction is emitted. */
4404 m68k_flush_pending_output (void)
4406 current_label
= NULL
;
4409 /* This is called at the end of the assembly, when the final value of
4410 the label is known. We warn if this is a text symbol aligned at an
4414 m68k_frob_symbol (symbolS
*sym
)
4416 if (S_GET_SEGMENT (sym
) == reg_section
4417 && (int) S_GET_VALUE (sym
) < 0)
4419 S_SET_SEGMENT (sym
, absolute_section
);
4420 S_SET_VALUE (sym
, ~(int)S_GET_VALUE (sym
));
4422 else if ((S_GET_VALUE (sym
) & 1) != 0)
4424 struct label_line
*l
;
4426 for (l
= labels
; l
!= NULL
; l
= l
->next
)
4428 if (l
->label
== sym
)
4431 as_warn_where (l
->file
, l
->line
,
4432 _("text label `%s' aligned to odd boundary"),
4440 /* This is called if we go in or out of MRI mode because of the .mri
4444 m68k_mri_mode_change (int on
)
4448 if (! flag_reg_prefix_optional
)
4450 flag_reg_prefix_optional
= 1;
4451 #ifdef REGISTER_PREFIX
4456 if (! m68k_rel32_from_cmdline
)
4461 if (! reg_prefix_optional_seen
)
4463 #ifdef REGISTER_PREFIX_OPTIONAL
4464 flag_reg_prefix_optional
= REGISTER_PREFIX_OPTIONAL
;
4466 flag_reg_prefix_optional
= 0;
4468 #ifdef REGISTER_PREFIX
4473 if (! m68k_rel32_from_cmdline
)
4478 /* Equal to MAX_PRECISION in atof-ieee.c. */
4479 #define MAX_LITTLENUMS 6
4481 /* Turn a string in input_line_pointer into a floating point constant
4482 of type TYPE, and store the appropriate bytes in *LITP. The number
4483 of LITTLENUMS emitted is stored in *SIZEP. An error message is
4484 returned, or NULL on OK. */
4487 md_atof (int type
, char *litP
, int *sizeP
)
4490 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
4491 LITTLENUM_TYPE
*wordP
;
4522 return _("Bad call to MD_ATOF()");
4524 t
= atof_ieee (input_line_pointer
, type
, words
);
4526 input_line_pointer
= t
;
4528 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
4529 for (wordP
= words
; prec
--;)
4531 md_number_to_chars (litP
, (long) (*wordP
++), sizeof (LITTLENUM_TYPE
));
4532 litP
+= sizeof (LITTLENUM_TYPE
);
4538 md_number_to_chars (char *buf
, valueT val
, int n
)
4540 number_to_chars_bigendian (buf
, val
, n
);
4544 md_apply_fix (fixS
*fixP
, valueT
*valP
, segT seg ATTRIBUTE_UNUSED
)
4546 offsetT val
= *valP
;
4547 addressT upper_limit
;
4548 offsetT lower_limit
;
4550 /* This is unnecessary but it convinces the native rs6000 compiler
4551 to generate the code we want. */
4552 char *buf
= fixP
->fx_frag
->fr_literal
;
4553 buf
+= fixP
->fx_where
;
4554 /* End ibm compiler workaround. */
4558 if (fixP
->fx_addsy
== NULL
&& fixP
->fx_pcrel
== 0)
4564 memset (buf
, 0, fixP
->fx_size
);
4565 fixP
->fx_addnumber
= val
; /* Remember value for emit_reloc. */
4567 if (fixP
->fx_r_type
== BFD_RELOC_VTABLE_INHERIT
4568 && !S_IS_DEFINED (fixP
->fx_addsy
)
4569 && !S_IS_WEAK (fixP
->fx_addsy
))
4570 S_SET_WEAK (fixP
->fx_addsy
);
4575 if (fixP
->fx_r_type
== BFD_RELOC_VTABLE_INHERIT
4576 || fixP
->fx_r_type
== BFD_RELOC_VTABLE_ENTRY
)
4579 switch (fixP
->fx_size
)
4581 /* The cast to offsetT below are necessary to make code
4582 correct for machines where ints are smaller than offsetT. */
4586 lower_limit
= - (offsetT
) 0x80;
4589 *buf
++ = (val
>> 8);
4591 upper_limit
= 0x7fff;
4592 lower_limit
= - (offsetT
) 0x8000;
4595 *buf
++ = (val
>> 24);
4596 *buf
++ = (val
>> 16);
4597 *buf
++ = (val
>> 8);
4599 upper_limit
= 0x7fffffff;
4600 lower_limit
= - (offsetT
) 0x7fffffff - 1; /* Avoid constant overflow. */
4603 BAD_CASE (fixP
->fx_size
);
4606 /* Fix up a negative reloc. */
4607 if (fixP
->fx_addsy
== NULL
&& fixP
->fx_subsy
!= NULL
)
4609 fixP
->fx_addsy
= fixP
->fx_subsy
;
4610 fixP
->fx_subsy
= NULL
;
4614 /* For non-pc-relative values, it's conceivable we might get something
4615 like "0xff" for a byte field. So extend the upper part of the range
4616 to accept such numbers. We arbitrarily disallow "-0xff" or "0xff+0xff",
4617 so that we can do any range checking at all. */
4618 if (! fixP
->fx_pcrel
&& ! fixP
->fx_signed
)
4619 upper_limit
= upper_limit
* 2 + 1;
4621 if ((addressT
) val
> upper_limit
4622 && (val
> 0 || val
< lower_limit
))
4623 as_bad_where (fixP
->fx_file
, fixP
->fx_line
, _("value out of range"));
4625 /* A one byte PC-relative reloc means a short branch. We can't use
4626 a short branch with a value of 0 or -1, because those indicate
4627 different opcodes (branches with longer offsets). fixup_segment
4628 in write.c may have clobbered fx_pcrel, so we need to examine the
4631 || fixP
->fx_r_type
== BFD_RELOC_8_PCREL
)
4632 && fixP
->fx_size
== 1
4633 && (fixP
->fx_addsy
== NULL
4634 || S_IS_DEFINED (fixP
->fx_addsy
))
4635 && (val
== 0 || val
== -1))
4636 as_bad_where (fixP
->fx_file
, fixP
->fx_line
, _("invalid byte branch offset"));
4639 /* *fragP has been relaxed to its final size, and now needs to have
4640 the bytes inside it modified to conform to the new size There is UGLY
4644 md_convert_frag_1 (fragS
*fragP
)
4649 /* Address in object code of the displacement. */
4650 register int object_address
= fragP
->fr_fix
+ fragP
->fr_address
;
4652 /* Address in gas core of the place to store the displacement. */
4653 /* This convinces the native rs6000 compiler to generate the code we
4655 register char *buffer_address
= fragP
->fr_literal
;
4656 buffer_address
+= fragP
->fr_fix
;
4657 /* End ibm compiler workaround. */
4659 /* The displacement of the address, from current location. */
4660 disp
= fragP
->fr_symbol
? S_GET_VALUE (fragP
->fr_symbol
) : 0;
4661 disp
= (disp
+ fragP
->fr_offset
) - object_address
;
4663 switch (fragP
->fr_subtype
)
4665 case TAB (BRANCHBWL
, BYTE
):
4666 case TAB (BRABSJUNC
, BYTE
):
4667 case TAB (BRABSJCOND
, BYTE
):
4668 case TAB (BRANCHBW
, BYTE
):
4669 know (issbyte (disp
));
4671 as_bad_where (fragP
->fr_file
, fragP
->fr_line
,
4672 _("short branch with zero offset: use :w"));
4673 fixP
= fix_new (fragP
, fragP
->fr_fix
- 1, 1, fragP
->fr_symbol
,
4674 fragP
->fr_offset
, 1, RELAX_RELOC_PC8
);
4675 fixP
->fx_pcrel_adjust
= -1;
4677 case TAB (BRANCHBWL
, SHORT
):
4678 case TAB (BRABSJUNC
, SHORT
):
4679 case TAB (BRABSJCOND
, SHORT
):
4680 case TAB (BRANCHBW
, SHORT
):
4681 fragP
->fr_opcode
[1] = 0x00;
4682 fix_new (fragP
, fragP
->fr_fix
, 2, fragP
->fr_symbol
, fragP
->fr_offset
,
4683 1, RELAX_RELOC_PC16
);
4686 case TAB (BRANCHBWL
, LONG
):
4687 fragP
->fr_opcode
[1] = (char) 0xFF;
4688 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4689 1, RELAX_RELOC_PC32
);
4692 case TAB (BRABSJUNC
, LONG
):
4693 if (fragP
->fr_opcode
[0] == 0x61) /* jbsr */
4695 if (flag_keep_pcrel
)
4696 as_fatal (_("Tried to convert PC relative BSR to absolute JSR"));
4697 fragP
->fr_opcode
[0] = 0x4E;
4698 fragP
->fr_opcode
[1] = (char) 0xB9; /* JSR with ABSL LONG operand. */
4699 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4700 0, RELAX_RELOC_ABS32
);
4703 else if (fragP
->fr_opcode
[0] == 0x60) /* jbra */
4705 if (flag_keep_pcrel
)
4706 as_fatal (_("Tried to convert PC relative branch to absolute jump"));
4707 fragP
->fr_opcode
[0] = 0x4E;
4708 fragP
->fr_opcode
[1] = (char) 0xF9; /* JMP with ABSL LONG operand. */
4709 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4710 0, RELAX_RELOC_ABS32
);
4715 /* This cannot happen, because jbsr and jbra are the only two
4716 unconditional branches. */
4720 case TAB (BRABSJCOND
, LONG
):
4721 if (flag_keep_pcrel
)
4722 as_fatal (_("Tried to convert PC relative conditional branch to absolute jump"));
4724 /* Only Bcc 68000 instructions can come here
4725 Change bcc into b!cc/jmp absl long. */
4726 fragP
->fr_opcode
[0] ^= 0x01; /* Invert bcc. */
4727 fragP
->fr_opcode
[1] = 0x06; /* Branch offset = 6. */
4729 /* JF: these used to be fr_opcode[2,3], but they may be in a
4730 different frag, in which case referring to them is a no-no.
4731 Only fr_opcode[0,1] are guaranteed to work. */
4732 *buffer_address
++ = 0x4e; /* put in jmp long (0x4ef9) */
4733 *buffer_address
++ = (char) 0xf9;
4734 fragP
->fr_fix
+= 2; /* Account for jmp instruction. */
4735 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
,
4736 fragP
->fr_offset
, 0, RELAX_RELOC_ABS32
);
4739 case TAB (FBRANCH
, SHORT
):
4740 know ((fragP
->fr_opcode
[1] & 0x40) == 0);
4741 fix_new (fragP
, fragP
->fr_fix
, 2, fragP
->fr_symbol
, fragP
->fr_offset
,
4742 1, RELAX_RELOC_PC16
);
4745 case TAB (FBRANCH
, LONG
):
4746 fragP
->fr_opcode
[1] |= 0x40; /* Turn on LONG bit. */
4747 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4748 1, RELAX_RELOC_PC32
);
4751 case TAB (DBCCLBR
, SHORT
):
4752 case TAB (DBCCABSJ
, SHORT
):
4753 fix_new (fragP
, fragP
->fr_fix
, 2, fragP
->fr_symbol
, fragP
->fr_offset
,
4754 1, RELAX_RELOC_PC16
);
4757 case TAB (DBCCLBR
, LONG
):
4758 /* Only DBcc instructions can come here.
4759 Change dbcc into dbcc/bral.
4760 JF: these used to be fr_opcode[2-7], but that's wrong. */
4761 if (flag_keep_pcrel
)
4762 as_fatal (_("Tried to convert DBcc to absolute jump"));
4764 *buffer_address
++ = 0x00; /* Branch offset = 4. */
4765 *buffer_address
++ = 0x04;
4766 *buffer_address
++ = 0x60; /* Put in bra pc+6. */
4767 *buffer_address
++ = 0x06;
4768 *buffer_address
++ = 0x60; /* Put in bral (0x60ff). */
4769 *buffer_address
++ = (char) 0xff;
4771 fragP
->fr_fix
+= 6; /* Account for bra/jmp instructions. */
4772 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
, 1,
4776 case TAB (DBCCABSJ
, LONG
):
4777 /* Only DBcc instructions can come here.
4778 Change dbcc into dbcc/jmp.
4779 JF: these used to be fr_opcode[2-7], but that's wrong. */
4780 if (flag_keep_pcrel
)
4781 as_fatal (_("Tried to convert PC relative conditional branch to absolute jump"));
4783 *buffer_address
++ = 0x00; /* Branch offset = 4. */
4784 *buffer_address
++ = 0x04;
4785 *buffer_address
++ = 0x60; /* Put in bra pc + 6. */
4786 *buffer_address
++ = 0x06;
4787 *buffer_address
++ = 0x4e; /* Put in jmp long (0x4ef9). */
4788 *buffer_address
++ = (char) 0xf9;
4790 fragP
->fr_fix
+= 6; /* Account for bra/jmp instructions. */
4791 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
, 0,
4795 case TAB (PCREL1632
, SHORT
):
4796 fragP
->fr_opcode
[1] &= ~0x3F;
4797 fragP
->fr_opcode
[1] |= 0x3A; /* 072 - mode 7.2 */
4798 fix_new (fragP
, (int) (fragP
->fr_fix
), 2, fragP
->fr_symbol
,
4799 fragP
->fr_offset
, 1, RELAX_RELOC_PC16
);
4802 case TAB (PCREL1632
, LONG
):
4803 /* Already set to mode 7.3; this indicates: PC indirect with
4804 suppressed index, 32-bit displacement. */
4805 *buffer_address
++ = 0x01;
4806 *buffer_address
++ = 0x70;
4808 fixP
= fix_new (fragP
, (int) (fragP
->fr_fix
), 4, fragP
->fr_symbol
,
4809 fragP
->fr_offset
, 1, RELAX_RELOC_PC32
);
4810 fixP
->fx_pcrel_adjust
= 2;
4813 case TAB (PCINDEX
, BYTE
):
4814 assert (fragP
->fr_fix
>= 2);
4815 buffer_address
[-2] &= ~1;
4816 fixP
= fix_new (fragP
, fragP
->fr_fix
- 1, 1, fragP
->fr_symbol
,
4817 fragP
->fr_offset
, 1, RELAX_RELOC_PC8
);
4818 fixP
->fx_pcrel_adjust
= 1;
4820 case TAB (PCINDEX
, SHORT
):
4821 assert (fragP
->fr_fix
>= 2);
4822 buffer_address
[-2] |= 0x1;
4823 buffer_address
[-1] = 0x20;
4824 fixP
= fix_new (fragP
, (int) (fragP
->fr_fix
), 2, fragP
->fr_symbol
,
4825 fragP
->fr_offset
, 1, RELAX_RELOC_PC16
);
4826 fixP
->fx_pcrel_adjust
= 2;
4829 case TAB (PCINDEX
, LONG
):
4830 assert (fragP
->fr_fix
>= 2);
4831 buffer_address
[-2] |= 0x1;
4832 buffer_address
[-1] = 0x30;
4833 fixP
= fix_new (fragP
, (int) (fragP
->fr_fix
), 4, fragP
->fr_symbol
,
4834 fragP
->fr_offset
, 1, RELAX_RELOC_PC32
);
4835 fixP
->fx_pcrel_adjust
= 2;
4838 case TAB (ABSTOPCREL
, SHORT
):
4839 fix_new (fragP
, fragP
->fr_fix
, 2, fragP
->fr_symbol
, fragP
->fr_offset
,
4840 1, RELAX_RELOC_PC16
);
4843 case TAB (ABSTOPCREL
, LONG
):
4844 if (flag_keep_pcrel
)
4845 as_fatal (_("Tried to convert PC relative conditional branch to absolute jump"));
4846 /* The thing to do here is force it to ABSOLUTE LONG, since
4847 ABSTOPCREL is really trying to shorten an ABSOLUTE address anyway. */
4848 if ((fragP
->fr_opcode
[1] & 0x3F) != 0x3A)
4850 fragP
->fr_opcode
[1] &= ~0x3F;
4851 fragP
->fr_opcode
[1] |= 0x39; /* Mode 7.1 */
4852 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4853 0, RELAX_RELOC_ABS32
);
4860 md_convert_frag (bfd
*abfd ATTRIBUTE_UNUSED
,
4861 segT sec ATTRIBUTE_UNUSED
,
4864 md_convert_frag_1 (fragP
);
4867 /* Force truly undefined symbols to their maximum size, and generally set up
4868 the frag list to be relaxed
4871 md_estimate_size_before_relax (fragS
*fragP
, segT segment
)
4873 /* Handle SZ_UNDEF first, it can be changed to BYTE or SHORT. */
4874 switch (fragP
->fr_subtype
)
4876 case TAB (BRANCHBWL
, SZ_UNDEF
):
4877 case TAB (BRABSJUNC
, SZ_UNDEF
):
4878 case TAB (BRABSJCOND
, SZ_UNDEF
):
4880 if (S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4881 && relaxable_symbol (fragP
->fr_symbol
))
4883 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), BYTE
);
4885 else if (flag_short_refs
)
4887 /* Symbol is undefined and we want short ref. */
4888 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), SHORT
);
4892 /* Symbol is still undefined. Make it LONG. */
4893 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), LONG
);
4898 case TAB (BRANCHBW
, SZ_UNDEF
):
4900 if (S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4901 && relaxable_symbol (fragP
->fr_symbol
))
4903 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), BYTE
);
4907 /* Symbol is undefined and we don't have long branches. */
4908 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), SHORT
);
4913 case TAB (FBRANCH
, SZ_UNDEF
):
4914 case TAB (DBCCLBR
, SZ_UNDEF
):
4915 case TAB (DBCCABSJ
, SZ_UNDEF
):
4916 case TAB (PCREL1632
, SZ_UNDEF
):
4918 if ((S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4919 && relaxable_symbol (fragP
->fr_symbol
))
4922 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), SHORT
);
4926 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), LONG
);
4931 case TAB (PCINDEX
, SZ_UNDEF
):
4932 if ((S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4933 && relaxable_symbol (fragP
->fr_symbol
)))
4935 fragP
->fr_subtype
= TAB (PCINDEX
, BYTE
);
4939 fragP
->fr_subtype
= TAB (PCINDEX
, LONG
);
4943 case TAB (ABSTOPCREL
, SZ_UNDEF
):
4945 if ((S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4946 && relaxable_symbol (fragP
->fr_symbol
)))
4948 fragP
->fr_subtype
= TAB (ABSTOPCREL
, SHORT
);
4952 fragP
->fr_subtype
= TAB (ABSTOPCREL
, LONG
);
4961 /* Now that SZ_UNDEF are taken care of, check others. */
4962 switch (fragP
->fr_subtype
)
4964 case TAB (BRANCHBWL
, BYTE
):
4965 case TAB (BRABSJUNC
, BYTE
):
4966 case TAB (BRABSJCOND
, BYTE
):
4967 case TAB (BRANCHBW
, BYTE
):
4968 /* We can't do a short jump to the next instruction, so in that
4969 case we force word mode. If the symbol is at the start of a
4970 frag, and it is the next frag with any data in it (usually
4971 this is just the next frag, but assembler listings may
4972 introduce empty frags), we must use word mode. */
4973 if (fragP
->fr_symbol
)
4977 sym_frag
= symbol_get_frag (fragP
->fr_symbol
);
4978 if (S_GET_VALUE (fragP
->fr_symbol
) == sym_frag
->fr_address
)
4982 for (l
= fragP
->fr_next
; l
&& l
!= sym_frag
; l
= l
->fr_next
)
4986 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), SHORT
);
4993 return md_relax_table
[fragP
->fr_subtype
].rlx_length
;
4996 #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
4997 /* the bit-field entries in the relocation_info struct plays hell
4998 with the byte-order problems of cross-assembly. So as a hack,
4999 I added this mach. dependent ri twiddler. Ugly, but it gets
5001 /* on m68k: first 4 bytes are normal unsigned long, next three bytes
5002 are symbolnum, most sig. byte first. Last byte is broken up with
5003 bit 7 as pcrel, bits 6 & 5 as length, bit 4 as pcrel, and the lower
5004 nibble as nuthin. (on Sun 3 at least) */
5005 /* Translate the internal relocation information into target-specific
5009 md_ri_to_chars (char *the_bytes
, struct reloc_info_generic
*ri
)
5012 md_number_to_chars (the_bytes
, ri
->r_address
, 4);
5013 /* Now the fun stuff. */
5014 the_bytes
[4] = (ri
->r_symbolnum
>> 16) & 0x0ff;
5015 the_bytes
[5] = (ri
->r_symbolnum
>> 8) & 0x0ff;
5016 the_bytes
[6] = ri
->r_symbolnum
& 0x0ff;
5017 the_bytes
[7] = (((ri
->r_pcrel
<< 7) & 0x80)
5018 | ((ri
->r_length
<< 5) & 0x60)
5019 | ((ri
->r_extern
<< 4) & 0x10));
5024 #endif /* OBJ_AOUT or OBJ_BOUT */
5026 #ifndef WORKING_DOT_WORD
5027 int md_short_jump_size
= 4;
5028 int md_long_jump_size
= 6;
5031 md_create_short_jump (char *ptr
, addressT from_addr
, addressT to_addr
,
5032 fragS
*frag ATTRIBUTE_UNUSED
,
5033 symbolS
*to_symbol ATTRIBUTE_UNUSED
)
5037 offset
= to_addr
- (from_addr
+ 2);
5039 md_number_to_chars (ptr
, (valueT
) 0x6000, 2);
5040 md_number_to_chars (ptr
+ 2, (valueT
) offset
, 2);
5044 md_create_long_jump (char *ptr
, addressT from_addr
, addressT to_addr
,
5045 fragS
*frag
, symbolS
*to_symbol
)
5049 if (!HAVE_LONG_BRANCH (current_architecture
))
5051 if (flag_keep_pcrel
)
5052 as_fatal (_("Tried to convert PC relative branch to absolute jump"));
5053 offset
= to_addr
- S_GET_VALUE (to_symbol
);
5054 md_number_to_chars (ptr
, (valueT
) 0x4EF9, 2);
5055 md_number_to_chars (ptr
+ 2, (valueT
) offset
, 4);
5056 fix_new (frag
, (ptr
+ 2) - frag
->fr_literal
, 4, to_symbol
, (offsetT
) 0,
5061 offset
= to_addr
- (from_addr
+ 2);
5062 md_number_to_chars (ptr
, (valueT
) 0x60ff, 2);
5063 md_number_to_chars (ptr
+ 2, (valueT
) offset
, 4);
5069 /* Different values of OK tell what its OK to return. Things that
5070 aren't OK are an error (what a shock, no?)
5073 10: Absolute 1:8 only
5074 20: Absolute 0:7 only
5075 30: absolute 0:15 only
5076 40: Absolute 0:31 only
5077 50: absolute 0:127 only
5078 55: absolute -64:63 only
5079 60: absolute -128:127 only
5080 70: absolute 0:4095 only
5081 80: absolute -1, 1:7 only
5085 get_num (struct m68k_exp
*exp
, int ok
)
5087 if (exp
->exp
.X_op
== O_absent
)
5089 /* Do the same thing the VAX asm does. */
5090 op (exp
) = O_constant
;
5096 as_warn (_("expression out of range: defaulting to 1"));
5100 else if (exp
->exp
.X_op
== O_constant
)
5105 if ((valueT
) TRUNC (offs (exp
)) - 1 > 7)
5107 as_warn (_("expression out of range: defaulting to 1"));
5112 if ((valueT
) TRUNC (offs (exp
)) > 7)
5116 if ((valueT
) TRUNC (offs (exp
)) > 15)
5120 if ((valueT
) TRUNC (offs (exp
)) > 32)
5124 if ((valueT
) TRUNC (offs (exp
)) > 127)
5128 if ((valueT
) SEXT (offs (exp
)) + 64 > 127)
5132 if ((valueT
) SEXT (offs (exp
)) + 128 > 255)
5136 if ((valueT
) TRUNC (offs (exp
)) > 4095)
5139 as_warn (_("expression out of range: defaulting to 0"));
5144 if ((valueT
) TRUNC (offs (exp
)) != 0xffffffff
5145 && (valueT
) TRUNC (offs (exp
)) - 1 > 6)
5147 as_warn (_("expression out of range: defaulting to 1"));
5155 else if (exp
->exp
.X_op
== O_big
)
5157 if (offs (exp
) <= 0 /* flonum. */
5158 && (ok
== 90 /* no bignums */
5159 || (ok
> 10 /* Small-int ranges including 0 ok. */
5160 /* If we have a flonum zero, a zero integer should
5161 do as well (e.g., in moveq). */
5162 && generic_floating_point_number
.exponent
== 0
5163 && generic_floating_point_number
.low
[0] == 0)))
5165 /* HACK! Turn it into a long. */
5166 LITTLENUM_TYPE words
[6];
5168 gen_to_words (words
, 2, 8L); /* These numbers are magic! */
5169 op (exp
) = O_constant
;
5172 offs (exp
) = words
[1] | (words
[0] << 16);
5176 op (exp
) = O_constant
;
5179 offs (exp
) = (ok
== 10) ? 1 : 0;
5180 as_warn (_("Can't deal with expression; defaulting to %ld"),
5186 if (ok
>= 10 && ok
<= 80)
5188 op (exp
) = O_constant
;
5191 offs (exp
) = (ok
== 10) ? 1 : 0;
5192 as_warn (_("Can't deal with expression; defaulting to %ld"),
5197 if (exp
->size
!= SIZE_UNSPEC
)
5205 if (!isbyte (offs (exp
)))
5206 as_warn (_("expression doesn't fit in BYTE"));
5209 if (!isword (offs (exp
)))
5210 as_warn (_("expression doesn't fit in WORD"));
5218 /* These are the back-ends for the various machine dependent pseudo-ops. */
5221 s_data1 (int ignore ATTRIBUTE_UNUSED
)
5223 subseg_set (data_section
, 1);
5224 demand_empty_rest_of_line ();
5228 s_data2 (int ignore ATTRIBUTE_UNUSED
)
5230 subseg_set (data_section
, 2);
5231 demand_empty_rest_of_line ();
5235 s_bss (int ignore ATTRIBUTE_UNUSED
)
5237 /* We don't support putting frags in the BSS segment, we fake it
5238 by marking in_bss, then looking at s_skip for clues. */
5240 subseg_set (bss_section
, 0);
5241 demand_empty_rest_of_line ();
5245 s_even (int ignore ATTRIBUTE_UNUSED
)
5248 register long temp_fill
;
5250 temp
= 1; /* JF should be 2? */
5251 temp_fill
= get_absolute_expression ();
5252 if (!need_pass_2
) /* Never make frag if expect extra pass. */
5253 frag_align (temp
, (int) temp_fill
, 0);
5254 demand_empty_rest_of_line ();
5255 record_alignment (now_seg
, temp
);
5259 s_proc (int ignore ATTRIBUTE_UNUSED
)
5261 demand_empty_rest_of_line ();
5264 /* Pseudo-ops handled for MRI compatibility. */
5266 /* This function returns non-zero if the argument is a conditional
5267 pseudo-op. This is called when checking whether a pending
5268 alignment is needed. */
5271 m68k_conditional_pseudoop (pseudo_typeS
*pop
)
5273 return (pop
->poc_handler
== s_mri_if
5274 || pop
->poc_handler
== s_mri_else
);
5277 /* Handle an MRI style chip specification. */
5286 s
= input_line_pointer
;
5287 /* We can't use get_symbol_end since the processor names are not proper
5289 while (is_part_of_name (c
= *input_line_pointer
++))
5291 *--input_line_pointer
= 0;
5292 for (i
= 0; m68k_cpus
[i
].name
; i
++)
5293 if (strcasecmp (s
, m68k_cpus
[i
].name
) == 0)
5295 if (!m68k_cpus
[i
].name
)
5297 as_bad (_("%s: unrecognized processor name"), s
);
5298 *input_line_pointer
= c
;
5299 ignore_rest_of_line ();
5302 *input_line_pointer
= c
;
5304 if (*input_line_pointer
== '/')
5305 current_architecture
= 0;
5307 current_architecture
&= m68881
| m68851
;
5308 current_architecture
|= m68k_cpus
[i
].arch
& ~(m68881
| m68851
);
5309 control_regs
= m68k_cpus
[i
].control_regs
;
5311 while (*input_line_pointer
== '/')
5313 ++input_line_pointer
;
5314 s
= input_line_pointer
;
5315 /* We can't use get_symbol_end since the processor names are not
5317 while (is_part_of_name (c
= *input_line_pointer
++))
5319 *--input_line_pointer
= 0;
5320 if (strcmp (s
, "68881") == 0)
5321 current_architecture
|= m68881
;
5322 else if (strcmp (s
, "68851") == 0)
5323 current_architecture
|= m68851
;
5324 *input_line_pointer
= c
;
5328 /* The MRI CHIP pseudo-op. */
5331 s_chip (int ignore ATTRIBUTE_UNUSED
)
5337 stop
= mri_comment_field (&stopc
);
5340 mri_comment_end (stop
, stopc
);
5341 demand_empty_rest_of_line ();
5344 /* The MRI FOPT pseudo-op. */
5347 s_fopt (int ignore ATTRIBUTE_UNUSED
)
5351 if (strncasecmp (input_line_pointer
, "ID=", 3) == 0)
5355 input_line_pointer
+= 3;
5356 temp
= get_absolute_expression ();
5357 if (temp
< 0 || temp
> 7)
5358 as_bad (_("bad coprocessor id"));
5360 m68k_float_copnum
= COP0
+ temp
;
5364 as_bad (_("unrecognized fopt option"));
5365 ignore_rest_of_line ();
5369 demand_empty_rest_of_line ();
5372 /* The structure used to handle the MRI OPT pseudo-op. */
5376 /* The name of the option. */
5379 /* If this is not NULL, just call this function. The first argument
5380 is the ARG field of this structure, the second argument is
5381 whether the option was negated. */
5382 void (*pfn
) (int arg
, int on
);
5384 /* If this is not NULL, and the PFN field is NULL, set the variable
5385 this points to. Set it to the ARG field if the option was not
5386 negated, and the NOTARG field otherwise. */
5389 /* The value to pass to PFN or to assign to *PVAR. */
5392 /* The value to assign to *PVAR if the option is negated. If PFN is
5393 NULL, and PVAR is not NULL, and ARG and NOTARG are the same, then
5394 the option may not be negated. */
5398 /* The table used to handle the MRI OPT pseudo-op. */
5400 static void skip_to_comma (int, int);
5401 static void opt_nest (int, int);
5402 static void opt_chip (int, int);
5403 static void opt_list (int, int);
5404 static void opt_list_symbols (int, int);
5406 static const struct opt_action opt_table
[] =
5408 { "abspcadd", 0, &m68k_abspcadd
, 1, 0 },
5410 /* We do relaxing, so there is little use for these options. */
5411 { "b", 0, 0, 0, 0 },
5412 { "brs", 0, 0, 0, 0 },
5413 { "brb", 0, 0, 0, 0 },
5414 { "brl", 0, 0, 0, 0 },
5415 { "brw", 0, 0, 0, 0 },
5417 { "c", 0, 0, 0, 0 },
5418 { "cex", 0, 0, 0, 0 },
5419 { "case", 0, &symbols_case_sensitive
, 1, 0 },
5420 { "cl", 0, 0, 0, 0 },
5421 { "cre", 0, 0, 0, 0 },
5422 { "d", 0, &flag_keep_locals
, 1, 0 },
5423 { "e", 0, 0, 0, 0 },
5424 { "f", 0, &flag_short_refs
, 1, 0 },
5425 { "frs", 0, &flag_short_refs
, 1, 0 },
5426 { "frl", 0, &flag_short_refs
, 0, 1 },
5427 { "g", 0, 0, 0, 0 },
5428 { "i", 0, 0, 0, 0 },
5429 { "m", 0, 0, 0, 0 },
5430 { "mex", 0, 0, 0, 0 },
5431 { "mc", 0, 0, 0, 0 },
5432 { "md", 0, 0, 0, 0 },
5433 { "nest", opt_nest
, 0, 0, 0 },
5434 { "next", skip_to_comma
, 0, 0, 0 },
5435 { "o", 0, 0, 0, 0 },
5436 { "old", 0, 0, 0, 0 },
5437 { "op", skip_to_comma
, 0, 0, 0 },
5438 { "pco", 0, 0, 0, 0 },
5439 { "p", opt_chip
, 0, 0, 0 },
5440 { "pcr", 0, 0, 0, 0 },
5441 { "pcs", 0, 0, 0, 0 },
5442 { "r", 0, 0, 0, 0 },
5443 { "quick", 0, &m68k_quick
, 1, 0 },
5444 { "rel32", 0, &m68k_rel32
, 1, 0 },
5445 { "s", opt_list
, 0, 0, 0 },
5446 { "t", opt_list_symbols
, 0, 0, 0 },
5447 { "w", 0, &flag_no_warnings
, 0, 1 },
5451 #define OPTCOUNT ((int) (sizeof opt_table / sizeof opt_table[0]))
5453 /* The MRI OPT pseudo-op. */
5456 s_opt (int ignore ATTRIBUTE_UNUSED
)
5464 const struct opt_action
*o
;
5469 if (*input_line_pointer
== '-')
5471 ++input_line_pointer
;
5474 else if (strncasecmp (input_line_pointer
, "NO", 2) == 0)
5476 input_line_pointer
+= 2;
5480 s
= input_line_pointer
;
5481 c
= get_symbol_end ();
5483 for (i
= 0, o
= opt_table
; i
< OPTCOUNT
; i
++, o
++)
5485 if (strcasecmp (s
, o
->name
) == 0)
5489 /* Restore input_line_pointer now in case the option
5491 *input_line_pointer
= c
;
5492 (*o
->pfn
) (o
->arg
, t
);
5494 else if (o
->pvar
!= NULL
)
5496 if (! t
&& o
->arg
== o
->notarg
)
5497 as_bad (_("option `%s' may not be negated"), s
);
5498 *input_line_pointer
= c
;
5499 *o
->pvar
= t
? o
->arg
: o
->notarg
;
5502 *input_line_pointer
= c
;
5508 as_bad (_("option `%s' not recognized"), s
);
5509 *input_line_pointer
= c
;
5512 while (*input_line_pointer
++ == ',');
5514 /* Move back to terminating character. */
5515 --input_line_pointer
;
5516 demand_empty_rest_of_line ();
5519 /* Skip ahead to a comma. This is used for OPT options which we do
5520 not support and which take arguments. */
5523 skip_to_comma (int arg ATTRIBUTE_UNUSED
, int on ATTRIBUTE_UNUSED
)
5525 while (*input_line_pointer
!= ','
5526 && ! is_end_of_line
[(unsigned char) *input_line_pointer
])
5527 ++input_line_pointer
;
5530 /* Handle the OPT NEST=depth option. */
5533 opt_nest (int arg ATTRIBUTE_UNUSED
, int on ATTRIBUTE_UNUSED
)
5535 if (*input_line_pointer
!= '=')
5537 as_bad (_("bad format of OPT NEST=depth"));
5541 ++input_line_pointer
;
5542 max_macro_nest
= get_absolute_expression ();
5545 /* Handle the OPT P=chip option. */
5548 opt_chip (int arg ATTRIBUTE_UNUSED
, int on ATTRIBUTE_UNUSED
)
5550 if (*input_line_pointer
!= '=')
5552 /* This is just OPT P, which we do not support. */
5556 ++input_line_pointer
;
5560 /* Handle the OPT S option. */
5563 opt_list (int arg ATTRIBUTE_UNUSED
, int on
)
5568 /* Handle the OPT T option. */
5571 opt_list_symbols (int arg ATTRIBUTE_UNUSED
, int on
)
5574 listing
|= LISTING_SYMBOLS
;
5576 listing
&= ~LISTING_SYMBOLS
;
5579 /* Handle the MRI REG pseudo-op. */
5582 s_reg (int ignore ATTRIBUTE_UNUSED
)
5591 if (line_label
== NULL
)
5593 as_bad (_("missing label"));
5594 ignore_rest_of_line ();
5599 stop
= mri_comment_field (&stopc
);
5603 s
= input_line_pointer
;
5604 while (ISALNUM (*input_line_pointer
)
5605 #ifdef REGISTER_PREFIX
5606 || *input_line_pointer
== REGISTER_PREFIX
5608 || *input_line_pointer
== '/'
5609 || *input_line_pointer
== '-')
5610 ++input_line_pointer
;
5611 c
= *input_line_pointer
;
5612 *input_line_pointer
= '\0';
5614 if (m68k_ip_op (s
, &rop
) != 0)
5616 if (rop
.error
== NULL
)
5617 as_bad (_("bad register list"));
5619 as_bad (_("bad register list: %s"), rop
.error
);
5620 *input_line_pointer
= c
;
5621 ignore_rest_of_line ();
5625 *input_line_pointer
= c
;
5627 if (rop
.mode
== REGLST
)
5629 else if (rop
.mode
== DREG
)
5630 mask
= 1 << (rop
.reg
- DATA0
);
5631 else if (rop
.mode
== AREG
)
5632 mask
= 1 << (rop
.reg
- ADDR0
+ 8);
5633 else if (rop
.mode
== FPREG
)
5634 mask
= 1 << (rop
.reg
- FP0
+ 16);
5635 else if (rop
.mode
== CONTROL
5638 else if (rop
.mode
== CONTROL
5641 else if (rop
.mode
== CONTROL
5646 as_bad (_("bad register list"));
5647 ignore_rest_of_line ();
5651 S_SET_SEGMENT (line_label
, reg_section
);
5652 S_SET_VALUE (line_label
, ~mask
);
5653 symbol_set_frag (line_label
, &zero_address_frag
);
5656 mri_comment_end (stop
, stopc
);
5658 demand_empty_rest_of_line ();
5661 /* This structure is used for the MRI SAVE and RESTORE pseudo-ops. */
5665 struct save_opts
*next
;
5667 int symbols_case_sensitive
;
5671 const enum m68k_register
*control_regs
;
5676 /* FIXME: We don't save OPT S. */
5679 /* This variable holds the stack of saved options. */
5681 static struct save_opts
*save_stack
;
5683 /* The MRI SAVE pseudo-op. */
5686 s_save (int ignore ATTRIBUTE_UNUSED
)
5688 struct save_opts
*s
;
5690 s
= (struct save_opts
*) xmalloc (sizeof (struct save_opts
));
5691 s
->abspcadd
= m68k_abspcadd
;
5692 s
->symbols_case_sensitive
= symbols_case_sensitive
;
5693 s
->keep_locals
= flag_keep_locals
;
5694 s
->short_refs
= flag_short_refs
;
5695 s
->architecture
= current_architecture
;
5696 s
->control_regs
= control_regs
;
5697 s
->quick
= m68k_quick
;
5698 s
->rel32
= m68k_rel32
;
5699 s
->listing
= listing
;
5700 s
->no_warnings
= flag_no_warnings
;
5702 s
->next
= save_stack
;
5705 demand_empty_rest_of_line ();
5708 /* The MRI RESTORE pseudo-op. */
5711 s_restore (int ignore ATTRIBUTE_UNUSED
)
5713 struct save_opts
*s
;
5715 if (save_stack
== NULL
)
5717 as_bad (_("restore without save"));
5718 ignore_rest_of_line ();
5723 save_stack
= s
->next
;
5725 m68k_abspcadd
= s
->abspcadd
;
5726 symbols_case_sensitive
= s
->symbols_case_sensitive
;
5727 flag_keep_locals
= s
->keep_locals
;
5728 flag_short_refs
= s
->short_refs
;
5729 current_architecture
= s
->architecture
;
5730 control_regs
= s
->control_regs
;
5731 m68k_quick
= s
->quick
;
5732 m68k_rel32
= s
->rel32
;
5733 listing
= s
->listing
;
5734 flag_no_warnings
= s
->no_warnings
;
5738 demand_empty_rest_of_line ();
5741 /* Types of MRI structured control directives. */
5743 enum mri_control_type
5751 /* This structure is used to stack the MRI structured control
5754 struct mri_control_info
5756 /* The directive within which this one is enclosed. */
5757 struct mri_control_info
*outer
;
5759 /* The type of directive. */
5760 enum mri_control_type type
;
5762 /* Whether an ELSE has been in an IF. */
5765 /* The add or sub statement at the end of a FOR. */
5768 /* The label of the top of a FOR or REPEAT loop. */
5771 /* The label to jump to for the next iteration, or the else
5772 expression of a conditional. */
5775 /* The label to jump to to break out of the loop, or the label past
5776 the end of a conditional. */
5780 /* The stack of MRI structured control directives. */
5782 static struct mri_control_info
*mri_control_stack
;
5784 /* The current MRI structured control directive index number, used to
5785 generate label names. */
5787 static int mri_control_index
;
5789 /* Assemble an instruction for an MRI structured control directive. */
5792 mri_assemble (char *str
)
5796 /* md_assemble expects the opcode to be in lower case. */
5797 for (s
= str
; *s
!= ' ' && *s
!= '\0'; s
++)
5803 /* Generate a new MRI label structured control directive label name. */
5806 mri_control_label (void)
5810 n
= (char *) xmalloc (20);
5811 sprintf (n
, "%smc%d", FAKE_LABEL_NAME
, mri_control_index
);
5812 ++mri_control_index
;
5816 /* Create a new MRI structured control directive. */
5818 static struct mri_control_info
*
5819 push_mri_control (enum mri_control_type type
)
5821 struct mri_control_info
*n
;
5823 n
= (struct mri_control_info
*) xmalloc (sizeof (struct mri_control_info
));
5827 if (type
== mri_if
|| type
== mri_while
)
5830 n
->top
= mri_control_label ();
5831 n
->next
= mri_control_label ();
5832 n
->bottom
= mri_control_label ();
5834 n
->outer
= mri_control_stack
;
5835 mri_control_stack
= n
;
5840 /* Pop off the stack of MRI structured control directives. */
5843 pop_mri_control (void)
5845 struct mri_control_info
*n
;
5847 n
= mri_control_stack
;
5848 mri_control_stack
= n
->outer
;
5856 /* Recognize a condition code in an MRI structured control expression. */
5859 parse_mri_condition (int *pcc
)
5863 know (*input_line_pointer
== '<');
5865 ++input_line_pointer
;
5866 c1
= *input_line_pointer
++;
5867 c2
= *input_line_pointer
++;
5869 if (*input_line_pointer
!= '>')
5871 as_bad (_("syntax error in structured control directive"));
5875 ++input_line_pointer
;
5881 *pcc
= (c1
<< 8) | c2
;
5886 /* Parse a single operand in an MRI structured control expression. */
5889 parse_mri_control_operand (int *pcc
, char **leftstart
, char **leftstop
,
5890 char **rightstart
, char **rightstop
)
5902 if (*input_line_pointer
== '<')
5904 /* It's just a condition code. */
5905 return parse_mri_condition (pcc
);
5908 /* Look ahead for the condition code. */
5909 for (s
= input_line_pointer
; *s
!= '\0'; ++s
)
5911 if (*s
== '<' && s
[1] != '\0' && s
[2] != '\0' && s
[3] == '>')
5916 as_bad (_("missing condition code in structured control directive"));
5920 *leftstart
= input_line_pointer
;
5922 if (*leftstop
> *leftstart
5923 && ((*leftstop
)[-1] == ' ' || (*leftstop
)[-1] == '\t'))
5926 input_line_pointer
= s
;
5927 if (! parse_mri_condition (pcc
))
5930 /* Look ahead for AND or OR or end of line. */
5931 for (s
= input_line_pointer
; *s
!= '\0'; ++s
)
5933 /* We must make sure we don't misinterpret AND/OR at the end of labels!
5934 if d0 <eq> #FOOAND and d1 <ne> #BAROR then
5936 if ((s
== input_line_pointer
5939 && ((strncasecmp (s
, "AND", 3) == 0
5940 && (s
[3] == '.' || ! is_part_of_name (s
[3])))
5941 || (strncasecmp (s
, "OR", 2) == 0
5942 && (s
[2] == '.' || ! is_part_of_name (s
[2])))))
5946 *rightstart
= input_line_pointer
;
5948 if (*rightstop
> *rightstart
5949 && ((*rightstop
)[-1] == ' ' || (*rightstop
)[-1] == '\t'))
5952 input_line_pointer
= s
;
5957 #define MCC(b1, b2) (((b1) << 8) | (b2))
5959 /* Swap the sense of a condition. This changes the condition so that
5960 it generates the same result when the operands are swapped. */
5963 swap_mri_condition (int cc
)
5967 case MCC ('h', 'i'): return MCC ('c', 's');
5968 case MCC ('l', 's'): return MCC ('c', 'c');
5969 /* <HS> is an alias for <CC>. */
5970 case MCC ('h', 's'):
5971 case MCC ('c', 'c'): return MCC ('l', 's');
5972 /* <LO> is an alias for <CS>. */
5973 case MCC ('l', 'o'):
5974 case MCC ('c', 's'): return MCC ('h', 'i');
5975 case MCC ('p', 'l'): return MCC ('m', 'i');
5976 case MCC ('m', 'i'): return MCC ('p', 'l');
5977 case MCC ('g', 'e'): return MCC ('l', 'e');
5978 case MCC ('l', 't'): return MCC ('g', 't');
5979 case MCC ('g', 't'): return MCC ('l', 't');
5980 case MCC ('l', 'e'): return MCC ('g', 'e');
5981 /* Issue a warning for conditions we can not swap. */
5982 case MCC ('n', 'e'): return MCC ('n', 'e'); // no problem here
5983 case MCC ('e', 'q'): return MCC ('e', 'q'); // also no problem
5984 case MCC ('v', 'c'):
5985 case MCC ('v', 's'):
5987 as_warn (_("Condition <%c%c> in structured control directive can not be encoded correctly"),
5988 (char) (cc
>> 8), (char) (cc
));
5994 /* Reverse the sense of a condition. */
5997 reverse_mri_condition (int cc
)
6001 case MCC ('h', 'i'): return MCC ('l', 's');
6002 case MCC ('l', 's'): return MCC ('h', 'i');
6003 /* <HS> is an alias for <CC> */
6004 case MCC ('h', 's'): return MCC ('l', 'o');
6005 case MCC ('c', 'c'): return MCC ('c', 's');
6006 /* <LO> is an alias for <CS> */
6007 case MCC ('l', 'o'): return MCC ('h', 's');
6008 case MCC ('c', 's'): return MCC ('c', 'c');
6009 case MCC ('n', 'e'): return MCC ('e', 'q');
6010 case MCC ('e', 'q'): return MCC ('n', 'e');
6011 case MCC ('v', 'c'): return MCC ('v', 's');
6012 case MCC ('v', 's'): return MCC ('v', 'c');
6013 case MCC ('p', 'l'): return MCC ('m', 'i');
6014 case MCC ('m', 'i'): return MCC ('p', 'l');
6015 case MCC ('g', 'e'): return MCC ('l', 't');
6016 case MCC ('l', 't'): return MCC ('g', 'e');
6017 case MCC ('g', 't'): return MCC ('l', 'e');
6018 case MCC ('l', 'e'): return MCC ('g', 't');
6023 /* Build an MRI structured control expression. This generates test
6024 and branch instructions. It goes to TRUELAB if the condition is
6025 true, and to FALSELAB if the condition is false. Exactly one of
6026 TRUELAB and FALSELAB will be NULL, meaning to fall through. QUAL
6027 is the size qualifier for the expression. EXTENT is the size to
6028 use for the branch. */
6031 build_mri_control_operand (int qual
, int cc
, char *leftstart
, char *leftstop
,
6032 char *rightstart
, char *rightstop
,
6033 const char *truelab
, const char *falselab
,
6039 if (leftstart
!= NULL
)
6041 struct m68k_op leftop
, rightop
;
6044 /* Swap the compare operands, if necessary, to produce a legal
6045 m68k compare instruction. Comparing a register operand with
6046 a non-register operand requires the register to be on the
6047 right (cmp, cmpa). Comparing an immediate value with
6048 anything requires the immediate value to be on the left
6053 (void) m68k_ip_op (leftstart
, &leftop
);
6058 (void) m68k_ip_op (rightstart
, &rightop
);
6061 if (rightop
.mode
== IMMED
6062 || ((leftop
.mode
== DREG
|| leftop
.mode
== AREG
)
6063 && (rightop
.mode
!= DREG
&& rightop
.mode
!= AREG
)))
6067 /* Correct conditional handling:
6068 if #1 <lt> d0 then ;means if (1 < d0)
6074 cmp #1,d0 if we do *not* swap the operands
6075 bgt true we need the swapped condition!
6082 leftstart
= rightstart
;
6085 leftstop
= rightstop
;
6090 cc
= swap_mri_condition (cc
);
6094 if (truelab
== NULL
)
6096 cc
= reverse_mri_condition (cc
);
6100 if (leftstart
!= NULL
)
6102 buf
= (char *) xmalloc (20
6103 + (leftstop
- leftstart
)
6104 + (rightstop
- rightstart
));
6110 *s
++ = TOLOWER (qual
);
6112 memcpy (s
, leftstart
, leftstop
- leftstart
);
6113 s
+= leftstop
- leftstart
;
6115 memcpy (s
, rightstart
, rightstop
- rightstart
);
6116 s
+= rightstop
- rightstart
;
6122 buf
= (char *) xmalloc (20 + strlen (truelab
));
6128 *s
++ = TOLOWER (extent
);
6130 strcpy (s
, truelab
);
6135 /* Parse an MRI structured control expression. This generates test
6136 and branch instructions. STOP is where the expression ends. It
6137 goes to TRUELAB if the condition is true, and to FALSELAB if the
6138 condition is false. Exactly one of TRUELAB and FALSELAB will be
6139 NULL, meaning to fall through. QUAL is the size qualifier for the
6140 expression. EXTENT is the size to use for the branch. */
6143 parse_mri_control_expression (char *stop
, int qual
, const char *truelab
,
6144 const char *falselab
, int extent
)
6156 if (! parse_mri_control_operand (&cc
, &leftstart
, &leftstop
,
6157 &rightstart
, &rightstop
))
6163 if (strncasecmp (input_line_pointer
, "AND", 3) == 0)
6167 if (falselab
!= NULL
)
6170 flab
= mri_control_label ();
6172 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6173 rightstop
, (const char *) NULL
, flab
, extent
);
6175 input_line_pointer
+= 3;
6176 if (*input_line_pointer
!= '.'
6177 || input_line_pointer
[1] == '\0')
6181 qual
= input_line_pointer
[1];
6182 input_line_pointer
+= 2;
6185 if (! parse_mri_control_operand (&cc
, &leftstart
, &leftstop
,
6186 &rightstart
, &rightstop
))
6192 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6193 rightstop
, truelab
, falselab
, extent
);
6195 if (falselab
== NULL
)
6198 else if (strncasecmp (input_line_pointer
, "OR", 2) == 0)
6202 if (truelab
!= NULL
)
6205 tlab
= mri_control_label ();
6207 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6208 rightstop
, tlab
, (const char *) NULL
, extent
);
6210 input_line_pointer
+= 2;
6211 if (*input_line_pointer
!= '.'
6212 || input_line_pointer
[1] == '\0')
6216 qual
= input_line_pointer
[1];
6217 input_line_pointer
+= 2;
6220 if (! parse_mri_control_operand (&cc
, &leftstart
, &leftstop
,
6221 &rightstart
, &rightstop
))
6227 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6228 rightstop
, truelab
, falselab
, extent
);
6230 if (truelab
== NULL
)
6235 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6236 rightstop
, truelab
, falselab
, extent
);
6240 if (input_line_pointer
!= stop
)
6241 as_bad (_("syntax error in structured control directive"));
6244 /* Handle the MRI IF pseudo-op. This may be a structured control
6245 directive, or it may be a regular assembler conditional, depending
6253 struct mri_control_info
*n
;
6255 /* A structured control directive must end with THEN with an
6256 optional qualifier. */
6257 s
= input_line_pointer
;
6258 /* We only accept '*' as introduction of comments if preceded by white space
6259 or at first column of a line (I think this can't actually happen here?)
6260 This is important when assembling:
6261 if d0 <ne> 12(a0,d0*2) then
6262 if d0 <ne> #CONST*20 then. */
6263 while (! (is_end_of_line
[(unsigned char) *s
]
6266 && (s
== input_line_pointer
6268 || *(s
-1) == '\t'))))
6271 while (s
> input_line_pointer
&& (*s
== ' ' || *s
== '\t'))
6274 if (s
- input_line_pointer
> 1
6278 if (s
- input_line_pointer
< 3
6279 || strncasecmp (s
- 3, "THEN", 4) != 0)
6283 as_bad (_("missing then"));
6284 ignore_rest_of_line ();
6288 /* It's a conditional. */
6293 /* Since this might be a conditional if, this pseudo-op will be
6294 called even if we are supported to be ignoring input. Double
6295 check now. Clobber *input_line_pointer so that ignore_input
6296 thinks that this is not a special pseudo-op. */
6297 c
= *input_line_pointer
;
6298 *input_line_pointer
= 0;
6299 if (ignore_input ())
6301 *input_line_pointer
= c
;
6302 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6303 ++input_line_pointer
;
6304 demand_empty_rest_of_line ();
6307 *input_line_pointer
= c
;
6309 n
= push_mri_control (mri_if
);
6311 parse_mri_control_expression (s
- 3, qual
, (const char *) NULL
,
6312 n
->next
, s
[1] == '.' ? s
[2] : '\0');
6315 input_line_pointer
= s
+ 3;
6317 input_line_pointer
= s
+ 1;
6321 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6322 ++input_line_pointer
;
6325 demand_empty_rest_of_line ();
6328 /* Handle the MRI else pseudo-op. If we are currently doing an MRI
6329 structured IF, associate the ELSE with the IF. Otherwise, assume
6330 it is a conditional else. */
6333 s_mri_else (int qual
)
6340 && (mri_control_stack
== NULL
6341 || mri_control_stack
->type
!= mri_if
6342 || mri_control_stack
->else_seen
))
6348 c
= *input_line_pointer
;
6349 *input_line_pointer
= 0;
6350 if (ignore_input ())
6352 *input_line_pointer
= c
;
6353 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6354 ++input_line_pointer
;
6355 demand_empty_rest_of_line ();
6358 *input_line_pointer
= c
;
6360 if (mri_control_stack
== NULL
6361 || mri_control_stack
->type
!= mri_if
6362 || mri_control_stack
->else_seen
)
6364 as_bad (_("else without matching if"));
6365 ignore_rest_of_line ();
6369 mri_control_stack
->else_seen
= 1;
6371 buf
= (char *) xmalloc (20 + strlen (mri_control_stack
->bottom
));
6372 q
[0] = TOLOWER (qual
);
6374 sprintf (buf
, "bra%s %s", q
, mri_control_stack
->bottom
);
6378 colon (mri_control_stack
->next
);
6382 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6383 ++input_line_pointer
;
6386 demand_empty_rest_of_line ();
6389 /* Handle the MRI ENDI pseudo-op. */
6392 s_mri_endi (int ignore ATTRIBUTE_UNUSED
)
6394 if (mri_control_stack
== NULL
6395 || mri_control_stack
->type
!= mri_if
)
6397 as_bad (_("endi without matching if"));
6398 ignore_rest_of_line ();
6402 /* ignore_input will not return true for ENDI, so we don't need to
6403 worry about checking it again here. */
6405 if (! mri_control_stack
->else_seen
)
6406 colon (mri_control_stack
->next
);
6407 colon (mri_control_stack
->bottom
);
6413 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6414 ++input_line_pointer
;
6417 demand_empty_rest_of_line ();
6420 /* Handle the MRI BREAK pseudo-op. */
6423 s_mri_break (int extent
)
6425 struct mri_control_info
*n
;
6429 n
= mri_control_stack
;
6431 && n
->type
!= mri_for
6432 && n
->type
!= mri_repeat
6433 && n
->type
!= mri_while
)
6437 as_bad (_("break outside of structured loop"));
6438 ignore_rest_of_line ();
6442 buf
= (char *) xmalloc (20 + strlen (n
->bottom
));
6443 ex
[0] = TOLOWER (extent
);
6445 sprintf (buf
, "bra%s %s", ex
, n
->bottom
);
6451 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6452 ++input_line_pointer
;
6455 demand_empty_rest_of_line ();
6458 /* Handle the MRI NEXT pseudo-op. */
6461 s_mri_next (int extent
)
6463 struct mri_control_info
*n
;
6467 n
= mri_control_stack
;
6469 && n
->type
!= mri_for
6470 && n
->type
!= mri_repeat
6471 && n
->type
!= mri_while
)
6475 as_bad (_("next outside of structured loop"));
6476 ignore_rest_of_line ();
6480 buf
= (char *) xmalloc (20 + strlen (n
->next
));
6481 ex
[0] = TOLOWER (extent
);
6483 sprintf (buf
, "bra%s %s", ex
, n
->next
);
6489 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6490 ++input_line_pointer
;
6493 demand_empty_rest_of_line ();
6496 /* Handle the MRI FOR pseudo-op. */
6499 s_mri_for (int qual
)
6501 const char *varstart
, *varstop
;
6502 const char *initstart
, *initstop
;
6503 const char *endstart
, *endstop
;
6504 const char *bystart
, *bystop
;
6508 struct mri_control_info
*n
;
6514 FOR.q var = init { TO | DOWNTO } end [ BY by ] DO.e
6518 varstart
= input_line_pointer
;
6520 /* Look for the '='. */
6521 while (! is_end_of_line
[(unsigned char) *input_line_pointer
]
6522 && *input_line_pointer
!= '=')
6523 ++input_line_pointer
;
6524 if (*input_line_pointer
!= '=')
6526 as_bad (_("missing ="));
6527 ignore_rest_of_line ();
6531 varstop
= input_line_pointer
;
6532 if (varstop
> varstart
6533 && (varstop
[-1] == ' ' || varstop
[-1] == '\t'))
6536 ++input_line_pointer
;
6538 initstart
= input_line_pointer
;
6540 /* Look for TO or DOWNTO. */
6543 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6545 if (strncasecmp (input_line_pointer
, "TO", 2) == 0
6546 && ! is_part_of_name (input_line_pointer
[2]))
6548 initstop
= input_line_pointer
;
6549 input_line_pointer
+= 2;
6552 if (strncasecmp (input_line_pointer
, "DOWNTO", 6) == 0
6553 && ! is_part_of_name (input_line_pointer
[6]))
6555 initstop
= input_line_pointer
;
6557 input_line_pointer
+= 6;
6560 ++input_line_pointer
;
6562 if (initstop
== NULL
)
6564 as_bad (_("missing to or downto"));
6565 ignore_rest_of_line ();
6568 if (initstop
> initstart
6569 && (initstop
[-1] == ' ' || initstop
[-1] == '\t'))
6573 endstart
= input_line_pointer
;
6575 /* Look for BY or DO. */
6578 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6580 if (strncasecmp (input_line_pointer
, "BY", 2) == 0
6581 && ! is_part_of_name (input_line_pointer
[2]))
6583 endstop
= input_line_pointer
;
6585 input_line_pointer
+= 2;
6588 if (strncasecmp (input_line_pointer
, "DO", 2) == 0
6589 && (input_line_pointer
[2] == '.'
6590 || ! is_part_of_name (input_line_pointer
[2])))
6592 endstop
= input_line_pointer
;
6593 input_line_pointer
+= 2;
6596 ++input_line_pointer
;
6598 if (endstop
== NULL
)
6600 as_bad (_("missing do"));
6601 ignore_rest_of_line ();
6604 if (endstop
> endstart
6605 && (endstop
[-1] == ' ' || endstop
[-1] == '\t'))
6611 bystop
= bystart
+ 2;
6616 bystart
= input_line_pointer
;
6620 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6622 if (strncasecmp (input_line_pointer
, "DO", 2) == 0
6623 && (input_line_pointer
[2] == '.'
6624 || ! is_part_of_name (input_line_pointer
[2])))
6626 bystop
= input_line_pointer
;
6627 input_line_pointer
+= 2;
6630 ++input_line_pointer
;
6634 as_bad (_("missing do"));
6635 ignore_rest_of_line ();
6638 if (bystop
> bystart
6639 && (bystop
[-1] == ' ' || bystop
[-1] == '\t'))
6643 if (*input_line_pointer
!= '.')
6647 extent
= input_line_pointer
[1];
6648 input_line_pointer
+= 2;
6651 /* We have fully parsed the FOR operands. Now build the loop. */
6652 n
= push_mri_control (mri_for
);
6654 buf
= (char *) xmalloc (50 + (input_line_pointer
- varstart
));
6656 /* Move init,var. */
6663 *s
++ = TOLOWER (qual
);
6665 memcpy (s
, initstart
, initstop
- initstart
);
6666 s
+= initstop
- initstart
;
6668 memcpy (s
, varstart
, varstop
- varstart
);
6669 s
+= varstop
- varstart
;
6681 *s
++ = TOLOWER (qual
);
6683 memcpy (s
, endstart
, endstop
- endstart
);
6684 s
+= endstop
- endstart
;
6686 memcpy (s
, varstart
, varstop
- varstart
);
6687 s
+= varstop
- varstart
;
6692 ex
[0] = TOLOWER (extent
);
6695 sprintf (buf
, "blt%s %s", ex
, n
->bottom
);
6697 sprintf (buf
, "bgt%s %s", ex
, n
->bottom
);
6700 /* Put together the add or sub instruction used by ENDF. */
6708 *s
++ = TOLOWER (qual
);
6710 memcpy (s
, bystart
, bystop
- bystart
);
6711 s
+= bystop
- bystart
;
6713 memcpy (s
, varstart
, varstop
- varstart
);
6714 s
+= varstop
- varstart
;
6720 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6721 ++input_line_pointer
;
6724 demand_empty_rest_of_line ();
6727 /* Handle the MRI ENDF pseudo-op. */
6730 s_mri_endf (int ignore ATTRIBUTE_UNUSED
)
6732 if (mri_control_stack
== NULL
6733 || mri_control_stack
->type
!= mri_for
)
6735 as_bad (_("endf without for"));
6736 ignore_rest_of_line ();
6740 colon (mri_control_stack
->next
);
6742 mri_assemble (mri_control_stack
->incr
);
6744 sprintf (mri_control_stack
->incr
, "bra %s", mri_control_stack
->top
);
6745 mri_assemble (mri_control_stack
->incr
);
6747 free (mri_control_stack
->incr
);
6749 colon (mri_control_stack
->bottom
);
6755 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6756 ++input_line_pointer
;
6759 demand_empty_rest_of_line ();
6762 /* Handle the MRI REPEAT pseudo-op. */
6765 s_mri_repeat (int ignore ATTRIBUTE_UNUSED
)
6767 struct mri_control_info
*n
;
6769 n
= push_mri_control (mri_repeat
);
6773 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6774 ++input_line_pointer
;
6776 demand_empty_rest_of_line ();
6779 /* Handle the MRI UNTIL pseudo-op. */
6782 s_mri_until (int qual
)
6786 if (mri_control_stack
== NULL
6787 || mri_control_stack
->type
!= mri_repeat
)
6789 as_bad (_("until without repeat"));
6790 ignore_rest_of_line ();
6794 colon (mri_control_stack
->next
);
6796 for (s
= input_line_pointer
; ! is_end_of_line
[(unsigned char) *s
]; s
++)
6799 parse_mri_control_expression (s
, qual
, (const char *) NULL
,
6800 mri_control_stack
->top
, '\0');
6802 colon (mri_control_stack
->bottom
);
6804 input_line_pointer
= s
;
6810 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6811 ++input_line_pointer
;
6814 demand_empty_rest_of_line ();
6817 /* Handle the MRI WHILE pseudo-op. */
6820 s_mri_while (int qual
)
6824 struct mri_control_info
*n
;
6826 s
= input_line_pointer
;
6827 /* We only accept '*' as introduction of comments if preceded by white space
6828 or at first column of a line (I think this can't actually happen here?)
6829 This is important when assembling:
6830 while d0 <ne> 12(a0,d0*2) do
6831 while d0 <ne> #CONST*20 do. */
6832 while (! (is_end_of_line
[(unsigned char) *s
]
6835 && (s
== input_line_pointer
6837 || *(s
-1) == '\t'))))
6840 while (*s
== ' ' || *s
== '\t')
6842 if (s
- input_line_pointer
> 1
6845 if (s
- input_line_pointer
< 2
6846 || strncasecmp (s
- 1, "DO", 2) != 0)
6848 as_bad (_("missing do"));
6849 ignore_rest_of_line ();
6853 n
= push_mri_control (mri_while
);
6857 parse_mri_control_expression (s
- 1, qual
, (const char *) NULL
, n
->bottom
,
6858 s
[1] == '.' ? s
[2] : '\0');
6860 input_line_pointer
= s
+ 1;
6861 if (*input_line_pointer
== '.')
6862 input_line_pointer
+= 2;
6866 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6867 ++input_line_pointer
;
6870 demand_empty_rest_of_line ();
6873 /* Handle the MRI ENDW pseudo-op. */
6876 s_mri_endw (int ignore ATTRIBUTE_UNUSED
)
6880 if (mri_control_stack
== NULL
6881 || mri_control_stack
->type
!= mri_while
)
6883 as_bad (_("endw without while"));
6884 ignore_rest_of_line ();
6888 buf
= (char *) xmalloc (20 + strlen (mri_control_stack
->next
));
6889 sprintf (buf
, "bra %s", mri_control_stack
->next
);
6893 colon (mri_control_stack
->bottom
);
6899 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6900 ++input_line_pointer
;
6903 demand_empty_rest_of_line ();
6906 /* Parse a .cpu directive. */
6909 s_m68k_cpu (int ignored ATTRIBUTE_UNUSED
)
6916 as_bad (_("already assembled instructions"));
6917 ignore_rest_of_line ();
6921 name
= input_line_pointer
;
6922 while (*input_line_pointer
&& !ISSPACE(*input_line_pointer
))
6923 input_line_pointer
++;
6924 saved_char
= *input_line_pointer
;
6925 *input_line_pointer
= 0;
6927 m68k_set_cpu (name
, 1, 0);
6929 *input_line_pointer
= saved_char
;
6930 demand_empty_rest_of_line ();
6934 /* Parse a .arch directive. */
6937 s_m68k_arch (int ignored ATTRIBUTE_UNUSED
)
6944 as_bad (_("already assembled instructions"));
6945 ignore_rest_of_line ();
6949 name
= input_line_pointer
;
6950 while (*input_line_pointer
&& *input_line_pointer
!= ','
6951 && !ISSPACE (*input_line_pointer
))
6952 input_line_pointer
++;
6953 saved_char
= *input_line_pointer
;
6954 *input_line_pointer
= 0;
6956 if (m68k_set_arch (name
, 1, 0))
6958 /* Scan extensions. */
6961 *input_line_pointer
++ = saved_char
;
6962 if (!*input_line_pointer
|| ISSPACE (*input_line_pointer
))
6964 name
= input_line_pointer
;
6965 while (*input_line_pointer
&& *input_line_pointer
!= ','
6966 && !ISSPACE (*input_line_pointer
))
6967 input_line_pointer
++;
6968 saved_char
= *input_line_pointer
;
6969 *input_line_pointer
= 0;
6971 while (m68k_set_extension (name
, 1, 0));
6974 *input_line_pointer
= saved_char
;
6975 demand_empty_rest_of_line ();
6979 /* Lookup a cpu name in TABLE and return the slot found. Return NULL
6980 if none is found, the caller is responsible for emitting an error
6981 message. If ALLOW_M is non-zero, we allow an initial 'm' on the
6982 cpu name, if it begins with a '6' (possibly skipping an intervening
6983 'c'. We also allow a 'c' in the same place. if NEGATED is
6984 non-zero, we accept a leading 'no-' and *NEGATED is set to true, if
6985 the option is indeed negated. */
6987 static const struct m68k_cpu
*
6988 m68k_lookup_cpu (const char *arg
, const struct m68k_cpu
*table
,
6989 int allow_m
, int *negated
)
6991 /* allow negated value? */
6996 if (arg
[0] == 'n' && arg
[1] == 'o' && arg
[2] == '-')
7003 /* Remove 'm' or 'mc' prefix from 68k variants. */
7010 else if (arg
[1] == 'c' && arg
[2] == '6')
7014 else if (arg
[0] == 'c' && arg
[1] == '6')
7017 for (; table
->name
; table
++)
7018 if (!strcmp (arg
, table
->name
))
7020 if (table
->alias
< -1 || table
->alias
> 1)
7021 as_bad (_("`%s' is deprecated, use `%s'"),
7022 table
->name
, table
[table
->alias
< 0 ? 1 : -1].name
);
7028 /* Set the cpu, issuing errors if it is unrecognized, or invalid */
7031 m68k_set_cpu (char const *name
, int allow_m
, int silent
)
7033 const struct m68k_cpu
*cpu
;
7035 cpu
= m68k_lookup_cpu (name
, m68k_cpus
, allow_m
, NULL
);
7040 as_bad (_("cpu `%s' unrecognized"), name
);
7044 if (selected_cpu
&& selected_cpu
!= cpu
)
7046 as_bad (_("already selected `%s' processor"),
7047 selected_cpu
->name
);
7054 /* Set the architecture, issuing errors if it is unrecognized, or invalid */
7057 m68k_set_arch (char const *name
, int allow_m
, int silent
)
7059 const struct m68k_cpu
*arch
;
7061 arch
= m68k_lookup_cpu (name
, m68k_archs
, allow_m
, NULL
);
7066 as_bad (_("architecture `%s' unrecognized"), name
);
7070 if (selected_arch
&& selected_arch
!= arch
)
7072 as_bad (_("already selected `%s' architecture"),
7073 selected_arch
->name
);
7077 selected_arch
= arch
;
7081 /* Set the architecture extension, issuing errors if it is
7082 unrecognized, or invalid */
7085 m68k_set_extension (char const *name
, int allow_m
, int silent
)
7088 const struct m68k_cpu
*ext
;
7090 ext
= m68k_lookup_cpu (name
, m68k_extensions
, allow_m
, &negated
);
7095 as_bad (_("extension `%s' unrecognized"), name
);
7100 not_current_architecture
|= ext
->arch
;
7102 current_architecture
|= ext
->arch
;
7107 Invocation line includes a switch not recognized by the base assembler.
7111 const char *md_shortopts
= "lSA:m:kQ:V";
7113 const char *md_shortopts
= "lSA:m:k";
7116 struct option md_longopts
[] = {
7117 #define OPTION_PIC (OPTION_MD_BASE)
7118 {"pic", no_argument
, NULL
, OPTION_PIC
},
7119 #define OPTION_REGISTER_PREFIX_OPTIONAL (OPTION_MD_BASE + 1)
7120 {"register-prefix-optional", no_argument
, NULL
,
7121 OPTION_REGISTER_PREFIX_OPTIONAL
},
7122 #define OPTION_BITWISE_OR (OPTION_MD_BASE + 2)
7123 {"bitwise-or", no_argument
, NULL
, OPTION_BITWISE_OR
},
7124 #define OPTION_BASE_SIZE_DEFAULT_16 (OPTION_MD_BASE + 3)
7125 {"base-size-default-16", no_argument
, NULL
, OPTION_BASE_SIZE_DEFAULT_16
},
7126 #define OPTION_BASE_SIZE_DEFAULT_32 (OPTION_MD_BASE + 4)
7127 {"base-size-default-32", no_argument
, NULL
, OPTION_BASE_SIZE_DEFAULT_32
},
7128 #define OPTION_DISP_SIZE_DEFAULT_16 (OPTION_MD_BASE + 5)
7129 {"disp-size-default-16", no_argument
, NULL
, OPTION_DISP_SIZE_DEFAULT_16
},
7130 #define OPTION_DISP_SIZE_DEFAULT_32 (OPTION_MD_BASE + 6)
7131 {"disp-size-default-32", no_argument
, NULL
, OPTION_DISP_SIZE_DEFAULT_32
},
7132 #define OPTION_PCREL (OPTION_MD_BASE + 7)
7133 {"pcrel", no_argument
, NULL
, OPTION_PCREL
},
7134 {NULL
, no_argument
, NULL
, 0}
7136 size_t md_longopts_size
= sizeof (md_longopts
);
7139 md_parse_option (int c
, char *arg
)
7143 case 'l': /* -l means keep external to 2 bit offset
7144 rather than 16 bit one. */
7145 flag_short_refs
= 1;
7148 case 'S': /* -S means that jbsr's always turn into
7150 flag_long_jumps
= 1;
7153 case OPTION_PCREL
: /* --pcrel means never turn PC-relative
7154 branches into absolute jumps. */
7155 flag_keep_pcrel
= 1;
7161 break; /* -pic, Position Independent Code. */
7163 case OPTION_REGISTER_PREFIX_OPTIONAL
:
7164 flag_reg_prefix_optional
= 1;
7165 reg_prefix_optional_seen
= 1;
7168 /* -V: SVR4 argument to print version ID. */
7170 print_version_id ();
7173 /* -Qy, -Qn: SVR4 arguments controlling whether a .comment section
7174 should be emitted or not. FIXME: Not implemented. */
7178 case OPTION_BITWISE_OR
:
7183 n
= (char *) xmalloc (strlen (m68k_comment_chars
) + 1);
7185 for (s
= m68k_comment_chars
; *s
!= '\0'; s
++)
7189 m68k_comment_chars
= n
;
7193 case OPTION_BASE_SIZE_DEFAULT_16
:
7194 m68k_index_width_default
= SIZE_WORD
;
7197 case OPTION_BASE_SIZE_DEFAULT_32
:
7198 m68k_index_width_default
= SIZE_LONG
;
7201 case OPTION_DISP_SIZE_DEFAULT_16
:
7203 m68k_rel32_from_cmdline
= 1;
7206 case OPTION_DISP_SIZE_DEFAULT_32
:
7208 m68k_rel32_from_cmdline
= 1;
7213 as_tsktsk (_ ("option `-A%s' is deprecated: use `-%s'",
7216 /* Intentional fall-through. */
7218 if (!strncmp (arg
, "arch=", 5))
7219 m68k_set_arch (arg
+ 5, 1, 0);
7220 else if (!strncmp (arg
, "cpu=", 4))
7221 m68k_set_cpu (arg
+ 4, 1, 0);
7222 else if (m68k_set_extension (arg
, 0, 1))
7224 else if (m68k_set_arch (arg
, 0, 1))
7226 else if (m68k_set_cpu (arg
, 0, 1))
7239 /* Setup tables from the selected arch and/or cpu */
7242 m68k_init_arch (void)
7244 if (not_current_architecture
& current_architecture
)
7246 as_bad (_("architecture features both enabled and disabled"));
7247 not_current_architecture
&= ~current_architecture
;
7251 current_architecture
|= selected_arch
->arch
;
7252 control_regs
= selected_arch
->control_regs
;
7255 current_architecture
|= selected_cpu
->arch
;
7257 current_architecture
&= ~not_current_architecture
;
7259 if ((current_architecture
& (cfloat
| m68881
)) == (cfloat
| m68881
))
7261 /* Determine which float is really meant. */
7262 if (current_architecture
& (m68k_mask
& ~m68881
))
7263 current_architecture
^= cfloat
;
7265 current_architecture
^= m68881
;
7270 control_regs
= selected_cpu
->control_regs
;
7271 if (current_architecture
& ~selected_cpu
->arch
)
7273 as_bad (_("selected processor does not have all features of selected architecture"));
7274 current_architecture
7275 = selected_cpu
->arch
& ~not_current_architecture
;
7279 if ((current_architecture
& m68k_mask
)
7280 && (current_architecture
& ~m68k_mask
))
7282 as_bad (_ ("m68k and cf features both selected"));
7283 if (current_architecture
& m68k_mask
)
7284 current_architecture
&= m68k_mask
;
7286 current_architecture
&= ~m68k_mask
;
7289 /* Permit m68881 specification with all cpus; those that can't work
7290 with a coprocessor could be doing emulation. */
7291 if (current_architecture
& m68851
)
7293 if (current_architecture
& m68040
)
7294 as_warn (_("68040 and 68851 specified; mmu instructions may assemble incorrectly"));
7296 /* What other incompatibilities could we check for? */
7298 if (cpu_of_arch (current_architecture
) < m68020
7299 || arch_coldfire_p (current_architecture
))
7300 md_relax_table
[TAB (PCINDEX
, BYTE
)].rlx_more
= 0;
7306 md_show_usage (FILE *stream
)
7308 const char *default_cpu
= TARGET_CPU
;
7310 unsigned int default_arch
;
7312 /* Get the canonical name for the default target CPU. */
7313 if (*default_cpu
== 'm')
7315 for (i
= 0; m68k_cpus
[i
].name
; i
++)
7317 if (strcasecmp (default_cpu
, m68k_cpus
[i
].name
) == 0)
7319 default_arch
= m68k_cpus
[i
].arch
;
7320 while (m68k_cpus
[i
].alias
> 0)
7322 while (m68k_cpus
[i
].alias
< 0)
7324 default_cpu
= m68k_cpus
[i
].name
;
7328 fprintf (stream
, _("\
7329 -march=<arch> set architecture\n\
7330 -mcpu=<cpu> set cpu [default %s]\n\
7332 for (i
= 0; m68k_extensions
[i
].name
; i
++)
7333 fprintf (stream
, _("\
7334 -m[no-]%-16s enable/disable%s architecture extension\n\
7335 "), m68k_extensions
[i
].name
,
7336 m68k_extensions
[i
].alias
> 0 ? " ColdFire"
7337 : m68k_extensions
[i
].alias
< 0 ? " m68k" : "");
7339 fprintf (stream
, _("\
7340 -l use 1 word for refs to undefined symbols [default 2]\n\
7341 -pic, -k generate position independent code\n\
7342 -S turn jbsr into jsr\n\
7343 --pcrel never turn PC-relative branches into absolute jumps\n\
7344 --register-prefix-optional\n\
7345 recognize register names without prefix character\n\
7346 --bitwise-or do not treat `|' as a comment character\n\
7347 --base-size-default-16 base reg without size is 16 bits\n\
7348 --base-size-default-32 base reg without size is 32 bits (default)\n\
7349 --disp-size-default-16 displacement with unknown size is 16 bits\n\
7350 --disp-size-default-32 displacement with unknown size is 32 bits (default)\n\
7353 fprintf (stream
, _("Architecture variants are: "));
7354 for (i
= 0; m68k_archs
[i
].name
; i
++)
7357 fprintf (stream
, " | ");
7358 fprintf (stream
, m68k_archs
[i
].name
);
7360 fprintf (stream
, "\n");
7362 fprintf (stream
, _("Processor variants are: "));
7363 for (i
= 0; m68k_cpus
[i
].name
; i
++)
7366 fprintf (stream
, " | ");
7367 fprintf (stream
, m68k_cpus
[i
].name
);
7369 fprintf (stream
, _("\n"));
7374 /* TEST2: Test md_assemble() */
7375 /* Warning, this routine probably doesn't work anymore. */
7379 struct m68k_it the_ins
;
7387 if (!gets (buf
) || !*buf
)
7389 if (buf
[0] == '|' || buf
[1] == '.')
7391 for (cp
= buf
; *cp
; cp
++)
7396 memset (&the_ins
, '\0', sizeof (the_ins
));
7397 m68k_ip (&the_ins
, buf
);
7400 printf (_("Error %s in %s\n"), the_ins
.error
, buf
);
7404 printf (_("Opcode(%d.%s): "), the_ins
.numo
, the_ins
.args
);
7405 for (n
= 0; n
< the_ins
.numo
; n
++)
7406 printf (" 0x%x", the_ins
.opcode
[n
] & 0xffff);
7408 print_the_insn (&the_ins
.opcode
[0], stdout
);
7409 (void) putchar ('\n');
7411 for (n
= 0; n
< strlen (the_ins
.args
) / 2; n
++)
7413 if (the_ins
.operands
[n
].error
)
7415 printf ("op%d Error %s in %s\n", n
, the_ins
.operands
[n
].error
, buf
);
7418 printf ("mode %d, reg %d, ", the_ins
.operands
[n
].mode
,
7419 the_ins
.operands
[n
].reg
);
7420 if (the_ins
.operands
[n
].b_const
)
7421 printf ("Constant: '%.*s', ",
7422 1 + the_ins
.operands
[n
].e_const
- the_ins
.operands
[n
].b_const
,
7423 the_ins
.operands
[n
].b_const
);
7424 printf ("ireg %d, isiz %d, imul %d, ", the_ins
.operands
[n
].ireg
,
7425 the_ins
.operands
[n
].isiz
, the_ins
.operands
[n
].imul
);
7426 if (the_ins
.operands
[n
].b_iadd
)
7427 printf ("Iadd: '%.*s',",
7428 1 + the_ins
.operands
[n
].e_iadd
- the_ins
.operands
[n
].b_iadd
,
7429 the_ins
.operands
[n
].b_iadd
);
7438 is_label (char *str
)
7442 while (*str
&& *str
!= ' ')
7444 if (str
[-1] == ':' || str
[1] == '=')
7451 /* Possible states for relaxation:
7453 0 0 branch offset byte (bra, etc)
7457 1 0 indexed offsets byte a0@(32,d4:w:1) etc
7461 2 0 two-offset index word-word a0@(32,d4)@(45) etc
7468 /* We have no need to default values of symbols. */
7471 md_undefined_symbol (char *name ATTRIBUTE_UNUSED
)
7476 /* Round up a section size to the appropriate boundary. */
7478 md_section_align (segT segment ATTRIBUTE_UNUSED
, valueT size
)
7481 /* For a.out, force the section size to be aligned. If we don't do
7482 this, BFD will align it for us, but it will not write out the
7483 final bytes of the section. This may be a bug in BFD, but it is
7484 easier to fix it here since that is how the other a.out targets
7488 align
= bfd_get_section_alignment (stdoutput
, segment
);
7489 size
= ((size
+ (1 << align
) - 1) & ((valueT
) -1 << align
));
7495 /* Exactly what point is a PC-relative offset relative TO?
7496 On the 68k, it is relative to the address of the first extension
7497 word. The difference between the addresses of the offset and the
7498 first extension word is stored in fx_pcrel_adjust. */
7500 md_pcrel_from (fixS
*fixP
)
7504 /* Because fx_pcrel_adjust is a char, and may be unsigned, we explicitly
7505 sign extend the value here. */
7506 adjust
= ((fixP
->fx_pcrel_adjust
& 0xff) ^ 0x80) - 0x80;
7509 return fixP
->fx_where
+ fixP
->fx_frag
->fr_address
- adjust
;
7514 m68k_elf_final_processing (void)
7518 if (arch_coldfire_fpu (current_architecture
))
7519 flags
|= EF_M68K_CFV4E
;
7520 /* Set file-specific flags if this is a cpu32 processor. */
7521 if (cpu_of_arch (current_architecture
) & cpu32
)
7522 flags
|= EF_M68K_CPU32
;
7523 else if ((cpu_of_arch (current_architecture
) & m68000up
)
7524 && !(cpu_of_arch (current_architecture
) & m68020up
))
7525 flags
|= EF_M68K_M68000
;
7527 if (current_architecture
& mcfisa_a
)
7529 static const unsigned isa_features
[][2] =
7531 {EF_M68K_ISA_A_NODIV
, mcfisa_a
},
7532 {EF_M68K_ISA_A
, mcfisa_a
|mcfhwdiv
},
7533 {EF_M68K_ISA_A_PLUS
,mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfusp
},
7534 {EF_M68K_ISA_B_NOUSP
,mcfisa_a
|mcfisa_b
|mcfhwdiv
},
7535 {EF_M68K_ISA_B
, mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfusp
},
7538 static const unsigned mac_features
[][2] =
7540 {EF_M68K_MAC
, mcfmac
},
7541 {EF_M68K_EMAC
, mcfemac
},
7547 pattern
= (current_architecture
7548 & (mcfisa_a
|mcfisa_aa
|mcfisa_b
|mcfhwdiv
|mcfusp
));
7549 for (ix
= 0; isa_features
[ix
][1]; ix
++)
7551 if (pattern
== isa_features
[ix
][1])
7553 flags
|= isa_features
[ix
][0];
7557 if (!isa_features
[ix
][1])
7560 as_warn (_("Not a defined coldfire architecture"));
7564 if (current_architecture
& cfloat
)
7565 flags
|= EF_M68K_FLOAT
| EF_M68K_CFV4E
;
7567 pattern
= current_architecture
& (mcfmac
|mcfemac
);
7570 for (ix
= 0; mac_features
[ix
][1]; ix
++)
7572 if (pattern
== mac_features
[ix
][1])
7574 flags
|= mac_features
[ix
][0];
7578 if (!mac_features
[ix
][1])
7583 elf_elfheader (stdoutput
)->e_flags
|= flags
;
7588 tc_m68k_regname_to_dw2regnum (const char *regname
)
7590 unsigned int regnum
;
7591 static const char *const regnames
[] =
7593 "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
7594 "a0", "a1", "a2", "a3", "a4", "a5", "a6", "sp",
7595 "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7",
7599 for (regnum
= 0; regnum
< ARRAY_SIZE (regnames
); regnum
++)
7600 if (strcmp (regname
, regnames
[regnum
]) == 0)
7607 tc_m68k_frame_initial_instructions (void)
7609 static int sp_regno
= -1;
7612 sp_regno
= tc_m68k_regname_to_dw2regnum ("sp");
7614 cfi_add_CFA_def_cfa (sp_regno
, -DWARF2_CIE_DATA_ALIGNMENT
);
7615 cfi_add_CFA_offset (DWARF2_DEFAULT_RETURN_COLUMN
, DWARF2_CIE_DATA_ALIGNMENT
);