1 /* tc-m68k.c -- Assemble for the m68k family
2 Copyright 1987, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
23 #include "safe-ctype.h"
26 #include "dwarf2dbg.h"
27 #include "dw2gencfi.h"
29 #include "opcode/m68k.h"
30 #include "m68k-parse.h"
40 /* This string holds the chars that always start a comment. If the
41 pre-processor is disabled, these aren't very useful. The macro
42 tc_comment_chars points to this. We use this, rather than the
43 usual comment_chars, so that the --bitwise-or option will work. */
44 #if defined (TE_SVR4) || defined (TE_DELTA)
45 const char *m68k_comment_chars
= "|#";
47 const char *m68k_comment_chars
= "|";
50 /* This array holds the chars that only start a comment at the beginning of
51 a line. If the line seems to have the form '# 123 filename'
52 .line and .file directives will appear in the pre-processed output */
53 /* Note that input_file.c hand checks for '#' at the beginning of the
54 first line of the input file. This is because the compiler outputs
55 #NO_APP at the beginning of its output. */
56 /* Also note that comments like this one will always work. */
57 const char line_comment_chars
[] = "#*";
59 const char line_separator_chars
[] = ";";
61 /* Chars that can be used to separate mant from exp in floating point nums. */
62 const char EXP_CHARS
[] = "eE";
64 /* Chars that mean this number is a floating point constant, as
65 in "0f12.456" or "0d1.2345e12". */
67 const char FLT_CHARS
[] = "rRsSfFdDxXeEpP";
69 /* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
70 changed in read.c . Ideally it shouldn't have to know about it at all,
71 but nothing is ideal around here. */
73 /* Are we trying to generate PIC code? If so, absolute references
74 ought to be made into linkage table references or pc-relative
75 references. Not implemented. For ELF there are other means
76 to denote pic relocations. */
79 static int flag_short_refs
; /* -l option. */
80 static int flag_long_jumps
; /* -S option. */
81 static int flag_keep_pcrel
; /* --pcrel option. */
83 #ifdef REGISTER_PREFIX_OPTIONAL
84 int flag_reg_prefix_optional
= REGISTER_PREFIX_OPTIONAL
;
86 int flag_reg_prefix_optional
;
89 /* Whether --register-prefix-optional was used on the command line. */
90 static int reg_prefix_optional_seen
;
92 /* The floating point coprocessor to use by default. */
93 static enum m68k_register m68k_float_copnum
= COP1
;
95 /* If this is non-zero, then references to number(%pc) will be taken
96 to refer to number, rather than to %pc + number. */
97 static int m68k_abspcadd
;
99 /* If this is non-zero, then the quick forms of the move, add, and sub
100 instructions are used when possible. */
101 static int m68k_quick
= 1;
103 /* If this is non-zero, then if the size is not specified for a base
104 or outer displacement, the assembler assumes that the size should
106 static int m68k_rel32
= 1;
108 /* This is non-zero if m68k_rel32 was set from the command line. */
109 static int m68k_rel32_from_cmdline
;
111 /* The default width to use for an index register when using a base
113 static enum m68k_size m68k_index_width_default
= SIZE_LONG
;
115 /* We want to warn if any text labels are misaligned. In order to get
116 the right line number, we need to record the line number for each
120 struct label_line
*next
;
127 /* The list of labels. */
129 static struct label_line
*labels
;
131 /* The current label. */
133 static struct label_line
*current_label
;
135 /* Pointer to list holding the opcodes sorted by name. */
136 static struct m68k_opcode
const ** m68k_sorted_opcodes
;
138 /* Its an arbitrary name: This means I don't approve of it.
140 static struct obstack robyn
;
144 const char *m_operands
;
145 unsigned long m_opcode
;
149 struct m68k_incant
*m_next
;
152 #define getone(x) ((((x)->m_opcode)>>16)&0xffff)
153 #define gettwo(x) (((x)->m_opcode)&0xffff)
155 static const enum m68k_register m68000_ctrl
[] = { 0 };
156 static const enum m68k_register m68010_ctrl
[] = {
160 static const enum m68k_register m68020_ctrl
[] = {
161 SFC
, DFC
, USP
, VBR
, CACR
, CAAR
, MSP
, ISP
,
164 static const enum m68k_register m68040_ctrl
[] = {
165 SFC
, DFC
, CACR
, TC
, ITT0
, ITT1
, DTT0
, DTT1
,
166 USP
, VBR
, MSP
, ISP
, MMUSR
, URP
, SRP
,
169 static const enum m68k_register m68060_ctrl
[] = {
170 SFC
, DFC
, CACR
, TC
, ITT0
, ITT1
, DTT0
, DTT1
, BUSCR
,
171 USP
, VBR
, URP
, SRP
, PCR
,
174 static const enum m68k_register mcf_ctrl
[] = {
175 CACR
, TC
, ACR0
, ACR1
, ACR2
, ACR3
, VBR
, ROMBAR
,
176 RAMBAR0
, RAMBAR1
, MBAR
,
179 static const enum m68k_register mcf5208_ctrl
[] = {
180 CACR
, ACR0
, ACR1
, VBR
, RAMBAR1
,
183 static const enum m68k_register mcf5213_ctrl
[] = {
184 VBR
, RAMBAR
, FLASHBAR
,
187 static const enum m68k_register mcf5216_ctrl
[] = {
188 VBR
, CACR
, ACR0
, ACR1
, FLASHBAR
, RAMBAR
,
191 static const enum m68k_register mcf5235_ctrl
[] = {
192 VBR
, CACR
, ACR0
, ACR1
, RAMBAR
,
195 static const enum m68k_register mcf5249_ctrl
[] = {
196 VBR
, CACR
, ACR0
, ACR1
, RAMBAR0
, RAMBAR1
, MBAR
, MBAR2
,
199 static const enum m68k_register mcf5250_ctrl
[] = {
203 static const enum m68k_register mcf5271_ctrl
[] = {
204 VBR
, CACR
, ACR0
, ACR1
, RAMBAR
,
207 static const enum m68k_register mcf5272_ctrl
[] = {
208 VBR
, CACR
, ACR0
, ACR1
, ROMBAR
, RAMBAR
, MBAR
,
211 static const enum m68k_register mcf5275_ctrl
[] = {
212 VBR
, CACR
, ACR0
, ACR1
, RAMBAR
,
215 static const enum m68k_register mcf5282_ctrl
[] = {
216 VBR
, CACR
, ACR0
, ACR1
, FLASHBAR
, RAMBAR
,
219 static const enum m68k_register mcf5329_ctrl
[] = {
220 VBR
, CACR
, ACR0
, ACR1
, RAMBAR
,
223 static const enum m68k_register mcf5373_ctrl
[] = {
224 VBR
, CACR
, ACR0
, ACR1
, RAMBAR
,
227 static const enum m68k_register mcfv4e_ctrl
[] = {
228 CACR
, TC
, ITT0
, ITT1
, DTT0
, DTT1
, BUSCR
, VBR
, PC
, ROMBAR
,
229 ROMBAR1
, RAMBAR0
, RAMBAR1
, MPCR
, EDRAMBAR
, SECMBAR
, MBAR
, MBAR0
, MBAR1
,
230 PCR1U0
, PCR1L0
, PCR1U1
, PCR1L1
, PCR2U0
, PCR2L0
, PCR2U1
, PCR2L1
,
231 PCR3U0
, PCR3L0
, PCR3U1
, PCR3L1
,
234 #define cpu32_ctrl m68010_ctrl
236 static const enum m68k_register
*control_regs
;
238 /* Internal form of a 68020 instruction. */
242 const char *args
; /* List of opcode info. */
245 int numo
; /* Number of shorts in opcode. */
248 struct m68k_op operands
[6];
250 int nexp
; /* Number of exprs in use. */
251 struct m68k_exp exprs
[4];
253 int nfrag
; /* Number of frags we have to produce. */
256 int fragoff
; /* Where in the current opcode the frag ends. */
263 int nrel
; /* Num of reloc strucs in use. */
270 /* In a pc relative address the difference between the address
271 of the offset and the address that the offset is relative
272 to. This depends on the addressing mode. Basically this
273 is the value to put in the offset field to address the
274 first byte of the offset, without regarding the special
275 significance of some values (in the branch instruction, for
279 /* Whether this expression needs special pic relocation, and if
281 enum pic_relocation pic_reloc
;
284 reloc
[5]; /* Five is enough??? */
287 #define cpu_of_arch(x) ((x) & (m68000up | mcfisa_a))
288 #define float_of_arch(x) ((x) & mfloat)
289 #define mmu_of_arch(x) ((x) & mmmu)
290 #define arch_coldfire_p(x) ((x) & mcfisa_a)
291 #define arch_coldfire_fpu(x) ((x) & cfloat)
293 /* Macros for determining if cpu supports a specific addressing mode. */
294 #define HAVE_LONG_BRANCH(x) ((x) & (m68020|m68030|m68040|m68060|cpu32|mcfisa_b))
296 static struct m68k_it the_ins
; /* The instruction being assembled. */
298 #define op(ex) ((ex)->exp.X_op)
299 #define adds(ex) ((ex)->exp.X_add_symbol)
300 #define subs(ex) ((ex)->exp.X_op_symbol)
301 #define offs(ex) ((ex)->exp.X_add_number)
303 /* Macros for adding things to the m68k_it struct. */
304 #define addword(w) (the_ins.opcode[the_ins.numo++] = (w))
306 /* Like addword, but goes BEFORE general operands. */
309 insop (int w
, const struct m68k_incant
*opcode
)
312 for (z
= the_ins
.numo
; z
> opcode
->m_codenum
; --z
)
313 the_ins
.opcode
[z
] = the_ins
.opcode
[z
- 1];
314 for (z
= 0; z
< the_ins
.nrel
; z
++)
315 the_ins
.reloc
[z
].n
+= 2;
316 for (z
= 0; z
< the_ins
.nfrag
; z
++)
317 the_ins
.fragb
[z
].fragoff
++;
318 the_ins
.opcode
[opcode
->m_codenum
] = w
;
322 /* The numo+1 kludge is so we can hit the low order byte of the prev word.
325 add_fix (int width
, struct m68k_exp
*exp
, int pc_rel
, int pc_fix
)
327 the_ins
.reloc
[the_ins
.nrel
].n
= (width
== 'B' || width
== '3'
328 ? the_ins
.numo
* 2 - 1
330 ? the_ins
.numo
* 2 + 1
331 : the_ins
.numo
* 2));
332 the_ins
.reloc
[the_ins
.nrel
].exp
= exp
->exp
;
333 the_ins
.reloc
[the_ins
.nrel
].wid
= width
;
334 the_ins
.reloc
[the_ins
.nrel
].pcrel_fix
= pc_fix
;
336 the_ins
.reloc
[the_ins
.nrel
].pic_reloc
= exp
->pic_reloc
;
338 the_ins
.reloc
[the_ins
.nrel
++].pcrel
= pc_rel
;
341 /* Cause an extra frag to be generated here, inserting up to 10 bytes
342 (that value is chosen in the frag_var call in md_assemble). TYPE
343 is the subtype of the frag to be generated; its primary type is
344 rs_machine_dependent.
346 The TYPE parameter is also used by md_convert_frag_1 and
347 md_estimate_size_before_relax. The appropriate type of fixup will
348 be emitted by md_convert_frag_1.
350 ADD becomes the FR_SYMBOL field of the frag, and OFF the FR_OFFSET. */
352 add_frag (symbolS
*add
, offsetT off
, int type
)
354 the_ins
.fragb
[the_ins
.nfrag
].fragoff
= the_ins
.numo
;
355 the_ins
.fragb
[the_ins
.nfrag
].fadd
= add
;
356 the_ins
.fragb
[the_ins
.nfrag
].foff
= off
;
357 the_ins
.fragb
[the_ins
.nfrag
++].fragty
= type
;
361 (op (ex) != O_constant && op (ex) != O_big)
363 static char *crack_operand (char *str
, struct m68k_op
*opP
);
364 static int get_num (struct m68k_exp
*exp
, int ok
);
365 static int reverse_16_bits (int in
);
366 static int reverse_8_bits (int in
);
367 static void install_gen_operand (int mode
, int val
);
368 static void install_operand (int mode
, int val
);
369 static void s_bss (int);
370 static void s_data1 (int);
371 static void s_data2 (int);
372 static void s_even (int);
373 static void s_proc (int);
374 static void s_chip (int);
375 static void s_fopt (int);
376 static void s_opt (int);
377 static void s_reg (int);
378 static void s_restore (int);
379 static void s_save (int);
380 static void s_mri_if (int);
381 static void s_mri_else (int);
382 static void s_mri_endi (int);
383 static void s_mri_break (int);
384 static void s_mri_next (int);
385 static void s_mri_for (int);
386 static void s_mri_endf (int);
387 static void s_mri_repeat (int);
388 static void s_mri_until (int);
389 static void s_mri_while (int);
390 static void s_mri_endw (int);
391 static void s_m68k_cpu (int);
392 static void s_m68k_arch (int);
396 unsigned long arch
; /* Architecture features. */
397 const enum m68k_register
*control_regs
; /* Control regs on chip */
398 const char *name
; /* Name */
399 int alias
; /* Alias for a cannonical name. If 1, then
400 succeeds canonical name, if -1 then
401 succeeds canonical name, if <-1 ||>1 this is a
402 deprecated name, and the next/previous name
406 /* We hold flags for features explicitly enabled and explicitly
408 static int current_architecture
;
409 static int not_current_architecture
;
410 static const struct m68k_cpu
*selected_arch
;
411 static const struct m68k_cpu
*selected_cpu
;
412 static int initialized
;
414 /* Architecture models. */
415 static const struct m68k_cpu m68k_archs
[] =
417 {m68000
, m68000_ctrl
, "68000", 0},
418 {m68010
, m68010_ctrl
, "68010", 0},
419 {m68020
|m68881
|m68851
, m68020_ctrl
, "68020", 0},
420 {m68030
|m68881
|m68851
, m68020_ctrl
, "68030", 0},
421 {m68040
, m68040_ctrl
, "68040", 0},
422 {m68060
, m68060_ctrl
, "68060", 0},
423 {cpu32
|m68881
, cpu32_ctrl
, "cpu32", 0},
424 {mcfisa_a
|mcfhwdiv
, NULL
, "isaa", 0},
425 {mcfisa_a
|mcfhwdiv
|mcfisa_aa
|mcfusp
, NULL
, "isaaplus", 0},
426 {mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfusp
, NULL
, "isab", 0},
427 {mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfmac
|mcfusp
, mcf_ctrl
, "cfv4", 0},
428 {mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "cfv4e", 0},
432 /* Architecture extensions, here 'alias' -1 for m68k, +1 for cf and 0
434 static const struct m68k_cpu m68k_extensions
[] =
436 {m68851
, NULL
, "68851", -1},
437 {m68881
, NULL
, "68881", -1},
438 {m68881
, NULL
, "68882", -1},
440 {cfloat
|m68881
, NULL
, "float", 0},
442 {mcfhwdiv
, NULL
, "div", 1},
443 {mcfusp
, NULL
, "usp", 1},
444 {mcfmac
, NULL
, "mac", 1},
445 {mcfemac
, NULL
, "emac", 1},
451 static const struct m68k_cpu m68k_cpus
[] =
453 {m68000
, m68000_ctrl
, "68000", 0},
454 {m68000
, m68000_ctrl
, "68ec000", 1},
455 {m68000
, m68000_ctrl
, "68hc000", 1},
456 {m68000
, m68000_ctrl
, "68hc001", 1},
457 {m68000
, m68000_ctrl
, "68008", 1},
458 {m68000
, m68000_ctrl
, "68302", 1},
459 {m68000
, m68000_ctrl
, "68306", 1},
460 {m68000
, m68000_ctrl
, "68307", 1},
461 {m68000
, m68000_ctrl
, "68322", 1},
462 {m68000
, m68000_ctrl
, "68356", 1},
463 {m68010
, m68010_ctrl
, "68010", 0},
464 {m68020
|m68881
|m68851
, m68020_ctrl
, "68020", 0},
465 {m68020
|m68881
|m68851
, m68020_ctrl
, "68k", 1},
466 {m68020
|m68881
|m68851
, m68020_ctrl
, "68ec020", 1},
467 {m68030
|m68881
|m68851
, m68020_ctrl
, "68030", 0},
468 {m68030
|m68881
|m68851
, m68020_ctrl
, "68ec030", 1},
469 {m68040
, m68040_ctrl
, "68040", 0},
470 {m68040
, m68040_ctrl
, "68ec040", 1},
471 {m68060
, m68060_ctrl
, "68060", 0},
472 {m68060
, m68060_ctrl
, "68ec060", 1},
474 {cpu32
|m68881
, cpu32_ctrl
, "cpu32", 0},
475 {cpu32
|m68881
, cpu32_ctrl
, "68330", 1},
476 {cpu32
|m68881
, cpu32_ctrl
, "68331", 1},
477 {cpu32
|m68881
, cpu32_ctrl
, "68332", 1},
478 {cpu32
|m68881
, cpu32_ctrl
, "68333", 1},
479 {cpu32
|m68881
, cpu32_ctrl
, "68334", 1},
480 {cpu32
|m68881
, cpu32_ctrl
, "68336", 1},
481 {cpu32
|m68881
, cpu32_ctrl
, "68340", 1},
482 {cpu32
|m68881
, cpu32_ctrl
, "68341", 1},
483 {cpu32
|m68881
, cpu32_ctrl
, "68349", 1},
484 {cpu32
|m68881
, cpu32_ctrl
, "68360", 1},
486 {mcfisa_a
, mcf_ctrl
, "5200", 0},
487 {mcfisa_a
, mcf_ctrl
, "5202", 1},
488 {mcfisa_a
, mcf_ctrl
, "5204", 1},
489 {mcfisa_a
, mcf_ctrl
, "5206", 1},
491 {mcfisa_a
|mcfhwdiv
|mcfmac
, mcf_ctrl
, "5206e", 0},
493 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5208_ctrl
, "5207", -1},
494 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5208_ctrl
, "5208", 0},
496 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfmac
|mcfusp
, mcf5213_ctrl
, "5211", -1},
497 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfmac
|mcfusp
, mcf5213_ctrl
, "5212", -1},
498 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfmac
|mcfusp
, mcf5213_ctrl
, "5213", 0},
500 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5216_ctrl
, "5214", -1},
501 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5216_ctrl
, "5216", 0},
502 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5216_ctrl
, "521x", 2},
504 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5235_ctrl
, "5232", -1},
505 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5235_ctrl
, "5233", -1},
506 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5235_ctrl
, "5234", -1},
507 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5235_ctrl
, "5235", -1},
508 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5235_ctrl
, "523x", 0},
510 {mcfisa_a
|mcfhwdiv
|mcfemac
, mcf5249_ctrl
, "5249", 0},
511 {mcfisa_a
|mcfhwdiv
|mcfemac
, mcf5250_ctrl
, "5250", 0},
513 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5271_ctrl
, "5270", -1},
514 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5271_ctrl
, "5271", 0},
516 {mcfisa_a
|mcfhwdiv
|mcfmac
, mcf5272_ctrl
, "5272", 0},
518 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5275_ctrl
, "5274", -1},
519 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5275_ctrl
, "5275", 0},
521 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5282_ctrl
, "5280", -1},
522 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5282_ctrl
, "5281", -1},
523 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5282_ctrl
, "5282", -1},
524 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5282_ctrl
, "528x", 0},
526 {mcfisa_a
|mcfhwdiv
|mcfmac
, mcf_ctrl
, "5307", 0},
528 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5329_ctrl
, "5327", -1},
529 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5329_ctrl
, "5328", -1},
530 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5329_ctrl
, "5329", -1},
531 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5329_ctrl
, "532x", 0},
533 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5373_ctrl
, "5372", -1},
534 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5373_ctrl
, "5373", -1},
535 {mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, mcf5373_ctrl
, "537x", 0},
537 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfmac
, mcf_ctrl
, "5407",0},
539 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5470", -1},
540 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5471", -1},
541 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5472", -1},
542 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5473", -1},
543 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5474", -1},
544 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5475", -1},
545 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "547x", 0},
547 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5480", -1},
548 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5481", -1},
549 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5482", -1},
550 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5483", -1},
551 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5484", -1},
552 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "5485", -1},
553 {mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfemac
|mcfusp
|cfloat
, mcfv4e_ctrl
, "548x", 0},
558 static const struct m68k_cpu
*m68k_lookup_cpu
559 (const char *, const struct m68k_cpu
*, int, int *);
560 static int m68k_set_arch (const char *, int, int);
561 static int m68k_set_cpu (const char *, int, int);
562 static int m68k_set_extension (const char *, int, int);
563 static void m68k_init_arch (void);
565 /* This is the assembler relaxation table for m68k. m68k is a rich CISC
566 architecture and we have a lot of relaxation modes. */
568 /* Macros used in the relaxation code. */
569 #define TAB(x,y) (((x) << 2) + (y))
570 #define TABTYPE(x) ((x) >> 2)
572 /* Relaxation states. */
578 /* Here are all the relaxation modes we support. First we can relax ordinary
579 branches. On 68020 and higher and on CPU32 all branch instructions take
580 three forms, so on these CPUs all branches always remain as such. When we
581 have to expand to the LONG form on a 68000, though, we substitute an
582 absolute jump instead. This is a direct replacement for unconditional
583 branches and a branch over a jump for conditional branches. However, if the
584 user requires PIC and disables this with --pcrel, we can only relax between
585 BYTE and SHORT forms, punting if that isn't enough. This gives us four
586 different relaxation modes for branches: */
588 #define BRANCHBWL 0 /* Branch byte, word, or long. */
589 #define BRABSJUNC 1 /* Absolute jump for LONG, unconditional. */
590 #define BRABSJCOND 2 /* Absolute jump for LONG, conditional. */
591 #define BRANCHBW 3 /* Branch byte or word. */
593 /* We also relax coprocessor branches and DBcc's. All CPUs that support
594 coprocessor branches support them in word and long forms, so we have only
595 one relaxation mode for them. DBcc's are word only on all CPUs. We can
596 relax them to the LONG form with a branch-around sequence. This sequence
597 can use a long branch (if available) or an absolute jump (if acceptable).
598 This gives us two relaxation modes. If long branches are not available and
599 absolute jumps are not acceptable, we don't relax DBcc's. */
601 #define FBRANCH 4 /* Coprocessor branch. */
602 #define DBCCLBR 5 /* DBcc relaxable with a long branch. */
603 #define DBCCABSJ 6 /* DBcc relaxable with an absolute jump. */
605 /* That's all for instruction relaxation. However, we also relax PC-relative
606 operands. Specifically, we have three operand relaxation modes. On the
607 68000 PC-relative operands can only be 16-bit, but on 68020 and higher and
608 on CPU32 they may be 16-bit or 32-bit. For the latter we relax between the
609 two. Also PC+displacement+index operands in their simple form (with a non-
610 suppressed index without memory indirection) are supported on all CPUs, but
611 on the 68000 the displacement can be 8-bit only, whereas on 68020 and higher
612 and on CPU32 we relax it to SHORT and LONG forms as well using the extended
613 form of the PC+displacement+index operand. Finally, some absolute operands
614 can be relaxed down to 16-bit PC-relative. */
616 #define PCREL1632 7 /* 16-bit or 32-bit PC-relative. */
617 #define PCINDEX 8 /* PC + displacement + index. */
618 #define ABSTOPCREL 9 /* Absolute relax down to 16-bit PC-relative. */
620 /* Note that calls to frag_var need to specify the maximum expansion
621 needed; this is currently 10 bytes for DBCC. */
624 How far Forward this mode will reach:
625 How far Backward this mode will reach:
626 How many bytes this mode will add to the size of the frag
627 Which mode to go to if the offset won't fit in this one
629 Please check tc-m68k.h:md_prepare_relax_scan if changing this table. */
630 relax_typeS md_relax_table
[] =
632 { 127, -128, 0, TAB (BRANCHBWL
, SHORT
) },
633 { 32767, -32768, 2, TAB (BRANCHBWL
, LONG
) },
637 { 127, -128, 0, TAB (BRABSJUNC
, SHORT
) },
638 { 32767, -32768, 2, TAB (BRABSJUNC
, LONG
) },
642 { 127, -128, 0, TAB (BRABSJCOND
, SHORT
) },
643 { 32767, -32768, 2, TAB (BRABSJCOND
, LONG
) },
647 { 127, -128, 0, TAB (BRANCHBW
, SHORT
) },
652 { 1, 1, 0, 0 }, /* FBRANCH doesn't come BYTE. */
653 { 32767, -32768, 2, TAB (FBRANCH
, LONG
) },
657 { 1, 1, 0, 0 }, /* DBCC doesn't come BYTE. */
658 { 32767, -32768, 2, TAB (DBCCLBR
, LONG
) },
662 { 1, 1, 0, 0 }, /* DBCC doesn't come BYTE. */
663 { 32767, -32768, 2, TAB (DBCCABSJ
, LONG
) },
667 { 1, 1, 0, 0 }, /* PCREL1632 doesn't come BYTE. */
668 { 32767, -32768, 2, TAB (PCREL1632
, LONG
) },
672 { 125, -130, 0, TAB (PCINDEX
, SHORT
) },
673 { 32765, -32770, 2, TAB (PCINDEX
, LONG
) },
677 { 1, 1, 0, 0 }, /* ABSTOPCREL doesn't come BYTE. */
678 { 32767, -32768, 2, TAB (ABSTOPCREL
, LONG
) },
683 /* These are the machine dependent pseudo-ops. These are included so
684 the assembler can work on the output from the SUN C compiler, which
687 /* This table describes all the machine specific pseudo-ops the assembler
688 has to support. The fields are:
689 pseudo-op name without dot
690 function to call to execute this pseudo-op
691 Integer arg to pass to the function. */
692 const pseudo_typeS md_pseudo_table
[] =
694 {"data1", s_data1
, 0},
695 {"data2", s_data2
, 0},
698 {"skip", s_space
, 0},
700 #if defined (TE_SUN3) || defined (OBJ_ELF)
701 {"align", s_align_bytes
, 0},
704 {"swbeg", s_ignore
, 0},
706 {"extend", float_cons
, 'x'},
707 {"ldouble", float_cons
, 'x'},
709 {"arch", s_m68k_arch
, 0},
710 {"cpu", s_m68k_cpu
, 0},
712 /* The following pseudo-ops are supported for MRI compatibility. */
714 {"comline", s_space
, 1},
716 {"mask2", s_ignore
, 0},
719 {"restore", s_restore
, 0},
723 {"if.b", s_mri_if
, 'b'},
724 {"if.w", s_mri_if
, 'w'},
725 {"if.l", s_mri_if
, 'l'},
726 {"else", s_mri_else
, 0},
727 {"else.s", s_mri_else
, 's'},
728 {"else.l", s_mri_else
, 'l'},
729 {"endi", s_mri_endi
, 0},
730 {"break", s_mri_break
, 0},
731 {"break.s", s_mri_break
, 's'},
732 {"break.l", s_mri_break
, 'l'},
733 {"next", s_mri_next
, 0},
734 {"next.s", s_mri_next
, 's'},
735 {"next.l", s_mri_next
, 'l'},
736 {"for", s_mri_for
, 0},
737 {"for.b", s_mri_for
, 'b'},
738 {"for.w", s_mri_for
, 'w'},
739 {"for.l", s_mri_for
, 'l'},
740 {"endf", s_mri_endf
, 0},
741 {"repeat", s_mri_repeat
, 0},
742 {"until", s_mri_until
, 0},
743 {"until.b", s_mri_until
, 'b'},
744 {"until.w", s_mri_until
, 'w'},
745 {"until.l", s_mri_until
, 'l'},
746 {"while", s_mri_while
, 0},
747 {"while.b", s_mri_while
, 'b'},
748 {"while.w", s_mri_while
, 'w'},
749 {"while.l", s_mri_while
, 'l'},
750 {"endw", s_mri_endw
, 0},
755 /* The mote pseudo ops are put into the opcode table, since they
756 don't start with a . they look like opcodes to gas. */
758 const pseudo_typeS mote_pseudo_table
[] =
771 {"xdef", s_globl
, 0},
773 {"align", s_align_bytes
, 0},
775 {"align", s_align_ptwo
, 0},
778 {"sect", obj_coff_section
, 0},
779 {"section", obj_coff_section
, 0},
784 /* Truncate and sign-extend at 32 bits, so that building on a 64-bit host
785 gives identical results to a 32-bit host. */
786 #define TRUNC(X) ((valueT) (X) & 0xffffffff)
787 #define SEXT(X) ((TRUNC (X) ^ 0x80000000) - 0x80000000)
789 #define issbyte(x) ((valueT) SEXT (x) + 0x80 < 0x100)
790 #define isubyte(x) ((valueT) TRUNC (x) < 0x100)
791 #define issword(x) ((valueT) SEXT (x) + 0x8000 < 0x10000)
792 #define isuword(x) ((valueT) TRUNC (x) < 0x10000)
794 #define isbyte(x) ((valueT) SEXT (x) + 0xff < 0x1ff)
795 #define isword(x) ((valueT) SEXT (x) + 0xffff < 0x1ffff)
796 #define islong(x) (1)
798 static char notend_table
[256];
799 static char alt_notend_table
[256];
801 (! (notend_table[(unsigned char) *s] \
803 && alt_notend_table[(unsigned char) s[1]])))
807 /* Return zero if the reference to SYMBOL from within the same segment may
810 /* On an ELF system, we can't relax an externally visible symbol,
811 because it may be overridden by a shared library. However, if
812 TARGET_OS is "elf", then we presume that we are assembling for an
813 embedded system, in which case we don't have to worry about shared
814 libraries, and we can relax any external sym. */
816 #define relaxable_symbol(symbol) \
817 (!((S_IS_EXTERNAL (symbol) && EXTERN_FORCE_RELOC) \
818 || S_IS_WEAK (symbol)))
820 /* Compute the relocation code for a fixup of SIZE bytes, using pc
821 relative relocation if PCREL is non-zero. PIC says whether a special
822 pic relocation was requested. */
824 static bfd_reloc_code_real_type
825 get_reloc_code (int size
, int pcrel
, enum pic_relocation pic
)
833 return BFD_RELOC_8_GOT_PCREL
;
835 return BFD_RELOC_16_GOT_PCREL
;
837 return BFD_RELOC_32_GOT_PCREL
;
845 return BFD_RELOC_8_GOTOFF
;
847 return BFD_RELOC_16_GOTOFF
;
849 return BFD_RELOC_32_GOTOFF
;
857 return BFD_RELOC_8_PLT_PCREL
;
859 return BFD_RELOC_16_PLT_PCREL
;
861 return BFD_RELOC_32_PLT_PCREL
;
869 return BFD_RELOC_8_PLTOFF
;
871 return BFD_RELOC_16_PLTOFF
;
873 return BFD_RELOC_32_PLTOFF
;
883 return BFD_RELOC_8_PCREL
;
885 return BFD_RELOC_16_PCREL
;
887 return BFD_RELOC_32_PCREL
;
907 as_bad (_("Can not do %d byte pc-relative relocation"), size
);
909 as_bad (_("Can not do %d byte pc-relative pic relocation"), size
);
914 as_bad (_("Can not do %d byte relocation"), size
);
916 as_bad (_("Can not do %d byte pic relocation"), size
);
919 return BFD_RELOC_NONE
;
922 /* Here we decide which fixups can be adjusted to make them relative
923 to the beginning of the section instead of the symbol. Basically
924 we need to make sure that the dynamic relocations are done
925 correctly, so in some cases we force the original symbol to be
928 tc_m68k_fix_adjustable (fixS
*fixP
)
930 /* Adjust_reloc_syms doesn't know about the GOT. */
931 switch (fixP
->fx_r_type
)
933 case BFD_RELOC_8_GOT_PCREL
:
934 case BFD_RELOC_16_GOT_PCREL
:
935 case BFD_RELOC_32_GOT_PCREL
:
936 case BFD_RELOC_8_GOTOFF
:
937 case BFD_RELOC_16_GOTOFF
:
938 case BFD_RELOC_32_GOTOFF
:
939 case BFD_RELOC_8_PLT_PCREL
:
940 case BFD_RELOC_16_PLT_PCREL
:
941 case BFD_RELOC_32_PLT_PCREL
:
942 case BFD_RELOC_8_PLTOFF
:
943 case BFD_RELOC_16_PLTOFF
:
944 case BFD_RELOC_32_PLTOFF
:
947 case BFD_RELOC_VTABLE_INHERIT
:
948 case BFD_RELOC_VTABLE_ENTRY
:
958 #define get_reloc_code(SIZE,PCREL,OTHER) NO_RELOC
960 #define relaxable_symbol(symbol) 1
965 tc_gen_reloc (asection
*section ATTRIBUTE_UNUSED
, fixS
*fixp
)
968 bfd_reloc_code_real_type code
;
970 /* If the tcbit is set, then this was a fixup of a negative value
971 that was never resolved. We do not have a reloc to handle this,
972 so just return. We assume that other code will have detected this
973 situation and produced a helpful error message, so we just tell the
974 user that the reloc cannot be produced. */
978 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
979 _("Unable to produce reloc against symbol '%s'"),
980 S_GET_NAME (fixp
->fx_addsy
));
984 if (fixp
->fx_r_type
!= BFD_RELOC_NONE
)
986 code
= fixp
->fx_r_type
;
988 /* Since DIFF_EXPR_OK is defined in tc-m68k.h, it is possible
989 that fixup_segment converted a non-PC relative reloc into a
990 PC relative reloc. In such a case, we need to convert the
997 code
= BFD_RELOC_8_PCREL
;
1000 code
= BFD_RELOC_16_PCREL
;
1003 code
= BFD_RELOC_32_PCREL
;
1005 case BFD_RELOC_8_PCREL
:
1006 case BFD_RELOC_16_PCREL
:
1007 case BFD_RELOC_32_PCREL
:
1008 case BFD_RELOC_8_GOT_PCREL
:
1009 case BFD_RELOC_16_GOT_PCREL
:
1010 case BFD_RELOC_32_GOT_PCREL
:
1011 case BFD_RELOC_8_GOTOFF
:
1012 case BFD_RELOC_16_GOTOFF
:
1013 case BFD_RELOC_32_GOTOFF
:
1014 case BFD_RELOC_8_PLT_PCREL
:
1015 case BFD_RELOC_16_PLT_PCREL
:
1016 case BFD_RELOC_32_PLT_PCREL
:
1017 case BFD_RELOC_8_PLTOFF
:
1018 case BFD_RELOC_16_PLTOFF
:
1019 case BFD_RELOC_32_PLTOFF
:
1022 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1023 _("Cannot make %s relocation PC relative"),
1024 bfd_get_reloc_code_name (code
));
1030 #define F(SZ,PCREL) (((SZ) << 1) + (PCREL))
1031 switch (F (fixp
->fx_size
, fixp
->fx_pcrel
))
1033 #define MAP(SZ,PCREL,TYPE) case F(SZ,PCREL): code = (TYPE); break
1034 MAP (1, 0, BFD_RELOC_8
);
1035 MAP (2, 0, BFD_RELOC_16
);
1036 MAP (4, 0, BFD_RELOC_32
);
1037 MAP (1, 1, BFD_RELOC_8_PCREL
);
1038 MAP (2, 1, BFD_RELOC_16_PCREL
);
1039 MAP (4, 1, BFD_RELOC_32_PCREL
);
1047 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
1048 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
1049 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
1050 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
1053 reloc
->addend
= fixp
->fx_addnumber
;
1057 if (!fixp
->fx_pcrel
)
1058 reloc
->addend
= fixp
->fx_addnumber
;
1060 reloc
->addend
= (section
->vma
1061 /* Explicit sign extension in case char is
1063 + ((fixp
->fx_pcrel_adjust
& 0xff) ^ 0x80) - 0x80
1064 + fixp
->fx_addnumber
1065 + md_pcrel_from (fixp
));
1068 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
1069 assert (reloc
->howto
!= 0);
1074 /* Handle of the OPCODE hash table. NULL means any use before
1075 m68k_ip_begin() will crash. */
1076 static struct hash_control
*op_hash
;
1078 /* Assemble an m68k instruction. */
1081 m68k_ip (char *instring
)
1084 register struct m68k_op
*opP
;
1085 register const struct m68k_incant
*opcode
;
1086 register const char *s
;
1087 register int tmpreg
= 0, baseo
= 0, outro
= 0, nextword
;
1088 char *pdot
, *pdotmove
;
1089 enum m68k_size siz1
, siz2
;
1093 struct m68k_op operands_backup
[6];
1094 LITTLENUM_TYPE words
[6];
1095 LITTLENUM_TYPE
*wordp
;
1096 unsigned long ok_arch
= 0;
1098 if (*instring
== ' ')
1099 instring
++; /* Skip leading whitespace. */
1101 /* Scan up to end of operation-code, which MUST end in end-of-string
1102 or exactly 1 space. */
1104 for (p
= instring
; *p
!= '\0'; p
++)
1114 the_ins
.error
= _("No operator");
1118 /* p now points to the end of the opcode name, probably whitespace.
1119 Make sure the name is null terminated by clobbering the
1120 whitespace, look it up in the hash table, then fix it back.
1121 Remove a dot, first, since the opcode tables have none. */
1124 for (pdotmove
= pdot
; pdotmove
< p
; pdotmove
++)
1125 *pdotmove
= pdotmove
[1];
1131 opcode
= (const struct m68k_incant
*) hash_find (op_hash
, instring
);
1136 for (pdotmove
= p
; pdotmove
> pdot
; pdotmove
--)
1137 *pdotmove
= pdotmove
[-1];
1144 the_ins
.error
= _("Unknown operator");
1148 /* Found a legitimate opcode, start matching operands. */
1152 if (opcode
->m_operands
== 0)
1154 char *old
= input_line_pointer
;
1156 input_line_pointer
= p
;
1157 /* Ahh - it's a motorola style psuedo op. */
1158 mote_pseudo_table
[opcode
->m_opnum
].poc_handler
1159 (mote_pseudo_table
[opcode
->m_opnum
].poc_val
);
1160 input_line_pointer
= old
;
1166 if (flag_mri
&& opcode
->m_opnum
== 0)
1168 /* In MRI mode, random garbage is allowed after an instruction
1169 which accepts no operands. */
1170 the_ins
.args
= opcode
->m_operands
;
1171 the_ins
.numargs
= opcode
->m_opnum
;
1172 the_ins
.numo
= opcode
->m_codenum
;
1173 the_ins
.opcode
[0] = getone (opcode
);
1174 the_ins
.opcode
[1] = gettwo (opcode
);
1178 for (opP
= &the_ins
.operands
[0]; *p
; opP
++)
1180 p
= crack_operand (p
, opP
);
1184 the_ins
.error
= opP
->error
;
1189 opsfound
= opP
- &the_ins
.operands
[0];
1191 /* This ugly hack is to support the floating pt opcodes in their
1192 standard form. Essentially, we fake a first enty of type COP#1 */
1193 if (opcode
->m_operands
[0] == 'I')
1197 for (n
= opsfound
; n
> 0; --n
)
1198 the_ins
.operands
[n
] = the_ins
.operands
[n
- 1];
1200 memset (&the_ins
.operands
[0], '\0', sizeof (the_ins
.operands
[0]));
1201 the_ins
.operands
[0].mode
= CONTROL
;
1202 the_ins
.operands
[0].reg
= m68k_float_copnum
;
1206 /* We've got the operands. Find an opcode that'll accept them. */
1209 /* If we didn't get the right number of ops, or we have no
1210 common model with this pattern then reject this pattern. */
1212 ok_arch
|= opcode
->m_arch
;
1213 if (opsfound
!= opcode
->m_opnum
1214 || ((opcode
->m_arch
& current_architecture
) == 0))
1220 /* Make a copy of the operands of this insn so that
1221 we can modify them safely, should we want to. */
1222 assert (opsfound
<= (int) ARRAY_SIZE (operands_backup
));
1223 for (i
= 0; i
< opsfound
; i
++)
1224 operands_backup
[i
] = the_ins
.operands
[i
];
1226 for (s
= opcode
->m_operands
, opP
= &operands_backup
[0];
1230 /* Warning: this switch is huge! */
1231 /* I've tried to organize the cases into this order:
1232 non-alpha first, then alpha by letter. Lower-case
1233 goes directly before uppercase counterpart. */
1234 /* Code with multiple case ...: gets sorted by the lowest
1235 case ... it belongs to. I hope this makes sense. */
1341 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
1358 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
1377 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
1387 if (opP
->mode
!= IMMED
)
1389 else if (s
[1] == 'b'
1390 && ! isvar (&opP
->disp
)
1391 && (opP
->disp
.exp
.X_op
!= O_constant
1392 || ! isbyte (opP
->disp
.exp
.X_add_number
)))
1394 else if (s
[1] == 'B'
1395 && ! isvar (&opP
->disp
)
1396 && (opP
->disp
.exp
.X_op
!= O_constant
1397 || ! issbyte (opP
->disp
.exp
.X_add_number
)))
1399 else if (s
[1] == 'w'
1400 && ! isvar (&opP
->disp
)
1401 && (opP
->disp
.exp
.X_op
!= O_constant
1402 || ! isword (opP
->disp
.exp
.X_add_number
)))
1404 else if (s
[1] == 'W'
1405 && ! isvar (&opP
->disp
)
1406 && (opP
->disp
.exp
.X_op
!= O_constant
1407 || ! issword (opP
->disp
.exp
.X_add_number
)))
1413 if (opP
->mode
!= IMMED
)
1418 if (opP
->mode
== AREG
1419 || opP
->mode
== CONTROL
1420 || opP
->mode
== FPREG
1421 || opP
->mode
== IMMED
1422 || opP
->mode
== REGLST
1423 || (opP
->mode
!= ABSL
1425 || opP
->reg
== ZPC
)))
1430 if (opP
->mode
== CONTROL
1431 || opP
->mode
== FPREG
1432 || opP
->mode
== REGLST
1433 || opP
->mode
== IMMED
1434 || (opP
->mode
!= ABSL
1436 || opP
->reg
== ZPC
)))
1464 if (opP
->mode
== CONTROL
1465 || opP
->mode
== FPREG
1466 || opP
->mode
== REGLST
)
1471 if (opP
->mode
!= AINC
)
1476 if (opP
->mode
!= ADEC
)
1526 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
1547 case '~': /* For now! (JF FOO is this right?) */
1569 if (opP
->mode
!= CONTROL
1570 || (opP
->reg
!= TT0
&& opP
->reg
!= TT1
))
1575 if (opP
->mode
!= AREG
)
1580 if (opP
->mode
!= AINDR
)
1585 if (opP
->mode
!= AINDR
&& opP
->mode
!= AINC
&& opP
->mode
!= ADEC
1586 && (opP
->mode
!= DISP
1588 || opP
->reg
> ADDR7
))
1593 if (opP
->mode
!= ABSL
1595 && strncmp (instring
, "jbsr", 4) == 0))
1618 if (opP
->mode
!= CONTROL
|| opP
->reg
!= CCR
)
1623 if (opP
->mode
!= DISP
1625 || opP
->reg
> ADDR7
)
1630 if (opP
->mode
!= DREG
)
1635 if (opP
->reg
!= ACC
)
1640 if (opP
->reg
!= ACC
&& opP
->reg
!= ACC1
1641 && opP
->reg
!= ACC2
&& opP
->reg
!= ACC3
)
1646 if (opP
->mode
!= FPREG
)
1651 if (opP
->reg
!= MACSR
)
1656 if (opP
->reg
!= ACCEXT01
&& opP
->reg
!= ACCEXT23
)
1661 if (opP
->reg
!= MASK
)
1666 if (opP
->mode
!= CONTROL
1673 if (opP
->mode
!= LSH
&& opP
->mode
!= RSH
)
1678 if (opP
->mode
!= CONTROL
1680 || opP
->reg
> last_movec_reg
1685 const enum m68k_register
*rp
;
1687 for (rp
= control_regs
; *rp
; rp
++)
1688 if (*rp
== opP
->reg
)
1696 if (opP
->mode
!= IMMED
)
1702 if (opP
->mode
== DREG
1703 || opP
->mode
== AREG
1704 || opP
->mode
== FPREG
)
1713 opP
->mask
= 1 << (opP
->reg
- DATA0
);
1716 opP
->mask
= 1 << (opP
->reg
- ADDR0
+ 8);
1719 opP
->mask
= 1 << (opP
->reg
- FP0
+ 16);
1727 else if (opP
->mode
== CONTROL
)
1736 opP
->mask
= 1 << 24;
1739 opP
->mask
= 1 << 25;
1742 opP
->mask
= 1 << 26;
1751 else if (opP
->mode
!= REGLST
)
1753 else if (s
[1] == '8' && (opP
->mask
& 0x0ffffff) != 0)
1755 else if (s
[1] == '3' && (opP
->mask
& 0x7000000) != 0)
1760 if (opP
->mode
!= IMMED
)
1762 else if (opP
->disp
.exp
.X_op
!= O_constant
1763 || ! issbyte (opP
->disp
.exp
.X_add_number
))
1765 else if (! m68k_quick
1766 && instring
[3] != 'q'
1767 && instring
[4] != 'q')
1772 if (opP
->mode
!= DREG
1773 && opP
->mode
!= IMMED
1774 && opP
->mode
!= ABSL
)
1779 if (opP
->mode
!= IMMED
)
1781 else if (opP
->disp
.exp
.X_op
!= O_constant
1782 || TRUNC (opP
->disp
.exp
.X_add_number
) - 1 > 7)
1784 else if (! m68k_quick
1785 && (strncmp (instring
, "add", 3) == 0
1786 || strncmp (instring
, "sub", 3) == 0)
1787 && instring
[3] != 'q')
1792 if (opP
->mode
!= DREG
&& opP
->mode
!= AREG
)
1797 if (opP
->mode
!= AINDR
1798 && (opP
->mode
!= BASE
1800 && opP
->reg
!= ZADDR0
)
1801 || opP
->disp
.exp
.X_op
!= O_absent
1802 || ((opP
->index
.reg
< DATA0
1803 || opP
->index
.reg
> DATA7
)
1804 && (opP
->index
.reg
< ADDR0
1805 || opP
->index
.reg
> ADDR7
))
1806 || opP
->index
.size
!= SIZE_UNSPEC
1807 || opP
->index
.scale
!= 1))
1812 if (opP
->mode
!= CONTROL
1813 || ! (opP
->reg
== FPI
1815 || opP
->reg
== FPC
))
1820 if (opP
->mode
!= CONTROL
|| opP
->reg
!= SR
)
1825 if (opP
->mode
!= IMMED
)
1827 else if (opP
->disp
.exp
.X_op
!= O_constant
1828 || TRUNC (opP
->disp
.exp
.X_add_number
) > 7)
1833 if (opP
->mode
!= CONTROL
|| opP
->reg
!= USP
)
1838 if (opP
->mode
!= IMMED
)
1840 else if (opP
->disp
.exp
.X_op
!= O_constant
1841 || (TRUNC (opP
->disp
.exp
.X_add_number
) != 0xffffffff
1842 && TRUNC (opP
->disp
.exp
.X_add_number
) - 1 > 6))
1846 /* JF these are out of order. We could put them
1847 in order if we were willing to put up with
1848 bunches of #ifdef m68851s in the code.
1850 Don't forget that you need these operands
1851 to use 68030 MMU instructions. */
1853 /* Memory addressing mode used by pflushr. */
1855 if (opP
->mode
== CONTROL
1856 || opP
->mode
== FPREG
1857 || opP
->mode
== DREG
1858 || opP
->mode
== AREG
1859 || opP
->mode
== REGLST
)
1861 /* We should accept immediate operands, but they
1862 supposedly have to be quad word, and we don't
1863 handle that. I would like to see what a Motorola
1864 assembler does before doing something here. */
1865 if (opP
->mode
== IMMED
)
1870 if (opP
->mode
!= CONTROL
1871 || (opP
->reg
!= SFC
&& opP
->reg
!= DFC
))
1876 if (opP
->mode
!= CONTROL
|| opP
->reg
!= TC
)
1881 if (opP
->mode
!= CONTROL
|| opP
->reg
!= AC
)
1886 if (opP
->mode
!= CONTROL
1889 && opP
->reg
!= SCC
))
1894 if (opP
->mode
!= CONTROL
1900 if (opP
->mode
!= CONTROL
1903 && opP
->reg
!= CRP
))
1927 if (opP
->mode
!= CONTROL
1928 || (!(opP
->reg
>= BAD
&& opP
->reg
<= BAD
+ 7)
1929 && !(opP
->reg
>= BAC
&& opP
->reg
<= BAC
+ 7)))
1934 if (opP
->mode
!= CONTROL
|| opP
->reg
!= PSR
)
1939 if (opP
->mode
!= CONTROL
|| opP
->reg
!= PCSR
)
1944 if (opP
->mode
!= CONTROL
1953 if (opP
->mode
!= ABSL
)
1958 if (opP
->reg
< DATA0L
|| opP
->reg
> ADDR7U
)
1960 /* FIXME: kludge instead of fixing parser:
1961 upper/lower registers are *not* CONTROL
1962 registers, but ordinary ones. */
1963 if ((opP
->reg
>= DATA0L
&& opP
->reg
<= DATA7L
)
1964 || (opP
->reg
>= DATA0U
&& opP
->reg
<= DATA7U
))
1971 if (!(opP
->mode
== AINDR
1972 || (opP
->mode
== DISP
1973 && !(opP
->reg
== PC
|| opP
->reg
== ZPC
))))
1978 if (!(opP
->mode
== AINDR
|| opP
->mode
== DISP
))
1990 /* Since we have found the correct instruction, copy
1991 in the modifications that we may have made. */
1993 for (i
= 0; i
< opsfound
; i
++)
1994 the_ins
.operands
[i
] = operands_backup
[i
];
2000 opcode
= opcode
->m_next
;
2005 && !(ok_arch
& current_architecture
))
2007 const struct m68k_cpu
*cpu
;
2010 char *buf
= xmalloc (space
+ 1);
2014 the_ins
.error
= buf
;
2015 /* Make sure there's a NUL at the end of the buffer -- strncpy
2016 won't write one when it runs out of buffer */
2018 #define APPEND(STRING) \
2019 (strncpy (buf, STRING, space), len = strlen (buf), buf += len, space -= len)
2021 APPEND (_("invalid instruction for this architecture; needs "));
2025 APPEND (_("ColdFire ISA_A"));
2028 APPEND (_("ColdFire hardware divide"));
2031 APPEND (_("ColdFire ISA_A+"));
2034 APPEND (_("ColdFire ISA_B"));
2037 APPEND (_("ColdFire fpu"));
2040 APPEND (_("M68K fpu"));
2043 APPEND (_("M68K mmu"));
2046 APPEND (_("68020 or higher"));
2049 APPEND (_("68000 or higher"));
2052 APPEND (_("68010 or higher"));
2060 for (cpu
= m68k_cpus
; cpu
->name
; cpu
++)
2061 if (!cpu
->alias
&& (cpu
->arch
& ok_arch
))
2063 const struct m68k_cpu
*alias
;
2070 if (cpu
!= m68k_cpus
)
2071 for (alias
= cpu
- 1; alias
->alias
; alias
--)
2075 APPEND (alias
->name
);
2078 for (alias
= cpu
+ 1; alias
->alias
; alias
++)
2082 APPEND (alias
->name
);
2094 /* we ran out of space, so replace the end of the list
2099 strcpy (buf
, " ...");
2103 the_ins
.error
= _("operands mismatch");
2110 /* Now assemble it. */
2111 the_ins
.args
= opcode
->m_operands
;
2112 the_ins
.numargs
= opcode
->m_opnum
;
2113 the_ins
.numo
= opcode
->m_codenum
;
2114 the_ins
.opcode
[0] = getone (opcode
);
2115 the_ins
.opcode
[1] = gettwo (opcode
);
2117 for (s
= the_ins
.args
, opP
= &the_ins
.operands
[0]; *s
; s
+= 2, opP
++)
2119 /* This switch is a doozy.
2120 Watch the first step; its a big one! */
2153 tmpreg
= 0x3c; /* 7.4 */
2154 if (strchr ("bwl", s
[1]))
2155 nextword
= get_num (&opP
->disp
, 90);
2157 nextword
= get_num (&opP
->disp
, 0);
2158 if (isvar (&opP
->disp
))
2159 add_fix (s
[1], &opP
->disp
, 0, 0);
2163 if (!isbyte (nextword
))
2164 opP
->error
= _("operand out of range");
2169 if (!isword (nextword
))
2170 opP
->error
= _("operand out of range");
2175 if (!issword (nextword
))
2176 opP
->error
= _("operand out of range");
2181 addword (nextword
>> 16);
2208 /* We gotta put out some float. */
2209 if (op (&opP
->disp
) != O_big
)
2214 /* Can other cases happen here? */
2215 if (op (&opP
->disp
) != O_constant
)
2218 val
= (valueT
) offs (&opP
->disp
);
2222 generic_bignum
[gencnt
] = (LITTLENUM_TYPE
) val
;
2223 val
>>= LITTLENUM_NUMBER_OF_BITS
;
2227 offs (&opP
->disp
) = gencnt
;
2229 if (offs (&opP
->disp
) > 0)
2231 if (offs (&opP
->disp
) > baseo
)
2233 as_warn (_("Bignum too big for %c format; truncated"),
2235 offs (&opP
->disp
) = baseo
;
2237 baseo
-= offs (&opP
->disp
);
2240 for (wordp
= generic_bignum
+ offs (&opP
->disp
) - 1;
2241 offs (&opP
->disp
)--;
2246 gen_to_words (words
, baseo
, (long) outro
);
2247 for (wordp
= words
; baseo
--; wordp
++)
2251 tmpreg
= opP
->reg
- DATA
; /* 0.dreg */
2254 tmpreg
= 0x08 + opP
->reg
- ADDR
; /* 1.areg */
2257 tmpreg
= 0x10 + opP
->reg
- ADDR
; /* 2.areg */
2260 tmpreg
= 0x20 + opP
->reg
- ADDR
; /* 4.areg */
2263 tmpreg
= 0x18 + opP
->reg
- ADDR
; /* 3.areg */
2267 nextword
= get_num (&opP
->disp
, 90);
2269 /* Convert mode 5 addressing with a zero offset into
2270 mode 2 addressing to reduce the instruction size by a
2272 if (! isvar (&opP
->disp
)
2274 && (opP
->disp
.size
== SIZE_UNSPEC
)
2275 && (opP
->reg
>= ADDR0
)
2276 && (opP
->reg
<= ADDR7
))
2278 tmpreg
= 0x10 + opP
->reg
- ADDR
; /* 2.areg */
2283 && ! isvar (&opP
->disp
)
2286 opP
->disp
.exp
.X_op
= O_symbol
;
2287 opP
->disp
.exp
.X_add_symbol
=
2288 section_symbol (absolute_section
);
2291 /* Force into index mode. Hope this works. */
2293 /* We do the first bit for 32-bit displacements, and the
2294 second bit for 16 bit ones. It is possible that we
2295 should make the default be WORD instead of LONG, but
2296 I think that'd break GCC, so we put up with a little
2297 inefficiency for the sake of working output. */
2299 if (!issword (nextword
)
2300 || (isvar (&opP
->disp
)
2301 && ((opP
->disp
.size
== SIZE_UNSPEC
2302 && flag_short_refs
== 0
2303 && cpu_of_arch (current_architecture
) >= m68020
2304 && ! arch_coldfire_p (current_architecture
))
2305 || opP
->disp
.size
== SIZE_LONG
)))
2307 if (cpu_of_arch (current_architecture
) < m68020
2308 || arch_coldfire_p (current_architecture
))
2310 _("displacement too large for this architecture; needs 68020 or higher");
2312 tmpreg
= 0x3B; /* 7.3 */
2314 tmpreg
= 0x30 + opP
->reg
- ADDR
; /* 6.areg */
2315 if (isvar (&opP
->disp
))
2319 if (opP
->disp
.size
== SIZE_LONG
2321 /* If the displacement needs pic
2322 relocation it cannot be relaxed. */
2323 || opP
->disp
.pic_reloc
!= pic_none
2328 add_fix ('l', &opP
->disp
, 1, 2);
2332 add_frag (adds (&opP
->disp
),
2333 SEXT (offs (&opP
->disp
)),
2334 TAB (PCREL1632
, SZ_UNDEF
));
2341 add_fix ('l', &opP
->disp
, 0, 0);
2346 addword (nextword
>> 16);
2351 tmpreg
= 0x3A; /* 7.2 */
2353 tmpreg
= 0x28 + opP
->reg
- ADDR
; /* 5.areg */
2355 if (isvar (&opP
->disp
))
2359 add_fix ('w', &opP
->disp
, 1, 0);
2362 add_fix ('w', &opP
->disp
, 0, 0);
2372 baseo
= get_num (&opP
->disp
, 90);
2373 if (opP
->mode
== POST
|| opP
->mode
== PRE
)
2374 outro
= get_num (&opP
->odisp
, 90);
2375 /* Figure out the `addressing mode'.
2376 Also turn on the BASE_DISABLE bit, if needed. */
2377 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
2379 tmpreg
= 0x3b; /* 7.3 */
2380 if (opP
->reg
== ZPC
)
2383 else if (opP
->reg
== 0)
2386 tmpreg
= 0x30; /* 6.garbage */
2388 else if (opP
->reg
>= ZADDR0
&& opP
->reg
<= ZADDR7
)
2391 tmpreg
= 0x30 + opP
->reg
- ZADDR0
;
2394 tmpreg
= 0x30 + opP
->reg
- ADDR
; /* 6.areg */
2396 siz1
= opP
->disp
.size
;
2397 if (opP
->mode
== POST
|| opP
->mode
== PRE
)
2398 siz2
= opP
->odisp
.size
;
2402 /* Index register stuff. */
2403 if (opP
->index
.reg
!= 0
2404 && opP
->index
.reg
>= DATA
2405 && opP
->index
.reg
<= ADDR7
)
2407 nextword
|= (opP
->index
.reg
- DATA
) << 12;
2409 if (opP
->index
.size
== SIZE_LONG
2410 || (opP
->index
.size
== SIZE_UNSPEC
2411 && m68k_index_width_default
== SIZE_LONG
))
2414 if ((opP
->index
.scale
!= 1
2415 && cpu_of_arch (current_architecture
) < m68020
)
2416 || (opP
->index
.scale
== 8
2417 && (arch_coldfire_p (current_architecture
)
2418 && !arch_coldfire_fpu (current_architecture
))))
2421 _("scale factor invalid on this architecture; needs cpu32 or 68020 or higher");
2424 if (arch_coldfire_p (current_architecture
)
2425 && opP
->index
.size
== SIZE_WORD
)
2426 opP
->error
= _("invalid index size for coldfire");
2428 switch (opP
->index
.scale
)
2445 GET US OUT OF HERE! */
2447 /* Must be INDEX, with an index register. Address
2448 register cannot be ZERO-PC, and either :b was
2449 forced, or we know it will fit. For a 68000 or
2450 68010, force this mode anyways, because the
2451 larger modes aren't supported. */
2452 if (opP
->mode
== BASE
2453 && ((opP
->reg
>= ADDR0
2454 && opP
->reg
<= ADDR7
)
2457 if (siz1
== SIZE_BYTE
2458 || cpu_of_arch (current_architecture
) < m68020
2459 || arch_coldfire_p (current_architecture
)
2460 || (siz1
== SIZE_UNSPEC
2461 && ! isvar (&opP
->disp
)
2462 && issbyte (baseo
)))
2464 nextword
+= baseo
& 0xff;
2466 if (isvar (&opP
->disp
))
2468 /* Do a byte relocation. If it doesn't
2469 fit (possible on m68000) let the
2470 fixup processing complain later. */
2472 add_fix ('B', &opP
->disp
, 1, 1);
2474 add_fix ('B', &opP
->disp
, 0, 0);
2476 else if (siz1
!= SIZE_BYTE
)
2478 if (siz1
!= SIZE_UNSPEC
)
2479 as_warn (_("Forcing byte displacement"));
2480 if (! issbyte (baseo
))
2481 opP
->error
= _("byte displacement out of range");
2486 else if (siz1
== SIZE_UNSPEC
2488 && isvar (&opP
->disp
)
2489 && subs (&opP
->disp
) == NULL
2491 /* If the displacement needs pic
2492 relocation it cannot be relaxed. */
2493 && opP
->disp
.pic_reloc
== pic_none
2497 /* The code in md_convert_frag_1 needs to be
2498 able to adjust nextword. Call frag_grow
2499 to ensure that we have enough space in
2500 the frag obstack to make all the bytes
2503 nextword
+= baseo
& 0xff;
2505 add_frag (adds (&opP
->disp
),
2506 SEXT (offs (&opP
->disp
)),
2507 TAB (PCINDEX
, SZ_UNDEF
));
2515 nextword
|= 0x40; /* No index reg. */
2516 if (opP
->index
.reg
>= ZDATA0
2517 && opP
->index
.reg
<= ZDATA7
)
2518 nextword
|= (opP
->index
.reg
- ZDATA0
) << 12;
2519 else if (opP
->index
.reg
>= ZADDR0
2520 || opP
->index
.reg
<= ZADDR7
)
2521 nextword
|= (opP
->index
.reg
- ZADDR0
+ 8) << 12;
2524 /* It isn't simple. */
2526 if (cpu_of_arch (current_architecture
) < m68020
2527 || arch_coldfire_p (current_architecture
))
2529 _("invalid operand mode for this architecture; needs 68020 or higher");
2532 /* If the guy specified a width, we assume that it is
2533 wide enough. Maybe it isn't. If so, we lose. */
2537 if (isvar (&opP
->disp
)
2539 : ! issword (baseo
))
2544 else if (! isvar (&opP
->disp
) && baseo
== 0)
2553 as_warn (_(":b not permitted; defaulting to :w"));
2563 /* Figure out inner displacement stuff. */
2564 if (opP
->mode
== POST
|| opP
->mode
== PRE
)
2566 if (cpu_of_arch (current_architecture
) & cpu32
)
2567 opP
->error
= _("invalid operand mode for this architecture; needs 68020 or higher");
2571 if (isvar (&opP
->odisp
)
2573 : ! issword (outro
))
2578 else if (! isvar (&opP
->odisp
) && outro
== 0)
2587 as_warn (_(":b not permitted; defaulting to :w"));
2596 if (opP
->mode
== POST
2597 && (nextword
& 0x40) == 0)
2602 if (siz1
!= SIZE_UNSPEC
&& isvar (&opP
->disp
))
2604 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
2605 add_fix (siz1
== SIZE_LONG
? 'l' : 'w', &opP
->disp
, 1, 2);
2607 add_fix (siz1
== SIZE_LONG
? 'l' : 'w', &opP
->disp
, 0, 0);
2609 if (siz1
== SIZE_LONG
)
2610 addword (baseo
>> 16);
2611 if (siz1
!= SIZE_UNSPEC
)
2614 if (siz2
!= SIZE_UNSPEC
&& isvar (&opP
->odisp
))
2615 add_fix (siz2
== SIZE_LONG
? 'l' : 'w', &opP
->odisp
, 0, 0);
2616 if (siz2
== SIZE_LONG
)
2617 addword (outro
>> 16);
2618 if (siz2
!= SIZE_UNSPEC
)
2624 nextword
= get_num (&opP
->disp
, 90);
2625 switch (opP
->disp
.size
)
2630 if (!isvar (&opP
->disp
) && issword (offs (&opP
->disp
)))
2632 tmpreg
= 0x38; /* 7.0 */
2636 if (isvar (&opP
->disp
)
2637 && !subs (&opP
->disp
)
2638 && adds (&opP
->disp
)
2640 /* If the displacement needs pic relocation it
2641 cannot be relaxed. */
2642 && opP
->disp
.pic_reloc
== pic_none
2645 && !strchr ("~%&$?", s
[0]))
2647 tmpreg
= 0x3A; /* 7.2 */
2648 add_frag (adds (&opP
->disp
),
2649 SEXT (offs (&opP
->disp
)),
2650 TAB (ABSTOPCREL
, SZ_UNDEF
));
2653 /* Fall through into long. */
2655 if (isvar (&opP
->disp
))
2656 add_fix ('l', &opP
->disp
, 0, 0);
2658 tmpreg
= 0x39;/* 7.1 mode */
2659 addword (nextword
>> 16);
2664 as_bad (_("unsupported byte value; use a different suffix"));
2668 if (isvar (&opP
->disp
))
2669 add_fix ('w', &opP
->disp
, 0, 0);
2671 tmpreg
= 0x38;/* 7.0 mode */
2679 as_bad (_("unknown/incorrect operand"));
2683 /* If s[0] is '4', then this is for the mac instructions
2684 that can have a trailing_ampersand set. If so, set 0x100
2685 bit on tmpreg so install_gen_operand can check for it and
2686 set the appropriate bit (word2, bit 5). */
2689 if (opP
->trailing_ampersand
)
2692 install_gen_operand (s
[1], tmpreg
);
2698 { /* JF: I hate floating point! */
2713 tmpreg
= get_num (&opP
->disp
, tmpreg
);
2714 if (isvar (&opP
->disp
))
2715 add_fix (s
[1], &opP
->disp
, 0, 0);
2718 case 'b': /* Danger: These do no check for
2719 certain types of overflow.
2721 if (!isbyte (tmpreg
))
2722 opP
->error
= _("out of range");
2723 insop (tmpreg
, opcode
);
2724 if (isvar (&opP
->disp
))
2725 the_ins
.reloc
[the_ins
.nrel
- 1].n
=
2726 (opcode
->m_codenum
) * 2 + 1;
2729 if (!issbyte (tmpreg
))
2730 opP
->error
= _("out of range");
2731 the_ins
.opcode
[the_ins
.numo
- 1] |= tmpreg
& 0xff;
2732 if (isvar (&opP
->disp
))
2733 the_ins
.reloc
[the_ins
.nrel
- 1].n
= opcode
->m_codenum
* 2 - 1;
2736 if (!isword (tmpreg
))
2737 opP
->error
= _("out of range");
2738 insop (tmpreg
, opcode
);
2739 if (isvar (&opP
->disp
))
2740 the_ins
.reloc
[the_ins
.nrel
- 1].n
= (opcode
->m_codenum
) * 2;
2743 if (!issword (tmpreg
))
2744 opP
->error
= _("out of range");
2745 insop (tmpreg
, opcode
);
2746 if (isvar (&opP
->disp
))
2747 the_ins
.reloc
[the_ins
.nrel
- 1].n
= (opcode
->m_codenum
) * 2;
2750 /* Because of the way insop works, we put these two out
2752 insop (tmpreg
, opcode
);
2753 insop (tmpreg
>> 16, opcode
);
2754 if (isvar (&opP
->disp
))
2755 the_ins
.reloc
[the_ins
.nrel
- 1].n
= (opcode
->m_codenum
) * 2;
2762 install_operand (s
[1], tmpreg
);
2773 install_operand (s
[1], opP
->reg
- ADDR
);
2777 tmpreg
= get_num (&opP
->disp
, 90);
2781 add_fix ('B', &opP
->disp
, 1, -1);
2784 add_fix ('w', &opP
->disp
, 1, 0);
2789 if (! HAVE_LONG_BRANCH (current_architecture
))
2790 as_warn (_("Can't use long branches on 68000/68010/5200"));
2791 the_ins
.opcode
[0] |= 0xff;
2792 add_fix ('l', &opP
->disp
, 1, 0);
2797 if (subs (&opP
->disp
)) /* We can't relax it. */
2801 /* If the displacement needs pic relocation it cannot be
2803 if (opP
->disp
.pic_reloc
!= pic_none
)
2806 /* This could either be a symbol, or an absolute
2807 address. If it's an absolute address, turn it into
2808 an absolute jump right here and keep it out of the
2810 if (adds (&opP
->disp
) == 0)
2812 if (the_ins
.opcode
[0] == 0x6000) /* jbra */
2813 the_ins
.opcode
[0] = 0x4EF9;
2814 else if (the_ins
.opcode
[0] == 0x6100) /* jbsr */
2815 the_ins
.opcode
[0] = 0x4EB9;
2818 the_ins
.opcode
[0] ^= 0x0100;
2819 the_ins
.opcode
[0] |= 0x0006;
2822 add_fix ('l', &opP
->disp
, 0, 0);
2828 /* Now we know it's going into the relaxer. Now figure
2829 out which mode. We try in this order of preference:
2830 long branch, absolute jump, byte/word branches only. */
2831 if (HAVE_LONG_BRANCH (current_architecture
))
2832 add_frag (adds (&opP
->disp
),
2833 SEXT (offs (&opP
->disp
)),
2834 TAB (BRANCHBWL
, SZ_UNDEF
));
2835 else if (! flag_keep_pcrel
)
2837 if ((the_ins
.opcode
[0] == 0x6000)
2838 || (the_ins
.opcode
[0] == 0x6100))
2839 add_frag (adds (&opP
->disp
),
2840 SEXT (offs (&opP
->disp
)),
2841 TAB (BRABSJUNC
, SZ_UNDEF
));
2843 add_frag (adds (&opP
->disp
),
2844 SEXT (offs (&opP
->disp
)),
2845 TAB (BRABSJCOND
, SZ_UNDEF
));
2848 add_frag (adds (&opP
->disp
),
2849 SEXT (offs (&opP
->disp
)),
2850 TAB (BRANCHBW
, SZ_UNDEF
));
2853 if (isvar (&opP
->disp
))
2855 /* Check for DBcc instructions. We can relax them,
2856 but only if we have long branches and/or absolute
2858 if (((the_ins
.opcode
[0] & 0xf0f8) == 0x50c8)
2859 && (HAVE_LONG_BRANCH (current_architecture
)
2860 || (! flag_keep_pcrel
)))
2862 if (HAVE_LONG_BRANCH (current_architecture
))
2863 add_frag (adds (&opP
->disp
),
2864 SEXT (offs (&opP
->disp
)),
2865 TAB (DBCCLBR
, SZ_UNDEF
));
2867 add_frag (adds (&opP
->disp
),
2868 SEXT (offs (&opP
->disp
)),
2869 TAB (DBCCABSJ
, SZ_UNDEF
));
2872 add_fix ('w', &opP
->disp
, 1, 0);
2876 case 'C': /* Fixed size LONG coproc branches. */
2877 add_fix ('l', &opP
->disp
, 1, 0);
2881 case 'c': /* Var size Coprocesssor branches. */
2882 if (subs (&opP
->disp
) || (adds (&opP
->disp
) == 0))
2884 the_ins
.opcode
[the_ins
.numo
- 1] |= 0x40;
2885 add_fix ('l', &opP
->disp
, 1, 0);
2890 add_frag (adds (&opP
->disp
),
2891 SEXT (offs (&opP
->disp
)),
2892 TAB (FBRANCH
, SZ_UNDEF
));
2899 case 'C': /* Ignore it. */
2902 case 'd': /* JF this is a kludge. */
2903 install_operand ('s', opP
->reg
- ADDR
);
2904 tmpreg
= get_num (&opP
->disp
, 90);
2905 if (!issword (tmpreg
))
2907 as_warn (_("Expression out of range, using 0"));
2914 install_operand (s
[1], opP
->reg
- DATA
);
2917 case 'e': /* EMAC ACCx, reg/reg. */
2918 install_operand (s
[1], opP
->reg
- ACC
);
2921 case 'E': /* Ignore it. */
2925 install_operand (s
[1], opP
->reg
- FP0
);
2928 case 'g': /* EMAC ACCEXTx. */
2929 install_operand (s
[1], opP
->reg
- ACCEXT01
);
2932 case 'G': /* Ignore it. */
2937 tmpreg
= opP
->reg
- COP0
;
2938 install_operand (s
[1], tmpreg
);
2941 case 'i': /* MAC/EMAC scale factor. */
2942 install_operand (s
[1], opP
->mode
== LSH
? 0x1 : 0x3);
2945 case 'J': /* JF foo. */
3075 install_operand (s
[1], tmpreg
);
3079 tmpreg
= get_num (&opP
->disp
, 55);
3080 install_operand (s
[1], tmpreg
& 0x7f);
3087 if (tmpreg
& 0x7FF0000)
3088 as_bad (_("Floating point register in register list"));
3089 insop (reverse_16_bits (tmpreg
), opcode
);
3093 if (tmpreg
& 0x700FFFF)
3094 as_bad (_("Wrong register in floating-point reglist"));
3095 install_operand (s
[1], reverse_8_bits (tmpreg
>> 16));
3103 if (tmpreg
& 0x7FF0000)
3104 as_bad (_("Floating point register in register list"));
3105 insop (tmpreg
, opcode
);
3107 else if (s
[1] == '8')
3109 if (tmpreg
& 0x0FFFFFF)
3110 as_bad (_("incorrect register in reglist"));
3111 install_operand (s
[1], tmpreg
>> 24);
3115 if (tmpreg
& 0x700FFFF)
3116 as_bad (_("wrong register in floating-point reglist"));
3118 install_operand (s
[1], tmpreg
>> 16);
3123 install_operand (s
[1], get_num (&opP
->disp
, 60));
3127 tmpreg
= ((opP
->mode
== DREG
)
3128 ? 0x20 + (int) (opP
->reg
- DATA
)
3129 : (get_num (&opP
->disp
, 40) & 0x1F));
3130 install_operand (s
[1], tmpreg
);
3134 tmpreg
= get_num (&opP
->disp
, 10);
3137 install_operand (s
[1], tmpreg
);
3141 /* This depends on the fact that ADDR registers are eight
3142 more than their corresponding DATA regs, so the result
3143 will have the ADDR_REG bit set. */
3144 install_operand (s
[1], opP
->reg
- DATA
);
3148 if (opP
->mode
== AINDR
)
3149 install_operand (s
[1], opP
->reg
- DATA
);
3151 install_operand (s
[1], opP
->index
.reg
- DATA
);
3155 if (opP
->reg
== FPI
)
3157 else if (opP
->reg
== FPS
)
3159 else if (opP
->reg
== FPC
)
3163 install_operand (s
[1], tmpreg
);
3166 case 'S': /* Ignore it. */
3170 install_operand (s
[1], get_num (&opP
->disp
, 30));
3173 case 'U': /* Ignore it. */
3192 as_fatal (_("failed sanity check"));
3193 } /* switch on cache token. */
3194 install_operand (s
[1], tmpreg
);
3197 /* JF: These are out of order, I fear. */
3210 install_operand (s
[1], tmpreg
);
3236 install_operand (s
[1], tmpreg
);
3240 if (opP
->reg
== VAL
)
3259 install_operand (s
[1], tmpreg
);
3273 tmpreg
= (4 << 10) | ((opP
->reg
- BAD
) << 2);
3284 tmpreg
= (5 << 10) | ((opP
->reg
- BAC
) << 2);
3290 install_operand (s
[1], tmpreg
);
3293 know (opP
->reg
== PSR
);
3296 know (opP
->reg
== PCSR
);
3311 install_operand (s
[1], tmpreg
);
3314 tmpreg
= get_num (&opP
->disp
, 20);
3315 install_operand (s
[1], tmpreg
);
3317 case '_': /* used only for move16 absolute 32-bit address. */
3318 if (isvar (&opP
->disp
))
3319 add_fix ('l', &opP
->disp
, 0, 0);
3320 tmpreg
= get_num (&opP
->disp
, 90);
3321 addword (tmpreg
>> 16);
3322 addword (tmpreg
& 0xFFFF);
3325 install_operand (s
[1], opP
->reg
- DATA0L
);
3326 opP
->reg
-= (DATA0L
);
3327 opP
->reg
&= 0x0F; /* remove upper/lower bit. */
3330 tmpreg
= get_num (&opP
->disp
, 80);
3333 install_operand (s
[1], tmpreg
);
3340 /* By the time whe get here (FINALLY) the_ins contains the complete
3341 instruction, ready to be emitted. . . */
3345 reverse_16_bits (int in
)
3350 static int mask
[16] =
3352 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
3353 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000
3355 for (n
= 0; n
< 16; n
++)
3358 out
|= mask
[15 - n
];
3361 } /* reverse_16_bits() */
3364 reverse_8_bits (int in
)
3369 static int mask
[8] =
3371 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
3374 for (n
= 0; n
< 8; n
++)
3380 } /* reverse_8_bits() */
3382 /* Cause an extra frag to be generated here, inserting up to 10 bytes
3383 (that value is chosen in the frag_var call in md_assemble). TYPE
3384 is the subtype of the frag to be generated; its primary type is
3385 rs_machine_dependent.
3387 The TYPE parameter is also used by md_convert_frag_1 and
3388 md_estimate_size_before_relax. The appropriate type of fixup will
3389 be emitted by md_convert_frag_1.
3391 ADD becomes the FR_SYMBOL field of the frag, and OFF the FR_OFFSET. */
3393 install_operand (int mode
, int val
)
3398 the_ins
.opcode
[0] |= val
& 0xFF; /* JF FF is for M kludge. */
3401 the_ins
.opcode
[0] |= val
<< 9;
3404 the_ins
.opcode
[1] |= val
<< 12;
3407 the_ins
.opcode
[1] |= val
<< 6;
3410 the_ins
.opcode
[1] |= val
;
3413 the_ins
.opcode
[2] |= val
<< 12;
3416 the_ins
.opcode
[2] |= val
<< 6;
3419 /* DANGER! This is a hack to force cas2l and cas2w cmds to be
3420 three words long! */
3422 the_ins
.opcode
[2] |= val
;
3425 the_ins
.opcode
[1] |= val
<< 7;
3428 the_ins
.opcode
[1] |= val
<< 10;
3432 the_ins
.opcode
[1] |= val
<< 5;
3437 the_ins
.opcode
[1] |= (val
<< 10) | (val
<< 7);
3440 the_ins
.opcode
[1] |= (val
<< 12) | val
;
3443 the_ins
.opcode
[0] |= val
= 0xff;
3446 the_ins
.opcode
[0] |= val
<< 9;
3449 the_ins
.opcode
[1] |= val
;
3452 the_ins
.opcode
[1] |= val
;
3453 the_ins
.numo
++; /* What a hack. */
3456 the_ins
.opcode
[1] |= val
<< 4;
3464 the_ins
.opcode
[0] |= (val
<< 6);
3467 the_ins
.opcode
[1] = (val
>> 16);
3468 the_ins
.opcode
[2] = val
& 0xffff;
3471 the_ins
.opcode
[0] |= ((val
& 0x8) << (6 - 3));
3472 the_ins
.opcode
[0] |= ((val
& 0x7) << 9);
3473 the_ins
.opcode
[1] |= ((val
& 0x10) << (7 - 4));
3475 case 'n': /* MAC/EMAC Rx on !load. */
3476 the_ins
.opcode
[0] |= ((val
& 0x8) << (6 - 3));
3477 the_ins
.opcode
[0] |= ((val
& 0x7) << 9);
3478 the_ins
.opcode
[1] |= ((val
& 0x10) << (7 - 4));
3480 case 'o': /* MAC/EMAC Rx on load. */
3481 the_ins
.opcode
[1] |= val
<< 12;
3482 the_ins
.opcode
[1] |= ((val
& 0x10) << (7 - 4));
3484 case 'M': /* MAC/EMAC Ry on !load. */
3485 the_ins
.opcode
[0] |= (val
& 0xF);
3486 the_ins
.opcode
[1] |= ((val
& 0x10) << (6 - 4));
3488 case 'N': /* MAC/EMAC Ry on load. */
3489 the_ins
.opcode
[1] |= (val
& 0xF);
3490 the_ins
.opcode
[1] |= ((val
& 0x10) << (6 - 4));
3493 the_ins
.opcode
[1] |= ((val
!= 1) << 10);
3496 the_ins
.opcode
[0] |= ((val
& 0x3) << 9);
3499 the_ins
.opcode
[0] |= ((val
& 0x3) << 0);
3501 case 'G': /* EMAC accumulator in a EMAC load instruction. */
3502 the_ins
.opcode
[0] |= ((~val
& 0x1) << 7);
3503 the_ins
.opcode
[1] |= ((val
& 0x2) << (4 - 1));
3505 case 'H': /* EMAC accumulator in a EMAC non-load instruction. */
3506 the_ins
.opcode
[0] |= ((val
& 0x1) << 7);
3507 the_ins
.opcode
[1] |= ((val
& 0x2) << (4 - 1));
3510 the_ins
.opcode
[1] |= ((val
& 0x3) << 9);
3513 the_ins
.opcode
[0] |= (val
& 0x1) <<10;
3517 as_fatal (_("failed sanity check."));
3522 install_gen_operand (int mode
, int val
)
3526 case '/': /* Special for mask loads for mac/msac insns with
3527 possible mask; trailing_ampersend set in bit 8. */
3528 the_ins
.opcode
[0] |= (val
& 0x3f);
3529 the_ins
.opcode
[1] |= (((val
& 0x100) >> 8) << 5);
3532 the_ins
.opcode
[0] |= val
;
3535 /* This is a kludge!!! */
3536 the_ins
.opcode
[0] |= (val
& 0x07) << 9 | (val
& 0x38) << 3;
3545 the_ins
.opcode
[0] |= val
;
3547 /* more stuff goes here. */
3549 as_fatal (_("failed sanity check."));
3553 /* Verify that we have some number of paren pairs, do m68k_ip_op(), and
3554 then deal with the bitfield hack. */
3557 crack_operand (char *str
, struct m68k_op
*opP
)
3559 register int parens
;
3561 register char *beg_str
;
3569 for (parens
= 0; *str
&& (parens
> 0 || inquote
|| notend (str
)); str
++)
3575 else if (*str
== ')')
3579 opP
->error
= _("Extra )");
3585 if (flag_mri
&& *str
== '\'')
3586 inquote
= ! inquote
;
3588 if (!*str
&& parens
)
3590 opP
->error
= _("Missing )");
3595 if (m68k_ip_op (beg_str
, opP
) != 0)
3602 c
= *++str
; /* JF bitfield hack. */
3607 as_bad (_("Missing operand"));
3610 /* Detect MRI REG symbols and convert them to REGLSTs. */
3611 if (opP
->mode
== CONTROL
&& (int)opP
->reg
< 0)
3614 opP
->mask
= ~(int)opP
->reg
;
3621 /* This is the guts of the machine-dependent assembler. STR points to a
3622 machine dependent instruction. This function is supposed to emit
3623 the frags/bytes it assembles to.
3627 insert_reg (const char *regname
, int regnum
)
3632 #ifdef REGISTER_PREFIX
3633 if (!flag_reg_prefix_optional
)
3635 buf
[0] = REGISTER_PREFIX
;
3636 strcpy (buf
+ 1, regname
);
3641 symbol_table_insert (symbol_new (regname
, reg_section
, regnum
,
3642 &zero_address_frag
));
3644 for (i
= 0; regname
[i
]; i
++)
3645 buf
[i
] = TOUPPER (regname
[i
]);
3648 symbol_table_insert (symbol_new (buf
, reg_section
, regnum
,
3649 &zero_address_frag
));
3658 static const struct init_entry init_table
[] =
3718 { "accext01", ACCEXT01
},
3719 { "accext23", ACCEXT23
},
3723 /* Control registers. */
3724 { "sfc", SFC
}, /* Source Function Code. */
3726 { "dfc", DFC
}, /* Destination Function Code. */
3728 { "cacr", CACR
}, /* Cache Control Register. */
3729 { "caar", CAAR
}, /* Cache Address Register. */
3731 { "usp", USP
}, /* User Stack Pointer. */
3732 { "vbr", VBR
}, /* Vector Base Register. */
3733 { "msp", MSP
}, /* Master Stack Pointer. */
3734 { "isp", ISP
}, /* Interrupt Stack Pointer. */
3736 { "itt0", ITT0
}, /* Instruction Transparent Translation Reg 0. */
3737 { "itt1", ITT1
}, /* Instruction Transparent Translation Reg 1. */
3738 { "dtt0", DTT0
}, /* Data Transparent Translation Register 0. */
3739 { "dtt1", DTT1
}, /* Data Transparent Translation Register 1. */
3741 /* 68ec040 versions of same */
3742 { "iacr0", ITT0
}, /* Instruction Access Control Register 0. */
3743 { "iacr1", ITT1
}, /* Instruction Access Control Register 0. */
3744 { "dacr0", DTT0
}, /* Data Access Control Register 0. */
3745 { "dacr1", DTT1
}, /* Data Access Control Register 0. */
3747 /* mcf5200 versions of same. The ColdFire programmer's reference
3748 manual indicated that the order is 2,3,0,1, but Ken Rose
3749 <rose@netcom.com> says that 0,1,2,3 is the correct order. */
3750 { "acr0", ACR0
}, /* Access Control Unit 0. */
3751 { "acr1", ACR1
}, /* Access Control Unit 1. */
3752 { "acr2", ACR2
}, /* Access Control Unit 2. */
3753 { "acr3", ACR3
}, /* Access Control Unit 3. */
3755 { "tc", TC
}, /* MMU Translation Control Register. */
3758 { "mmusr", MMUSR
}, /* MMU Status Register. */
3759 { "srp", SRP
}, /* User Root Pointer. */
3760 { "urp", URP
}, /* Supervisor Root Pointer. */
3765 { "rombar", ROMBAR
}, /* ROM Base Address Register. */
3766 { "rambar0", RAMBAR0
}, /* ROM Base Address Register. */
3767 { "rambar1", RAMBAR1
}, /* ROM Base Address Register. */
3768 { "mbar", MBAR
}, /* Module Base Address Register. */
3770 { "mbar0", MBAR0
}, /* mcfv4e registers. */
3771 { "mbar1", MBAR1
}, /* mcfv4e registers. */
3772 { "rombar0", ROMBAR
}, /* mcfv4e registers. */
3773 { "rombar1", ROMBAR1
}, /* mcfv4e registers. */
3774 { "mpcr", MPCR
}, /* mcfv4e registers. */
3775 { "edrambar", EDRAMBAR
}, /* mcfv4e registers. */
3776 { "secmbar", SECMBAR
}, /* mcfv4e registers. */
3777 { "asid", TC
}, /* mcfv4e registers. */
3778 { "mmubar", BUSCR
}, /* mcfv4e registers. */
3779 { "pcr1u0", PCR1U0
}, /* mcfv4e registers. */
3780 { "pcr1l0", PCR1L0
}, /* mcfv4e registers. */
3781 { "pcr2u0", PCR2U0
}, /* mcfv4e registers. */
3782 { "pcr2l0", PCR2L0
}, /* mcfv4e registers. */
3783 { "pcr3u0", PCR3U0
}, /* mcfv4e registers. */
3784 { "pcr3l0", PCR3L0
}, /* mcfv4e registers. */
3785 { "pcr1u1", PCR1U1
}, /* mcfv4e registers. */
3786 { "pcr1l1", PCR1L1
}, /* mcfv4e registers. */
3787 { "pcr2u1", PCR2U1
}, /* mcfv4e registers. */
3788 { "pcr2l1", PCR2L1
}, /* mcfv4e registers. */
3789 { "pcr3u1", PCR3U1
}, /* mcfv4e registers. */
3790 { "pcr3l1", PCR3L1
}, /* mcfv4e registers. */
3792 { "flashbar", FLASHBAR
}, /* mcf528x registers. */
3793 { "rambar", RAMBAR
}, /* mcf528x registers. */
3795 { "mbar2", MBAR2
}, /* mcf5249 registers. */
3796 /* End of control registers. */
3830 /* 68ec030 versions of same. */
3833 /* 68ec030 access control unit, identical to 030 MMU status reg. */
3836 /* Suppressed data and address registers. */
3854 /* Upper and lower data and address registers, used by macw and msacw. */
3895 init_regtable (void)
3898 for (i
= 0; init_table
[i
].name
; i
++)
3899 insert_reg (init_table
[i
].name
, init_table
[i
].number
);
3903 md_assemble (char *str
)
3910 int shorts_this_frag
;
3913 if (!selected_cpu
&& !selected_arch
)
3915 /* We've not selected an architecture yet. Set the default
3916 now. We do this lazily so that an initial .cpu or .arch directive
3918 if (!m68k_set_cpu (TARGET_CPU
, 1, 1))
3919 as_bad (_("unrecognized default cpu `%s'"), TARGET_CPU
);
3924 /* In MRI mode, the instruction and operands are separated by a
3925 space. Anything following the operands is a comment. The label
3926 has already been removed. */
3934 for (s
= str
; *s
!= '\0'; s
++)
3936 if ((*s
== ' ' || *s
== '\t') && ! inquote
)
3954 inquote
= ! inquote
;
3959 memset (&the_ins
, '\0', sizeof (the_ins
));
3964 for (n
= 0; n
< the_ins
.numargs
; n
++)
3965 if (the_ins
.operands
[n
].error
)
3967 er
= the_ins
.operands
[n
].error
;
3973 as_bad (_("%s -- statement `%s' ignored"), er
, str
);
3977 /* If there is a current label, record that it marks an instruction. */
3978 if (current_label
!= NULL
)
3980 current_label
->text
= 1;
3981 current_label
= NULL
;
3985 /* Tie dwarf2 debug info to the address at the start of the insn. */
3986 dwarf2_emit_insn (0);
3989 if (the_ins
.nfrag
== 0)
3991 /* No frag hacking involved; just put it out. */
3992 toP
= frag_more (2 * the_ins
.numo
);
3993 fromP
= &the_ins
.opcode
[0];
3994 for (m
= the_ins
.numo
; m
; --m
)
3996 md_number_to_chars (toP
, (long) (*fromP
), 2);
4000 /* Put out symbol-dependent info. */
4001 for (m
= 0; m
< the_ins
.nrel
; m
++)
4003 switch (the_ins
.reloc
[m
].wid
)
4022 as_fatal (_("Don't know how to figure width of %c in md_assemble()"),
4023 the_ins
.reloc
[m
].wid
);
4026 fixP
= fix_new_exp (frag_now
,
4027 ((toP
- frag_now
->fr_literal
)
4028 - the_ins
.numo
* 2 + the_ins
.reloc
[m
].n
),
4030 &the_ins
.reloc
[m
].exp
,
4031 the_ins
.reloc
[m
].pcrel
,
4032 get_reloc_code (n
, the_ins
.reloc
[m
].pcrel
,
4033 the_ins
.reloc
[m
].pic_reloc
));
4034 fixP
->fx_pcrel_adjust
= the_ins
.reloc
[m
].pcrel_fix
;
4035 if (the_ins
.reloc
[m
].wid
== 'B')
4036 fixP
->fx_signed
= 1;
4041 /* There's some frag hacking. */
4043 /* Calculate the max frag size. */
4046 wid
= 2 * the_ins
.fragb
[0].fragoff
;
4047 for (n
= 1; n
< the_ins
.nfrag
; n
++)
4048 wid
+= 2 * (the_ins
.numo
- the_ins
.fragb
[n
- 1].fragoff
);
4049 /* frag_var part. */
4051 /* Make sure the whole insn fits in one chunk, in particular that
4052 the var part is attached, as we access one byte before the
4053 variable frag for byte branches. */
4057 for (n
= 0, fromP
= &the_ins
.opcode
[0]; n
< the_ins
.nfrag
; n
++)
4062 wid
= 2 * the_ins
.fragb
[n
].fragoff
;
4064 wid
= 2 * (the_ins
.numo
- the_ins
.fragb
[n
- 1].fragoff
);
4065 toP
= frag_more (wid
);
4067 shorts_this_frag
= 0;
4068 for (m
= wid
/ 2; m
; --m
)
4070 md_number_to_chars (toP
, (long) (*fromP
), 2);
4075 for (m
= 0; m
< the_ins
.nrel
; m
++)
4077 if ((the_ins
.reloc
[m
].n
) >= 2 * shorts_this_frag
)
4079 the_ins
.reloc
[m
].n
-= 2 * shorts_this_frag
;
4082 wid
= the_ins
.reloc
[m
].wid
;
4085 the_ins
.reloc
[m
].wid
= 0;
4086 wid
= (wid
== 'b') ? 1 : (wid
== 'w') ? 2 : (wid
== 'l') ? 4 : 4000;
4088 fixP
= fix_new_exp (frag_now
,
4089 ((toP
- frag_now
->fr_literal
)
4090 - the_ins
.numo
* 2 + the_ins
.reloc
[m
].n
),
4092 &the_ins
.reloc
[m
].exp
,
4093 the_ins
.reloc
[m
].pcrel
,
4094 get_reloc_code (wid
, the_ins
.reloc
[m
].pcrel
,
4095 the_ins
.reloc
[m
].pic_reloc
));
4096 fixP
->fx_pcrel_adjust
= the_ins
.reloc
[m
].pcrel_fix
;
4098 (void) frag_var (rs_machine_dependent
, 10, 0,
4099 (relax_substateT
) (the_ins
.fragb
[n
].fragty
),
4100 the_ins
.fragb
[n
].fadd
, the_ins
.fragb
[n
].foff
, to_beg_P
);
4102 n
= (the_ins
.numo
- the_ins
.fragb
[n
- 1].fragoff
);
4103 shorts_this_frag
= 0;
4106 toP
= frag_more (n
* 2);
4109 md_number_to_chars (toP
, (long) (*fromP
), 2);
4115 for (m
= 0; m
< the_ins
.nrel
; m
++)
4119 wid
= the_ins
.reloc
[m
].wid
;
4122 the_ins
.reloc
[m
].wid
= 0;
4123 wid
= (wid
== 'b') ? 1 : (wid
== 'w') ? 2 : (wid
== 'l') ? 4 : 4000;
4125 fixP
= fix_new_exp (frag_now
,
4126 ((the_ins
.reloc
[m
].n
+ toP
- frag_now
->fr_literal
)
4127 - shorts_this_frag
* 2),
4129 &the_ins
.reloc
[m
].exp
,
4130 the_ins
.reloc
[m
].pcrel
,
4131 get_reloc_code (wid
, the_ins
.reloc
[m
].pcrel
,
4132 the_ins
.reloc
[m
].pic_reloc
));
4133 fixP
->fx_pcrel_adjust
= the_ins
.reloc
[m
].pcrel_fix
;
4137 /* Comparison function used by qsort to rank the opcode entries by name. */
4140 m68k_compare_opcode (const void * v1
, const void * v2
)
4142 struct m68k_opcode
* op1
, * op2
;
4148 op1
= *(struct m68k_opcode
**) v1
;
4149 op2
= *(struct m68k_opcode
**) v2
;
4151 /* Compare the two names. If different, return the comparison.
4152 If the same, return the order they are in the opcode table. */
4153 ret
= strcmp (op1
->name
, op2
->name
);
4164 const struct m68k_opcode
*ins
;
4165 struct m68k_incant
*hack
, *slak
;
4166 const char *retval
= 0; /* Empty string, or error msg text. */
4169 /* Set up hash tables with 68000 instructions.
4170 similar to what the vax assembler does. */
4171 /* RMS claims the thing to do is take the m68k-opcode.h table, and make
4172 a copy of it at runtime, adding in the information we want but isn't
4173 there. I think it'd be better to have an awk script hack the table
4174 at compile time. Or even just xstr the table and use it as-is. But
4175 my lord ghod hath spoken, so we do it this way. Excuse the ugly var
4180 flag_reg_prefix_optional
= 1;
4182 if (! m68k_rel32_from_cmdline
)
4186 /* First sort the opcode table into alphabetical order to seperate
4187 the order that the assembler wants to see the opcodes from the
4188 order that the disassembler wants to see them. */
4189 m68k_sorted_opcodes
= xmalloc (m68k_numopcodes
* sizeof (* m68k_sorted_opcodes
));
4190 if (!m68k_sorted_opcodes
)
4191 as_fatal (_("Internal Error: Can't allocate m68k_sorted_opcodes of size %d"),
4192 m68k_numopcodes
* ((int) sizeof (* m68k_sorted_opcodes
)));
4194 for (i
= m68k_numopcodes
; i
--;)
4195 m68k_sorted_opcodes
[i
] = m68k_opcodes
+ i
;
4197 qsort (m68k_sorted_opcodes
, m68k_numopcodes
,
4198 sizeof (m68k_sorted_opcodes
[0]), m68k_compare_opcode
);
4200 op_hash
= hash_new ();
4202 obstack_begin (&robyn
, 4000);
4203 for (i
= 0; i
< m68k_numopcodes
; i
++)
4205 hack
= slak
= (struct m68k_incant
*) obstack_alloc (&robyn
, sizeof (struct m68k_incant
));
4208 ins
= m68k_sorted_opcodes
[i
];
4210 /* We *could* ignore insns that don't match our
4211 arch here by just leaving them out of the hash. */
4212 slak
->m_operands
= ins
->args
;
4213 slak
->m_opnum
= strlen (slak
->m_operands
) / 2;
4214 slak
->m_arch
= ins
->arch
;
4215 slak
->m_opcode
= ins
->opcode
;
4216 /* This is kludgey. */
4217 slak
->m_codenum
= ((ins
->match
) & 0xffffL
) ? 2 : 1;
4218 if (i
+ 1 != m68k_numopcodes
4219 && !strcmp (ins
->name
, m68k_sorted_opcodes
[i
+ 1]->name
))
4221 slak
->m_next
= obstack_alloc (&robyn
, sizeof (struct m68k_incant
));
4226 slak
= slak
->m_next
;
4230 retval
= hash_insert (op_hash
, ins
->name
, (char *) hack
);
4232 as_fatal (_("Internal Error: Can't hash %s: %s"), ins
->name
, retval
);
4235 for (i
= 0; i
< m68k_numaliases
; i
++)
4237 const char *name
= m68k_opcode_aliases
[i
].primary
;
4238 const char *alias
= m68k_opcode_aliases
[i
].alias
;
4239 PTR val
= hash_find (op_hash
, name
);
4242 as_fatal (_("Internal Error: Can't find %s in hash table"), name
);
4243 retval
= hash_insert (op_hash
, alias
, val
);
4245 as_fatal (_("Internal Error: Can't hash %s: %s"), alias
, retval
);
4248 /* In MRI mode, all unsized branches are variable sized. Normally,
4249 they are word sized. */
4252 static struct m68k_opcode_alias mri_aliases
[] =
4273 i
< (int) (sizeof mri_aliases
/ sizeof mri_aliases
[0]);
4276 const char *name
= mri_aliases
[i
].primary
;
4277 const char *alias
= mri_aliases
[i
].alias
;
4278 PTR val
= hash_find (op_hash
, name
);
4281 as_fatal (_("Internal Error: Can't find %s in hash table"), name
);
4282 retval
= hash_jam (op_hash
, alias
, val
);
4284 as_fatal (_("Internal Error: Can't hash %s: %s"), alias
, retval
);
4288 for (i
= 0; i
< (int) sizeof (notend_table
); i
++)
4290 notend_table
[i
] = 0;
4291 alt_notend_table
[i
] = 0;
4294 notend_table
[','] = 1;
4295 notend_table
['{'] = 1;
4296 notend_table
['}'] = 1;
4297 alt_notend_table
['a'] = 1;
4298 alt_notend_table
['A'] = 1;
4299 alt_notend_table
['d'] = 1;
4300 alt_notend_table
['D'] = 1;
4301 alt_notend_table
['#'] = 1;
4302 alt_notend_table
['&'] = 1;
4303 alt_notend_table
['f'] = 1;
4304 alt_notend_table
['F'] = 1;
4305 #ifdef REGISTER_PREFIX
4306 alt_notend_table
[REGISTER_PREFIX
] = 1;
4309 /* We need to put '(' in alt_notend_table to handle
4310 cas2 %d0:%d2,%d3:%d4,(%a0):(%a1) */
4311 alt_notend_table
['('] = 1;
4313 /* We need to put '@' in alt_notend_table to handle
4314 cas2 %d0:%d2,%d3:%d4,@(%d0):@(%d1) */
4315 alt_notend_table
['@'] = 1;
4317 /* We need to put digits in alt_notend_table to handle
4318 bfextu %d0{24:1},%d0 */
4319 alt_notend_table
['0'] = 1;
4320 alt_notend_table
['1'] = 1;
4321 alt_notend_table
['2'] = 1;
4322 alt_notend_table
['3'] = 1;
4323 alt_notend_table
['4'] = 1;
4324 alt_notend_table
['5'] = 1;
4325 alt_notend_table
['6'] = 1;
4326 alt_notend_table
['7'] = 1;
4327 alt_notend_table
['8'] = 1;
4328 alt_notend_table
['9'] = 1;
4330 #ifndef MIT_SYNTAX_ONLY
4331 /* Insert pseudo ops, these have to go into the opcode table since
4332 gas expects pseudo ops to start with a dot. */
4336 while (mote_pseudo_table
[n
].poc_name
)
4338 hack
= obstack_alloc (&robyn
, sizeof (struct m68k_incant
));
4339 hash_insert (op_hash
,
4340 mote_pseudo_table
[n
].poc_name
, (char *) hack
);
4341 hack
->m_operands
= 0;
4351 record_alignment (text_section
, 2);
4352 record_alignment (data_section
, 2);
4353 record_alignment (bss_section
, 2);
4358 /* This is called when a label is defined. */
4361 m68k_frob_label (symbolS
*sym
)
4363 struct label_line
*n
;
4365 n
= (struct label_line
*) xmalloc (sizeof *n
);
4368 as_where (&n
->file
, &n
->line
);
4374 dwarf2_emit_label (sym
);
4378 /* This is called when a value that is not an instruction is emitted. */
4381 m68k_flush_pending_output (void)
4383 current_label
= NULL
;
4386 /* This is called at the end of the assembly, when the final value of
4387 the label is known. We warn if this is a text symbol aligned at an
4391 m68k_frob_symbol (symbolS
*sym
)
4393 if (S_GET_SEGMENT (sym
) == reg_section
4394 && (int) S_GET_VALUE (sym
) < 0)
4396 S_SET_SEGMENT (sym
, absolute_section
);
4397 S_SET_VALUE (sym
, ~(int)S_GET_VALUE (sym
));
4399 else if ((S_GET_VALUE (sym
) & 1) != 0)
4401 struct label_line
*l
;
4403 for (l
= labels
; l
!= NULL
; l
= l
->next
)
4405 if (l
->label
== sym
)
4408 as_warn_where (l
->file
, l
->line
,
4409 _("text label `%s' aligned to odd boundary"),
4417 /* This is called if we go in or out of MRI mode because of the .mri
4421 m68k_mri_mode_change (int on
)
4425 if (! flag_reg_prefix_optional
)
4427 flag_reg_prefix_optional
= 1;
4428 #ifdef REGISTER_PREFIX
4433 if (! m68k_rel32_from_cmdline
)
4438 if (! reg_prefix_optional_seen
)
4440 #ifdef REGISTER_PREFIX_OPTIONAL
4441 flag_reg_prefix_optional
= REGISTER_PREFIX_OPTIONAL
;
4443 flag_reg_prefix_optional
= 0;
4445 #ifdef REGISTER_PREFIX
4450 if (! m68k_rel32_from_cmdline
)
4455 /* Equal to MAX_PRECISION in atof-ieee.c. */
4456 #define MAX_LITTLENUMS 6
4458 /* Turn a string in input_line_pointer into a floating point constant
4459 of type TYPE, and store the appropriate bytes in *LITP. The number
4460 of LITTLENUMS emitted is stored in *SIZEP. An error message is
4461 returned, or NULL on OK. */
4464 md_atof (int type
, char *litP
, int *sizeP
)
4467 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
4468 LITTLENUM_TYPE
*wordP
;
4499 return _("Bad call to MD_ATOF()");
4501 t
= atof_ieee (input_line_pointer
, type
, words
);
4503 input_line_pointer
= t
;
4505 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
4506 for (wordP
= words
; prec
--;)
4508 md_number_to_chars (litP
, (long) (*wordP
++), sizeof (LITTLENUM_TYPE
));
4509 litP
+= sizeof (LITTLENUM_TYPE
);
4515 md_number_to_chars (char *buf
, valueT val
, int n
)
4517 number_to_chars_bigendian (buf
, val
, n
);
4521 md_apply_fix (fixS
*fixP
, valueT
*valP
, segT seg ATTRIBUTE_UNUSED
)
4523 offsetT val
= *valP
;
4524 addressT upper_limit
;
4525 offsetT lower_limit
;
4527 /* This is unnecessary but it convinces the native rs6000 compiler
4528 to generate the code we want. */
4529 char *buf
= fixP
->fx_frag
->fr_literal
;
4530 buf
+= fixP
->fx_where
;
4531 /* End ibm compiler workaround. */
4535 if (fixP
->fx_addsy
== NULL
&& fixP
->fx_pcrel
== 0)
4541 memset (buf
, 0, fixP
->fx_size
);
4542 fixP
->fx_addnumber
= val
; /* Remember value for emit_reloc. */
4544 if (fixP
->fx_r_type
== BFD_RELOC_VTABLE_INHERIT
4545 && !S_IS_DEFINED (fixP
->fx_addsy
)
4546 && !S_IS_WEAK (fixP
->fx_addsy
))
4547 S_SET_WEAK (fixP
->fx_addsy
);
4552 if (fixP
->fx_r_type
== BFD_RELOC_VTABLE_INHERIT
4553 || fixP
->fx_r_type
== BFD_RELOC_VTABLE_ENTRY
)
4556 switch (fixP
->fx_size
)
4558 /* The cast to offsetT below are necessary to make code
4559 correct for machines where ints are smaller than offsetT. */
4563 lower_limit
= - (offsetT
) 0x80;
4566 *buf
++ = (val
>> 8);
4568 upper_limit
= 0x7fff;
4569 lower_limit
= - (offsetT
) 0x8000;
4572 *buf
++ = (val
>> 24);
4573 *buf
++ = (val
>> 16);
4574 *buf
++ = (val
>> 8);
4576 upper_limit
= 0x7fffffff;
4577 lower_limit
= - (offsetT
) 0x7fffffff - 1; /* Avoid constant overflow. */
4580 BAD_CASE (fixP
->fx_size
);
4583 /* Fix up a negative reloc. */
4584 if (fixP
->fx_addsy
== NULL
&& fixP
->fx_subsy
!= NULL
)
4586 fixP
->fx_addsy
= fixP
->fx_subsy
;
4587 fixP
->fx_subsy
= NULL
;
4591 /* For non-pc-relative values, it's conceivable we might get something
4592 like "0xff" for a byte field. So extend the upper part of the range
4593 to accept such numbers. We arbitrarily disallow "-0xff" or "0xff+0xff",
4594 so that we can do any range checking at all. */
4595 if (! fixP
->fx_pcrel
&& ! fixP
->fx_signed
)
4596 upper_limit
= upper_limit
* 2 + 1;
4598 if ((addressT
) val
> upper_limit
4599 && (val
> 0 || val
< lower_limit
))
4600 as_bad_where (fixP
->fx_file
, fixP
->fx_line
, _("value out of range"));
4602 /* A one byte PC-relative reloc means a short branch. We can't use
4603 a short branch with a value of 0 or -1, because those indicate
4604 different opcodes (branches with longer offsets). fixup_segment
4605 in write.c may have clobbered fx_pcrel, so we need to examine the
4608 || fixP
->fx_r_type
== BFD_RELOC_8_PCREL
)
4609 && fixP
->fx_size
== 1
4610 && (fixP
->fx_addsy
== NULL
4611 || S_IS_DEFINED (fixP
->fx_addsy
))
4612 && (val
== 0 || val
== -1))
4613 as_bad_where (fixP
->fx_file
, fixP
->fx_line
, _("invalid byte branch offset"));
4616 /* *fragP has been relaxed to its final size, and now needs to have
4617 the bytes inside it modified to conform to the new size There is UGLY
4621 md_convert_frag_1 (fragS
*fragP
)
4626 /* Address in object code of the displacement. */
4627 register int object_address
= fragP
->fr_fix
+ fragP
->fr_address
;
4629 /* Address in gas core of the place to store the displacement. */
4630 /* This convinces the native rs6000 compiler to generate the code we
4632 register char *buffer_address
= fragP
->fr_literal
;
4633 buffer_address
+= fragP
->fr_fix
;
4634 /* End ibm compiler workaround. */
4636 /* The displacement of the address, from current location. */
4637 disp
= fragP
->fr_symbol
? S_GET_VALUE (fragP
->fr_symbol
) : 0;
4638 disp
= (disp
+ fragP
->fr_offset
) - object_address
;
4640 switch (fragP
->fr_subtype
)
4642 case TAB (BRANCHBWL
, BYTE
):
4643 case TAB (BRABSJUNC
, BYTE
):
4644 case TAB (BRABSJCOND
, BYTE
):
4645 case TAB (BRANCHBW
, BYTE
):
4646 know (issbyte (disp
));
4648 as_bad_where (fragP
->fr_file
, fragP
->fr_line
,
4649 _("short branch with zero offset: use :w"));
4650 fixP
= fix_new (fragP
, fragP
->fr_fix
- 1, 1, fragP
->fr_symbol
,
4651 fragP
->fr_offset
, 1, RELAX_RELOC_PC8
);
4652 fixP
->fx_pcrel_adjust
= -1;
4654 case TAB (BRANCHBWL
, SHORT
):
4655 case TAB (BRABSJUNC
, SHORT
):
4656 case TAB (BRABSJCOND
, SHORT
):
4657 case TAB (BRANCHBW
, SHORT
):
4658 fragP
->fr_opcode
[1] = 0x00;
4659 fix_new (fragP
, fragP
->fr_fix
, 2, fragP
->fr_symbol
, fragP
->fr_offset
,
4660 1, RELAX_RELOC_PC16
);
4663 case TAB (BRANCHBWL
, LONG
):
4664 fragP
->fr_opcode
[1] = (char) 0xFF;
4665 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4666 1, RELAX_RELOC_PC32
);
4669 case TAB (BRABSJUNC
, LONG
):
4670 if (fragP
->fr_opcode
[0] == 0x61) /* jbsr */
4672 if (flag_keep_pcrel
)
4673 as_fatal (_("Tried to convert PC relative BSR to absolute JSR"));
4674 fragP
->fr_opcode
[0] = 0x4E;
4675 fragP
->fr_opcode
[1] = (char) 0xB9; /* JSR with ABSL LONG operand. */
4676 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4677 0, RELAX_RELOC_ABS32
);
4680 else if (fragP
->fr_opcode
[0] == 0x60) /* jbra */
4682 if (flag_keep_pcrel
)
4683 as_fatal (_("Tried to convert PC relative branch to absolute jump"));
4684 fragP
->fr_opcode
[0] = 0x4E;
4685 fragP
->fr_opcode
[1] = (char) 0xF9; /* JMP with ABSL LONG operand. */
4686 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4687 0, RELAX_RELOC_ABS32
);
4692 /* This cannot happen, because jbsr and jbra are the only two
4693 unconditional branches. */
4697 case TAB (BRABSJCOND
, LONG
):
4698 if (flag_keep_pcrel
)
4699 as_fatal (_("Tried to convert PC relative conditional branch to absolute jump"));
4701 /* Only Bcc 68000 instructions can come here
4702 Change bcc into b!cc/jmp absl long. */
4703 fragP
->fr_opcode
[0] ^= 0x01; /* Invert bcc. */
4704 fragP
->fr_opcode
[1] = 0x06; /* Branch offset = 6. */
4706 /* JF: these used to be fr_opcode[2,3], but they may be in a
4707 different frag, in which case referring to them is a no-no.
4708 Only fr_opcode[0,1] are guaranteed to work. */
4709 *buffer_address
++ = 0x4e; /* put in jmp long (0x4ef9) */
4710 *buffer_address
++ = (char) 0xf9;
4711 fragP
->fr_fix
+= 2; /* Account for jmp instruction. */
4712 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
,
4713 fragP
->fr_offset
, 0, RELAX_RELOC_ABS32
);
4716 case TAB (FBRANCH
, SHORT
):
4717 know ((fragP
->fr_opcode
[1] & 0x40) == 0);
4718 fix_new (fragP
, fragP
->fr_fix
, 2, fragP
->fr_symbol
, fragP
->fr_offset
,
4719 1, RELAX_RELOC_PC16
);
4722 case TAB (FBRANCH
, LONG
):
4723 fragP
->fr_opcode
[1] |= 0x40; /* Turn on LONG bit. */
4724 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4725 1, RELAX_RELOC_PC32
);
4728 case TAB (DBCCLBR
, SHORT
):
4729 case TAB (DBCCABSJ
, SHORT
):
4730 fix_new (fragP
, fragP
->fr_fix
, 2, fragP
->fr_symbol
, fragP
->fr_offset
,
4731 1, RELAX_RELOC_PC16
);
4734 case TAB (DBCCLBR
, LONG
):
4735 /* Only DBcc instructions can come here.
4736 Change dbcc into dbcc/bral.
4737 JF: these used to be fr_opcode[2-7], but that's wrong. */
4738 if (flag_keep_pcrel
)
4739 as_fatal (_("Tried to convert DBcc to absolute jump"));
4741 *buffer_address
++ = 0x00; /* Branch offset = 4. */
4742 *buffer_address
++ = 0x04;
4743 *buffer_address
++ = 0x60; /* Put in bra pc+6. */
4744 *buffer_address
++ = 0x06;
4745 *buffer_address
++ = 0x60; /* Put in bral (0x60ff). */
4746 *buffer_address
++ = (char) 0xff;
4748 fragP
->fr_fix
+= 6; /* Account for bra/jmp instructions. */
4749 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
, 1,
4753 case TAB (DBCCABSJ
, LONG
):
4754 /* Only DBcc instructions can come here.
4755 Change dbcc into dbcc/jmp.
4756 JF: these used to be fr_opcode[2-7], but that's wrong. */
4757 if (flag_keep_pcrel
)
4758 as_fatal (_("Tried to convert PC relative conditional branch to absolute jump"));
4760 *buffer_address
++ = 0x00; /* Branch offset = 4. */
4761 *buffer_address
++ = 0x04;
4762 *buffer_address
++ = 0x60; /* Put in bra pc + 6. */
4763 *buffer_address
++ = 0x06;
4764 *buffer_address
++ = 0x4e; /* Put in jmp long (0x4ef9). */
4765 *buffer_address
++ = (char) 0xf9;
4767 fragP
->fr_fix
+= 6; /* Account for bra/jmp instructions. */
4768 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
, 0,
4772 case TAB (PCREL1632
, SHORT
):
4773 fragP
->fr_opcode
[1] &= ~0x3F;
4774 fragP
->fr_opcode
[1] |= 0x3A; /* 072 - mode 7.2 */
4775 fix_new (fragP
, (int) (fragP
->fr_fix
), 2, fragP
->fr_symbol
,
4776 fragP
->fr_offset
, 1, RELAX_RELOC_PC16
);
4779 case TAB (PCREL1632
, LONG
):
4780 /* Already set to mode 7.3; this indicates: PC indirect with
4781 suppressed index, 32-bit displacement. */
4782 *buffer_address
++ = 0x01;
4783 *buffer_address
++ = 0x70;
4785 fixP
= fix_new (fragP
, (int) (fragP
->fr_fix
), 4, fragP
->fr_symbol
,
4786 fragP
->fr_offset
, 1, RELAX_RELOC_PC32
);
4787 fixP
->fx_pcrel_adjust
= 2;
4790 case TAB (PCINDEX
, BYTE
):
4791 assert (fragP
->fr_fix
>= 2);
4792 buffer_address
[-2] &= ~1;
4793 fixP
= fix_new (fragP
, fragP
->fr_fix
- 1, 1, fragP
->fr_symbol
,
4794 fragP
->fr_offset
, 1, RELAX_RELOC_PC8
);
4795 fixP
->fx_pcrel_adjust
= 1;
4797 case TAB (PCINDEX
, SHORT
):
4798 assert (fragP
->fr_fix
>= 2);
4799 buffer_address
[-2] |= 0x1;
4800 buffer_address
[-1] = 0x20;
4801 fixP
= fix_new (fragP
, (int) (fragP
->fr_fix
), 2, fragP
->fr_symbol
,
4802 fragP
->fr_offset
, 1, RELAX_RELOC_PC16
);
4803 fixP
->fx_pcrel_adjust
= 2;
4806 case TAB (PCINDEX
, LONG
):
4807 assert (fragP
->fr_fix
>= 2);
4808 buffer_address
[-2] |= 0x1;
4809 buffer_address
[-1] = 0x30;
4810 fixP
= fix_new (fragP
, (int) (fragP
->fr_fix
), 4, fragP
->fr_symbol
,
4811 fragP
->fr_offset
, 1, RELAX_RELOC_PC32
);
4812 fixP
->fx_pcrel_adjust
= 2;
4815 case TAB (ABSTOPCREL
, SHORT
):
4816 fix_new (fragP
, fragP
->fr_fix
, 2, fragP
->fr_symbol
, fragP
->fr_offset
,
4817 1, RELAX_RELOC_PC16
);
4820 case TAB (ABSTOPCREL
, LONG
):
4821 if (flag_keep_pcrel
)
4822 as_fatal (_("Tried to convert PC relative conditional branch to absolute jump"));
4823 /* The thing to do here is force it to ABSOLUTE LONG, since
4824 ABSTOPCREL is really trying to shorten an ABSOLUTE address anyway. */
4825 if ((fragP
->fr_opcode
[1] & 0x3F) != 0x3A)
4827 fragP
->fr_opcode
[1] &= ~0x3F;
4828 fragP
->fr_opcode
[1] |= 0x39; /* Mode 7.1 */
4829 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4830 0, RELAX_RELOC_ABS32
);
4837 md_convert_frag (bfd
*abfd ATTRIBUTE_UNUSED
,
4838 segT sec ATTRIBUTE_UNUSED
,
4841 md_convert_frag_1 (fragP
);
4844 /* Force truly undefined symbols to their maximum size, and generally set up
4845 the frag list to be relaxed
4848 md_estimate_size_before_relax (fragS
*fragP
, segT segment
)
4850 /* Handle SZ_UNDEF first, it can be changed to BYTE or SHORT. */
4851 switch (fragP
->fr_subtype
)
4853 case TAB (BRANCHBWL
, SZ_UNDEF
):
4854 case TAB (BRABSJUNC
, SZ_UNDEF
):
4855 case TAB (BRABSJCOND
, SZ_UNDEF
):
4857 if (S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4858 && relaxable_symbol (fragP
->fr_symbol
))
4860 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), BYTE
);
4862 else if (flag_short_refs
)
4864 /* Symbol is undefined and we want short ref. */
4865 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), SHORT
);
4869 /* Symbol is still undefined. Make it LONG. */
4870 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), LONG
);
4875 case TAB (BRANCHBW
, SZ_UNDEF
):
4877 if (S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4878 && relaxable_symbol (fragP
->fr_symbol
))
4880 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), BYTE
);
4884 /* Symbol is undefined and we don't have long branches. */
4885 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), SHORT
);
4890 case TAB (FBRANCH
, SZ_UNDEF
):
4891 case TAB (DBCCLBR
, SZ_UNDEF
):
4892 case TAB (DBCCABSJ
, SZ_UNDEF
):
4893 case TAB (PCREL1632
, SZ_UNDEF
):
4895 if ((S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4896 && relaxable_symbol (fragP
->fr_symbol
))
4899 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), SHORT
);
4903 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), LONG
);
4908 case TAB (PCINDEX
, SZ_UNDEF
):
4909 if ((S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4910 && relaxable_symbol (fragP
->fr_symbol
)))
4912 fragP
->fr_subtype
= TAB (PCINDEX
, BYTE
);
4916 fragP
->fr_subtype
= TAB (PCINDEX
, LONG
);
4920 case TAB (ABSTOPCREL
, SZ_UNDEF
):
4922 if ((S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4923 && relaxable_symbol (fragP
->fr_symbol
)))
4925 fragP
->fr_subtype
= TAB (ABSTOPCREL
, SHORT
);
4929 fragP
->fr_subtype
= TAB (ABSTOPCREL
, LONG
);
4938 /* Now that SZ_UNDEF are taken care of, check others. */
4939 switch (fragP
->fr_subtype
)
4941 case TAB (BRANCHBWL
, BYTE
):
4942 case TAB (BRABSJUNC
, BYTE
):
4943 case TAB (BRABSJCOND
, BYTE
):
4944 case TAB (BRANCHBW
, BYTE
):
4945 /* We can't do a short jump to the next instruction, so in that
4946 case we force word mode. If the symbol is at the start of a
4947 frag, and it is the next frag with any data in it (usually
4948 this is just the next frag, but assembler listings may
4949 introduce empty frags), we must use word mode. */
4950 if (fragP
->fr_symbol
)
4954 sym_frag
= symbol_get_frag (fragP
->fr_symbol
);
4955 if (S_GET_VALUE (fragP
->fr_symbol
) == sym_frag
->fr_address
)
4959 for (l
= fragP
->fr_next
; l
&& l
!= sym_frag
; l
= l
->fr_next
)
4963 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), SHORT
);
4970 return md_relax_table
[fragP
->fr_subtype
].rlx_length
;
4973 #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
4974 /* the bit-field entries in the relocation_info struct plays hell
4975 with the byte-order problems of cross-assembly. So as a hack,
4976 I added this mach. dependent ri twiddler. Ugly, but it gets
4978 /* on m68k: first 4 bytes are normal unsigned long, next three bytes
4979 are symbolnum, most sig. byte first. Last byte is broken up with
4980 bit 7 as pcrel, bits 6 & 5 as length, bit 4 as pcrel, and the lower
4981 nibble as nuthin. (on Sun 3 at least) */
4982 /* Translate the internal relocation information into target-specific
4986 md_ri_to_chars (char *the_bytes
, struct reloc_info_generic
*ri
)
4989 md_number_to_chars (the_bytes
, ri
->r_address
, 4);
4990 /* Now the fun stuff. */
4991 the_bytes
[4] = (ri
->r_symbolnum
>> 16) & 0x0ff;
4992 the_bytes
[5] = (ri
->r_symbolnum
>> 8) & 0x0ff;
4993 the_bytes
[6] = ri
->r_symbolnum
& 0x0ff;
4994 the_bytes
[7] = (((ri
->r_pcrel
<< 7) & 0x80)
4995 | ((ri
->r_length
<< 5) & 0x60)
4996 | ((ri
->r_extern
<< 4) & 0x10));
5001 #endif /* OBJ_AOUT or OBJ_BOUT */
5003 #ifndef WORKING_DOT_WORD
5004 int md_short_jump_size
= 4;
5005 int md_long_jump_size
= 6;
5008 md_create_short_jump (char *ptr
, addressT from_addr
, addressT to_addr
,
5009 fragS
*frag ATTRIBUTE_UNUSED
,
5010 symbolS
*to_symbol ATTRIBUTE_UNUSED
)
5014 offset
= to_addr
- (from_addr
+ 2);
5016 md_number_to_chars (ptr
, (valueT
) 0x6000, 2);
5017 md_number_to_chars (ptr
+ 2, (valueT
) offset
, 2);
5021 md_create_long_jump (char *ptr
, addressT from_addr
, addressT to_addr
,
5022 fragS
*frag
, symbolS
*to_symbol
)
5026 if (!HAVE_LONG_BRANCH (current_architecture
))
5028 if (flag_keep_pcrel
)
5029 as_fatal (_("Tried to convert PC relative branch to absolute jump"));
5030 offset
= to_addr
- S_GET_VALUE (to_symbol
);
5031 md_number_to_chars (ptr
, (valueT
) 0x4EF9, 2);
5032 md_number_to_chars (ptr
+ 2, (valueT
) offset
, 4);
5033 fix_new (frag
, (ptr
+ 2) - frag
->fr_literal
, 4, to_symbol
, (offsetT
) 0,
5038 offset
= to_addr
- (from_addr
+ 2);
5039 md_number_to_chars (ptr
, (valueT
) 0x60ff, 2);
5040 md_number_to_chars (ptr
+ 2, (valueT
) offset
, 4);
5046 /* Different values of OK tell what its OK to return. Things that
5047 aren't OK are an error (what a shock, no?)
5050 10: Absolute 1:8 only
5051 20: Absolute 0:7 only
5052 30: absolute 0:15 only
5053 40: Absolute 0:31 only
5054 50: absolute 0:127 only
5055 55: absolute -64:63 only
5056 60: absolute -128:127 only
5057 70: absolute 0:4095 only
5058 80: absolute -1, 1:7 only
5062 get_num (struct m68k_exp
*exp
, int ok
)
5064 if (exp
->exp
.X_op
== O_absent
)
5066 /* Do the same thing the VAX asm does. */
5067 op (exp
) = O_constant
;
5073 as_warn (_("expression out of range: defaulting to 1"));
5077 else if (exp
->exp
.X_op
== O_constant
)
5082 if ((valueT
) TRUNC (offs (exp
)) - 1 > 7)
5084 as_warn (_("expression out of range: defaulting to 1"));
5089 if ((valueT
) TRUNC (offs (exp
)) > 7)
5093 if ((valueT
) TRUNC (offs (exp
)) > 15)
5097 if ((valueT
) TRUNC (offs (exp
)) > 32)
5101 if ((valueT
) TRUNC (offs (exp
)) > 127)
5105 if ((valueT
) SEXT (offs (exp
)) + 64 > 127)
5109 if ((valueT
) SEXT (offs (exp
)) + 128 > 255)
5113 if ((valueT
) TRUNC (offs (exp
)) > 4095)
5116 as_warn (_("expression out of range: defaulting to 0"));
5121 if ((valueT
) TRUNC (offs (exp
)) != 0xffffffff
5122 && (valueT
) TRUNC (offs (exp
)) - 1 > 6)
5124 as_warn (_("expression out of range: defaulting to 1"));
5132 else if (exp
->exp
.X_op
== O_big
)
5134 if (offs (exp
) <= 0 /* flonum. */
5135 && (ok
== 90 /* no bignums */
5136 || (ok
> 10 /* Small-int ranges including 0 ok. */
5137 /* If we have a flonum zero, a zero integer should
5138 do as well (e.g., in moveq). */
5139 && generic_floating_point_number
.exponent
== 0
5140 && generic_floating_point_number
.low
[0] == 0)))
5142 /* HACK! Turn it into a long. */
5143 LITTLENUM_TYPE words
[6];
5145 gen_to_words (words
, 2, 8L); /* These numbers are magic! */
5146 op (exp
) = O_constant
;
5149 offs (exp
) = words
[1] | (words
[0] << 16);
5153 op (exp
) = O_constant
;
5156 offs (exp
) = (ok
== 10) ? 1 : 0;
5157 as_warn (_("Can't deal with expression; defaulting to %ld"),
5163 if (ok
>= 10 && ok
<= 80)
5165 op (exp
) = O_constant
;
5168 offs (exp
) = (ok
== 10) ? 1 : 0;
5169 as_warn (_("Can't deal with expression; defaulting to %ld"),
5174 if (exp
->size
!= SIZE_UNSPEC
)
5182 if (!isbyte (offs (exp
)))
5183 as_warn (_("expression doesn't fit in BYTE"));
5186 if (!isword (offs (exp
)))
5187 as_warn (_("expression doesn't fit in WORD"));
5195 /* These are the back-ends for the various machine dependent pseudo-ops. */
5198 s_data1 (int ignore ATTRIBUTE_UNUSED
)
5200 subseg_set (data_section
, 1);
5201 demand_empty_rest_of_line ();
5205 s_data2 (int ignore ATTRIBUTE_UNUSED
)
5207 subseg_set (data_section
, 2);
5208 demand_empty_rest_of_line ();
5212 s_bss (int ignore ATTRIBUTE_UNUSED
)
5214 /* We don't support putting frags in the BSS segment, we fake it
5215 by marking in_bss, then looking at s_skip for clues. */
5217 subseg_set (bss_section
, 0);
5218 demand_empty_rest_of_line ();
5222 s_even (int ignore ATTRIBUTE_UNUSED
)
5225 register long temp_fill
;
5227 temp
= 1; /* JF should be 2? */
5228 temp_fill
= get_absolute_expression ();
5229 if (!need_pass_2
) /* Never make frag if expect extra pass. */
5230 frag_align (temp
, (int) temp_fill
, 0);
5231 demand_empty_rest_of_line ();
5232 record_alignment (now_seg
, temp
);
5236 s_proc (int ignore ATTRIBUTE_UNUSED
)
5238 demand_empty_rest_of_line ();
5241 /* Pseudo-ops handled for MRI compatibility. */
5243 /* This function returns non-zero if the argument is a conditional
5244 pseudo-op. This is called when checking whether a pending
5245 alignment is needed. */
5248 m68k_conditional_pseudoop (pseudo_typeS
*pop
)
5250 return (pop
->poc_handler
== s_mri_if
5251 || pop
->poc_handler
== s_mri_else
);
5254 /* Handle an MRI style chip specification. */
5263 s
= input_line_pointer
;
5264 /* We can't use get_symbol_end since the processor names are not proper
5266 while (is_part_of_name (c
= *input_line_pointer
++))
5268 *--input_line_pointer
= 0;
5269 for (i
= 0; m68k_cpus
[i
].name
; i
++)
5270 if (strcasecmp (s
, m68k_cpus
[i
].name
) == 0)
5272 if (!m68k_cpus
[i
].name
)
5274 as_bad (_("%s: unrecognized processor name"), s
);
5275 *input_line_pointer
= c
;
5276 ignore_rest_of_line ();
5279 *input_line_pointer
= c
;
5281 if (*input_line_pointer
== '/')
5282 current_architecture
= 0;
5284 current_architecture
&= m68881
| m68851
;
5285 current_architecture
|= m68k_cpus
[i
].arch
& ~(m68881
| m68851
);
5286 control_regs
= m68k_cpus
[i
].control_regs
;
5288 while (*input_line_pointer
== '/')
5290 ++input_line_pointer
;
5291 s
= input_line_pointer
;
5292 /* We can't use get_symbol_end since the processor names are not
5294 while (is_part_of_name (c
= *input_line_pointer
++))
5296 *--input_line_pointer
= 0;
5297 if (strcmp (s
, "68881") == 0)
5298 current_architecture
|= m68881
;
5299 else if (strcmp (s
, "68851") == 0)
5300 current_architecture
|= m68851
;
5301 *input_line_pointer
= c
;
5305 /* The MRI CHIP pseudo-op. */
5308 s_chip (int ignore ATTRIBUTE_UNUSED
)
5314 stop
= mri_comment_field (&stopc
);
5317 mri_comment_end (stop
, stopc
);
5318 demand_empty_rest_of_line ();
5321 /* The MRI FOPT pseudo-op. */
5324 s_fopt (int ignore ATTRIBUTE_UNUSED
)
5328 if (strncasecmp (input_line_pointer
, "ID=", 3) == 0)
5332 input_line_pointer
+= 3;
5333 temp
= get_absolute_expression ();
5334 if (temp
< 0 || temp
> 7)
5335 as_bad (_("bad coprocessor id"));
5337 m68k_float_copnum
= COP0
+ temp
;
5341 as_bad (_("unrecognized fopt option"));
5342 ignore_rest_of_line ();
5346 demand_empty_rest_of_line ();
5349 /* The structure used to handle the MRI OPT pseudo-op. */
5353 /* The name of the option. */
5356 /* If this is not NULL, just call this function. The first argument
5357 is the ARG field of this structure, the second argument is
5358 whether the option was negated. */
5359 void (*pfn
) (int arg
, int on
);
5361 /* If this is not NULL, and the PFN field is NULL, set the variable
5362 this points to. Set it to the ARG field if the option was not
5363 negated, and the NOTARG field otherwise. */
5366 /* The value to pass to PFN or to assign to *PVAR. */
5369 /* The value to assign to *PVAR if the option is negated. If PFN is
5370 NULL, and PVAR is not NULL, and ARG and NOTARG are the same, then
5371 the option may not be negated. */
5375 /* The table used to handle the MRI OPT pseudo-op. */
5377 static void skip_to_comma (int, int);
5378 static void opt_nest (int, int);
5379 static void opt_chip (int, int);
5380 static void opt_list (int, int);
5381 static void opt_list_symbols (int, int);
5383 static const struct opt_action opt_table
[] =
5385 { "abspcadd", 0, &m68k_abspcadd
, 1, 0 },
5387 /* We do relaxing, so there is little use for these options. */
5388 { "b", 0, 0, 0, 0 },
5389 { "brs", 0, 0, 0, 0 },
5390 { "brb", 0, 0, 0, 0 },
5391 { "brl", 0, 0, 0, 0 },
5392 { "brw", 0, 0, 0, 0 },
5394 { "c", 0, 0, 0, 0 },
5395 { "cex", 0, 0, 0, 0 },
5396 { "case", 0, &symbols_case_sensitive
, 1, 0 },
5397 { "cl", 0, 0, 0, 0 },
5398 { "cre", 0, 0, 0, 0 },
5399 { "d", 0, &flag_keep_locals
, 1, 0 },
5400 { "e", 0, 0, 0, 0 },
5401 { "f", 0, &flag_short_refs
, 1, 0 },
5402 { "frs", 0, &flag_short_refs
, 1, 0 },
5403 { "frl", 0, &flag_short_refs
, 0, 1 },
5404 { "g", 0, 0, 0, 0 },
5405 { "i", 0, 0, 0, 0 },
5406 { "m", 0, 0, 0, 0 },
5407 { "mex", 0, 0, 0, 0 },
5408 { "mc", 0, 0, 0, 0 },
5409 { "md", 0, 0, 0, 0 },
5410 { "nest", opt_nest
, 0, 0, 0 },
5411 { "next", skip_to_comma
, 0, 0, 0 },
5412 { "o", 0, 0, 0, 0 },
5413 { "old", 0, 0, 0, 0 },
5414 { "op", skip_to_comma
, 0, 0, 0 },
5415 { "pco", 0, 0, 0, 0 },
5416 { "p", opt_chip
, 0, 0, 0 },
5417 { "pcr", 0, 0, 0, 0 },
5418 { "pcs", 0, 0, 0, 0 },
5419 { "r", 0, 0, 0, 0 },
5420 { "quick", 0, &m68k_quick
, 1, 0 },
5421 { "rel32", 0, &m68k_rel32
, 1, 0 },
5422 { "s", opt_list
, 0, 0, 0 },
5423 { "t", opt_list_symbols
, 0, 0, 0 },
5424 { "w", 0, &flag_no_warnings
, 0, 1 },
5428 #define OPTCOUNT ((int) (sizeof opt_table / sizeof opt_table[0]))
5430 /* The MRI OPT pseudo-op. */
5433 s_opt (int ignore ATTRIBUTE_UNUSED
)
5441 const struct opt_action
*o
;
5446 if (*input_line_pointer
== '-')
5448 ++input_line_pointer
;
5451 else if (strncasecmp (input_line_pointer
, "NO", 2) == 0)
5453 input_line_pointer
+= 2;
5457 s
= input_line_pointer
;
5458 c
= get_symbol_end ();
5460 for (i
= 0, o
= opt_table
; i
< OPTCOUNT
; i
++, o
++)
5462 if (strcasecmp (s
, o
->name
) == 0)
5466 /* Restore input_line_pointer now in case the option
5468 *input_line_pointer
= c
;
5469 (*o
->pfn
) (o
->arg
, t
);
5471 else if (o
->pvar
!= NULL
)
5473 if (! t
&& o
->arg
== o
->notarg
)
5474 as_bad (_("option `%s' may not be negated"), s
);
5475 *input_line_pointer
= c
;
5476 *o
->pvar
= t
? o
->arg
: o
->notarg
;
5479 *input_line_pointer
= c
;
5485 as_bad (_("option `%s' not recognized"), s
);
5486 *input_line_pointer
= c
;
5489 while (*input_line_pointer
++ == ',');
5491 /* Move back to terminating character. */
5492 --input_line_pointer
;
5493 demand_empty_rest_of_line ();
5496 /* Skip ahead to a comma. This is used for OPT options which we do
5497 not support and which take arguments. */
5500 skip_to_comma (int arg ATTRIBUTE_UNUSED
, int on ATTRIBUTE_UNUSED
)
5502 while (*input_line_pointer
!= ','
5503 && ! is_end_of_line
[(unsigned char) *input_line_pointer
])
5504 ++input_line_pointer
;
5507 /* Handle the OPT NEST=depth option. */
5510 opt_nest (int arg ATTRIBUTE_UNUSED
, int on ATTRIBUTE_UNUSED
)
5512 if (*input_line_pointer
!= '=')
5514 as_bad (_("bad format of OPT NEST=depth"));
5518 ++input_line_pointer
;
5519 max_macro_nest
= get_absolute_expression ();
5522 /* Handle the OPT P=chip option. */
5525 opt_chip (int arg ATTRIBUTE_UNUSED
, int on ATTRIBUTE_UNUSED
)
5527 if (*input_line_pointer
!= '=')
5529 /* This is just OPT P, which we do not support. */
5533 ++input_line_pointer
;
5537 /* Handle the OPT S option. */
5540 opt_list (int arg ATTRIBUTE_UNUSED
, int on
)
5545 /* Handle the OPT T option. */
5548 opt_list_symbols (int arg ATTRIBUTE_UNUSED
, int on
)
5551 listing
|= LISTING_SYMBOLS
;
5553 listing
&= ~LISTING_SYMBOLS
;
5556 /* Handle the MRI REG pseudo-op. */
5559 s_reg (int ignore ATTRIBUTE_UNUSED
)
5568 if (line_label
== NULL
)
5570 as_bad (_("missing label"));
5571 ignore_rest_of_line ();
5576 stop
= mri_comment_field (&stopc
);
5580 s
= input_line_pointer
;
5581 while (ISALNUM (*input_line_pointer
)
5582 #ifdef REGISTER_PREFIX
5583 || *input_line_pointer
== REGISTER_PREFIX
5585 || *input_line_pointer
== '/'
5586 || *input_line_pointer
== '-')
5587 ++input_line_pointer
;
5588 c
= *input_line_pointer
;
5589 *input_line_pointer
= '\0';
5591 if (m68k_ip_op (s
, &rop
) != 0)
5593 if (rop
.error
== NULL
)
5594 as_bad (_("bad register list"));
5596 as_bad (_("bad register list: %s"), rop
.error
);
5597 *input_line_pointer
= c
;
5598 ignore_rest_of_line ();
5602 *input_line_pointer
= c
;
5604 if (rop
.mode
== REGLST
)
5606 else if (rop
.mode
== DREG
)
5607 mask
= 1 << (rop
.reg
- DATA0
);
5608 else if (rop
.mode
== AREG
)
5609 mask
= 1 << (rop
.reg
- ADDR0
+ 8);
5610 else if (rop
.mode
== FPREG
)
5611 mask
= 1 << (rop
.reg
- FP0
+ 16);
5612 else if (rop
.mode
== CONTROL
5615 else if (rop
.mode
== CONTROL
5618 else if (rop
.mode
== CONTROL
5623 as_bad (_("bad register list"));
5624 ignore_rest_of_line ();
5628 S_SET_SEGMENT (line_label
, reg_section
);
5629 S_SET_VALUE (line_label
, ~mask
);
5630 symbol_set_frag (line_label
, &zero_address_frag
);
5633 mri_comment_end (stop
, stopc
);
5635 demand_empty_rest_of_line ();
5638 /* This structure is used for the MRI SAVE and RESTORE pseudo-ops. */
5642 struct save_opts
*next
;
5644 int symbols_case_sensitive
;
5648 const enum m68k_register
*control_regs
;
5653 /* FIXME: We don't save OPT S. */
5656 /* This variable holds the stack of saved options. */
5658 static struct save_opts
*save_stack
;
5660 /* The MRI SAVE pseudo-op. */
5663 s_save (int ignore ATTRIBUTE_UNUSED
)
5665 struct save_opts
*s
;
5667 s
= (struct save_opts
*) xmalloc (sizeof (struct save_opts
));
5668 s
->abspcadd
= m68k_abspcadd
;
5669 s
->symbols_case_sensitive
= symbols_case_sensitive
;
5670 s
->keep_locals
= flag_keep_locals
;
5671 s
->short_refs
= flag_short_refs
;
5672 s
->architecture
= current_architecture
;
5673 s
->control_regs
= control_regs
;
5674 s
->quick
= m68k_quick
;
5675 s
->rel32
= m68k_rel32
;
5676 s
->listing
= listing
;
5677 s
->no_warnings
= flag_no_warnings
;
5679 s
->next
= save_stack
;
5682 demand_empty_rest_of_line ();
5685 /* The MRI RESTORE pseudo-op. */
5688 s_restore (int ignore ATTRIBUTE_UNUSED
)
5690 struct save_opts
*s
;
5692 if (save_stack
== NULL
)
5694 as_bad (_("restore without save"));
5695 ignore_rest_of_line ();
5700 save_stack
= s
->next
;
5702 m68k_abspcadd
= s
->abspcadd
;
5703 symbols_case_sensitive
= s
->symbols_case_sensitive
;
5704 flag_keep_locals
= s
->keep_locals
;
5705 flag_short_refs
= s
->short_refs
;
5706 current_architecture
= s
->architecture
;
5707 control_regs
= s
->control_regs
;
5708 m68k_quick
= s
->quick
;
5709 m68k_rel32
= s
->rel32
;
5710 listing
= s
->listing
;
5711 flag_no_warnings
= s
->no_warnings
;
5715 demand_empty_rest_of_line ();
5718 /* Types of MRI structured control directives. */
5720 enum mri_control_type
5728 /* This structure is used to stack the MRI structured control
5731 struct mri_control_info
5733 /* The directive within which this one is enclosed. */
5734 struct mri_control_info
*outer
;
5736 /* The type of directive. */
5737 enum mri_control_type type
;
5739 /* Whether an ELSE has been in an IF. */
5742 /* The add or sub statement at the end of a FOR. */
5745 /* The label of the top of a FOR or REPEAT loop. */
5748 /* The label to jump to for the next iteration, or the else
5749 expression of a conditional. */
5752 /* The label to jump to to break out of the loop, or the label past
5753 the end of a conditional. */
5757 /* The stack of MRI structured control directives. */
5759 static struct mri_control_info
*mri_control_stack
;
5761 /* The current MRI structured control directive index number, used to
5762 generate label names. */
5764 static int mri_control_index
;
5766 /* Assemble an instruction for an MRI structured control directive. */
5769 mri_assemble (char *str
)
5773 /* md_assemble expects the opcode to be in lower case. */
5774 for (s
= str
; *s
!= ' ' && *s
!= '\0'; s
++)
5780 /* Generate a new MRI label structured control directive label name. */
5783 mri_control_label (void)
5787 n
= (char *) xmalloc (20);
5788 sprintf (n
, "%smc%d", FAKE_LABEL_NAME
, mri_control_index
);
5789 ++mri_control_index
;
5793 /* Create a new MRI structured control directive. */
5795 static struct mri_control_info
*
5796 push_mri_control (enum mri_control_type type
)
5798 struct mri_control_info
*n
;
5800 n
= (struct mri_control_info
*) xmalloc (sizeof (struct mri_control_info
));
5804 if (type
== mri_if
|| type
== mri_while
)
5807 n
->top
= mri_control_label ();
5808 n
->next
= mri_control_label ();
5809 n
->bottom
= mri_control_label ();
5811 n
->outer
= mri_control_stack
;
5812 mri_control_stack
= n
;
5817 /* Pop off the stack of MRI structured control directives. */
5820 pop_mri_control (void)
5822 struct mri_control_info
*n
;
5824 n
= mri_control_stack
;
5825 mri_control_stack
= n
->outer
;
5833 /* Recognize a condition code in an MRI structured control expression. */
5836 parse_mri_condition (int *pcc
)
5840 know (*input_line_pointer
== '<');
5842 ++input_line_pointer
;
5843 c1
= *input_line_pointer
++;
5844 c2
= *input_line_pointer
++;
5846 if (*input_line_pointer
!= '>')
5848 as_bad (_("syntax error in structured control directive"));
5852 ++input_line_pointer
;
5858 *pcc
= (c1
<< 8) | c2
;
5863 /* Parse a single operand in an MRI structured control expression. */
5866 parse_mri_control_operand (int *pcc
, char **leftstart
, char **leftstop
,
5867 char **rightstart
, char **rightstop
)
5879 if (*input_line_pointer
== '<')
5881 /* It's just a condition code. */
5882 return parse_mri_condition (pcc
);
5885 /* Look ahead for the condition code. */
5886 for (s
= input_line_pointer
; *s
!= '\0'; ++s
)
5888 if (*s
== '<' && s
[1] != '\0' && s
[2] != '\0' && s
[3] == '>')
5893 as_bad (_("missing condition code in structured control directive"));
5897 *leftstart
= input_line_pointer
;
5899 if (*leftstop
> *leftstart
5900 && ((*leftstop
)[-1] == ' ' || (*leftstop
)[-1] == '\t'))
5903 input_line_pointer
= s
;
5904 if (! parse_mri_condition (pcc
))
5907 /* Look ahead for AND or OR or end of line. */
5908 for (s
= input_line_pointer
; *s
!= '\0'; ++s
)
5910 /* We must make sure we don't misinterpret AND/OR at the end of labels!
5911 if d0 <eq> #FOOAND and d1 <ne> #BAROR then
5913 if ((s
== input_line_pointer
5916 && ((strncasecmp (s
, "AND", 3) == 0
5917 && (s
[3] == '.' || ! is_part_of_name (s
[3])))
5918 || (strncasecmp (s
, "OR", 2) == 0
5919 && (s
[2] == '.' || ! is_part_of_name (s
[2])))))
5923 *rightstart
= input_line_pointer
;
5925 if (*rightstop
> *rightstart
5926 && ((*rightstop
)[-1] == ' ' || (*rightstop
)[-1] == '\t'))
5929 input_line_pointer
= s
;
5934 #define MCC(b1, b2) (((b1) << 8) | (b2))
5936 /* Swap the sense of a condition. This changes the condition so that
5937 it generates the same result when the operands are swapped. */
5940 swap_mri_condition (int cc
)
5944 case MCC ('h', 'i'): return MCC ('c', 's');
5945 case MCC ('l', 's'): return MCC ('c', 'c');
5946 /* <HS> is an alias for <CC>. */
5947 case MCC ('h', 's'):
5948 case MCC ('c', 'c'): return MCC ('l', 's');
5949 /* <LO> is an alias for <CS>. */
5950 case MCC ('l', 'o'):
5951 case MCC ('c', 's'): return MCC ('h', 'i');
5952 case MCC ('p', 'l'): return MCC ('m', 'i');
5953 case MCC ('m', 'i'): return MCC ('p', 'l');
5954 case MCC ('g', 'e'): return MCC ('l', 'e');
5955 case MCC ('l', 't'): return MCC ('g', 't');
5956 case MCC ('g', 't'): return MCC ('l', 't');
5957 case MCC ('l', 'e'): return MCC ('g', 'e');
5958 /* Issue a warning for conditions we can not swap. */
5959 case MCC ('n', 'e'): return MCC ('n', 'e'); // no problem here
5960 case MCC ('e', 'q'): return MCC ('e', 'q'); // also no problem
5961 case MCC ('v', 'c'):
5962 case MCC ('v', 's'):
5964 as_warn (_("Condition <%c%c> in structured control directive can not be encoded correctly"),
5965 (char) (cc
>> 8), (char) (cc
));
5971 /* Reverse the sense of a condition. */
5974 reverse_mri_condition (int cc
)
5978 case MCC ('h', 'i'): return MCC ('l', 's');
5979 case MCC ('l', 's'): return MCC ('h', 'i');
5980 /* <HS> is an alias for <CC> */
5981 case MCC ('h', 's'): return MCC ('l', 'o');
5982 case MCC ('c', 'c'): return MCC ('c', 's');
5983 /* <LO> is an alias for <CS> */
5984 case MCC ('l', 'o'): return MCC ('h', 's');
5985 case MCC ('c', 's'): return MCC ('c', 'c');
5986 case MCC ('n', 'e'): return MCC ('e', 'q');
5987 case MCC ('e', 'q'): return MCC ('n', 'e');
5988 case MCC ('v', 'c'): return MCC ('v', 's');
5989 case MCC ('v', 's'): return MCC ('v', 'c');
5990 case MCC ('p', 'l'): return MCC ('m', 'i');
5991 case MCC ('m', 'i'): return MCC ('p', 'l');
5992 case MCC ('g', 'e'): return MCC ('l', 't');
5993 case MCC ('l', 't'): return MCC ('g', 'e');
5994 case MCC ('g', 't'): return MCC ('l', 'e');
5995 case MCC ('l', 'e'): return MCC ('g', 't');
6000 /* Build an MRI structured control expression. This generates test
6001 and branch instructions. It goes to TRUELAB if the condition is
6002 true, and to FALSELAB if the condition is false. Exactly one of
6003 TRUELAB and FALSELAB will be NULL, meaning to fall through. QUAL
6004 is the size qualifier for the expression. EXTENT is the size to
6005 use for the branch. */
6008 build_mri_control_operand (int qual
, int cc
, char *leftstart
, char *leftstop
,
6009 char *rightstart
, char *rightstop
,
6010 const char *truelab
, const char *falselab
,
6016 if (leftstart
!= NULL
)
6018 struct m68k_op leftop
, rightop
;
6021 /* Swap the compare operands, if necessary, to produce a legal
6022 m68k compare instruction. Comparing a register operand with
6023 a non-register operand requires the register to be on the
6024 right (cmp, cmpa). Comparing an immediate value with
6025 anything requires the immediate value to be on the left
6030 (void) m68k_ip_op (leftstart
, &leftop
);
6035 (void) m68k_ip_op (rightstart
, &rightop
);
6038 if (rightop
.mode
== IMMED
6039 || ((leftop
.mode
== DREG
|| leftop
.mode
== AREG
)
6040 && (rightop
.mode
!= DREG
&& rightop
.mode
!= AREG
)))
6044 /* Correct conditional handling:
6045 if #1 <lt> d0 then ;means if (1 < d0)
6051 cmp #1,d0 if we do *not* swap the operands
6052 bgt true we need the swapped condition!
6059 leftstart
= rightstart
;
6062 leftstop
= rightstop
;
6067 cc
= swap_mri_condition (cc
);
6071 if (truelab
== NULL
)
6073 cc
= reverse_mri_condition (cc
);
6077 if (leftstart
!= NULL
)
6079 buf
= (char *) xmalloc (20
6080 + (leftstop
- leftstart
)
6081 + (rightstop
- rightstart
));
6087 *s
++ = TOLOWER (qual
);
6089 memcpy (s
, leftstart
, leftstop
- leftstart
);
6090 s
+= leftstop
- leftstart
;
6092 memcpy (s
, rightstart
, rightstop
- rightstart
);
6093 s
+= rightstop
- rightstart
;
6099 buf
= (char *) xmalloc (20 + strlen (truelab
));
6105 *s
++ = TOLOWER (extent
);
6107 strcpy (s
, truelab
);
6112 /* Parse an MRI structured control expression. This generates test
6113 and branch instructions. STOP is where the expression ends. It
6114 goes to TRUELAB if the condition is true, and to FALSELAB if the
6115 condition is false. Exactly one of TRUELAB and FALSELAB will be
6116 NULL, meaning to fall through. QUAL is the size qualifier for the
6117 expression. EXTENT is the size to use for the branch. */
6120 parse_mri_control_expression (char *stop
, int qual
, const char *truelab
,
6121 const char *falselab
, int extent
)
6133 if (! parse_mri_control_operand (&cc
, &leftstart
, &leftstop
,
6134 &rightstart
, &rightstop
))
6140 if (strncasecmp (input_line_pointer
, "AND", 3) == 0)
6144 if (falselab
!= NULL
)
6147 flab
= mri_control_label ();
6149 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6150 rightstop
, (const char *) NULL
, flab
, extent
);
6152 input_line_pointer
+= 3;
6153 if (*input_line_pointer
!= '.'
6154 || input_line_pointer
[1] == '\0')
6158 qual
= input_line_pointer
[1];
6159 input_line_pointer
+= 2;
6162 if (! parse_mri_control_operand (&cc
, &leftstart
, &leftstop
,
6163 &rightstart
, &rightstop
))
6169 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6170 rightstop
, truelab
, falselab
, extent
);
6172 if (falselab
== NULL
)
6175 else if (strncasecmp (input_line_pointer
, "OR", 2) == 0)
6179 if (truelab
!= NULL
)
6182 tlab
= mri_control_label ();
6184 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6185 rightstop
, tlab
, (const char *) NULL
, extent
);
6187 input_line_pointer
+= 2;
6188 if (*input_line_pointer
!= '.'
6189 || input_line_pointer
[1] == '\0')
6193 qual
= input_line_pointer
[1];
6194 input_line_pointer
+= 2;
6197 if (! parse_mri_control_operand (&cc
, &leftstart
, &leftstop
,
6198 &rightstart
, &rightstop
))
6204 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6205 rightstop
, truelab
, falselab
, extent
);
6207 if (truelab
== NULL
)
6212 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6213 rightstop
, truelab
, falselab
, extent
);
6217 if (input_line_pointer
!= stop
)
6218 as_bad (_("syntax error in structured control directive"));
6221 /* Handle the MRI IF pseudo-op. This may be a structured control
6222 directive, or it may be a regular assembler conditional, depending
6230 struct mri_control_info
*n
;
6232 /* A structured control directive must end with THEN with an
6233 optional qualifier. */
6234 s
= input_line_pointer
;
6235 /* We only accept '*' as introduction of comments if preceded by white space
6236 or at first column of a line (I think this can't actually happen here?)
6237 This is important when assembling:
6238 if d0 <ne> 12(a0,d0*2) then
6239 if d0 <ne> #CONST*20 then. */
6240 while (! (is_end_of_line
[(unsigned char) *s
]
6243 && (s
== input_line_pointer
6245 || *(s
-1) == '\t'))))
6248 while (s
> input_line_pointer
&& (*s
== ' ' || *s
== '\t'))
6251 if (s
- input_line_pointer
> 1
6255 if (s
- input_line_pointer
< 3
6256 || strncasecmp (s
- 3, "THEN", 4) != 0)
6260 as_bad (_("missing then"));
6261 ignore_rest_of_line ();
6265 /* It's a conditional. */
6270 /* Since this might be a conditional if, this pseudo-op will be
6271 called even if we are supported to be ignoring input. Double
6272 check now. Clobber *input_line_pointer so that ignore_input
6273 thinks that this is not a special pseudo-op. */
6274 c
= *input_line_pointer
;
6275 *input_line_pointer
= 0;
6276 if (ignore_input ())
6278 *input_line_pointer
= c
;
6279 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6280 ++input_line_pointer
;
6281 demand_empty_rest_of_line ();
6284 *input_line_pointer
= c
;
6286 n
= push_mri_control (mri_if
);
6288 parse_mri_control_expression (s
- 3, qual
, (const char *) NULL
,
6289 n
->next
, s
[1] == '.' ? s
[2] : '\0');
6292 input_line_pointer
= s
+ 3;
6294 input_line_pointer
= s
+ 1;
6298 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6299 ++input_line_pointer
;
6302 demand_empty_rest_of_line ();
6305 /* Handle the MRI else pseudo-op. If we are currently doing an MRI
6306 structured IF, associate the ELSE with the IF. Otherwise, assume
6307 it is a conditional else. */
6310 s_mri_else (int qual
)
6317 && (mri_control_stack
== NULL
6318 || mri_control_stack
->type
!= mri_if
6319 || mri_control_stack
->else_seen
))
6325 c
= *input_line_pointer
;
6326 *input_line_pointer
= 0;
6327 if (ignore_input ())
6329 *input_line_pointer
= c
;
6330 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6331 ++input_line_pointer
;
6332 demand_empty_rest_of_line ();
6335 *input_line_pointer
= c
;
6337 if (mri_control_stack
== NULL
6338 || mri_control_stack
->type
!= mri_if
6339 || mri_control_stack
->else_seen
)
6341 as_bad (_("else without matching if"));
6342 ignore_rest_of_line ();
6346 mri_control_stack
->else_seen
= 1;
6348 buf
= (char *) xmalloc (20 + strlen (mri_control_stack
->bottom
));
6349 q
[0] = TOLOWER (qual
);
6351 sprintf (buf
, "bra%s %s", q
, mri_control_stack
->bottom
);
6355 colon (mri_control_stack
->next
);
6359 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6360 ++input_line_pointer
;
6363 demand_empty_rest_of_line ();
6366 /* Handle the MRI ENDI pseudo-op. */
6369 s_mri_endi (int ignore ATTRIBUTE_UNUSED
)
6371 if (mri_control_stack
== NULL
6372 || mri_control_stack
->type
!= mri_if
)
6374 as_bad (_("endi without matching if"));
6375 ignore_rest_of_line ();
6379 /* ignore_input will not return true for ENDI, so we don't need to
6380 worry about checking it again here. */
6382 if (! mri_control_stack
->else_seen
)
6383 colon (mri_control_stack
->next
);
6384 colon (mri_control_stack
->bottom
);
6390 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6391 ++input_line_pointer
;
6394 demand_empty_rest_of_line ();
6397 /* Handle the MRI BREAK pseudo-op. */
6400 s_mri_break (int extent
)
6402 struct mri_control_info
*n
;
6406 n
= mri_control_stack
;
6408 && n
->type
!= mri_for
6409 && n
->type
!= mri_repeat
6410 && n
->type
!= mri_while
)
6414 as_bad (_("break outside of structured loop"));
6415 ignore_rest_of_line ();
6419 buf
= (char *) xmalloc (20 + strlen (n
->bottom
));
6420 ex
[0] = TOLOWER (extent
);
6422 sprintf (buf
, "bra%s %s", ex
, n
->bottom
);
6428 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6429 ++input_line_pointer
;
6432 demand_empty_rest_of_line ();
6435 /* Handle the MRI NEXT pseudo-op. */
6438 s_mri_next (int extent
)
6440 struct mri_control_info
*n
;
6444 n
= mri_control_stack
;
6446 && n
->type
!= mri_for
6447 && n
->type
!= mri_repeat
6448 && n
->type
!= mri_while
)
6452 as_bad (_("next outside of structured loop"));
6453 ignore_rest_of_line ();
6457 buf
= (char *) xmalloc (20 + strlen (n
->next
));
6458 ex
[0] = TOLOWER (extent
);
6460 sprintf (buf
, "bra%s %s", ex
, n
->next
);
6466 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6467 ++input_line_pointer
;
6470 demand_empty_rest_of_line ();
6473 /* Handle the MRI FOR pseudo-op. */
6476 s_mri_for (int qual
)
6478 const char *varstart
, *varstop
;
6479 const char *initstart
, *initstop
;
6480 const char *endstart
, *endstop
;
6481 const char *bystart
, *bystop
;
6485 struct mri_control_info
*n
;
6491 FOR.q var = init { TO | DOWNTO } end [ BY by ] DO.e
6495 varstart
= input_line_pointer
;
6497 /* Look for the '='. */
6498 while (! is_end_of_line
[(unsigned char) *input_line_pointer
]
6499 && *input_line_pointer
!= '=')
6500 ++input_line_pointer
;
6501 if (*input_line_pointer
!= '=')
6503 as_bad (_("missing ="));
6504 ignore_rest_of_line ();
6508 varstop
= input_line_pointer
;
6509 if (varstop
> varstart
6510 && (varstop
[-1] == ' ' || varstop
[-1] == '\t'))
6513 ++input_line_pointer
;
6515 initstart
= input_line_pointer
;
6517 /* Look for TO or DOWNTO. */
6520 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6522 if (strncasecmp (input_line_pointer
, "TO", 2) == 0
6523 && ! is_part_of_name (input_line_pointer
[2]))
6525 initstop
= input_line_pointer
;
6526 input_line_pointer
+= 2;
6529 if (strncasecmp (input_line_pointer
, "DOWNTO", 6) == 0
6530 && ! is_part_of_name (input_line_pointer
[6]))
6532 initstop
= input_line_pointer
;
6534 input_line_pointer
+= 6;
6537 ++input_line_pointer
;
6539 if (initstop
== NULL
)
6541 as_bad (_("missing to or downto"));
6542 ignore_rest_of_line ();
6545 if (initstop
> initstart
6546 && (initstop
[-1] == ' ' || initstop
[-1] == '\t'))
6550 endstart
= input_line_pointer
;
6552 /* Look for BY or DO. */
6555 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6557 if (strncasecmp (input_line_pointer
, "BY", 2) == 0
6558 && ! is_part_of_name (input_line_pointer
[2]))
6560 endstop
= input_line_pointer
;
6562 input_line_pointer
+= 2;
6565 if (strncasecmp (input_line_pointer
, "DO", 2) == 0
6566 && (input_line_pointer
[2] == '.'
6567 || ! is_part_of_name (input_line_pointer
[2])))
6569 endstop
= input_line_pointer
;
6570 input_line_pointer
+= 2;
6573 ++input_line_pointer
;
6575 if (endstop
== NULL
)
6577 as_bad (_("missing do"));
6578 ignore_rest_of_line ();
6581 if (endstop
> endstart
6582 && (endstop
[-1] == ' ' || endstop
[-1] == '\t'))
6588 bystop
= bystart
+ 2;
6593 bystart
= input_line_pointer
;
6597 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6599 if (strncasecmp (input_line_pointer
, "DO", 2) == 0
6600 && (input_line_pointer
[2] == '.'
6601 || ! is_part_of_name (input_line_pointer
[2])))
6603 bystop
= input_line_pointer
;
6604 input_line_pointer
+= 2;
6607 ++input_line_pointer
;
6611 as_bad (_("missing do"));
6612 ignore_rest_of_line ();
6615 if (bystop
> bystart
6616 && (bystop
[-1] == ' ' || bystop
[-1] == '\t'))
6620 if (*input_line_pointer
!= '.')
6624 extent
= input_line_pointer
[1];
6625 input_line_pointer
+= 2;
6628 /* We have fully parsed the FOR operands. Now build the loop. */
6629 n
= push_mri_control (mri_for
);
6631 buf
= (char *) xmalloc (50 + (input_line_pointer
- varstart
));
6633 /* Move init,var. */
6640 *s
++ = TOLOWER (qual
);
6642 memcpy (s
, initstart
, initstop
- initstart
);
6643 s
+= initstop
- initstart
;
6645 memcpy (s
, varstart
, varstop
- varstart
);
6646 s
+= varstop
- varstart
;
6658 *s
++ = TOLOWER (qual
);
6660 memcpy (s
, endstart
, endstop
- endstart
);
6661 s
+= endstop
- endstart
;
6663 memcpy (s
, varstart
, varstop
- varstart
);
6664 s
+= varstop
- varstart
;
6669 ex
[0] = TOLOWER (extent
);
6672 sprintf (buf
, "blt%s %s", ex
, n
->bottom
);
6674 sprintf (buf
, "bgt%s %s", ex
, n
->bottom
);
6677 /* Put together the add or sub instruction used by ENDF. */
6685 *s
++ = TOLOWER (qual
);
6687 memcpy (s
, bystart
, bystop
- bystart
);
6688 s
+= bystop
- bystart
;
6690 memcpy (s
, varstart
, varstop
- varstart
);
6691 s
+= varstop
- varstart
;
6697 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6698 ++input_line_pointer
;
6701 demand_empty_rest_of_line ();
6704 /* Handle the MRI ENDF pseudo-op. */
6707 s_mri_endf (int ignore ATTRIBUTE_UNUSED
)
6709 if (mri_control_stack
== NULL
6710 || mri_control_stack
->type
!= mri_for
)
6712 as_bad (_("endf without for"));
6713 ignore_rest_of_line ();
6717 colon (mri_control_stack
->next
);
6719 mri_assemble (mri_control_stack
->incr
);
6721 sprintf (mri_control_stack
->incr
, "bra %s", mri_control_stack
->top
);
6722 mri_assemble (mri_control_stack
->incr
);
6724 free (mri_control_stack
->incr
);
6726 colon (mri_control_stack
->bottom
);
6732 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6733 ++input_line_pointer
;
6736 demand_empty_rest_of_line ();
6739 /* Handle the MRI REPEAT pseudo-op. */
6742 s_mri_repeat (int ignore ATTRIBUTE_UNUSED
)
6744 struct mri_control_info
*n
;
6746 n
= push_mri_control (mri_repeat
);
6750 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6751 ++input_line_pointer
;
6753 demand_empty_rest_of_line ();
6756 /* Handle the MRI UNTIL pseudo-op. */
6759 s_mri_until (int qual
)
6763 if (mri_control_stack
== NULL
6764 || mri_control_stack
->type
!= mri_repeat
)
6766 as_bad (_("until without repeat"));
6767 ignore_rest_of_line ();
6771 colon (mri_control_stack
->next
);
6773 for (s
= input_line_pointer
; ! is_end_of_line
[(unsigned char) *s
]; s
++)
6776 parse_mri_control_expression (s
, qual
, (const char *) NULL
,
6777 mri_control_stack
->top
, '\0');
6779 colon (mri_control_stack
->bottom
);
6781 input_line_pointer
= s
;
6787 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6788 ++input_line_pointer
;
6791 demand_empty_rest_of_line ();
6794 /* Handle the MRI WHILE pseudo-op. */
6797 s_mri_while (int qual
)
6801 struct mri_control_info
*n
;
6803 s
= input_line_pointer
;
6804 /* We only accept '*' as introduction of comments if preceded by white space
6805 or at first column of a line (I think this can't actually happen here?)
6806 This is important when assembling:
6807 while d0 <ne> 12(a0,d0*2) do
6808 while d0 <ne> #CONST*20 do. */
6809 while (! (is_end_of_line
[(unsigned char) *s
]
6812 && (s
== input_line_pointer
6814 || *(s
-1) == '\t'))))
6817 while (*s
== ' ' || *s
== '\t')
6819 if (s
- input_line_pointer
> 1
6822 if (s
- input_line_pointer
< 2
6823 || strncasecmp (s
- 1, "DO", 2) != 0)
6825 as_bad (_("missing do"));
6826 ignore_rest_of_line ();
6830 n
= push_mri_control (mri_while
);
6834 parse_mri_control_expression (s
- 1, qual
, (const char *) NULL
, n
->bottom
,
6835 s
[1] == '.' ? s
[2] : '\0');
6837 input_line_pointer
= s
+ 1;
6838 if (*input_line_pointer
== '.')
6839 input_line_pointer
+= 2;
6843 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6844 ++input_line_pointer
;
6847 demand_empty_rest_of_line ();
6850 /* Handle the MRI ENDW pseudo-op. */
6853 s_mri_endw (int ignore ATTRIBUTE_UNUSED
)
6857 if (mri_control_stack
== NULL
6858 || mri_control_stack
->type
!= mri_while
)
6860 as_bad (_("endw without while"));
6861 ignore_rest_of_line ();
6865 buf
= (char *) xmalloc (20 + strlen (mri_control_stack
->next
));
6866 sprintf (buf
, "bra %s", mri_control_stack
->next
);
6870 colon (mri_control_stack
->bottom
);
6876 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6877 ++input_line_pointer
;
6880 demand_empty_rest_of_line ();
6883 /* Parse a .cpu directive. */
6886 s_m68k_cpu (int ignored ATTRIBUTE_UNUSED
)
6893 as_bad (_("already assembled instructions"));
6894 ignore_rest_of_line ();
6898 name
= input_line_pointer
;
6899 while (*input_line_pointer
&& !ISSPACE(*input_line_pointer
))
6900 input_line_pointer
++;
6901 saved_char
= *input_line_pointer
;
6902 *input_line_pointer
= 0;
6904 m68k_set_cpu (name
, 1, 0);
6906 *input_line_pointer
= saved_char
;
6907 demand_empty_rest_of_line ();
6911 /* Parse a .arch directive. */
6914 s_m68k_arch (int ignored ATTRIBUTE_UNUSED
)
6921 as_bad (_("already assembled instructions"));
6922 ignore_rest_of_line ();
6926 name
= input_line_pointer
;
6927 while (*input_line_pointer
&& *input_line_pointer
!= ','
6928 && !ISSPACE (*input_line_pointer
))
6929 input_line_pointer
++;
6930 saved_char
= *input_line_pointer
;
6931 *input_line_pointer
= 0;
6933 if (m68k_set_arch (name
, 1, 0))
6935 /* Scan extensions. */
6938 *input_line_pointer
++ = saved_char
;
6939 if (!*input_line_pointer
|| ISSPACE (*input_line_pointer
))
6941 name
= input_line_pointer
;
6942 while (*input_line_pointer
&& *input_line_pointer
!= ','
6943 && !ISSPACE (*input_line_pointer
))
6944 input_line_pointer
++;
6945 saved_char
= *input_line_pointer
;
6946 *input_line_pointer
= 0;
6948 while (m68k_set_extension (name
, 1, 0));
6951 *input_line_pointer
= saved_char
;
6952 demand_empty_rest_of_line ();
6956 /* Lookup a cpu name in TABLE and return the slot found. Return NULL
6957 if none is found, the caller is responsible for emitting an error
6958 message. If ALLOW_M is non-zero, we allow an initial 'm' on the
6959 cpu name, if it begins with a '6' (possibly skipping an intervening
6960 'c'. We also allow a 'c' in the same place. if NEGATED is
6961 non-zero, we accept a leading 'no-' and *NEGATED is set to true, if
6962 the option is indeed negated. */
6964 static const struct m68k_cpu
*
6965 m68k_lookup_cpu (const char *arg
, const struct m68k_cpu
*table
,
6966 int allow_m
, int *negated
)
6968 /* allow negated value? */
6973 if (arg
[0] == 'n' && arg
[1] == 'o' && arg
[2] == '-')
6980 /* Remove 'm' or 'mc' prefix from 68k variants. */
6987 else if (arg
[1] == 'c' && arg
[2] == '6')
6991 else if (arg
[0] == 'c' && arg
[1] == '6')
6994 for (; table
->name
; table
++)
6995 if (!strcmp (arg
, table
->name
))
6997 if (table
->alias
< -1 || table
->alias
> 1)
6998 as_bad (_("`%s' is deprecated, use `%s'"),
6999 table
->name
, table
[table
->alias
< 0 ? 1 : -1].name
);
7005 /* Set the cpu, issuing errors if it is unrecognized, or invalid */
7008 m68k_set_cpu (char const *name
, int allow_m
, int silent
)
7010 const struct m68k_cpu
*cpu
;
7012 cpu
= m68k_lookup_cpu (name
, m68k_cpus
, allow_m
, NULL
);
7017 as_bad (_("cpu `%s' unrecognized"), name
);
7021 if (selected_cpu
&& selected_cpu
!= cpu
)
7023 as_bad (_("already selected `%s' processor"),
7024 selected_cpu
->name
);
7031 /* Set the architecture, issuing errors if it is unrecognized, or invalid */
7034 m68k_set_arch (char const *name
, int allow_m
, int silent
)
7036 const struct m68k_cpu
*arch
;
7038 arch
= m68k_lookup_cpu (name
, m68k_archs
, allow_m
, NULL
);
7043 as_bad (_("architecture `%s' unrecognized"), name
);
7047 if (selected_arch
&& selected_arch
!= arch
)
7049 as_bad (_("already selected `%s' architecture"),
7050 selected_arch
->name
);
7054 selected_arch
= arch
;
7058 /* Set the architecture extension, issuing errors if it is
7059 unrecognized, or invalid */
7062 m68k_set_extension (char const *name
, int allow_m
, int silent
)
7065 const struct m68k_cpu
*ext
;
7067 ext
= m68k_lookup_cpu (name
, m68k_extensions
, allow_m
, &negated
);
7072 as_bad (_("extension `%s' unrecognized"), name
);
7077 not_current_architecture
|= ext
->arch
;
7079 current_architecture
|= ext
->arch
;
7084 Invocation line includes a switch not recognized by the base assembler.
7088 const char *md_shortopts
= "lSA:m:kQ:V";
7090 const char *md_shortopts
= "lSA:m:k";
7093 struct option md_longopts
[] = {
7094 #define OPTION_PIC (OPTION_MD_BASE)
7095 {"pic", no_argument
, NULL
, OPTION_PIC
},
7096 #define OPTION_REGISTER_PREFIX_OPTIONAL (OPTION_MD_BASE + 1)
7097 {"register-prefix-optional", no_argument
, NULL
,
7098 OPTION_REGISTER_PREFIX_OPTIONAL
},
7099 #define OPTION_BITWISE_OR (OPTION_MD_BASE + 2)
7100 {"bitwise-or", no_argument
, NULL
, OPTION_BITWISE_OR
},
7101 #define OPTION_BASE_SIZE_DEFAULT_16 (OPTION_MD_BASE + 3)
7102 {"base-size-default-16", no_argument
, NULL
, OPTION_BASE_SIZE_DEFAULT_16
},
7103 #define OPTION_BASE_SIZE_DEFAULT_32 (OPTION_MD_BASE + 4)
7104 {"base-size-default-32", no_argument
, NULL
, OPTION_BASE_SIZE_DEFAULT_32
},
7105 #define OPTION_DISP_SIZE_DEFAULT_16 (OPTION_MD_BASE + 5)
7106 {"disp-size-default-16", no_argument
, NULL
, OPTION_DISP_SIZE_DEFAULT_16
},
7107 #define OPTION_DISP_SIZE_DEFAULT_32 (OPTION_MD_BASE + 6)
7108 {"disp-size-default-32", no_argument
, NULL
, OPTION_DISP_SIZE_DEFAULT_32
},
7109 #define OPTION_PCREL (OPTION_MD_BASE + 7)
7110 {"pcrel", no_argument
, NULL
, OPTION_PCREL
},
7111 {NULL
, no_argument
, NULL
, 0}
7113 size_t md_longopts_size
= sizeof (md_longopts
);
7116 md_parse_option (int c
, char *arg
)
7120 case 'l': /* -l means keep external to 2 bit offset
7121 rather than 16 bit one. */
7122 flag_short_refs
= 1;
7125 case 'S': /* -S means that jbsr's always turn into
7127 flag_long_jumps
= 1;
7130 case OPTION_PCREL
: /* --pcrel means never turn PC-relative
7131 branches into absolute jumps. */
7132 flag_keep_pcrel
= 1;
7138 break; /* -pic, Position Independent Code. */
7140 case OPTION_REGISTER_PREFIX_OPTIONAL
:
7141 flag_reg_prefix_optional
= 1;
7142 reg_prefix_optional_seen
= 1;
7145 /* -V: SVR4 argument to print version ID. */
7147 print_version_id ();
7150 /* -Qy, -Qn: SVR4 arguments controlling whether a .comment section
7151 should be emitted or not. FIXME: Not implemented. */
7155 case OPTION_BITWISE_OR
:
7160 n
= (char *) xmalloc (strlen (m68k_comment_chars
) + 1);
7162 for (s
= m68k_comment_chars
; *s
!= '\0'; s
++)
7166 m68k_comment_chars
= n
;
7170 case OPTION_BASE_SIZE_DEFAULT_16
:
7171 m68k_index_width_default
= SIZE_WORD
;
7174 case OPTION_BASE_SIZE_DEFAULT_32
:
7175 m68k_index_width_default
= SIZE_LONG
;
7178 case OPTION_DISP_SIZE_DEFAULT_16
:
7180 m68k_rel32_from_cmdline
= 1;
7183 case OPTION_DISP_SIZE_DEFAULT_32
:
7185 m68k_rel32_from_cmdline
= 1;
7190 as_tsktsk (_ ("option `-A%s' is deprecated: use `-%s'",
7193 /* Intentional fall-through. */
7195 if (!strncmp (arg
, "arch=", 5))
7196 m68k_set_arch (arg
+ 5, 1, 0);
7197 else if (!strncmp (arg
, "cpu=", 4))
7198 m68k_set_cpu (arg
+ 4, 1, 0);
7199 else if (m68k_set_extension (arg
, 0, 1))
7201 else if (m68k_set_arch (arg
, 0, 1))
7203 else if (m68k_set_cpu (arg
, 0, 1))
7216 /* Setup tables from the selected arch and/or cpu */
7219 m68k_init_arch (void)
7221 if (not_current_architecture
& current_architecture
)
7223 as_bad (_("architecture features both enabled and disabled"));
7224 not_current_architecture
&= ~current_architecture
;
7228 current_architecture
|= selected_arch
->arch
;
7229 control_regs
= selected_arch
->control_regs
;
7232 current_architecture
|= selected_cpu
->arch
;
7234 current_architecture
&= ~not_current_architecture
;
7238 control_regs
= selected_cpu
->control_regs
;
7239 if (current_architecture
& ~selected_cpu
->arch
)
7241 as_bad (_("selected processor does not have all features of selected architecture"));
7242 current_architecture
7243 = selected_cpu
->arch
& ~not_current_architecture
;
7247 if ((current_architecture
& (cfloat
| m68881
)) == (cfloat
| m68881
))
7249 /* Determine which float is really meant. */
7250 if (current_architecture
& (m68k_mask
& ~m68881
))
7251 current_architecture
^= cfloat
;
7253 current_architecture
^= m68881
;
7256 if ((current_architecture
& m68k_mask
)
7257 && (current_architecture
& ~m68k_mask
))
7259 as_bad (_ ("m68k and cf features both selected"));
7260 if (current_architecture
& m68k_mask
)
7261 current_architecture
&= m68k_mask
;
7263 current_architecture
&= ~m68k_mask
;
7266 /* Permit m68881 specification with all cpus; those that can't work
7267 with a coprocessor could be doing emulation. */
7268 if (current_architecture
& m68851
)
7270 if (current_architecture
& m68040
)
7271 as_warn (_("68040 and 68851 specified; mmu instructions may assemble incorrectly"));
7273 /* What other incompatibilities could we check for? */
7275 if (cpu_of_arch (current_architecture
) < m68020
7276 || arch_coldfire_p (current_architecture
))
7277 md_relax_table
[TAB (PCINDEX
, BYTE
)].rlx_more
= 0;
7283 md_show_usage (FILE *stream
)
7285 const char *default_cpu
= TARGET_CPU
;
7287 unsigned int default_arch
;
7289 /* Get the canonical name for the default target CPU. */
7290 if (*default_cpu
== 'm')
7292 for (i
= 0; m68k_cpus
[i
].name
; i
++)
7294 if (strcasecmp (default_cpu
, m68k_cpus
[i
].name
) == 0)
7296 default_arch
= m68k_cpus
[i
].arch
;
7297 while (m68k_cpus
[i
].alias
> 0)
7299 while (m68k_cpus
[i
].alias
< 0)
7301 default_cpu
= m68k_cpus
[i
].name
;
7305 fprintf (stream
, _("\
7306 -march=<arch> set architecture\n\
7307 -mcpu=<cpu> set cpu [default %s]\n\
7309 for (i
= 0; m68k_extensions
[i
].name
; i
++)
7310 fprintf (stream
, _("\
7311 -m[no-]%-16s enable/disable%s architecture extension\n\
7312 "), m68k_extensions
[i
].name
,
7313 m68k_extensions
[i
].alias
> 0 ? " ColdFire"
7314 : m68k_extensions
[i
].alias
< 0 ? " m68k" : "");
7316 fprintf (stream
, _("\
7317 -l use 1 word for refs to undefined symbols [default 2]\n\
7318 -pic, -k generate position independent code\n\
7319 -S turn jbsr into jsr\n\
7320 --pcrel never turn PC-relative branches into absolute jumps\n\
7321 --register-prefix-optional\n\
7322 recognize register names without prefix character\n\
7323 --bitwise-or do not treat `|' as a comment character\n\
7324 --base-size-default-16 base reg without size is 16 bits\n\
7325 --base-size-default-32 base reg without size is 32 bits (default)\n\
7326 --disp-size-default-16 displacement with unknown size is 16 bits\n\
7327 --disp-size-default-32 displacement with unknown size is 32 bits (default)\n\
7330 fprintf (stream
, _("Architecture variants are: "));
7331 for (i
= 0; m68k_archs
[i
].name
; i
++)
7334 fprintf (stream
, " | ");
7335 fprintf (stream
, m68k_archs
[i
].name
);
7337 fprintf (stream
, "\n");
7339 fprintf (stream
, _("Processor variants are: "));
7340 for (i
= 0; m68k_cpus
[i
].name
; i
++)
7343 fprintf (stream
, " | ");
7344 fprintf (stream
, m68k_cpus
[i
].name
);
7346 fprintf (stream
, _("\n"));
7351 /* TEST2: Test md_assemble() */
7352 /* Warning, this routine probably doesn't work anymore. */
7356 struct m68k_it the_ins
;
7364 if (!gets (buf
) || !*buf
)
7366 if (buf
[0] == '|' || buf
[1] == '.')
7368 for (cp
= buf
; *cp
; cp
++)
7373 memset (&the_ins
, '\0', sizeof (the_ins
));
7374 m68k_ip (&the_ins
, buf
);
7377 printf (_("Error %s in %s\n"), the_ins
.error
, buf
);
7381 printf (_("Opcode(%d.%s): "), the_ins
.numo
, the_ins
.args
);
7382 for (n
= 0; n
< the_ins
.numo
; n
++)
7383 printf (" 0x%x", the_ins
.opcode
[n
] & 0xffff);
7385 print_the_insn (&the_ins
.opcode
[0], stdout
);
7386 (void) putchar ('\n');
7388 for (n
= 0; n
< strlen (the_ins
.args
) / 2; n
++)
7390 if (the_ins
.operands
[n
].error
)
7392 printf ("op%d Error %s in %s\n", n
, the_ins
.operands
[n
].error
, buf
);
7395 printf ("mode %d, reg %d, ", the_ins
.operands
[n
].mode
,
7396 the_ins
.operands
[n
].reg
);
7397 if (the_ins
.operands
[n
].b_const
)
7398 printf ("Constant: '%.*s', ",
7399 1 + the_ins
.operands
[n
].e_const
- the_ins
.operands
[n
].b_const
,
7400 the_ins
.operands
[n
].b_const
);
7401 printf ("ireg %d, isiz %d, imul %d, ", the_ins
.operands
[n
].ireg
,
7402 the_ins
.operands
[n
].isiz
, the_ins
.operands
[n
].imul
);
7403 if (the_ins
.operands
[n
].b_iadd
)
7404 printf ("Iadd: '%.*s',",
7405 1 + the_ins
.operands
[n
].e_iadd
- the_ins
.operands
[n
].b_iadd
,
7406 the_ins
.operands
[n
].b_iadd
);
7415 is_label (char *str
)
7419 while (*str
&& *str
!= ' ')
7421 if (str
[-1] == ':' || str
[1] == '=')
7428 /* Possible states for relaxation:
7430 0 0 branch offset byte (bra, etc)
7434 1 0 indexed offsets byte a0@(32,d4:w:1) etc
7438 2 0 two-offset index word-word a0@(32,d4)@(45) etc
7445 /* We have no need to default values of symbols. */
7448 md_undefined_symbol (char *name ATTRIBUTE_UNUSED
)
7453 /* Round up a section size to the appropriate boundary. */
7455 md_section_align (segT segment ATTRIBUTE_UNUSED
, valueT size
)
7458 /* For a.out, force the section size to be aligned. If we don't do
7459 this, BFD will align it for us, but it will not write out the
7460 final bytes of the section. This may be a bug in BFD, but it is
7461 easier to fix it here since that is how the other a.out targets
7465 align
= bfd_get_section_alignment (stdoutput
, segment
);
7466 size
= ((size
+ (1 << align
) - 1) & ((valueT
) -1 << align
));
7472 /* Exactly what point is a PC-relative offset relative TO?
7473 On the 68k, it is relative to the address of the first extension
7474 word. The difference between the addresses of the offset and the
7475 first extension word is stored in fx_pcrel_adjust. */
7477 md_pcrel_from (fixS
*fixP
)
7481 /* Because fx_pcrel_adjust is a char, and may be unsigned, we explicitly
7482 sign extend the value here. */
7483 adjust
= ((fixP
->fx_pcrel_adjust
& 0xff) ^ 0x80) - 0x80;
7486 return fixP
->fx_where
+ fixP
->fx_frag
->fr_address
- adjust
;
7491 m68k_elf_final_processing (void)
7495 if (arch_coldfire_fpu (current_architecture
))
7496 flags
|= EF_M68K_CFV4E
;
7497 /* Set file-specific flags if this is a cpu32 processor. */
7498 if (cpu_of_arch (current_architecture
) & cpu32
)
7499 flags
|= EF_M68K_CPU32
;
7500 else if ((cpu_of_arch (current_architecture
) & m68000up
)
7501 && !(cpu_of_arch (current_architecture
) & m68020up
))
7502 flags
|= EF_M68K_M68000
;
7504 if (current_architecture
& mcfisa_a
)
7506 static const unsigned isa_features
[][2] =
7508 {EF_M68K_ISA_A_NODIV
, mcfisa_a
},
7509 {EF_M68K_ISA_A
, mcfisa_a
|mcfhwdiv
},
7510 {EF_M68K_ISA_A_PLUS
,mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfusp
},
7511 {EF_M68K_ISA_B_NOUSP
,mcfisa_a
|mcfisa_b
|mcfhwdiv
},
7512 {EF_M68K_ISA_B
, mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfusp
},
7515 static const unsigned mac_features
[][2] =
7517 {EF_M68K_MAC
, mcfmac
},
7518 {EF_M68K_EMAC
, mcfemac
},
7524 pattern
= (current_architecture
7525 & (mcfisa_a
|mcfisa_aa
|mcfisa_b
|mcfhwdiv
|mcfusp
));
7526 for (ix
= 0; isa_features
[ix
][1]; ix
++)
7528 if (pattern
== isa_features
[ix
][1])
7530 flags
|= isa_features
[ix
][0];
7534 if (!isa_features
[ix
][1])
7537 as_warn (_("Not a defined coldfire architecture"));
7541 if (current_architecture
& cfloat
)
7542 flags
|= EF_M68K_FLOAT
| EF_M68K_CFV4E
;
7544 pattern
= current_architecture
& (mcfmac
|mcfemac
);
7547 for (ix
= 0; mac_features
[ix
][1]; ix
++)
7549 if (pattern
== mac_features
[ix
][1])
7551 flags
|= mac_features
[ix
][0];
7555 if (!mac_features
[ix
][1])
7560 elf_elfheader (stdoutput
)->e_flags
|= flags
;
7565 tc_m68k_regname_to_dw2regnum (const char *regname
)
7567 unsigned int regnum
;
7568 static const char *const regnames
[] =
7570 "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
7571 "a0", "a1", "a2", "a3", "a4", "a5", "a6", "sp",
7572 "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7",
7576 for (regnum
= 0; regnum
< ARRAY_SIZE (regnames
); regnum
++)
7577 if (strcmp (regname
, regnames
[regnum
]) == 0)
7584 tc_m68k_frame_initial_instructions (void)
7586 static int sp_regno
= -1;
7589 sp_regno
= tc_m68k_regname_to_dw2regnum ("sp");
7591 cfi_add_CFA_def_cfa (sp_regno
, -DWARF2_CIE_DATA_ALIGNMENT
);
7592 cfi_add_CFA_offset (DWARF2_DEFAULT_RETURN_COLUMN
, DWARF2_CIE_DATA_ALIGNMENT
);