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 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, 59 Temple Place - Suite 330, 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"
36 /* This string holds the chars that always start a comment. If the
37 pre-processor is disabled, these aren't very useful. The macro
38 tc_comment_chars points to this. We use this, rather than the
39 usual comment_chars, so that the --bitwise-or option will work. */
40 #if defined (TE_SVR4) || defined (TE_DELTA)
41 const char *m68k_comment_chars
= "|#";
43 const char *m68k_comment_chars
= "|";
46 /* This array holds the chars that only start a comment at the beginning of
47 a line. If the line seems to have the form '# 123 filename'
48 .line and .file directives will appear in the pre-processed output */
49 /* Note that input_file.c hand checks for '#' at the beginning of the
50 first line of the input file. This is because the compiler outputs
51 #NO_APP at the beginning of its output. */
52 /* Also note that comments like this one will always work. */
53 const char line_comment_chars
[] = "#*";
55 const char line_separator_chars
[] = ";";
57 /* Chars that can be used to separate mant from exp in floating point nums. */
58 const char EXP_CHARS
[] = "eE";
60 /* Chars that mean this number is a floating point constant, as
61 in "0f12.456" or "0d1.2345e12". */
63 const char FLT_CHARS
[] = "rRsSfFdDxXeEpP";
65 /* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
66 changed in read.c . Ideally it shouldn't have to know about it at all,
67 but nothing is ideal around here. */
69 const int md_reloc_size
= 8; /* Size of relocation record. */
71 /* Are we trying to generate PIC code? If so, absolute references
72 ought to be made into linkage table references or pc-relative
73 references. Not implemented. For ELF there are other means
74 to denote pic relocations. */
77 static int flag_short_refs
; /* -l option. */
78 static int flag_long_jumps
; /* -S option. */
79 static int flag_keep_pcrel
; /* --pcrel option. */
81 #ifdef REGISTER_PREFIX_OPTIONAL
82 int flag_reg_prefix_optional
= REGISTER_PREFIX_OPTIONAL
;
84 int flag_reg_prefix_optional
;
87 /* Whether --register-prefix-optional was used on the command line. */
88 static int reg_prefix_optional_seen
;
90 /* The floating point coprocessor to use by default. */
91 static enum m68k_register m68k_float_copnum
= COP1
;
93 /* If this is non-zero, then references to number(%pc) will be taken
94 to refer to number, rather than to %pc + number. */
95 static int m68k_abspcadd
;
97 /* If this is non-zero, then the quick forms of the move, add, and sub
98 instructions are used when possible. */
99 static int m68k_quick
= 1;
101 /* If this is non-zero, then if the size is not specified for a base
102 or outer displacement, the assembler assumes that the size should
104 static int m68k_rel32
= 1;
106 /* This is non-zero if m68k_rel32 was set from the command line. */
107 static int m68k_rel32_from_cmdline
;
109 /* The default width to use for an index register when using a base
111 static enum m68k_size m68k_index_width_default
= SIZE_LONG
;
113 /* We want to warn if any text labels are misaligned. In order to get
114 the right line number, we need to record the line number for each
118 struct label_line
*next
;
125 /* The list of labels. */
127 static struct label_line
*labels
;
129 /* The current label. */
131 static struct label_line
*current_label
;
133 /* Its an arbitrary name: This means I don't approve of it.
135 static struct obstack robyn
;
139 const char *m_operands
;
140 unsigned long m_opcode
;
144 struct m68k_incant
*m_next
;
147 #define getone(x) ((((x)->m_opcode)>>16)&0xffff)
148 #define gettwo(x) (((x)->m_opcode)&0xffff)
150 static const enum m68k_register m68000_control_regs
[] = { 0 };
151 static const enum m68k_register m68010_control_regs
[] = {
155 static const enum m68k_register m68020_control_regs
[] = {
156 SFC
, DFC
, USP
, VBR
, CACR
, CAAR
, MSP
, ISP
,
159 static const enum m68k_register m68040_control_regs
[] = {
160 SFC
, DFC
, CACR
, TC
, ITT0
, ITT1
, DTT0
, DTT1
,
161 USP
, VBR
, MSP
, ISP
, MMUSR
, URP
, SRP
,
164 static const enum m68k_register m68060_control_regs
[] = {
165 SFC
, DFC
, CACR
, TC
, ITT0
, ITT1
, DTT0
, DTT1
, BUSCR
,
166 USP
, VBR
, URP
, SRP
, PCR
,
169 static const enum m68k_register mcf_control_regs
[] = {
170 CACR
, TC
, ACR0
, ACR1
, ACR2
, ACR3
, VBR
, ROMBAR
,
171 RAMBAR0
, RAMBAR1
, MBAR
,
174 static const enum m68k_register mcf528x_control_regs
[] = {
175 CACR
, ACR0
, ACR1
, VBR
, FLASHBAR
, RAMBAR
,
178 static const enum m68k_register mcfv4e_control_regs
[] = {
179 CACR
, TC
, ITT0
, ITT1
, DTT0
, DTT1
, BUSCR
, VBR
, PC
, ROMBAR
,
180 ROMBAR1
, RAMBAR0
, RAMBAR1
, MPCR
, EDRAMBAR
, SECMBAR
, MBAR
, MBAR0
, MBAR1
,
181 PCR1U0
, PCR1L0
, PCR1U1
, PCR1L1
, PCR2U0
, PCR2L0
, PCR2U1
, PCR2L1
,
182 PCR3U0
, PCR3L0
, PCR3U1
, PCR3L1
,
185 #define cpu32_control_regs m68010_control_regs
187 static const enum m68k_register
*control_regs
;
189 /* Internal form of a 68020 instruction. */
193 const char *args
; /* List of opcode info. */
196 int numo
; /* Number of shorts in opcode. */
199 struct m68k_op operands
[6];
201 int nexp
; /* Number of exprs in use. */
202 struct m68k_exp exprs
[4];
204 int nfrag
; /* Number of frags we have to produce. */
207 int fragoff
; /* Where in the current opcode the frag ends. */
214 int nrel
; /* Num of reloc strucs in use. */
221 /* In a pc relative address the difference between the address
222 of the offset and the address that the offset is relative
223 to. This depends on the addressing mode. Basically this
224 is the value to put in the offset field to address the
225 first byte of the offset, without regarding the special
226 significance of some values (in the branch instruction, for
230 /* Whether this expression needs special pic relocation, and if
232 enum pic_relocation pic_reloc
;
235 reloc
[5]; /* Five is enough??? */
238 #define cpu_of_arch(x) ((x) & (m68000up | mcf))
239 #define float_of_arch(x) ((x) & mfloat)
240 #define mmu_of_arch(x) ((x) & mmmu)
241 #define arch_coldfire_p(x) ((x) & mcf)
242 #define arch_coldfire_v4e_p(x) ((x) & mcfv4e)
244 /* Macros for determining if cpu supports a specific addressing mode. */
245 #define HAVE_LONG_BRANCH(x) ((x) & (m68020|m68030|m68040|m68060|cpu32|mcf5407|mcfv4e))
247 static struct m68k_it the_ins
; /* The instruction being assembled. */
249 #define op(ex) ((ex)->exp.X_op)
250 #define adds(ex) ((ex)->exp.X_add_symbol)
251 #define subs(ex) ((ex)->exp.X_op_symbol)
252 #define offs(ex) ((ex)->exp.X_add_number)
254 /* Macros for adding things to the m68k_it struct. */
255 #define addword(w) the_ins.opcode[the_ins.numo++]=(w)
257 /* Static functions. */
258 static void insop
PARAMS ((int, const struct m68k_incant
*));
259 static void add_fix
PARAMS ((int, struct m68k_exp
*, int, int));
260 static void add_frag
PARAMS ((symbolS
*, offsetT
, int));
262 /* Like addword, but goes BEFORE general operands. */
267 const struct m68k_incant
*opcode
;
270 for (z
= the_ins
.numo
; z
> opcode
->m_codenum
; --z
)
271 the_ins
.opcode
[z
] = the_ins
.opcode
[z
- 1];
272 for (z
= 0; z
< the_ins
.nrel
; z
++)
273 the_ins
.reloc
[z
].n
+= 2;
274 for (z
= 0; z
< the_ins
.nfrag
; z
++)
275 the_ins
.fragb
[z
].fragoff
++;
276 the_ins
.opcode
[opcode
->m_codenum
] = w
;
280 /* The numo+1 kludge is so we can hit the low order byte of the prev word.
283 add_fix (width
, exp
, pc_rel
, pc_fix
)
285 struct m68k_exp
*exp
;
289 the_ins
.reloc
[the_ins
.nrel
].n
= ((width
== 'B' || width
== '3')
293 : (the_ins
.numo
*2)));
294 the_ins
.reloc
[the_ins
.nrel
].exp
= exp
->exp
;
295 the_ins
.reloc
[the_ins
.nrel
].wid
= width
;
296 the_ins
.reloc
[the_ins
.nrel
].pcrel_fix
= pc_fix
;
298 the_ins
.reloc
[the_ins
.nrel
].pic_reloc
= exp
->pic_reloc
;
300 the_ins
.reloc
[the_ins
.nrel
++].pcrel
= pc_rel
;
303 /* Cause an extra frag to be generated here, inserting up to 10 bytes
304 (that value is chosen in the frag_var call in md_assemble). TYPE
305 is the subtype of the frag to be generated; its primary type is
306 rs_machine_dependent.
308 The TYPE parameter is also used by md_convert_frag_1 and
309 md_estimate_size_before_relax. The appropriate type of fixup will
310 be emitted by md_convert_frag_1.
312 ADD becomes the FR_SYMBOL field of the frag, and OFF the FR_OFFSET. */
314 add_frag (add
, off
, type
)
319 the_ins
.fragb
[the_ins
.nfrag
].fragoff
= the_ins
.numo
;
320 the_ins
.fragb
[the_ins
.nfrag
].fadd
= add
;
321 the_ins
.fragb
[the_ins
.nfrag
].foff
= off
;
322 the_ins
.fragb
[the_ins
.nfrag
++].fragty
= type
;
326 (op (ex) != O_constant && op (ex) != O_big)
328 static char *crack_operand
PARAMS ((char *str
, struct m68k_op
*opP
));
329 static int get_num
PARAMS ((struct m68k_exp
*exp
, int ok
));
330 static void m68k_ip
PARAMS ((char *));
331 static void insert_reg
PARAMS ((const char *, int));
332 static void select_control_regs
PARAMS ((void));
333 static void init_regtable
PARAMS ((void));
334 static int reverse_16_bits
PARAMS ((int in
));
335 static int reverse_8_bits
PARAMS ((int in
));
336 static void install_gen_operand
PARAMS ((int mode
, int val
));
337 static void install_operand
PARAMS ((int mode
, int val
));
338 static void s_bss
PARAMS ((int));
339 static void s_data1
PARAMS ((int));
340 static void s_data2
PARAMS ((int));
341 static void s_even
PARAMS ((int));
342 static void s_proc
PARAMS ((int));
343 static void mri_chip
PARAMS ((void));
344 static void s_chip
PARAMS ((int));
345 static void s_fopt
PARAMS ((int));
346 static void s_opt
PARAMS ((int));
347 static void s_reg
PARAMS ((int));
348 static void s_restore
PARAMS ((int));
349 static void s_save
PARAMS ((int));
350 static void s_mri_if
PARAMS ((int));
351 static void s_mri_else
PARAMS ((int));
352 static void s_mri_endi
PARAMS ((int));
353 static void s_mri_break
PARAMS ((int));
354 static void s_mri_next
PARAMS ((int));
355 static void s_mri_for
PARAMS ((int));
356 static void s_mri_endf
PARAMS ((int));
357 static void s_mri_repeat
PARAMS ((int));
358 static void s_mri_until
PARAMS ((int));
359 static void s_mri_while
PARAMS ((int));
360 static void s_mri_endw
PARAMS ((int));
361 static void md_convert_frag_1
PARAMS ((fragS
*));
363 static int current_architecture
;
372 static const struct m68k_cpu archs
[] =
374 { m68000
, "68000", 0 },
375 { m68010
, "68010", 0 },
376 { m68020
, "68020", 0 },
377 { m68030
, "68030", 0 },
378 { m68040
, "68040", 0 },
379 { m68060
, "68060", 0 },
380 { cpu32
, "cpu32", 0 },
381 { m68881
, "68881", 0 },
382 { m68851
, "68851", 0 },
383 { mcf5200
, "5200", 0 },
384 { mcf5206e
,"5206e", 0 },
385 { mcf528x
, "528x", 0 },
386 { mcf5307
, "5307", 0 },
387 { mcf5407
, "5407", 0 },
388 { mcfv4e
, "cfv4e", 0 },
389 /* Aliases (effectively, so far as gas is concerned) for the above
391 { m68020
, "68k", 1 },
392 { m68000
, "68008", 1 },
393 { m68000
, "68302", 1 },
394 { m68000
, "68306", 1 },
395 { m68000
, "68307", 1 },
396 { m68000
, "68322", 1 },
397 { m68000
, "68356", 1 },
398 { m68000
, "68ec000", 1 },
399 { m68000
, "68hc000", 1 },
400 { m68000
, "68hc001", 1 },
401 { m68020
, "68ec020", 1 },
402 { m68030
, "68ec030", 1 },
403 { m68040
, "68ec040", 1 },
404 { m68060
, "68ec060", 1 },
405 { cpu32
, "68330", 1 },
406 { cpu32
, "68331", 1 },
407 { cpu32
, "68332", 1 },
408 { cpu32
, "68333", 1 },
409 { cpu32
, "68334", 1 },
410 { cpu32
, "68336", 1 },
411 { cpu32
, "68340", 1 },
412 { cpu32
, "68341", 1 },
413 { cpu32
, "68349", 1 },
414 { cpu32
, "68360", 1 },
415 { m68881
, "68882", 1 },
416 { mcf5200
, "5202", 1 },
417 { mcf5200
, "5204", 1 },
418 { mcf5200
, "5206", 1 },
419 { mcf5407
, "cfv4", 1 },
422 static const int n_archs
= sizeof (archs
) / sizeof (archs
[0]);
424 /* This is the assembler relaxation table for m68k. m68k is a rich CISC
425 architecture and we have a lot of relaxation modes. */
427 /* Macros used in the relaxation code. */
428 #define TAB(x,y) (((x) << 2) + (y))
429 #define TABTYPE(x) ((x) >> 2)
431 /* Relaxation states. */
437 /* Here are all the relaxation modes we support. First we can relax ordinary
438 branches. On 68020 and higher and on CPU32 all branch instructions take
439 three forms, so on these CPUs all branches always remain as such. When we
440 have to expand to the LONG form on a 68000, though, we substitute an
441 absolute jump instead. This is a direct replacement for unconditional
442 branches and a branch over a jump for conditional branches. However, if the
443 user requires PIC and disables this with --pcrel, we can only relax between
444 BYTE and SHORT forms, punting if that isn't enough. This gives us four
445 different relaxation modes for branches: */
447 #define BRANCHBWL 0 /* Branch byte, word, or long. */
448 #define BRABSJUNC 1 /* Absolute jump for LONG, unconditional. */
449 #define BRABSJCOND 2 /* Absolute jump for LONG, conditional. */
450 #define BRANCHBW 3 /* Branch byte or word. */
452 /* We also relax coprocessor branches and DBcc's. All CPUs that support
453 coprocessor branches support them in word and long forms, so we have only
454 one relaxation mode for them. DBcc's are word only on all CPUs. We can
455 relax them to the LONG form with a branch-around sequence. This sequence
456 can use a long branch (if available) or an absolute jump (if acceptable).
457 This gives us two relaxation modes. If long branches are not available and
458 absolute jumps are not acceptable, we don't relax DBcc's. */
460 #define FBRANCH 4 /* Coprocessor branch. */
461 #define DBCCLBR 5 /* DBcc relaxable with a long branch. */
462 #define DBCCABSJ 6 /* DBcc relaxable with an absolute jump. */
464 /* That's all for instruction relaxation. However, we also relax PC-relative
465 operands. Specifically, we have three operand relaxation modes. On the
466 68000 PC-relative operands can only be 16-bit, but on 68020 and higher and
467 on CPU32 they may be 16-bit or 32-bit. For the latter we relax between the
468 two. Also PC+displacement+index operands in their simple form (with a non-
469 suppressed index without memory indirection) are supported on all CPUs, but
470 on the 68000 the displacement can be 8-bit only, whereas on 68020 and higher
471 and on CPU32 we relax it to SHORT and LONG forms as well using the extended
472 form of the PC+displacement+index operand. Finally, some absolute operands
473 can be relaxed down to 16-bit PC-relative. */
475 #define PCREL1632 7 /* 16-bit or 32-bit PC-relative. */
476 #define PCINDEX 8 /* PC + displacement + index. */
477 #define ABSTOPCREL 9 /* Absolute relax down to 16-bit PC-relative. */
479 /* Note that calls to frag_var need to specify the maximum expansion
480 needed; this is currently 10 bytes for DBCC. */
483 How far Forward this mode will reach:
484 How far Backward this mode will reach:
485 How many bytes this mode will add to the size of the frag
486 Which mode to go to if the offset won't fit in this one
488 Please check tc-m68k.h:md_prepare_relax_scan if changing this table. */
489 relax_typeS md_relax_table
[] =
491 { 127, -128, 0, TAB (BRANCHBWL
, SHORT
) },
492 { 32767, -32768, 2, TAB (BRANCHBWL
, LONG
) },
496 { 127, -128, 0, TAB (BRABSJUNC
, SHORT
) },
497 { 32767, -32768, 2, TAB (BRABSJUNC
, LONG
) },
501 { 127, -128, 0, TAB (BRABSJCOND
, SHORT
) },
502 { 32767, -32768, 2, TAB (BRABSJCOND
, LONG
) },
506 { 127, -128, 0, TAB (BRANCHBW
, SHORT
) },
511 { 1, 1, 0, 0 }, /* FBRANCH doesn't come BYTE. */
512 { 32767, -32768, 2, TAB (FBRANCH
, LONG
) },
516 { 1, 1, 0, 0 }, /* DBCC doesn't come BYTE. */
517 { 32767, -32768, 2, TAB (DBCCLBR
, LONG
) },
521 { 1, 1, 0, 0 }, /* DBCC doesn't come BYTE. */
522 { 32767, -32768, 2, TAB (DBCCABSJ
, LONG
) },
526 { 1, 1, 0, 0 }, /* PCREL1632 doesn't come BYTE. */
527 { 32767, -32768, 2, TAB (PCREL1632
, LONG
) },
531 { 125, -130, 0, TAB (PCINDEX
, SHORT
) },
532 { 32765, -32770, 2, TAB (PCINDEX
, LONG
) },
536 { 1, 1, 0, 0 }, /* ABSTOPCREL doesn't come BYTE. */
537 { 32767, -32768, 2, TAB (ABSTOPCREL
, LONG
) },
542 /* These are the machine dependent pseudo-ops. These are included so
543 the assembler can work on the output from the SUN C compiler, which
546 /* This table describes all the machine specific pseudo-ops the assembler
547 has to support. The fields are:
548 pseudo-op name without dot
549 function to call to execute this pseudo-op
550 Integer arg to pass to the function. */
551 const pseudo_typeS md_pseudo_table
[] =
553 {"data1", s_data1
, 0},
554 {"data2", s_data2
, 0},
557 {"skip", s_space
, 0},
559 #if defined (TE_SUN3) || defined (OBJ_ELF)
560 {"align", s_align_bytes
, 0},
563 {"swbeg", s_ignore
, 0},
565 {"extend", float_cons
, 'x'},
566 {"ldouble", float_cons
, 'x'},
568 /* The following pseudo-ops are supported for MRI compatibility. */
570 {"comline", s_space
, 1},
572 {"mask2", s_ignore
, 0},
575 {"restore", s_restore
, 0},
579 {"if.b", s_mri_if
, 'b'},
580 {"if.w", s_mri_if
, 'w'},
581 {"if.l", s_mri_if
, 'l'},
582 {"else", s_mri_else
, 0},
583 {"else.s", s_mri_else
, 's'},
584 {"else.l", s_mri_else
, 'l'},
585 {"endi", s_mri_endi
, 0},
586 {"break", s_mri_break
, 0},
587 {"break.s", s_mri_break
, 's'},
588 {"break.l", s_mri_break
, 'l'},
589 {"next", s_mri_next
, 0},
590 {"next.s", s_mri_next
, 's'},
591 {"next.l", s_mri_next
, 'l'},
592 {"for", s_mri_for
, 0},
593 {"for.b", s_mri_for
, 'b'},
594 {"for.w", s_mri_for
, 'w'},
595 {"for.l", s_mri_for
, 'l'},
596 {"endf", s_mri_endf
, 0},
597 {"repeat", s_mri_repeat
, 0},
598 {"until", s_mri_until
, 0},
599 {"until.b", s_mri_until
, 'b'},
600 {"until.w", s_mri_until
, 'w'},
601 {"until.l", s_mri_until
, 'l'},
602 {"while", s_mri_while
, 0},
603 {"while.b", s_mri_while
, 'b'},
604 {"while.w", s_mri_while
, 'w'},
605 {"while.l", s_mri_while
, 'l'},
606 {"endw", s_mri_endw
, 0},
611 /* The mote pseudo ops are put into the opcode table, since they
612 don't start with a . they look like opcodes to gas.
616 extern void obj_coff_section
PARAMS ((int));
619 const pseudo_typeS mote_pseudo_table
[] =
632 {"xdef", s_globl
, 0},
634 {"align", s_align_bytes
, 0},
636 {"align", s_align_ptwo
, 0},
639 {"sect", obj_coff_section
, 0},
640 {"section", obj_coff_section
, 0},
645 #define issbyte(x) ((x)>=-128 && (x)<=127)
646 #define isubyte(x) ((x)>=0 && (x)<=255)
647 #define issword(x) ((x)>=-32768 && (x)<=32767)
648 #define isuword(x) ((x)>=0 && (x)<=65535)
650 #define isbyte(x) ((x)>= -255 && (x)<=255)
651 #define isword(x) ((x)>=-65536 && (x)<=65535)
652 #define islong(x) (1)
654 extern char *input_line_pointer
;
656 static char notend_table
[256];
657 static char alt_notend_table
[256];
659 (! (notend_table[(unsigned char) *s] \
661 && alt_notend_table[(unsigned char) s[1]])))
663 #if defined (M68KCOFF) && !defined (BFD_ASSEMBLER)
665 #ifdef NO_PCREL_RELOCS
668 make_pcrel_absolute(fixP
, add_number
)
672 register unsigned char *opcode
= fixP
->fx_frag
->fr_opcode
;
674 /* Rewrite the PC relative instructions to absolute address ones.
675 these are rumored to be faster, and the apollo linker refuses
676 to deal with the PC relative relocations. */
677 if (opcode
[0] == 0x60 && opcode
[1] == 0xff) /* BRA -> JMP. */
680 as_fatal(_("Tried to convert PC relative branch to absolute jump"));
684 else if (opcode
[0] == 0x61 && opcode
[1] == 0xff) /* BSR -> JSR. */
687 as_fatal(_("Tried to convert PC relative BSR to absolute JSR"));
692 as_fatal (_("Unknown PC relative instruction"));
697 #endif /* NO_PCREL_RELOCS */
700 tc_coff_fix2rtype (fixP
)
703 if (fixP
->fx_tcbit
&& fixP
->fx_size
== 4)
704 return R_RELLONG_NEG
;
705 #ifdef NO_PCREL_RELOCS
706 know (fixP
->fx_pcrel
== 0);
707 return (fixP
->fx_size
== 1 ? R_RELBYTE
708 : fixP
->fx_size
== 2 ? R_DIR16
711 return (fixP
->fx_pcrel
?
712 (fixP
->fx_size
== 1 ? R_PCRBYTE
:
713 fixP
->fx_size
== 2 ? R_PCRWORD
:
715 (fixP
->fx_size
== 1 ? R_RELBYTE
:
716 fixP
->fx_size
== 2 ? R_RELWORD
:
725 /* Return zero if the reference to SYMBOL from within the same segment may
728 /* On an ELF system, we can't relax an externally visible symbol,
729 because it may be overridden by a shared library. However, if
730 TARGET_OS is "elf", then we presume that we are assembling for an
731 embedded system, in which case we don't have to worry about shared
732 libraries, and we can relax any external sym. */
734 #define relaxable_symbol(symbol) \
735 (!((S_IS_EXTERNAL (symbol) && EXTERN_FORCE_RELOC) \
736 || S_IS_WEAK (symbol)))
738 /* Compute the relocation code for a fixup of SIZE bytes, using pc
739 relative relocation if PCREL is non-zero. PIC says whether a special
740 pic relocation was requested. */
742 static bfd_reloc_code_real_type get_reloc_code
743 PARAMS ((int, int, enum pic_relocation
));
745 static bfd_reloc_code_real_type
746 get_reloc_code (size
, pcrel
, pic
)
749 enum pic_relocation pic
;
757 return BFD_RELOC_8_GOT_PCREL
;
759 return BFD_RELOC_16_GOT_PCREL
;
761 return BFD_RELOC_32_GOT_PCREL
;
769 return BFD_RELOC_8_GOTOFF
;
771 return BFD_RELOC_16_GOTOFF
;
773 return BFD_RELOC_32_GOTOFF
;
781 return BFD_RELOC_8_PLT_PCREL
;
783 return BFD_RELOC_16_PLT_PCREL
;
785 return BFD_RELOC_32_PLT_PCREL
;
793 return BFD_RELOC_8_PLTOFF
;
795 return BFD_RELOC_16_PLTOFF
;
797 return BFD_RELOC_32_PLTOFF
;
807 return BFD_RELOC_8_PCREL
;
809 return BFD_RELOC_16_PCREL
;
811 return BFD_RELOC_32_PCREL
;
831 as_bad (_("Can not do %d byte pc-relative relocation"), size
);
833 as_bad (_("Can not do %d byte pc-relative pic relocation"), size
);
838 as_bad (_("Can not do %d byte relocation"), size
);
840 as_bad (_("Can not do %d byte pic relocation"), size
);
843 return BFD_RELOC_NONE
;
846 /* Here we decide which fixups can be adjusted to make them relative
847 to the beginning of the section instead of the symbol. Basically
848 we need to make sure that the dynamic relocations are done
849 correctly, so in some cases we force the original symbol to be
852 tc_m68k_fix_adjustable (fixP
)
855 /* Adjust_reloc_syms doesn't know about the GOT. */
856 switch (fixP
->fx_r_type
)
858 case BFD_RELOC_8_GOT_PCREL
:
859 case BFD_RELOC_16_GOT_PCREL
:
860 case BFD_RELOC_32_GOT_PCREL
:
861 case BFD_RELOC_8_GOTOFF
:
862 case BFD_RELOC_16_GOTOFF
:
863 case BFD_RELOC_32_GOTOFF
:
864 case BFD_RELOC_8_PLT_PCREL
:
865 case BFD_RELOC_16_PLT_PCREL
:
866 case BFD_RELOC_32_PLT_PCREL
:
867 case BFD_RELOC_8_PLTOFF
:
868 case BFD_RELOC_16_PLTOFF
:
869 case BFD_RELOC_32_PLTOFF
:
872 case BFD_RELOC_VTABLE_INHERIT
:
873 case BFD_RELOC_VTABLE_ENTRY
:
883 #define get_reloc_code(SIZE,PCREL,OTHER) NO_RELOC
885 #define relaxable_symbol(symbol) 1
892 tc_gen_reloc (section
, fixp
)
893 asection
*section ATTRIBUTE_UNUSED
;
897 bfd_reloc_code_real_type code
;
899 /* If the tcbit is set, then this was a fixup of a negative value
900 that was never resolved. We do not have a reloc to handle this,
901 so just return. We assume that other code will have detected this
902 situation and produced a helpful error message, so we just tell the
903 user that the reloc cannot be produced. */
907 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
908 _("Unable to produce reloc against symbol '%s'"),
909 S_GET_NAME (fixp
->fx_addsy
));
913 if (fixp
->fx_r_type
!= BFD_RELOC_NONE
)
915 code
= fixp
->fx_r_type
;
917 /* Since DIFF_EXPR_OK is defined in tc-m68k.h, it is possible
918 that fixup_segment converted a non-PC relative reloc into a
919 PC relative reloc. In such a case, we need to convert the
926 code
= BFD_RELOC_8_PCREL
;
929 code
= BFD_RELOC_16_PCREL
;
932 code
= BFD_RELOC_32_PCREL
;
934 case BFD_RELOC_8_PCREL
:
935 case BFD_RELOC_16_PCREL
:
936 case BFD_RELOC_32_PCREL
:
937 case BFD_RELOC_8_GOT_PCREL
:
938 case BFD_RELOC_16_GOT_PCREL
:
939 case BFD_RELOC_32_GOT_PCREL
:
940 case BFD_RELOC_8_GOTOFF
:
941 case BFD_RELOC_16_GOTOFF
:
942 case BFD_RELOC_32_GOTOFF
:
943 case BFD_RELOC_8_PLT_PCREL
:
944 case BFD_RELOC_16_PLT_PCREL
:
945 case BFD_RELOC_32_PLT_PCREL
:
946 case BFD_RELOC_8_PLTOFF
:
947 case BFD_RELOC_16_PLTOFF
:
948 case BFD_RELOC_32_PLTOFF
:
951 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
952 _("Cannot make %s relocation PC relative"),
953 bfd_get_reloc_code_name (code
));
959 #define F(SZ,PCREL) (((SZ) << 1) + (PCREL))
960 switch (F (fixp
->fx_size
, fixp
->fx_pcrel
))
962 #define MAP(SZ,PCREL,TYPE) case F(SZ,PCREL): code = (TYPE); break
963 MAP (1, 0, BFD_RELOC_8
);
964 MAP (2, 0, BFD_RELOC_16
);
965 MAP (4, 0, BFD_RELOC_32
);
966 MAP (1, 1, BFD_RELOC_8_PCREL
);
967 MAP (2, 1, BFD_RELOC_16_PCREL
);
968 MAP (4, 1, BFD_RELOC_32_PCREL
);
976 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
977 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
978 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
979 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
982 reloc
->addend
= fixp
->fx_addnumber
;
987 reloc
->addend
= fixp
->fx_addnumber
;
989 reloc
->addend
= (section
->vma
990 /* Explicit sign extension in case char is
992 + ((fixp
->fx_pcrel_adjust
& 0xff) ^ 0x80) - 0x80
994 + md_pcrel_from (fixp
));
997 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
998 assert (reloc
->howto
!= 0);
1003 #endif /* BFD_ASSEMBLER */
1005 /* Handle of the OPCODE hash table. NULL means any use before
1006 m68k_ip_begin() will crash. */
1007 static struct hash_control
*op_hash
;
1009 /* Assemble an m68k instruction. */
1016 register struct m68k_op
*opP
;
1017 register const struct m68k_incant
*opcode
;
1018 register const char *s
;
1019 register int tmpreg
= 0, baseo
= 0, outro
= 0, nextword
;
1020 char *pdot
, *pdotmove
;
1021 enum m68k_size siz1
, siz2
;
1025 LITTLENUM_TYPE words
[6];
1026 LITTLENUM_TYPE
*wordp
;
1027 unsigned long ok_arch
= 0;
1029 if (*instring
== ' ')
1030 instring
++; /* Skip leading whitespace. */
1032 /* Scan up to end of operation-code, which MUST end in end-of-string
1033 or exactly 1 space. */
1035 for (p
= instring
; *p
!= '\0'; p
++)
1045 the_ins
.error
= _("No operator");
1049 /* p now points to the end of the opcode name, probably whitespace.
1050 Make sure the name is null terminated by clobbering the
1051 whitespace, look it up in the hash table, then fix it back.
1052 Remove a dot, first, since the opcode tables have none. */
1055 for (pdotmove
= pdot
; pdotmove
< p
; pdotmove
++)
1056 *pdotmove
= pdotmove
[1];
1062 opcode
= (const struct m68k_incant
*) hash_find (op_hash
, instring
);
1067 for (pdotmove
= p
; pdotmove
> pdot
; pdotmove
--)
1068 *pdotmove
= pdotmove
[-1];
1075 the_ins
.error
= _("Unknown operator");
1079 /* Found a legitimate opcode, start matching operands. */
1083 if (opcode
->m_operands
== 0)
1085 char *old
= input_line_pointer
;
1087 input_line_pointer
= p
;
1088 /* Ahh - it's a motorola style psuedo op. */
1089 mote_pseudo_table
[opcode
->m_opnum
].poc_handler
1090 (mote_pseudo_table
[opcode
->m_opnum
].poc_val
);
1091 input_line_pointer
= old
;
1097 if (flag_mri
&& opcode
->m_opnum
== 0)
1099 /* In MRI mode, random garbage is allowed after an instruction
1100 which accepts no operands. */
1101 the_ins
.args
= opcode
->m_operands
;
1102 the_ins
.numargs
= opcode
->m_opnum
;
1103 the_ins
.numo
= opcode
->m_codenum
;
1104 the_ins
.opcode
[0] = getone (opcode
);
1105 the_ins
.opcode
[1] = gettwo (opcode
);
1109 for (opP
= &the_ins
.operands
[0]; *p
; opP
++)
1111 p
= crack_operand (p
, opP
);
1115 the_ins
.error
= opP
->error
;
1120 opsfound
= opP
- &the_ins
.operands
[0];
1122 /* This ugly hack is to support the floating pt opcodes in their
1123 standard form. Essentially, we fake a first enty of type COP#1 */
1124 if (opcode
->m_operands
[0] == 'I')
1128 for (n
= opsfound
; n
> 0; --n
)
1129 the_ins
.operands
[n
] = the_ins
.operands
[n
- 1];
1131 memset ((char *) (&the_ins
.operands
[0]), '\0',
1132 sizeof (the_ins
.operands
[0]));
1133 the_ins
.operands
[0].mode
= CONTROL
;
1134 the_ins
.operands
[0].reg
= m68k_float_copnum
;
1138 /* We've got the operands. Find an opcode that'll accept them. */
1141 /* If we didn't get the right number of ops, or we have no
1142 common model with this pattern then reject this pattern. */
1144 ok_arch
|= opcode
->m_arch
;
1145 if (opsfound
!= opcode
->m_opnum
1146 || ((opcode
->m_arch
& current_architecture
) == 0))
1150 for (s
= opcode
->m_operands
, opP
= &the_ins
.operands
[0];
1154 /* Warning: this switch is huge! */
1155 /* I've tried to organize the cases into this order:
1156 non-alpha first, then alpha by letter. Lower-case
1157 goes directly before uppercase counterpart. */
1158 /* Code with multiple case ...: gets sorted by the lowest
1159 case ... it belongs to. I hope this makes sense. */
1265 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
1282 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
1301 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
1311 if (opP
->mode
!= IMMED
)
1313 else if (s
[1] == 'b'
1314 && ! isvar (&opP
->disp
)
1315 && (opP
->disp
.exp
.X_op
!= O_constant
1316 || ! isbyte (opP
->disp
.exp
.X_add_number
)))
1318 else if (s
[1] == 'B'
1319 && ! isvar (&opP
->disp
)
1320 && (opP
->disp
.exp
.X_op
!= O_constant
1321 || ! issbyte (opP
->disp
.exp
.X_add_number
)))
1323 else if (s
[1] == 'w'
1324 && ! isvar (&opP
->disp
)
1325 && (opP
->disp
.exp
.X_op
!= O_constant
1326 || ! isword (opP
->disp
.exp
.X_add_number
)))
1328 else if (s
[1] == 'W'
1329 && ! isvar (&opP
->disp
)
1330 && (opP
->disp
.exp
.X_op
!= O_constant
1331 || ! issword (opP
->disp
.exp
.X_add_number
)))
1337 if (opP
->mode
!= IMMED
)
1342 if (opP
->mode
== AREG
1343 || opP
->mode
== CONTROL
1344 || opP
->mode
== FPREG
1345 || opP
->mode
== IMMED
1346 || opP
->mode
== REGLST
1347 || (opP
->mode
!= ABSL
1349 || opP
->reg
== ZPC
)))
1354 if (opP
->mode
== CONTROL
1355 || opP
->mode
== FPREG
1356 || opP
->mode
== REGLST
1357 || opP
->mode
== IMMED
1358 || (opP
->mode
!= ABSL
1360 || opP
->reg
== ZPC
)))
1388 if (opP
->mode
== CONTROL
1389 || opP
->mode
== FPREG
1390 || opP
->mode
== REGLST
)
1395 if (opP
->mode
!= AINC
)
1400 if (opP
->mode
!= ADEC
)
1450 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
1471 case '~': /* For now! (JF FOO is this right?) */
1493 if (opP
->mode
!= CONTROL
1494 || (opP
->reg
!= TT0
&& opP
->reg
!= TT1
))
1499 if (opP
->mode
!= AREG
)
1504 if (opP
->mode
!= AINDR
)
1509 if (opP
->mode
!= ABSL
1511 && strncmp (instring
, "jbsr", 4) == 0))
1534 if (opP
->mode
!= CONTROL
|| opP
->reg
!= CCR
)
1539 if (opP
->mode
!= DISP
1541 || opP
->reg
> ADDR7
)
1546 if (opP
->mode
!= DREG
)
1551 if (opP
->reg
!= ACC
)
1556 if (opP
->mode
!= FPREG
)
1561 if (opP
->reg
!= MACSR
)
1566 if (opP
->reg
!= MASK
)
1571 if (opP
->mode
!= CONTROL
1578 if (opP
->mode
!= CONTROL
1580 || opP
->reg
> last_movec_reg
)
1584 const enum m68k_register
*rp
;
1585 for (rp
= control_regs
; *rp
; rp
++)
1586 if (*rp
== opP
->reg
)
1594 if (opP
->mode
!= IMMED
)
1600 if (opP
->mode
== DREG
1601 || opP
->mode
== AREG
1602 || opP
->mode
== FPREG
)
1611 opP
->mask
= 1 << (opP
->reg
- DATA0
);
1614 opP
->mask
= 1 << (opP
->reg
- ADDR0
+ 8);
1617 opP
->mask
= 1 << (opP
->reg
- FP0
+ 16);
1625 else if (opP
->mode
== CONTROL
)
1634 opP
->mask
= 1 << 24;
1637 opP
->mask
= 1 << 25;
1640 opP
->mask
= 1 << 26;
1649 else if (opP
->mode
!= REGLST
)
1651 else if (s
[1] == '8' && (opP
->mask
& 0x0ffffff) != 0)
1653 else if (s
[1] == '3' && (opP
->mask
& 0x7000000) != 0)
1658 if (opP
->mode
!= IMMED
)
1660 else if (opP
->disp
.exp
.X_op
!= O_constant
1661 || ! issbyte (opP
->disp
.exp
.X_add_number
))
1663 else if (! m68k_quick
1664 && instring
[3] != 'q'
1665 && instring
[4] != 'q')
1670 if (opP
->mode
!= DREG
1671 && opP
->mode
!= IMMED
1672 && opP
->mode
!= ABSL
)
1677 if (opP
->mode
!= IMMED
)
1679 else if (opP
->disp
.exp
.X_op
!= O_constant
1680 || opP
->disp
.exp
.X_add_number
< 1
1681 || opP
->disp
.exp
.X_add_number
> 8)
1683 else if (! m68k_quick
1684 && (strncmp (instring
, "add", 3) == 0
1685 || strncmp (instring
, "sub", 3) == 0)
1686 && instring
[3] != 'q')
1691 if (opP
->mode
!= DREG
&& opP
->mode
!= AREG
)
1696 if (opP
->mode
!= AINDR
1697 && (opP
->mode
!= BASE
1699 && opP
->reg
!= ZADDR0
)
1700 || opP
->disp
.exp
.X_op
!= O_absent
1701 || ((opP
->index
.reg
< DATA0
1702 || opP
->index
.reg
> DATA7
)
1703 && (opP
->index
.reg
< ADDR0
1704 || opP
->index
.reg
> ADDR7
))
1705 || opP
->index
.size
!= SIZE_UNSPEC
1706 || opP
->index
.scale
!= 1))
1711 if (opP
->mode
!= CONTROL
1712 || ! (opP
->reg
== FPI
1714 || opP
->reg
== FPC
))
1719 if (opP
->mode
!= CONTROL
|| opP
->reg
!= SR
)
1724 if (opP
->mode
!= IMMED
)
1726 else if (opP
->disp
.exp
.X_op
!= O_constant
1727 || opP
->disp
.exp
.X_add_number
< 0
1728 || opP
->disp
.exp
.X_add_number
> 7)
1733 if (opP
->mode
!= CONTROL
|| opP
->reg
!= USP
)
1738 if (opP
->mode
!= IMMED
)
1740 else if (opP
->disp
.exp
.X_op
!= O_constant
1741 || opP
->disp
.exp
.X_add_number
< -1
1742 || opP
->disp
.exp
.X_add_number
> 7
1743 || opP
->disp
.exp
.X_add_number
== 0)
1747 /* JF these are out of order. We could put them
1748 in order if we were willing to put up with
1749 bunches of #ifdef m68851s in the code.
1751 Don't forget that you need these operands
1752 to use 68030 MMU instructions. */
1754 /* Memory addressing mode used by pflushr. */
1756 if (opP
->mode
== CONTROL
1757 || opP
->mode
== FPREG
1758 || opP
->mode
== DREG
1759 || opP
->mode
== AREG
1760 || opP
->mode
== REGLST
)
1762 /* We should accept immediate operands, but they
1763 supposedly have to be quad word, and we don't
1764 handle that. I would like to see what a Motorola
1765 assembler does before doing something here. */
1766 if (opP
->mode
== IMMED
)
1771 if (opP
->mode
!= CONTROL
1772 || (opP
->reg
!= SFC
&& opP
->reg
!= DFC
))
1777 if (opP
->mode
!= CONTROL
|| opP
->reg
!= TC
)
1782 if (opP
->mode
!= CONTROL
|| opP
->reg
!= AC
)
1787 if (opP
->mode
!= CONTROL
1790 && opP
->reg
!= SCC
))
1795 if (opP
->mode
!= CONTROL
1801 if (opP
->mode
!= CONTROL
1804 && opP
->reg
!= CRP
))
1828 if (opP
->mode
!= CONTROL
1829 || (!(opP
->reg
>= BAD
&& opP
->reg
<= BAD
+ 7)
1830 && !(opP
->reg
>= BAC
&& opP
->reg
<= BAC
+ 7)))
1835 if (opP
->mode
!= CONTROL
|| opP
->reg
!= PSR
)
1840 if (opP
->mode
!= CONTROL
|| opP
->reg
!= PCSR
)
1845 if (opP
->mode
!= CONTROL
1854 if (opP
->mode
!= ABSL
)
1859 if (opP
->reg
< DATA0L
|| opP
->reg
> ADDR7U
)
1861 /* FIXME: kludge instead of fixing parser:
1862 upper/lower registers are *not* CONTROL
1863 registers, but ordinary ones. */
1864 if ((opP
->reg
>= DATA0L
&& opP
->reg
<= DATA7L
)
1865 || (opP
->reg
>= DATA0U
&& opP
->reg
<= DATA7U
))
1872 if (!(opP
->mode
== AINDR
1873 || (opP
->mode
== DISP
&& !(opP
->reg
== PC
||
1879 if (!(opP
->mode
== AINDR
|| opP
->mode
== DISP
))
1895 opcode
= opcode
->m_next
;
1900 && !(ok_arch
& current_architecture
))
1905 _("invalid instruction for this architecture; needs "));
1906 cp
= buf
+ strlen (buf
);
1910 strcpy (cp
, _("ColdFire fpu (cfv4e)"));
1913 strcpy (cp
, _("fpu (68040, 68060 or 68881/68882)"));
1916 strcpy (cp
, _("mmu (68030 or 68851)"));
1919 strcpy (cp
, _("68020 or higher"));
1922 strcpy (cp
, _("68000 or higher"));
1925 strcpy (cp
, _("68010 or higher"));
1929 int got_one
= 0, idx
;
1931 idx
< (int) (sizeof (archs
) / sizeof (archs
[0]));
1934 if ((archs
[idx
].arch
& ok_arch
)
1935 && ! archs
[idx
].alias
)
1939 strcpy (cp
, " or ");
1943 strcpy (cp
, archs
[idx
].name
);
1949 cp
= xmalloc (strlen (buf
) + 1);
1954 the_ins
.error
= _("operands mismatch");
1961 /* Now assemble it. */
1962 the_ins
.args
= opcode
->m_operands
;
1963 the_ins
.numargs
= opcode
->m_opnum
;
1964 the_ins
.numo
= opcode
->m_codenum
;
1965 the_ins
.opcode
[0] = getone (opcode
);
1966 the_ins
.opcode
[1] = gettwo (opcode
);
1968 for (s
= the_ins
.args
, opP
= &the_ins
.operands
[0]; *s
; s
+= 2, opP
++)
1970 /* This switch is a doozy.
1971 Watch the first step; its a big one! */
2003 tmpreg
= 0x3c; /* 7.4 */
2004 if (strchr ("bwl", s
[1]))
2005 nextword
= get_num (&opP
->disp
, 90);
2007 nextword
= get_num (&opP
->disp
, 0);
2008 if (isvar (&opP
->disp
))
2009 add_fix (s
[1], &opP
->disp
, 0, 0);
2013 if (!isbyte (nextword
))
2014 opP
->error
= _("operand out of range");
2019 if (!isword (nextword
))
2020 opP
->error
= _("operand out of range");
2025 if (!issword (nextword
))
2026 opP
->error
= _("operand out of range");
2031 addword (nextword
>> 16);
2058 /* We gotta put out some float. */
2059 if (op (&opP
->disp
) != O_big
)
2064 /* Can other cases happen here? */
2065 if (op (&opP
->disp
) != O_constant
)
2068 val
= (valueT
) offs (&opP
->disp
);
2072 generic_bignum
[gencnt
] = (LITTLENUM_TYPE
) val
;
2073 val
>>= LITTLENUM_NUMBER_OF_BITS
;
2077 offs (&opP
->disp
) = gencnt
;
2079 if (offs (&opP
->disp
) > 0)
2081 if (offs (&opP
->disp
) > baseo
)
2083 as_warn (_("Bignum too big for %c format; truncated"),
2085 offs (&opP
->disp
) = baseo
;
2087 baseo
-= offs (&opP
->disp
);
2090 for (wordp
= generic_bignum
+ offs (&opP
->disp
) - 1;
2091 offs (&opP
->disp
)--;
2096 gen_to_words (words
, baseo
, (long) outro
);
2097 for (wordp
= words
; baseo
--; wordp
++)
2101 tmpreg
= opP
->reg
- DATA
; /* 0.dreg */
2104 tmpreg
= 0x08 + opP
->reg
- ADDR
; /* 1.areg */
2107 tmpreg
= 0x10 + opP
->reg
- ADDR
; /* 2.areg */
2110 tmpreg
= 0x20 + opP
->reg
- ADDR
; /* 4.areg */
2113 tmpreg
= 0x18 + opP
->reg
- ADDR
; /* 3.areg */
2117 nextword
= get_num (&opP
->disp
, 90);
2120 && ! isvar (&opP
->disp
)
2123 opP
->disp
.exp
.X_op
= O_symbol
;
2124 #ifndef BFD_ASSEMBLER
2125 opP
->disp
.exp
.X_add_symbol
= &abs_symbol
;
2127 opP
->disp
.exp
.X_add_symbol
=
2128 section_symbol (absolute_section
);
2132 /* Force into index mode. Hope this works. */
2134 /* We do the first bit for 32-bit displacements, and the
2135 second bit for 16 bit ones. It is possible that we
2136 should make the default be WORD instead of LONG, but
2137 I think that'd break GCC, so we put up with a little
2138 inefficiency for the sake of working output. */
2140 if (!issword (nextword
)
2141 || (isvar (&opP
->disp
)
2142 && ((opP
->disp
.size
== SIZE_UNSPEC
2143 && flag_short_refs
== 0
2144 && cpu_of_arch (current_architecture
) >= m68020
2145 && ! arch_coldfire_p (current_architecture
))
2146 || opP
->disp
.size
== SIZE_LONG
)))
2148 if (cpu_of_arch (current_architecture
) < m68020
2149 || arch_coldfire_p (current_architecture
))
2151 _("displacement too large for this architecture; needs 68020 or higher");
2153 tmpreg
= 0x3B; /* 7.3 */
2155 tmpreg
= 0x30 + opP
->reg
- ADDR
; /* 6.areg */
2156 if (isvar (&opP
->disp
))
2160 if (opP
->disp
.size
== SIZE_LONG
2162 /* If the displacement needs pic
2163 relocation it cannot be relaxed. */
2164 || opP
->disp
.pic_reloc
!= pic_none
2169 add_fix ('l', &opP
->disp
, 1, 2);
2173 add_frag (adds (&opP
->disp
),
2175 TAB (PCREL1632
, SZ_UNDEF
));
2182 add_fix ('l', &opP
->disp
, 0, 0);
2187 addword (nextword
>> 16);
2192 tmpreg
= 0x3A; /* 7.2 */
2194 tmpreg
= 0x28 + opP
->reg
- ADDR
; /* 5.areg */
2196 if (isvar (&opP
->disp
))
2200 add_fix ('w', &opP
->disp
, 1, 0);
2203 add_fix ('w', &opP
->disp
, 0, 0);
2213 baseo
= get_num (&opP
->disp
, 90);
2214 if (opP
->mode
== POST
|| opP
->mode
== PRE
)
2215 outro
= get_num (&opP
->odisp
, 90);
2216 /* Figure out the `addressing mode'.
2217 Also turn on the BASE_DISABLE bit, if needed. */
2218 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
2220 tmpreg
= 0x3b; /* 7.3 */
2221 if (opP
->reg
== ZPC
)
2224 else if (opP
->reg
== 0)
2227 tmpreg
= 0x30; /* 6.garbage */
2229 else if (opP
->reg
>= ZADDR0
&& opP
->reg
<= ZADDR7
)
2232 tmpreg
= 0x30 + opP
->reg
- ZADDR0
;
2235 tmpreg
= 0x30 + opP
->reg
- ADDR
; /* 6.areg */
2237 siz1
= opP
->disp
.size
;
2238 if (opP
->mode
== POST
|| opP
->mode
== PRE
)
2239 siz2
= opP
->odisp
.size
;
2243 /* Index register stuff. */
2244 if (opP
->index
.reg
!= 0
2245 && opP
->index
.reg
>= DATA
2246 && opP
->index
.reg
<= ADDR7
)
2248 nextword
|= (opP
->index
.reg
- DATA
) << 12;
2250 if (opP
->index
.size
== SIZE_LONG
2251 || (opP
->index
.size
== SIZE_UNSPEC
2252 && m68k_index_width_default
== SIZE_LONG
))
2255 if ((opP
->index
.scale
!= 1
2256 && cpu_of_arch (current_architecture
) < m68020
)
2257 || (opP
->index
.scale
== 8
2258 && (arch_coldfire_p (current_architecture
)
2259 && !arch_coldfire_v4e_p(current_architecture
))))
2262 _("scale factor invalid on this architecture; needs cpu32 or 68020 or higher");
2265 if (arch_coldfire_p (current_architecture
)
2266 && opP
->index
.size
== SIZE_WORD
)
2267 opP
->error
= _("invalid index size for coldfire");
2269 switch (opP
->index
.scale
)
2286 GET US OUT OF HERE! */
2288 /* Must be INDEX, with an index register. Address
2289 register cannot be ZERO-PC, and either :b was
2290 forced, or we know it will fit. For a 68000 or
2291 68010, force this mode anyways, because the
2292 larger modes aren't supported. */
2293 if (opP
->mode
== BASE
2294 && ((opP
->reg
>= ADDR0
2295 && opP
->reg
<= ADDR7
)
2298 if (siz1
== SIZE_BYTE
2299 || cpu_of_arch (current_architecture
) < m68020
2300 || arch_coldfire_p (current_architecture
)
2301 || (siz1
== SIZE_UNSPEC
2302 && ! isvar (&opP
->disp
)
2303 && issbyte (baseo
)))
2305 nextword
+= baseo
& 0xff;
2307 if (isvar (&opP
->disp
))
2309 /* Do a byte relocation. If it doesn't
2310 fit (possible on m68000) let the
2311 fixup processing complain later. */
2313 add_fix ('B', &opP
->disp
, 1, 1);
2315 add_fix ('B', &opP
->disp
, 0, 0);
2317 else if (siz1
!= SIZE_BYTE
)
2319 if (siz1
!= SIZE_UNSPEC
)
2320 as_warn (_("Forcing byte displacement"));
2321 if (! issbyte (baseo
))
2322 opP
->error
= _("byte displacement out of range");
2327 else if (siz1
== SIZE_UNSPEC
2329 && isvar (&opP
->disp
)
2330 && subs (&opP
->disp
) == NULL
2332 /* If the displacement needs pic
2333 relocation it cannot be relaxed. */
2334 && opP
->disp
.pic_reloc
== pic_none
2338 /* The code in md_convert_frag_1 needs to be
2339 able to adjust nextword. Call frag_grow
2340 to ensure that we have enough space in
2341 the frag obstack to make all the bytes
2344 nextword
+= baseo
& 0xff;
2346 add_frag (adds (&opP
->disp
), offs (&opP
->disp
),
2347 TAB (PCINDEX
, SZ_UNDEF
));
2355 nextword
|= 0x40; /* No index reg. */
2356 if (opP
->index
.reg
>= ZDATA0
2357 && opP
->index
.reg
<= ZDATA7
)
2358 nextword
|= (opP
->index
.reg
- ZDATA0
) << 12;
2359 else if (opP
->index
.reg
>= ZADDR0
2360 || opP
->index
.reg
<= ZADDR7
)
2361 nextword
|= (opP
->index
.reg
- ZADDR0
+ 8) << 12;
2364 /* It isn't simple. */
2366 if (cpu_of_arch (current_architecture
) < m68020
2367 || arch_coldfire_p (current_architecture
))
2369 _("invalid operand mode for this architecture; needs 68020 or higher");
2372 /* If the guy specified a width, we assume that it is
2373 wide enough. Maybe it isn't. If so, we lose. */
2377 if (isvar (&opP
->disp
)
2379 : ! issword (baseo
))
2384 else if (! isvar (&opP
->disp
) && baseo
== 0)
2393 as_warn (_(":b not permitted; defaulting to :w"));
2403 /* Figure out inner displacement stuff. */
2404 if (opP
->mode
== POST
|| opP
->mode
== PRE
)
2406 if (cpu_of_arch (current_architecture
) & cpu32
)
2407 opP
->error
= _("invalid operand mode for this architecture; needs 68020 or higher");
2411 if (isvar (&opP
->odisp
)
2413 : ! issword (outro
))
2418 else if (! isvar (&opP
->odisp
) && outro
== 0)
2427 as_warn (_(":b not permitted; defaulting to :w"));
2436 if (opP
->mode
== POST
2437 && (nextword
& 0x40) == 0)
2442 if (siz1
!= SIZE_UNSPEC
&& isvar (&opP
->disp
))
2444 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
2445 add_fix (siz1
== SIZE_LONG
? 'l' : 'w', &opP
->disp
, 1, 2);
2447 add_fix (siz1
== SIZE_LONG
? 'l' : 'w', &opP
->disp
, 0, 0);
2449 if (siz1
== SIZE_LONG
)
2450 addword (baseo
>> 16);
2451 if (siz1
!= SIZE_UNSPEC
)
2454 if (siz2
!= SIZE_UNSPEC
&& isvar (&opP
->odisp
))
2455 add_fix (siz2
== SIZE_LONG
? 'l' : 'w', &opP
->odisp
, 0, 0);
2456 if (siz2
== SIZE_LONG
)
2457 addword (outro
>> 16);
2458 if (siz2
!= SIZE_UNSPEC
)
2464 nextword
= get_num (&opP
->disp
, 90);
2465 switch (opP
->disp
.size
)
2470 if (!isvar (&opP
->disp
) && issword (offs (&opP
->disp
)))
2472 tmpreg
= 0x38; /* 7.0 */
2476 if (isvar (&opP
->disp
)
2477 && !subs (&opP
->disp
)
2478 && adds (&opP
->disp
)
2480 /* If the displacement needs pic relocation it
2481 cannot be relaxed. */
2482 && opP
->disp
.pic_reloc
== pic_none
2485 && !strchr ("~%&$?", s
[0]))
2487 tmpreg
= 0x3A; /* 7.2 */
2488 add_frag (adds (&opP
->disp
),
2490 TAB (ABSTOPCREL
, SZ_UNDEF
));
2493 /* Fall through into long. */
2495 if (isvar (&opP
->disp
))
2496 add_fix ('l', &opP
->disp
, 0, 0);
2498 tmpreg
= 0x39;/* 7.1 mode */
2499 addword (nextword
>> 16);
2504 as_bad (_("unsupported byte value; use a different suffix"));
2508 if (isvar (&opP
->disp
))
2509 add_fix ('w', &opP
->disp
, 0, 0);
2511 tmpreg
= 0x38;/* 7.0 mode */
2519 as_bad (_("unknown/incorrect operand"));
2522 install_gen_operand (s
[1], tmpreg
);
2528 { /* JF: I hate floating point! */
2543 tmpreg
= get_num (&opP
->disp
, tmpreg
);
2544 if (isvar (&opP
->disp
))
2545 add_fix (s
[1], &opP
->disp
, 0, 0);
2548 case 'b': /* Danger: These do no check for
2549 certain types of overflow.
2551 if (!isbyte (tmpreg
))
2552 opP
->error
= _("out of range");
2553 insop (tmpreg
, opcode
);
2554 if (isvar (&opP
->disp
))
2555 the_ins
.reloc
[the_ins
.nrel
- 1].n
=
2556 (opcode
->m_codenum
) * 2 + 1;
2559 if (!issbyte (tmpreg
))
2560 opP
->error
= _("out of range");
2561 the_ins
.opcode
[the_ins
.numo
- 1] |= tmpreg
& 0xff;
2562 if (isvar (&opP
->disp
))
2563 the_ins
.reloc
[the_ins
.nrel
- 1].n
= opcode
->m_codenum
* 2 - 1;
2566 if (!isword (tmpreg
))
2567 opP
->error
= _("out of range");
2568 insop (tmpreg
, opcode
);
2569 if (isvar (&opP
->disp
))
2570 the_ins
.reloc
[the_ins
.nrel
- 1].n
= (opcode
->m_codenum
) * 2;
2573 if (!issword (tmpreg
))
2574 opP
->error
= _("out of range");
2575 insop (tmpreg
, opcode
);
2576 if (isvar (&opP
->disp
))
2577 the_ins
.reloc
[the_ins
.nrel
- 1].n
= (opcode
->m_codenum
) * 2;
2580 /* Because of the way insop works, we put these two out
2582 insop (tmpreg
, opcode
);
2583 insop (tmpreg
>> 16, opcode
);
2584 if (isvar (&opP
->disp
))
2585 the_ins
.reloc
[the_ins
.nrel
- 1].n
= (opcode
->m_codenum
) * 2;
2592 install_operand (s
[1], tmpreg
);
2603 install_operand (s
[1], opP
->reg
- ADDR
);
2607 tmpreg
= get_num (&opP
->disp
, 90);
2611 add_fix ('B', &opP
->disp
, 1, -1);
2614 add_fix ('w', &opP
->disp
, 1, 0);
2619 if (! HAVE_LONG_BRANCH (current_architecture
))
2620 as_warn (_("Can't use long branches on 68000/68010/5200"));
2621 the_ins
.opcode
[0] |= 0xff;
2622 add_fix ('l', &opP
->disp
, 1, 0);
2627 if (subs (&opP
->disp
)) /* We can't relax it. */
2631 /* If the displacement needs pic relocation it cannot be
2633 if (opP
->disp
.pic_reloc
!= pic_none
)
2636 /* This could either be a symbol, or an absolute
2637 address. If it's an absolute address, turn it into
2638 an absolute jump right here and keep it out of the
2640 if (adds (&opP
->disp
) == 0)
2642 if (the_ins
.opcode
[0] == 0x6000) /* jbra */
2643 the_ins
.opcode
[0] = 0x4EF9;
2644 else if (the_ins
.opcode
[0] == 0x6100) /* jbsr */
2645 the_ins
.opcode
[0] = 0x4EB9;
2648 the_ins
.opcode
[0] ^= 0x0100;
2649 the_ins
.opcode
[0] |= 0x0006;
2652 add_fix ('l', &opP
->disp
, 0, 0);
2658 /* Now we know it's going into the relaxer. Now figure
2659 out which mode. We try in this order of preference:
2660 long branch, absolute jump, byte/word branches only. */
2661 if (HAVE_LONG_BRANCH (current_architecture
))
2662 add_frag (adds (&opP
->disp
), offs (&opP
->disp
),
2663 TAB (BRANCHBWL
, SZ_UNDEF
));
2664 else if (! flag_keep_pcrel
)
2666 if ((the_ins
.opcode
[0] == 0x6000)
2667 || (the_ins
.opcode
[0] == 0x6100))
2668 add_frag (adds (&opP
->disp
), offs (&opP
->disp
),
2669 TAB (BRABSJUNC
, SZ_UNDEF
));
2671 add_frag (adds (&opP
->disp
), offs (&opP
->disp
),
2672 TAB (BRABSJCOND
, SZ_UNDEF
));
2675 add_frag (adds (&opP
->disp
), offs (&opP
->disp
),
2676 TAB (BRANCHBW
, SZ_UNDEF
));
2679 if (isvar (&opP
->disp
))
2681 /* Check for DBcc instructions. We can relax them,
2682 but only if we have long branches and/or absolute
2684 if (((the_ins
.opcode
[0] & 0xf0f8) == 0x50c8)
2685 && (HAVE_LONG_BRANCH (current_architecture
)
2686 || (! flag_keep_pcrel
)))
2688 if (HAVE_LONG_BRANCH (current_architecture
))
2689 add_frag (adds (&opP
->disp
), offs (&opP
->disp
),
2690 TAB (DBCCLBR
, SZ_UNDEF
));
2692 add_frag (adds (&opP
->disp
), offs (&opP
->disp
),
2693 TAB (DBCCABSJ
, SZ_UNDEF
));
2696 add_fix ('w', &opP
->disp
, 1, 0);
2700 case 'C': /* Fixed size LONG coproc branches. */
2701 add_fix ('l', &opP
->disp
, 1, 0);
2705 case 'c': /* Var size Coprocesssor branches. */
2706 if (subs (&opP
->disp
) || (adds (&opP
->disp
) == 0))
2708 the_ins
.opcode
[the_ins
.numo
- 1] |= 0x40;
2709 add_fix ('l', &opP
->disp
, 1, 0);
2714 add_frag (adds (&opP
->disp
), offs (&opP
->disp
),
2715 TAB (FBRANCH
, SZ_UNDEF
));
2722 case 'C': /* Ignore it. */
2725 case 'd': /* JF this is a kludge. */
2726 install_operand ('s', opP
->reg
- ADDR
);
2727 tmpreg
= get_num (&opP
->disp
, 90);
2728 if (!issword (tmpreg
))
2730 as_warn (_("Expression out of range, using 0"));
2737 install_operand (s
[1], opP
->reg
- DATA
);
2740 case 'E': /* Ignore it. */
2744 install_operand (s
[1], opP
->reg
- FP0
);
2747 case 'G': /* Ignore it. */
2752 tmpreg
= opP
->reg
- COP0
;
2753 install_operand (s
[1], tmpreg
);
2756 case 'J': /* JF foo. */
2885 install_operand (s
[1], tmpreg
);
2889 tmpreg
= get_num (&opP
->disp
, 55);
2890 install_operand (s
[1], tmpreg
& 0x7f);
2897 if (tmpreg
& 0x7FF0000)
2898 as_bad (_("Floating point register in register list"));
2899 insop (reverse_16_bits (tmpreg
), opcode
);
2903 if (tmpreg
& 0x700FFFF)
2904 as_bad (_("Wrong register in floating-point reglist"));
2905 install_operand (s
[1], reverse_8_bits (tmpreg
>> 16));
2913 if (tmpreg
& 0x7FF0000)
2914 as_bad (_("Floating point register in register list"));
2915 insop (tmpreg
, opcode
);
2917 else if (s
[1] == '8')
2919 if (tmpreg
& 0x0FFFFFF)
2920 as_bad (_("incorrect register in reglist"));
2921 install_operand (s
[1], tmpreg
>> 24);
2925 if (tmpreg
& 0x700FFFF)
2926 as_bad (_("wrong register in floating-point reglist"));
2928 install_operand (s
[1], tmpreg
>> 16);
2933 install_operand (s
[1], get_num (&opP
->disp
, 60));
2937 tmpreg
= ((opP
->mode
== DREG
)
2938 ? 0x20 + (int) (opP
->reg
- DATA
)
2939 : (get_num (&opP
->disp
, 40) & 0x1F));
2940 install_operand (s
[1], tmpreg
);
2944 tmpreg
= get_num (&opP
->disp
, 10);
2947 install_operand (s
[1], tmpreg
);
2951 /* This depends on the fact that ADDR registers are eight
2952 more than their corresponding DATA regs, so the result
2953 will have the ADDR_REG bit set. */
2954 install_operand (s
[1], opP
->reg
- DATA
);
2958 if (opP
->mode
== AINDR
)
2959 install_operand (s
[1], opP
->reg
- DATA
);
2961 install_operand (s
[1], opP
->index
.reg
- DATA
);
2965 if (opP
->reg
== FPI
)
2967 else if (opP
->reg
== FPS
)
2969 else if (opP
->reg
== FPC
)
2973 install_operand (s
[1], tmpreg
);
2976 case 'S': /* Ignore it. */
2980 install_operand (s
[1], get_num (&opP
->disp
, 30));
2983 case 'U': /* Ignore it. */
3002 as_fatal (_("failed sanity check"));
3003 } /* switch on cache token. */
3004 install_operand (s
[1], tmpreg
);
3007 /* JF: These are out of order, I fear. */
3020 install_operand (s
[1], tmpreg
);
3046 install_operand (s
[1], tmpreg
);
3050 if (opP
->reg
== VAL
)
3069 install_operand (s
[1], tmpreg
);
3083 tmpreg
= (4 << 10) | ((opP
->reg
- BAD
) << 2);
3094 tmpreg
= (5 << 10) | ((opP
->reg
- BAC
) << 2);
3100 install_operand (s
[1], tmpreg
);
3103 know (opP
->reg
== PSR
);
3106 know (opP
->reg
== PCSR
);
3121 install_operand (s
[1], tmpreg
);
3124 tmpreg
= get_num (&opP
->disp
, 20);
3125 install_operand (s
[1], tmpreg
);
3127 case '_': /* used only for move16 absolute 32-bit address. */
3128 if (isvar (&opP
->disp
))
3129 add_fix ('l', &opP
->disp
, 0, 0);
3130 tmpreg
= get_num (&opP
->disp
, 90);
3131 addword (tmpreg
>> 16);
3132 addword (tmpreg
& 0xFFFF);
3135 install_operand (s
[1], opP
->reg
- DATA0L
);
3136 opP
->reg
-= (DATA0L
);
3137 opP
->reg
&= 0x0F; /* remove upper/lower bit. */
3140 tmpreg
= get_num (&opP
->disp
, 80);
3143 install_operand (s
[1], tmpreg
);
3150 /* By the time whe get here (FINALLY) the_ins contains the complete
3151 instruction, ready to be emitted. . . */
3155 reverse_16_bits (in
)
3161 static int mask
[16] =
3163 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
3164 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000
3166 for (n
= 0; n
< 16; n
++)
3169 out
|= mask
[15 - n
];
3172 } /* reverse_16_bits() */
3181 static int mask
[8] =
3183 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
3186 for (n
= 0; n
< 8; n
++)
3192 } /* reverse_8_bits() */
3194 /* Cause an extra frag to be generated here, inserting up to 10 bytes
3195 (that value is chosen in the frag_var call in md_assemble). TYPE
3196 is the subtype of the frag to be generated; its primary type is
3197 rs_machine_dependent.
3199 The TYPE parameter is also used by md_convert_frag_1 and
3200 md_estimate_size_before_relax. The appropriate type of fixup will
3201 be emitted by md_convert_frag_1.
3203 ADD becomes the FR_SYMBOL field of the frag, and OFF the FR_OFFSET. */
3205 install_operand (mode
, val
)
3212 the_ins
.opcode
[0] |= val
& 0xFF; /* JF FF is for M kludge. */
3215 the_ins
.opcode
[0] |= val
<< 9;
3218 the_ins
.opcode
[1] |= val
<< 12;
3221 the_ins
.opcode
[1] |= val
<< 6;
3224 the_ins
.opcode
[1] |= val
;
3227 the_ins
.opcode
[2] |= val
<< 12;
3230 the_ins
.opcode
[2] |= val
<< 6;
3233 /* DANGER! This is a hack to force cas2l and cas2w cmds to be
3234 three words long! */
3236 the_ins
.opcode
[2] |= val
;
3239 the_ins
.opcode
[1] |= val
<< 7;
3242 the_ins
.opcode
[1] |= val
<< 10;
3246 the_ins
.opcode
[1] |= val
<< 5;
3251 the_ins
.opcode
[1] |= (val
<< 10) | (val
<< 7);
3254 the_ins
.opcode
[1] |= (val
<< 12) | val
;
3257 the_ins
.opcode
[0] |= val
= 0xff;
3260 the_ins
.opcode
[0] |= val
<< 9;
3263 the_ins
.opcode
[1] |= val
;
3266 the_ins
.opcode
[1] |= val
;
3267 the_ins
.numo
++; /* What a hack. */
3270 the_ins
.opcode
[1] |= val
<< 4;
3278 the_ins
.opcode
[0] |= (val
<< 6);
3281 the_ins
.opcode
[1] = (val
>> 16);
3282 the_ins
.opcode
[2] = val
& 0xffff;
3285 the_ins
.opcode
[0] |= ((val
& 0x8) << (6 - 3));
3286 the_ins
.opcode
[0] |= ((val
& 0x7) << 9);
3287 the_ins
.opcode
[1] |= ((val
& 0x10) << (7 - 4));
3290 the_ins
.opcode
[0] |= ((val
& 0x8) << (6 - 3));
3291 the_ins
.opcode
[0] |= ((val
& 0x7) << 9);
3294 the_ins
.opcode
[1] |= val
<< 12;
3295 the_ins
.opcode
[1] |= ((val
& 0x10) << (7 - 4));
3298 the_ins
.opcode
[0] |= (val
& 0xF);
3299 the_ins
.opcode
[1] |= ((val
& 0x10) << (6 - 4));
3302 the_ins
.opcode
[1] |= (val
& 0xF);
3303 the_ins
.opcode
[1] |= ((val
& 0x10) << (6 - 4));
3306 the_ins
.opcode
[1] |= ((val
!= 1) << 10);
3310 as_fatal (_("failed sanity check."));
3312 } /* install_operand() */
3315 install_gen_operand (mode
, val
)
3322 the_ins
.opcode
[0] |= val
;
3325 /* This is a kludge!!! */
3326 the_ins
.opcode
[0] |= (val
& 0x07) << 9 | (val
& 0x38) << 3;
3335 the_ins
.opcode
[0] |= val
;
3337 /* more stuff goes here. */
3339 as_fatal (_("failed sanity check."));
3341 } /* install_gen_operand() */
3344 * verify that we have some number of paren pairs, do m68k_ip_op(), and
3345 * then deal with the bitfield hack.
3349 crack_operand (str
, opP
)
3351 register struct m68k_op
*opP
;
3353 register int parens
;
3355 register char *beg_str
;
3363 for (parens
= 0; *str
&& (parens
> 0 || inquote
|| notend (str
)); str
++)
3369 else if (*str
== ')')
3373 opP
->error
= _("Extra )");
3379 if (flag_mri
&& *str
== '\'')
3380 inquote
= ! inquote
;
3382 if (!*str
&& parens
)
3384 opP
->error
= _("Missing )");
3389 if (m68k_ip_op (beg_str
, opP
) != 0)
3396 c
= *++str
; /* JF bitfield hack. */
3401 as_bad (_("Missing operand"));
3404 /* Detect MRI REG symbols and convert them to REGLSTs. */
3405 if (opP
->mode
== CONTROL
&& (int)opP
->reg
< 0)
3408 opP
->mask
= ~(int)opP
->reg
;
3415 /* This is the guts of the machine-dependent assembler. STR points to a
3416 machine dependent instruction. This function is supposed to emit
3417 the frags/bytes it assembles to.
3421 insert_reg (regname
, regnum
)
3422 const char *regname
;
3428 #ifdef REGISTER_PREFIX
3429 if (!flag_reg_prefix_optional
)
3431 buf
[0] = REGISTER_PREFIX
;
3432 strcpy (buf
+ 1, regname
);
3437 symbol_table_insert (symbol_new (regname
, reg_section
, regnum
,
3438 &zero_address_frag
));
3440 for (i
= 0; regname
[i
]; i
++)
3441 buf
[i
] = TOUPPER (regname
[i
]);
3444 symbol_table_insert (symbol_new (buf
, reg_section
, regnum
,
3445 &zero_address_frag
));
3454 static const struct init_entry init_table
[] =
3513 /* Control registers. */
3514 { "sfc", SFC
}, /* Source Function Code. */
3516 { "dfc", DFC
}, /* Destination Function Code. */
3518 { "cacr", CACR
}, /* Cache Control Register. */
3519 { "caar", CAAR
}, /* Cache Address Register. */
3521 { "usp", USP
}, /* User Stack Pointer. */
3522 { "vbr", VBR
}, /* Vector Base Register. */
3523 { "msp", MSP
}, /* Master Stack Pointer. */
3524 { "isp", ISP
}, /* Interrupt Stack Pointer. */
3526 { "itt0", ITT0
}, /* Instruction Transparent Translation Reg 0. */
3527 { "itt1", ITT1
}, /* Instruction Transparent Translation Reg 1. */
3528 { "dtt0", DTT0
}, /* Data Transparent Translation Register 0. */
3529 { "dtt1", DTT1
}, /* Data Transparent Translation Register 1. */
3531 /* 68ec040 versions of same */
3532 { "iacr0", ITT0
}, /* Instruction Access Control Register 0. */
3533 { "iacr1", ITT1
}, /* Instruction Access Control Register 0. */
3534 { "dacr0", DTT0
}, /* Data Access Control Register 0. */
3535 { "dacr1", DTT1
}, /* Data Access Control Register 0. */
3537 /* mcf5200 versions of same. The ColdFire programmer's reference
3538 manual indicated that the order is 2,3,0,1, but Ken Rose
3539 <rose@netcom.com> says that 0,1,2,3 is the correct order. */
3540 { "acr0", ACR0
}, /* Access Control Unit 0. */
3541 { "acr1", ACR1
}, /* Access Control Unit 1. */
3542 { "acr2", ACR2
}, /* Access Control Unit 2. */
3543 { "acr3", ACR3
}, /* Access Control Unit 3. */
3545 { "tc", TC
}, /* MMU Translation Control Register. */
3548 { "mmusr", MMUSR
}, /* MMU Status Register. */
3549 { "srp", SRP
}, /* User Root Pointer. */
3550 { "urp", URP
}, /* Supervisor Root Pointer. */
3555 { "rombar", ROMBAR
}, /* ROM Base Address Register. */
3556 { "rambar0", RAMBAR0
}, /* ROM Base Address Register. */
3557 { "rambar1", RAMBAR1
}, /* ROM Base Address Register. */
3558 { "mbar", MBAR
}, /* Module Base Address Register. */
3560 { "mbar0", MBAR0
}, /* mcfv4e registers. */
3561 { "mbar1", MBAR1
}, /* mcfv4e registers. */
3562 { "rombar0", ROMBAR
}, /* mcfv4e registers. */
3563 { "rombar1", ROMBAR1
}, /* mcfv4e registers. */
3564 { "mpcr", MPCR
}, /* mcfv4e registers. */
3565 { "edrambar", EDRAMBAR
}, /* mcfv4e registers. */
3566 { "secmbar", SECMBAR
}, /* mcfv4e registers. */
3567 { "asid", TC
}, /* mcfv4e registers. */
3568 { "mmubar", BUSCR
}, /* mcfv4e registers. */
3569 { "pcr1u0", PCR1U0
}, /* mcfv4e registers. */
3570 { "pcr1l0", PCR1L0
}, /* mcfv4e registers. */
3571 { "pcr2u0", PCR2U0
}, /* mcfv4e registers. */
3572 { "pcr2l0", PCR2L0
}, /* mcfv4e registers. */
3573 { "pcr3u0", PCR3U0
}, /* mcfv4e registers. */
3574 { "pcr3l0", PCR3L0
}, /* mcfv4e registers. */
3575 { "pcr1u1", PCR1U1
}, /* mcfv4e registers. */
3576 { "pcr1l1", PCR1L1
}, /* mcfv4e registers. */
3577 { "pcr2u1", PCR2U1
}, /* mcfv4e registers. */
3578 { "pcr2l1", PCR2L1
}, /* mcfv4e registers. */
3579 { "pcr3u1", PCR3U1
}, /* mcfv4e registers. */
3580 { "pcr3l1", PCR3L1
}, /* mcfv4e registers. */
3582 { "flashbar", FLASHBAR
}, /* mcf528x registers. */
3583 { "rambar", RAMBAR
}, /* mcf528x registers. */
3584 /* End of control registers. */
3618 /* 68ec030 versions of same. */
3621 /* 68ec030 access control unit, identical to 030 MMU status reg. */
3624 /* Suppressed data and address registers. */
3642 /* Upper and lower data and address registers, used by macw and msacw. */
3686 for (i
= 0; init_table
[i
].name
; i
++)
3687 insert_reg (init_table
[i
].name
, init_table
[i
].number
);
3690 static int no_68851
, no_68881
;
3693 /* a.out machine type. Default to 68020. */
3694 int m68k_aout_machtype
= 2;
3706 int shorts_this_frag
;
3709 /* In MRI mode, the instruction and operands are separated by a
3710 space. Anything following the operands is a comment. The label
3711 has already been removed. */
3719 for (s
= str
; *s
!= '\0'; s
++)
3721 if ((*s
== ' ' || *s
== '\t') && ! inquote
)
3739 inquote
= ! inquote
;
3744 memset ((char *) (&the_ins
), '\0', sizeof (the_ins
));
3749 for (n
= 0; n
< the_ins
.numargs
; n
++)
3750 if (the_ins
.operands
[n
].error
)
3752 er
= the_ins
.operands
[n
].error
;
3758 as_bad (_("%s -- statement `%s' ignored"), er
, str
);
3762 /* If there is a current label, record that it marks an instruction. */
3763 if (current_label
!= NULL
)
3765 current_label
->text
= 1;
3766 current_label
= NULL
;
3770 /* Tie dwarf2 debug info to the address at the start of the insn. */
3771 dwarf2_emit_insn (0);
3774 if (the_ins
.nfrag
== 0)
3776 /* No frag hacking involved; just put it out. */
3777 toP
= frag_more (2 * the_ins
.numo
);
3778 fromP
= &the_ins
.opcode
[0];
3779 for (m
= the_ins
.numo
; m
; --m
)
3781 md_number_to_chars (toP
, (long) (*fromP
), 2);
3785 /* Put out symbol-dependent info. */
3786 for (m
= 0; m
< the_ins
.nrel
; m
++)
3788 switch (the_ins
.reloc
[m
].wid
)
3807 as_fatal (_("Don't know how to figure width of %c in md_assemble()"),
3808 the_ins
.reloc
[m
].wid
);
3811 fixP
= fix_new_exp (frag_now
,
3812 ((toP
- frag_now
->fr_literal
)
3813 - the_ins
.numo
* 2 + the_ins
.reloc
[m
].n
),
3815 &the_ins
.reloc
[m
].exp
,
3816 the_ins
.reloc
[m
].pcrel
,
3817 get_reloc_code (n
, the_ins
.reloc
[m
].pcrel
,
3818 the_ins
.reloc
[m
].pic_reloc
));
3819 fixP
->fx_pcrel_adjust
= the_ins
.reloc
[m
].pcrel_fix
;
3820 if (the_ins
.reloc
[m
].wid
== 'B')
3821 fixP
->fx_signed
= 1;
3826 /* There's some frag hacking. */
3828 /* Calculate the max frag size. */
3831 wid
= 2 * the_ins
.fragb
[0].fragoff
;
3832 for (n
= 1; n
< the_ins
.nfrag
; n
++)
3833 wid
+= 2 * (the_ins
.numo
- the_ins
.fragb
[n
- 1].fragoff
);
3834 /* frag_var part. */
3836 /* Make sure the whole insn fits in one chunk, in particular that
3837 the var part is attached, as we access one byte before the
3838 variable frag for byte branches. */
3842 for (n
= 0, fromP
= &the_ins
.opcode
[0]; n
< the_ins
.nfrag
; n
++)
3847 wid
= 2 * the_ins
.fragb
[n
].fragoff
;
3849 wid
= 2 * (the_ins
.numo
- the_ins
.fragb
[n
- 1].fragoff
);
3850 toP
= frag_more (wid
);
3852 shorts_this_frag
= 0;
3853 for (m
= wid
/ 2; m
; --m
)
3855 md_number_to_chars (toP
, (long) (*fromP
), 2);
3860 for (m
= 0; m
< the_ins
.nrel
; m
++)
3862 if ((the_ins
.reloc
[m
].n
) >= 2 * shorts_this_frag
)
3864 the_ins
.reloc
[m
].n
-= 2 * shorts_this_frag
;
3867 wid
= the_ins
.reloc
[m
].wid
;
3870 the_ins
.reloc
[m
].wid
= 0;
3871 wid
= (wid
== 'b') ? 1 : (wid
== 'w') ? 2 : (wid
== 'l') ? 4 : 4000;
3873 fixP
= fix_new_exp (frag_now
,
3874 ((toP
- frag_now
->fr_literal
)
3875 - the_ins
.numo
* 2 + the_ins
.reloc
[m
].n
),
3877 &the_ins
.reloc
[m
].exp
,
3878 the_ins
.reloc
[m
].pcrel
,
3879 get_reloc_code (wid
, the_ins
.reloc
[m
].pcrel
,
3880 the_ins
.reloc
[m
].pic_reloc
));
3881 fixP
->fx_pcrel_adjust
= the_ins
.reloc
[m
].pcrel_fix
;
3883 (void) frag_var (rs_machine_dependent
, 10, 0,
3884 (relax_substateT
) (the_ins
.fragb
[n
].fragty
),
3885 the_ins
.fragb
[n
].fadd
, the_ins
.fragb
[n
].foff
, to_beg_P
);
3887 n
= (the_ins
.numo
- the_ins
.fragb
[n
- 1].fragoff
);
3888 shorts_this_frag
= 0;
3891 toP
= frag_more (n
* sizeof (short));
3894 md_number_to_chars (toP
, (long) (*fromP
), 2);
3900 for (m
= 0; m
< the_ins
.nrel
; m
++)
3904 wid
= the_ins
.reloc
[m
].wid
;
3907 the_ins
.reloc
[m
].wid
= 0;
3908 wid
= (wid
== 'b') ? 1 : (wid
== 'w') ? 2 : (wid
== 'l') ? 4 : 4000;
3910 fixP
= fix_new_exp (frag_now
,
3911 ((the_ins
.reloc
[m
].n
+ toP
- frag_now
->fr_literal
)
3912 - shorts_this_frag
* 2),
3914 &the_ins
.reloc
[m
].exp
,
3915 the_ins
.reloc
[m
].pcrel
,
3916 get_reloc_code (wid
, the_ins
.reloc
[m
].pcrel
,
3917 the_ins
.reloc
[m
].pic_reloc
));
3918 fixP
->fx_pcrel_adjust
= the_ins
.reloc
[m
].pcrel_fix
;
3926 * md_begin -- set up hash tables with 68000 instructions.
3927 * similar to what the vax assembler does. ---phr
3929 /* RMS claims the thing to do is take the m68k-opcode.h table, and make
3930 a copy of it at runtime, adding in the information we want but isn't
3931 there. I think it'd be better to have an awk script hack the table
3932 at compile time. Or even just xstr the table and use it as-is. But
3933 my lord ghod hath spoken, so we do it this way. Excuse the ugly var
3936 const struct m68k_opcode
*ins
;
3937 struct m68k_incant
*hack
, *slak
;
3938 const char *retval
= 0; /* Empty string, or error msg text. */
3943 flag_reg_prefix_optional
= 1;
3945 if (! m68k_rel32_from_cmdline
)
3949 op_hash
= hash_new ();
3951 obstack_begin (&robyn
, 4000);
3952 for (i
= 0; i
< m68k_numopcodes
; i
++)
3954 hack
= slak
= (struct m68k_incant
*) obstack_alloc (&robyn
, sizeof (struct m68k_incant
));
3957 ins
= &m68k_opcodes
[i
];
3958 /* We *could* ignore insns that don't match our arch here
3959 but just leaving them out of the hash. */
3960 slak
->m_operands
= ins
->args
;
3961 slak
->m_opnum
= strlen (slak
->m_operands
) / 2;
3962 slak
->m_arch
= ins
->arch
;
3963 slak
->m_opcode
= ins
->opcode
;
3964 /* This is kludgey. */
3965 slak
->m_codenum
= ((ins
->match
) & 0xffffL
) ? 2 : 1;
3966 if (i
+ 1 != m68k_numopcodes
3967 && !strcmp (ins
->name
, m68k_opcodes
[i
+ 1].name
))
3969 slak
->m_next
= (struct m68k_incant
*) obstack_alloc (&robyn
, sizeof (struct m68k_incant
));
3974 slak
= slak
->m_next
;
3978 retval
= hash_insert (op_hash
, ins
->name
, (char *) hack
);
3980 as_fatal (_("Internal Error: Can't hash %s: %s"), ins
->name
, retval
);
3983 for (i
= 0; i
< m68k_numaliases
; i
++)
3985 const char *name
= m68k_opcode_aliases
[i
].primary
;
3986 const char *alias
= m68k_opcode_aliases
[i
].alias
;
3987 PTR val
= hash_find (op_hash
, name
);
3989 as_fatal (_("Internal Error: Can't find %s in hash table"), name
);
3990 retval
= hash_insert (op_hash
, alias
, val
);
3992 as_fatal (_("Internal Error: Can't hash %s: %s"), alias
, retval
);
3995 /* In MRI mode, all unsized branches are variable sized. Normally,
3996 they are word sized. */
3999 static struct m68k_opcode_alias mri_aliases
[] =
4020 i
< (int) (sizeof mri_aliases
/ sizeof mri_aliases
[0]);
4023 const char *name
= mri_aliases
[i
].primary
;
4024 const char *alias
= mri_aliases
[i
].alias
;
4025 PTR val
= hash_find (op_hash
, name
);
4027 as_fatal (_("Internal Error: Can't find %s in hash table"), name
);
4028 retval
= hash_jam (op_hash
, alias
, val
);
4030 as_fatal (_("Internal Error: Can't hash %s: %s"), alias
, retval
);
4034 for (i
= 0; i
< (int) sizeof (notend_table
); i
++)
4036 notend_table
[i
] = 0;
4037 alt_notend_table
[i
] = 0;
4039 notend_table
[','] = 1;
4040 notend_table
['{'] = 1;
4041 notend_table
['}'] = 1;
4042 alt_notend_table
['a'] = 1;
4043 alt_notend_table
['A'] = 1;
4044 alt_notend_table
['d'] = 1;
4045 alt_notend_table
['D'] = 1;
4046 alt_notend_table
['#'] = 1;
4047 alt_notend_table
['&'] = 1;
4048 alt_notend_table
['f'] = 1;
4049 alt_notend_table
['F'] = 1;
4050 #ifdef REGISTER_PREFIX
4051 alt_notend_table
[REGISTER_PREFIX
] = 1;
4054 /* We need to put '(' in alt_notend_table to handle
4055 cas2 %d0:%d2,%d3:%d4,(%a0):(%a1)
4057 alt_notend_table
['('] = 1;
4059 /* We need to put '@' in alt_notend_table to handle
4060 cas2 %d0:%d2,%d3:%d4,@(%d0):@(%d1)
4062 alt_notend_table
['@'] = 1;
4064 /* We need to put digits in alt_notend_table to handle
4065 bfextu %d0{24:1},%d0
4067 alt_notend_table
['0'] = 1;
4068 alt_notend_table
['1'] = 1;
4069 alt_notend_table
['2'] = 1;
4070 alt_notend_table
['3'] = 1;
4071 alt_notend_table
['4'] = 1;
4072 alt_notend_table
['5'] = 1;
4073 alt_notend_table
['6'] = 1;
4074 alt_notend_table
['7'] = 1;
4075 alt_notend_table
['8'] = 1;
4076 alt_notend_table
['9'] = 1;
4078 #ifndef MIT_SYNTAX_ONLY
4079 /* Insert pseudo ops, these have to go into the opcode table since
4080 gas expects pseudo ops to start with a dot. */
4083 while (mote_pseudo_table
[n
].poc_name
)
4085 hack
= (struct m68k_incant
*)
4086 obstack_alloc (&robyn
, sizeof (struct m68k_incant
));
4087 hash_insert (op_hash
,
4088 mote_pseudo_table
[n
].poc_name
, (char *) hack
);
4089 hack
->m_operands
= 0;
4099 record_alignment (text_section
, 2);
4100 record_alignment (data_section
, 2);
4101 record_alignment (bss_section
, 2);
4106 select_control_regs ()
4108 /* Note which set of "movec" control registers is available. */
4109 switch (cpu_of_arch (current_architecture
))
4112 as_warn (_("architecture not yet selected: defaulting to 68020"));
4113 control_regs
= m68020_control_regs
;
4117 control_regs
= m68000_control_regs
;
4120 control_regs
= m68010_control_regs
;
4124 control_regs
= m68020_control_regs
;
4127 control_regs
= m68040_control_regs
;
4130 control_regs
= m68060_control_regs
;
4133 control_regs
= cpu32_control_regs
;
4139 control_regs
= mcf_control_regs
;
4142 control_regs
= mcf528x_control_regs
;
4145 control_regs
= mcfv4e_control_regs
;
4153 m68k_init_after_args ()
4155 if (cpu_of_arch (current_architecture
) == 0)
4158 const char *default_cpu
= TARGET_CPU
;
4160 if (*default_cpu
== 'm')
4162 for (i
= 0; i
< n_archs
; i
++)
4163 if (strcasecmp (default_cpu
, archs
[i
].name
) == 0)
4167 as_bad (_("unrecognized default cpu `%s' ???"), TARGET_CPU
);
4168 current_architecture
|= m68020
;
4171 current_architecture
|= archs
[i
].arch
;
4173 /* Permit m68881 specification with all cpus; those that can't work
4174 with a coprocessor could be doing emulation. */
4175 if (current_architecture
& m68851
)
4177 if (current_architecture
& m68040
)
4179 as_warn (_("68040 and 68851 specified; mmu instructions may assemble incorrectly"));
4182 /* What other incompatibilities could we check for? */
4184 /* Toss in some default assumptions about coprocessors. */
4186 && (cpu_of_arch (current_architecture
)
4187 /* Can CPU32 have a 68881 coprocessor?? */
4188 & (m68020
| m68030
| cpu32
)))
4190 current_architecture
|= m68881
;
4193 && (cpu_of_arch (current_architecture
) & m68020up
) != 0
4194 && (cpu_of_arch (current_architecture
) & m68040up
) == 0)
4196 current_architecture
|= m68851
;
4198 if (no_68881
&& (current_architecture
& m68881
))
4199 as_bad (_("options for 68881 and no-68881 both given"));
4200 if (no_68851
&& (current_architecture
& m68851
))
4201 as_bad (_("options for 68851 and no-68851 both given"));
4204 /* Work out the magic number. This isn't very general. */
4205 if (current_architecture
& m68000
)
4206 m68k_aout_machtype
= 0;
4207 else if (current_architecture
& m68010
)
4208 m68k_aout_machtype
= 1;
4209 else if (current_architecture
& m68020
)
4210 m68k_aout_machtype
= 2;
4212 m68k_aout_machtype
= 2;
4215 /* Note which set of "movec" control registers is available. */
4216 select_control_regs ();
4218 if (cpu_of_arch (current_architecture
) < m68020
4219 || arch_coldfire_p (current_architecture
))
4220 md_relax_table
[TAB (PCINDEX
, BYTE
)].rlx_more
= 0;
4223 /* This is called when a label is defined. */
4226 m68k_frob_label (sym
)
4229 struct label_line
*n
;
4231 n
= (struct label_line
*) xmalloc (sizeof *n
);
4234 as_where (&n
->file
, &n
->line
);
4240 /* This is called when a value that is not an instruction is emitted. */
4243 m68k_flush_pending_output ()
4245 current_label
= NULL
;
4248 /* This is called at the end of the assembly, when the final value of
4249 the label is known. We warn if this is a text symbol aligned at an
4253 m68k_frob_symbol (sym
)
4256 if (S_GET_SEGMENT (sym
) == reg_section
4257 && (int) S_GET_VALUE (sym
) < 0)
4259 S_SET_SEGMENT (sym
, absolute_section
);
4260 S_SET_VALUE (sym
, ~(int)S_GET_VALUE (sym
));
4262 else if ((S_GET_VALUE (sym
) & 1) != 0)
4264 struct label_line
*l
;
4266 for (l
= labels
; l
!= NULL
; l
= l
->next
)
4268 if (l
->label
== sym
)
4271 as_warn_where (l
->file
, l
->line
,
4272 _("text label `%s' aligned to odd boundary"),
4280 /* This is called if we go in or out of MRI mode because of the .mri
4284 m68k_mri_mode_change (on
)
4289 if (! flag_reg_prefix_optional
)
4291 flag_reg_prefix_optional
= 1;
4292 #ifdef REGISTER_PREFIX
4297 if (! m68k_rel32_from_cmdline
)
4302 if (! reg_prefix_optional_seen
)
4304 #ifdef REGISTER_PREFIX_OPTIONAL
4305 flag_reg_prefix_optional
= REGISTER_PREFIX_OPTIONAL
;
4307 flag_reg_prefix_optional
= 0;
4309 #ifdef REGISTER_PREFIX
4314 if (! m68k_rel32_from_cmdline
)
4319 /* Equal to MAX_PRECISION in atof-ieee.c. */
4320 #define MAX_LITTLENUMS 6
4322 /* Turn a string in input_line_pointer into a floating point constant
4323 of type TYPE, and store the appropriate bytes in *LITP. The number
4324 of LITTLENUMS emitted is stored in *SIZEP. An error message is
4325 returned, or NULL on OK. */
4328 md_atof (type
, litP
, sizeP
)
4334 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
4335 LITTLENUM_TYPE
*wordP
;
4366 return _("Bad call to MD_ATOF()");
4368 t
= atof_ieee (input_line_pointer
, type
, words
);
4370 input_line_pointer
= t
;
4372 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
4373 for (wordP
= words
; prec
--;)
4375 md_number_to_chars (litP
, (long) (*wordP
++), sizeof (LITTLENUM_TYPE
));
4376 litP
+= sizeof (LITTLENUM_TYPE
);
4382 md_number_to_chars (buf
, val
, n
)
4387 number_to_chars_bigendian (buf
, val
, n
);
4391 md_apply_fix3 (fixP
, valP
, seg
)
4394 segT seg ATTRIBUTE_UNUSED
;
4396 offsetT val
= *valP
;
4397 addressT upper_limit
;
4398 offsetT lower_limit
;
4400 /* This is unnecessary but it convinces the native rs6000 compiler
4401 to generate the code we want. */
4402 char *buf
= fixP
->fx_frag
->fr_literal
;
4403 buf
+= fixP
->fx_where
;
4404 /* End ibm compiler workaround. */
4406 val
= ((val
& 0xffffffff) ^ 0x80000000) - 0x80000000;
4408 if (fixP
->fx_addsy
== NULL
&& fixP
->fx_pcrel
== 0)
4414 memset (buf
, 0, fixP
->fx_size
);
4415 fixP
->fx_addnumber
= val
; /* Remember value for emit_reloc. */
4417 if (fixP
->fx_r_type
== BFD_RELOC_VTABLE_INHERIT
4418 && !S_IS_DEFINED (fixP
->fx_addsy
)
4419 && !S_IS_WEAK (fixP
->fx_addsy
))
4420 S_SET_WEAK (fixP
->fx_addsy
);
4425 #ifdef BFD_ASSEMBLER
4426 if (fixP
->fx_r_type
== BFD_RELOC_VTABLE_INHERIT
4427 || fixP
->fx_r_type
== BFD_RELOC_VTABLE_ENTRY
)
4431 switch (fixP
->fx_size
)
4433 /* The cast to offsetT below are necessary to make code
4434 correct for machines where ints are smaller than offsetT. */
4438 lower_limit
= - (offsetT
) 0x80;
4441 *buf
++ = (val
>> 8);
4443 upper_limit
= 0x7fff;
4444 lower_limit
= - (offsetT
) 0x8000;
4447 *buf
++ = (val
>> 24);
4448 *buf
++ = (val
>> 16);
4449 *buf
++ = (val
>> 8);
4451 upper_limit
= 0x7fffffff;
4452 lower_limit
= - (offsetT
) 0x7fffffff - 1; /* Avoid constant overflow. */
4455 BAD_CASE (fixP
->fx_size
);
4458 /* Fix up a negative reloc. */
4459 if (fixP
->fx_addsy
== NULL
&& fixP
->fx_subsy
!= NULL
)
4461 fixP
->fx_addsy
= fixP
->fx_subsy
;
4462 fixP
->fx_subsy
= NULL
;
4466 /* For non-pc-relative values, it's conceivable we might get something
4467 like "0xff" for a byte field. So extend the upper part of the range
4468 to accept such numbers. We arbitrarily disallow "-0xff" or "0xff+0xff",
4469 so that we can do any range checking at all. */
4470 if (! fixP
->fx_pcrel
&& ! fixP
->fx_signed
)
4471 upper_limit
= upper_limit
* 2 + 1;
4473 if ((addressT
) val
> upper_limit
4474 && (val
> 0 || val
< lower_limit
))
4475 as_bad_where (fixP
->fx_file
, fixP
->fx_line
, _("value out of range"));
4477 /* A one byte PC-relative reloc means a short branch. We can't use
4478 a short branch with a value of 0 or -1, because those indicate
4479 different opcodes (branches with longer offsets). fixup_segment
4480 in write.c may have clobbered fx_pcrel, so we need to examine the
4483 #ifdef BFD_ASSEMBLER
4484 || fixP
->fx_r_type
== BFD_RELOC_8_PCREL
4487 && fixP
->fx_size
== 1
4488 && (fixP
->fx_addsy
== NULL
4489 || S_IS_DEFINED (fixP
->fx_addsy
))
4490 && (val
== 0 || val
== -1))
4491 as_bad_where (fixP
->fx_file
, fixP
->fx_line
, _("invalid byte branch offset"));
4494 /* *fragP has been relaxed to its final size, and now needs to have
4495 the bytes inside it modified to conform to the new size There is UGLY
4499 md_convert_frag_1 (fragP
)
4500 register fragS
*fragP
;
4505 /* Address in object code of the displacement. */
4506 register int object_address
= fragP
->fr_fix
+ fragP
->fr_address
;
4508 /* Address in gas core of the place to store the displacement. */
4509 /* This convinces the native rs6000 compiler to generate the code we
4511 register char *buffer_address
= fragP
->fr_literal
;
4512 buffer_address
+= fragP
->fr_fix
;
4513 /* End ibm compiler workaround. */
4515 /* The displacement of the address, from current location. */
4516 disp
= fragP
->fr_symbol
? S_GET_VALUE (fragP
->fr_symbol
) : 0;
4517 disp
= (disp
+ fragP
->fr_offset
) - object_address
;
4519 switch (fragP
->fr_subtype
)
4521 case TAB (BRANCHBWL
, BYTE
):
4522 case TAB (BRABSJUNC
, BYTE
):
4523 case TAB (BRABSJCOND
, BYTE
):
4524 case TAB (BRANCHBW
, BYTE
):
4525 know (issbyte (disp
));
4527 as_bad_where (fragP
->fr_file
, fragP
->fr_line
,
4528 _("short branch with zero offset: use :w"));
4529 fixP
= fix_new (fragP
, fragP
->fr_fix
- 1, 1, fragP
->fr_symbol
,
4530 fragP
->fr_offset
, 1, RELAX_RELOC_PC8
);
4531 fixP
->fx_pcrel_adjust
= -1;
4533 case TAB (BRANCHBWL
, SHORT
):
4534 case TAB (BRABSJUNC
, SHORT
):
4535 case TAB (BRABSJCOND
, SHORT
):
4536 case TAB (BRANCHBW
, SHORT
):
4537 fragP
->fr_opcode
[1] = 0x00;
4538 fix_new (fragP
, fragP
->fr_fix
, 2, fragP
->fr_symbol
, fragP
->fr_offset
,
4539 1, RELAX_RELOC_PC16
);
4542 case TAB (BRANCHBWL
, LONG
):
4543 fragP
->fr_opcode
[1] = (char) 0xFF;
4544 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4545 1, RELAX_RELOC_PC32
);
4548 case TAB (BRABSJUNC
, LONG
):
4549 if (fragP
->fr_opcode
[0] == 0x61) /* jbsr */
4551 if (flag_keep_pcrel
)
4552 as_fatal(_("Tried to convert PC relative BSR to absolute JSR"));
4553 fragP
->fr_opcode
[0] = 0x4E;
4554 fragP
->fr_opcode
[1] = (char) 0xB9; /* JSR with ABSL LONG operand. */
4555 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4556 0, RELAX_RELOC_ABS32
);
4559 else if (fragP
->fr_opcode
[0] == 0x60) /* jbra */
4561 if (flag_keep_pcrel
)
4562 as_fatal(_("Tried to convert PC relative branch to absolute jump"));
4563 fragP
->fr_opcode
[0] = 0x4E;
4564 fragP
->fr_opcode
[1] = (char) 0xF9; /* JMP with ABSL LONG operand. */
4565 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4566 0, RELAX_RELOC_ABS32
);
4571 /* This cannot happen, because jbsr and jbra are the only two
4572 unconditional branches. */
4576 case TAB (BRABSJCOND
, LONG
):
4577 if (flag_keep_pcrel
)
4578 as_fatal(_("Tried to convert PC relative conditional branch to absolute jump"));
4580 /* Only Bcc 68000 instructions can come here
4581 Change bcc into b!cc/jmp absl long. */
4582 fragP
->fr_opcode
[0] ^= 0x01; /* Invert bcc. */
4583 fragP
->fr_opcode
[1] = 0x06; /* Branch offset = 6. */
4585 /* JF: these used to be fr_opcode[2,3], but they may be in a
4586 different frag, in which case referring to them is a no-no.
4587 Only fr_opcode[0,1] are guaranteed to work. */
4588 *buffer_address
++ = 0x4e; /* put in jmp long (0x4ef9) */
4589 *buffer_address
++ = (char) 0xf9;
4590 fragP
->fr_fix
+= 2; /* Account for jmp instruction. */
4591 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
,
4592 fragP
->fr_offset
, 0, RELAX_RELOC_ABS32
);
4595 case TAB (FBRANCH
, SHORT
):
4596 know ((fragP
->fr_opcode
[1] & 0x40) == 0);
4597 fix_new (fragP
, fragP
->fr_fix
, 2, fragP
->fr_symbol
, fragP
->fr_offset
,
4598 1, RELAX_RELOC_PC16
);
4601 case TAB (FBRANCH
, LONG
):
4602 fragP
->fr_opcode
[1] |= 0x40; /* Turn on LONG bit. */
4603 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4604 1, RELAX_RELOC_PC32
);
4607 case TAB (DBCCLBR
, SHORT
):
4608 case TAB (DBCCABSJ
, SHORT
):
4609 fix_new (fragP
, fragP
->fr_fix
, 2, fragP
->fr_symbol
, fragP
->fr_offset
,
4610 1, RELAX_RELOC_PC16
);
4613 case TAB (DBCCLBR
, LONG
):
4614 /* Only DBcc instructions can come here.
4615 Change dbcc into dbcc/bral.
4616 JF: these used to be fr_opcode[2-7], but that's wrong. */
4617 if (flag_keep_pcrel
)
4618 as_fatal(_("Tried to convert DBcc to absolute jump"));
4620 *buffer_address
++ = 0x00; /* Branch offset = 4. */
4621 *buffer_address
++ = 0x04;
4622 *buffer_address
++ = 0x60; /* Put in bra pc+6. */
4623 *buffer_address
++ = 0x06;
4624 *buffer_address
++ = 0x60; /* Put in bral (0x60ff). */
4625 *buffer_address
++ = (char) 0xff;
4627 fragP
->fr_fix
+= 6; /* Account for bra/jmp instructions. */
4628 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
, 1,
4632 case TAB (DBCCABSJ
, LONG
):
4633 /* Only DBcc instructions can come here.
4634 Change dbcc into dbcc/jmp.
4635 JF: these used to be fr_opcode[2-7], but that's wrong. */
4636 if (flag_keep_pcrel
)
4637 as_fatal(_("Tried to convert PC relative conditional branch to absolute jump"));
4639 *buffer_address
++ = 0x00; /* Branch offset = 4. */
4640 *buffer_address
++ = 0x04;
4641 *buffer_address
++ = 0x60; /* Put in bra pc + 6. */
4642 *buffer_address
++ = 0x06;
4643 *buffer_address
++ = 0x4e; /* Put in jmp long (0x4ef9). */
4644 *buffer_address
++ = (char) 0xf9;
4646 fragP
->fr_fix
+= 6; /* Account for bra/jmp instructions. */
4647 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
, 0,
4651 case TAB (PCREL1632
, SHORT
):
4652 fragP
->fr_opcode
[1] &= ~0x3F;
4653 fragP
->fr_opcode
[1] |= 0x3A; /* 072 - mode 7.2 */
4654 fix_new (fragP
, (int) (fragP
->fr_fix
), 2, fragP
->fr_symbol
,
4655 fragP
->fr_offset
, 1, RELAX_RELOC_PC16
);
4658 case TAB (PCREL1632
, LONG
):
4659 /* Already set to mode 7.3; this indicates: PC indirect with
4660 suppressed index, 32-bit displacement. */
4661 *buffer_address
++ = 0x01;
4662 *buffer_address
++ = 0x70;
4664 fixP
= fix_new (fragP
, (int) (fragP
->fr_fix
), 4, fragP
->fr_symbol
,
4665 fragP
->fr_offset
, 1, RELAX_RELOC_PC32
);
4666 fixP
->fx_pcrel_adjust
= 2;
4669 case TAB (PCINDEX
, BYTE
):
4670 assert (fragP
->fr_fix
>= 2);
4671 buffer_address
[-2] &= ~1;
4672 fixP
= fix_new (fragP
, fragP
->fr_fix
- 1, 1, fragP
->fr_symbol
,
4673 fragP
->fr_offset
, 1, RELAX_RELOC_PC8
);
4674 fixP
->fx_pcrel_adjust
= 1;
4676 case TAB (PCINDEX
, SHORT
):
4677 assert (fragP
->fr_fix
>= 2);
4678 buffer_address
[-2] |= 0x1;
4679 buffer_address
[-1] = 0x20;
4680 fixP
= fix_new (fragP
, (int) (fragP
->fr_fix
), 2, fragP
->fr_symbol
,
4681 fragP
->fr_offset
, 1, RELAX_RELOC_PC16
);
4682 fixP
->fx_pcrel_adjust
= 2;
4685 case TAB (PCINDEX
, LONG
):
4686 assert (fragP
->fr_fix
>= 2);
4687 buffer_address
[-2] |= 0x1;
4688 buffer_address
[-1] = 0x30;
4689 fixP
= fix_new (fragP
, (int) (fragP
->fr_fix
), 4, fragP
->fr_symbol
,
4690 fragP
->fr_offset
, 1, RELAX_RELOC_PC32
);
4691 fixP
->fx_pcrel_adjust
= 2;
4694 case TAB (ABSTOPCREL
, SHORT
):
4695 fix_new (fragP
, fragP
->fr_fix
, 2, fragP
->fr_symbol
, fragP
->fr_offset
,
4696 1, RELAX_RELOC_PC16
);
4699 case TAB (ABSTOPCREL
, LONG
):
4700 if (flag_keep_pcrel
)
4701 as_fatal(_("Tried to convert PC relative conditional branch to absolute jump"));
4702 /* The thing to do here is force it to ABSOLUTE LONG, since
4703 ABSTOPCREL is really trying to shorten an ABSOLUTE address anyway. */
4704 if ((fragP
->fr_opcode
[1] & 0x3F) != 0x3A)
4706 fragP
->fr_opcode
[1] &= ~0x3F;
4707 fragP
->fr_opcode
[1] |= 0x39; /* Mode 7.1 */
4708 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4709 0, RELAX_RELOC_ABS32
);
4715 #ifndef BFD_ASSEMBLER
4718 md_convert_frag (headers
, sec
, fragP
)
4719 object_headers
*headers ATTRIBUTE_UNUSED
;
4720 segT sec ATTRIBUTE_UNUSED
;
4723 md_convert_frag_1 (fragP
);
4729 md_convert_frag (abfd
, sec
, fragP
)
4730 bfd
*abfd ATTRIBUTE_UNUSED
;
4731 segT sec ATTRIBUTE_UNUSED
;
4734 md_convert_frag_1 (fragP
);
4738 /* Force truly undefined symbols to their maximum size, and generally set up
4739 the frag list to be relaxed
4742 md_estimate_size_before_relax (fragP
, segment
)
4743 register fragS
*fragP
;
4746 /* Handle SZ_UNDEF first, it can be changed to BYTE or SHORT. */
4747 switch (fragP
->fr_subtype
)
4749 case TAB (BRANCHBWL
, SZ_UNDEF
):
4750 case TAB (BRABSJUNC
, SZ_UNDEF
):
4751 case TAB (BRABSJCOND
, SZ_UNDEF
):
4753 if (S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4754 && relaxable_symbol (fragP
->fr_symbol
))
4756 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), BYTE
);
4758 else if (flag_short_refs
)
4760 /* Symbol is undefined and we want short ref. */
4761 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), SHORT
);
4765 /* Symbol is still undefined. Make it LONG. */
4766 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), LONG
);
4771 case TAB (BRANCHBW
, SZ_UNDEF
):
4773 if (S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4774 && relaxable_symbol (fragP
->fr_symbol
))
4776 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), BYTE
);
4780 /* Symbol is undefined and we don't have long branches. */
4781 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), SHORT
);
4786 case TAB (FBRANCH
, SZ_UNDEF
):
4787 case TAB (DBCCLBR
, SZ_UNDEF
):
4788 case TAB (DBCCABSJ
, SZ_UNDEF
):
4789 case TAB (PCREL1632
, SZ_UNDEF
):
4791 if ((S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4792 && relaxable_symbol (fragP
->fr_symbol
))
4795 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), SHORT
);
4799 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), LONG
);
4804 case TAB (PCINDEX
, SZ_UNDEF
):
4805 if ((S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4806 && relaxable_symbol (fragP
->fr_symbol
)))
4808 fragP
->fr_subtype
= TAB (PCINDEX
, BYTE
);
4812 fragP
->fr_subtype
= TAB (PCINDEX
, LONG
);
4816 case TAB (ABSTOPCREL
, SZ_UNDEF
):
4818 if ((S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4819 && relaxable_symbol (fragP
->fr_symbol
)))
4821 fragP
->fr_subtype
= TAB (ABSTOPCREL
, SHORT
);
4825 fragP
->fr_subtype
= TAB (ABSTOPCREL
, LONG
);
4834 /* Now that SZ_UNDEF are taken care of, check others. */
4835 switch (fragP
->fr_subtype
)
4837 case TAB (BRANCHBWL
, BYTE
):
4838 case TAB (BRABSJUNC
, BYTE
):
4839 case TAB (BRABSJCOND
, BYTE
):
4840 case TAB (BRANCHBW
, BYTE
):
4841 /* We can't do a short jump to the next instruction, so in that
4842 case we force word mode. If the symbol is at the start of a
4843 frag, and it is the next frag with any data in it (usually
4844 this is just the next frag, but assembler listings may
4845 introduce empty frags), we must use word mode. */
4846 if (fragP
->fr_symbol
)
4850 sym_frag
= symbol_get_frag (fragP
->fr_symbol
);
4851 if (S_GET_VALUE (fragP
->fr_symbol
) == sym_frag
->fr_address
)
4855 for (l
= fragP
->fr_next
; l
&& l
!= sym_frag
; l
= l
->fr_next
)
4859 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), SHORT
);
4866 return md_relax_table
[fragP
->fr_subtype
].rlx_length
;
4869 #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
4870 /* the bit-field entries in the relocation_info struct plays hell
4871 with the byte-order problems of cross-assembly. So as a hack,
4872 I added this mach. dependent ri twiddler. Ugly, but it gets
4874 /* on m68k: first 4 bytes are normal unsigned long, next three bytes
4875 are symbolnum, most sig. byte first. Last byte is broken up with
4876 bit 7 as pcrel, bits 6 & 5 as length, bit 4 as pcrel, and the lower
4877 nibble as nuthin. (on Sun 3 at least) */
4878 /* Translate the internal relocation information into target-specific
4882 md_ri_to_chars (the_bytes
, ri
)
4884 struct reloc_info_generic
*ri
;
4887 md_number_to_chars (the_bytes
, ri
->r_address
, 4);
4888 /* Now the fun stuff. */
4889 the_bytes
[4] = (ri
->r_symbolnum
>> 16) & 0x0ff;
4890 the_bytes
[5] = (ri
->r_symbolnum
>> 8) & 0x0ff;
4891 the_bytes
[6] = ri
->r_symbolnum
& 0x0ff;
4892 the_bytes
[7] = (((ri
->r_pcrel
<< 7) & 0x80) | ((ri
->r_length
<< 5) & 0x60) |
4893 ((ri
->r_extern
<< 4) & 0x10));
4898 #ifndef BFD_ASSEMBLER
4900 tc_aout_fix_to_chars (where
, fixP
, segment_address_in_file
)
4903 relax_addressT segment_address_in_file
;
4906 * In: length of relocation (or of address) in chars: 1, 2 or 4.
4907 * Out: GNU LD relocation length code: 0, 1, or 2.
4910 static const unsigned char nbytes_r_length
[] = {42, 0, 1, 42, 2};
4913 know (fixP
->fx_addsy
!= NULL
);
4915 md_number_to_chars (where
,
4916 fixP
->fx_frag
->fr_address
+ fixP
->fx_where
- segment_address_in_file
,
4919 r_symbolnum
= (S_IS_DEFINED (fixP
->fx_addsy
)
4920 ? S_GET_TYPE (fixP
->fx_addsy
)
4921 : fixP
->fx_addsy
->sy_number
);
4923 where
[4] = (r_symbolnum
>> 16) & 0x0ff;
4924 where
[5] = (r_symbolnum
>> 8) & 0x0ff;
4925 where
[6] = r_symbolnum
& 0x0ff;
4926 where
[7] = (((fixP
->fx_pcrel
<< 7) & 0x80) | ((nbytes_r_length
[fixP
->fx_size
] << 5) & 0x60) |
4927 (((!S_IS_DEFINED (fixP
->fx_addsy
)) << 4) & 0x10));
4931 #endif /* OBJ_AOUT or OBJ_BOUT */
4933 #ifndef WORKING_DOT_WORD
4934 const int md_short_jump_size
= 4;
4935 const int md_long_jump_size
= 6;
4938 md_create_short_jump (ptr
, from_addr
, to_addr
, frag
, to_symbol
)
4940 addressT from_addr
, to_addr
;
4941 fragS
*frag ATTRIBUTE_UNUSED
;
4942 symbolS
*to_symbol ATTRIBUTE_UNUSED
;
4946 offset
= to_addr
- (from_addr
+ 2);
4948 md_number_to_chars (ptr
, (valueT
) 0x6000, 2);
4949 md_number_to_chars (ptr
+ 2, (valueT
) offset
, 2);
4953 md_create_long_jump (ptr
, from_addr
, to_addr
, frag
, to_symbol
)
4955 addressT from_addr
, to_addr
;
4961 if (!HAVE_LONG_BRANCH(current_architecture
))
4963 if (flag_keep_pcrel
)
4964 as_fatal(_("Tried to convert PC relative branch to absolute jump"));
4965 offset
= to_addr
- S_GET_VALUE (to_symbol
);
4966 md_number_to_chars (ptr
, (valueT
) 0x4EF9, 2);
4967 md_number_to_chars (ptr
+ 2, (valueT
) offset
, 4);
4968 fix_new (frag
, (ptr
+ 2) - frag
->fr_literal
, 4, to_symbol
, (offsetT
) 0,
4973 offset
= to_addr
- (from_addr
+ 2);
4974 md_number_to_chars (ptr
, (valueT
) 0x60ff, 2);
4975 md_number_to_chars (ptr
+ 2, (valueT
) offset
, 4);
4981 /* Different values of OK tell what its OK to return. Things that
4982 aren't OK are an error (what a shock, no?)
4985 10: Absolute 1:8 only
4986 20: Absolute 0:7 only
4987 30: absolute 0:15 only
4988 40: Absolute 0:31 only
4989 50: absolute 0:127 only
4990 55: absolute -64:63 only
4991 60: absolute -128:127 only
4992 70: absolute 0:4095 only
4993 80: absolute -1, 1:7 only
4998 struct m68k_exp
*exp
;
5001 if (exp
->exp
.X_op
== O_absent
)
5003 /* Do the same thing the VAX asm does. */
5004 op (exp
) = O_constant
;
5010 as_warn (_("expression out of range: defaulting to 1"));
5014 else if (exp
->exp
.X_op
== O_constant
)
5019 if (offs (exp
) < 1 || offs (exp
) > 8)
5021 as_warn (_("expression out of range: defaulting to 1"));
5026 if (offs (exp
) < 0 || offs (exp
) > 7)
5030 if (offs (exp
) < 0 || offs (exp
) > 15)
5034 if (offs (exp
) < 0 || offs (exp
) > 32)
5038 if (offs (exp
) < 0 || offs (exp
) > 127)
5042 if (offs (exp
) < -64 || offs (exp
) > 63)
5046 if (offs (exp
) < -128 || offs (exp
) > 127)
5050 if (offs (exp
) < 0 || offs (exp
) > 4095)
5053 as_warn (_("expression out of range: defaulting to 0"));
5062 as_warn (_("expression out of range: defaulting to 1"));
5070 else if (exp
->exp
.X_op
== O_big
)
5072 if (offs (exp
) <= 0 /* flonum. */
5073 && (ok
== 90 /* no bignums */
5074 || (ok
> 10 /* Small-int ranges including 0 ok. */
5075 /* If we have a flonum zero, a zero integer should
5076 do as well (e.g., in moveq). */
5077 && generic_floating_point_number
.exponent
== 0
5078 && generic_floating_point_number
.low
[0] == 0)))
5080 /* HACK! Turn it into a long. */
5081 LITTLENUM_TYPE words
[6];
5083 gen_to_words (words
, 2, 8L); /* These numbers are magic! */
5084 op (exp
) = O_constant
;
5087 offs (exp
) = words
[1] | (words
[0] << 16);
5091 op (exp
) = O_constant
;
5094 offs (exp
) = (ok
== 10) ? 1 : 0;
5095 as_warn (_("Can't deal with expression; defaulting to %ld"),
5101 if (ok
>= 10 && ok
<= 80)
5103 op (exp
) = O_constant
;
5106 offs (exp
) = (ok
== 10) ? 1 : 0;
5107 as_warn (_("Can't deal with expression; defaulting to %ld"),
5112 if (exp
->size
!= SIZE_UNSPEC
)
5120 if (!isbyte (offs (exp
)))
5121 as_warn (_("expression doesn't fit in BYTE"));
5124 if (!isword (offs (exp
)))
5125 as_warn (_("expression doesn't fit in WORD"));
5133 /* These are the back-ends for the various machine dependent pseudo-ops. */
5137 int ignore ATTRIBUTE_UNUSED
;
5139 subseg_set (data_section
, 1);
5140 demand_empty_rest_of_line ();
5145 int ignore ATTRIBUTE_UNUSED
;
5147 subseg_set (data_section
, 2);
5148 demand_empty_rest_of_line ();
5153 int ignore ATTRIBUTE_UNUSED
;
5155 /* We don't support putting frags in the BSS segment, we fake it
5156 by marking in_bss, then looking at s_skip for clues. */
5158 subseg_set (bss_section
, 0);
5159 demand_empty_rest_of_line ();
5164 int ignore ATTRIBUTE_UNUSED
;
5167 register long temp_fill
;
5169 temp
= 1; /* JF should be 2? */
5170 temp_fill
= get_absolute_expression ();
5171 if (!need_pass_2
) /* Never make frag if expect extra pass. */
5172 frag_align (temp
, (int) temp_fill
, 0);
5173 demand_empty_rest_of_line ();
5174 record_alignment (now_seg
, temp
);
5179 int ignore ATTRIBUTE_UNUSED
;
5181 demand_empty_rest_of_line ();
5184 /* Pseudo-ops handled for MRI compatibility. */
5186 /* This function returns non-zero if the argument is a conditional
5187 pseudo-op. This is called when checking whether a pending
5188 alignment is needed. */
5191 m68k_conditional_pseudoop (pop
)
5194 return (pop
->poc_handler
== s_mri_if
5195 || pop
->poc_handler
== s_mri_else
);
5198 /* Handle an MRI style chip specification. */
5207 s
= input_line_pointer
;
5208 /* We can't use get_symbol_end since the processor names are not proper
5210 while (is_part_of_name (c
= *input_line_pointer
++))
5212 *--input_line_pointer
= 0;
5213 for (i
= 0; i
< n_archs
; i
++)
5214 if (strcasecmp (s
, archs
[i
].name
) == 0)
5218 as_bad (_("%s: unrecognized processor name"), s
);
5219 *input_line_pointer
= c
;
5220 ignore_rest_of_line ();
5223 *input_line_pointer
= c
;
5225 if (*input_line_pointer
== '/')
5226 current_architecture
= 0;
5228 current_architecture
&= m68881
| m68851
;
5229 current_architecture
|= archs
[i
].arch
;
5231 while (*input_line_pointer
== '/')
5233 ++input_line_pointer
;
5234 s
= input_line_pointer
;
5235 /* We can't use get_symbol_end since the processor names are not
5237 while (is_part_of_name (c
= *input_line_pointer
++))
5239 *--input_line_pointer
= 0;
5240 if (strcmp (s
, "68881") == 0)
5241 current_architecture
|= m68881
;
5242 else if (strcmp (s
, "68851") == 0)
5243 current_architecture
|= m68851
;
5244 *input_line_pointer
= c
;
5247 /* Update info about available control registers. */
5248 select_control_regs ();
5251 /* The MRI CHIP pseudo-op. */
5255 int ignore ATTRIBUTE_UNUSED
;
5261 stop
= mri_comment_field (&stopc
);
5264 mri_comment_end (stop
, stopc
);
5265 demand_empty_rest_of_line ();
5268 /* The MRI FOPT pseudo-op. */
5272 int ignore ATTRIBUTE_UNUSED
;
5276 if (strncasecmp (input_line_pointer
, "ID=", 3) == 0)
5280 input_line_pointer
+= 3;
5281 temp
= get_absolute_expression ();
5282 if (temp
< 0 || temp
> 7)
5283 as_bad (_("bad coprocessor id"));
5285 m68k_float_copnum
= COP0
+ temp
;
5289 as_bad (_("unrecognized fopt option"));
5290 ignore_rest_of_line ();
5294 demand_empty_rest_of_line ();
5297 /* The structure used to handle the MRI OPT pseudo-op. */
5301 /* The name of the option. */
5304 /* If this is not NULL, just call this function. The first argument
5305 is the ARG field of this structure, the second argument is
5306 whether the option was negated. */
5307 void (*pfn
) PARAMS ((int arg
, int on
));
5309 /* If this is not NULL, and the PFN field is NULL, set the variable
5310 this points to. Set it to the ARG field if the option was not
5311 negated, and the NOTARG field otherwise. */
5314 /* The value to pass to PFN or to assign to *PVAR. */
5317 /* The value to assign to *PVAR if the option is negated. If PFN is
5318 NULL, and PVAR is not NULL, and ARG and NOTARG are the same, then
5319 the option may not be negated. */
5323 /* The table used to handle the MRI OPT pseudo-op. */
5325 static void skip_to_comma
PARAMS ((int, int));
5326 static void opt_nest
PARAMS ((int, int));
5327 static void opt_chip
PARAMS ((int, int));
5328 static void opt_list
PARAMS ((int, int));
5329 static void opt_list_symbols
PARAMS ((int, int));
5331 static const struct opt_action opt_table
[] =
5333 { "abspcadd", 0, &m68k_abspcadd
, 1, 0 },
5335 /* We do relaxing, so there is little use for these options. */
5336 { "b", 0, 0, 0, 0 },
5337 { "brs", 0, 0, 0, 0 },
5338 { "brb", 0, 0, 0, 0 },
5339 { "brl", 0, 0, 0, 0 },
5340 { "brw", 0, 0, 0, 0 },
5342 { "c", 0, 0, 0, 0 },
5343 { "cex", 0, 0, 0, 0 },
5344 { "case", 0, &symbols_case_sensitive
, 1, 0 },
5345 { "cl", 0, 0, 0, 0 },
5346 { "cre", 0, 0, 0, 0 },
5347 { "d", 0, &flag_keep_locals
, 1, 0 },
5348 { "e", 0, 0, 0, 0 },
5349 { "f", 0, &flag_short_refs
, 1, 0 },
5350 { "frs", 0, &flag_short_refs
, 1, 0 },
5351 { "frl", 0, &flag_short_refs
, 0, 1 },
5352 { "g", 0, 0, 0, 0 },
5353 { "i", 0, 0, 0, 0 },
5354 { "m", 0, 0, 0, 0 },
5355 { "mex", 0, 0, 0, 0 },
5356 { "mc", 0, 0, 0, 0 },
5357 { "md", 0, 0, 0, 0 },
5358 { "nest", opt_nest
, 0, 0, 0 },
5359 { "next", skip_to_comma
, 0, 0, 0 },
5360 { "o", 0, 0, 0, 0 },
5361 { "old", 0, 0, 0, 0 },
5362 { "op", skip_to_comma
, 0, 0, 0 },
5363 { "pco", 0, 0, 0, 0 },
5364 { "p", opt_chip
, 0, 0, 0 },
5365 { "pcr", 0, 0, 0, 0 },
5366 { "pcs", 0, 0, 0, 0 },
5367 { "r", 0, 0, 0, 0 },
5368 { "quick", 0, &m68k_quick
, 1, 0 },
5369 { "rel32", 0, &m68k_rel32
, 1, 0 },
5370 { "s", opt_list
, 0, 0, 0 },
5371 { "t", opt_list_symbols
, 0, 0, 0 },
5372 { "w", 0, &flag_no_warnings
, 0, 1 },
5376 #define OPTCOUNT ((int) (sizeof opt_table / sizeof opt_table[0]))
5378 /* The MRI OPT pseudo-op. */
5382 int ignore ATTRIBUTE_UNUSED
;
5390 const struct opt_action
*o
;
5395 if (*input_line_pointer
== '-')
5397 ++input_line_pointer
;
5400 else if (strncasecmp (input_line_pointer
, "NO", 2) == 0)
5402 input_line_pointer
+= 2;
5406 s
= input_line_pointer
;
5407 c
= get_symbol_end ();
5409 for (i
= 0, o
= opt_table
; i
< OPTCOUNT
; i
++, o
++)
5411 if (strcasecmp (s
, o
->name
) == 0)
5415 /* Restore input_line_pointer now in case the option
5417 *input_line_pointer
= c
;
5418 (*o
->pfn
) (o
->arg
, t
);
5420 else if (o
->pvar
!= NULL
)
5422 if (! t
&& o
->arg
== o
->notarg
)
5423 as_bad (_("option `%s' may not be negated"), s
);
5424 *input_line_pointer
= c
;
5425 *o
->pvar
= t
? o
->arg
: o
->notarg
;
5428 *input_line_pointer
= c
;
5434 as_bad (_("option `%s' not recognized"), s
);
5435 *input_line_pointer
= c
;
5438 while (*input_line_pointer
++ == ',');
5440 /* Move back to terminating character. */
5441 --input_line_pointer
;
5442 demand_empty_rest_of_line ();
5445 /* Skip ahead to a comma. This is used for OPT options which we do
5446 not support and which take arguments. */
5449 skip_to_comma (arg
, on
)
5450 int arg ATTRIBUTE_UNUSED
;
5451 int on ATTRIBUTE_UNUSED
;
5453 while (*input_line_pointer
!= ','
5454 && ! is_end_of_line
[(unsigned char) *input_line_pointer
])
5455 ++input_line_pointer
;
5458 /* Handle the OPT NEST=depth option. */
5462 int arg ATTRIBUTE_UNUSED
;
5463 int on ATTRIBUTE_UNUSED
;
5465 if (*input_line_pointer
!= '=')
5467 as_bad (_("bad format of OPT NEST=depth"));
5471 ++input_line_pointer
;
5472 max_macro_nest
= get_absolute_expression ();
5475 /* Handle the OPT P=chip option. */
5479 int arg ATTRIBUTE_UNUSED
;
5480 int on ATTRIBUTE_UNUSED
;
5482 if (*input_line_pointer
!= '=')
5484 /* This is just OPT P, which we do not support. */
5488 ++input_line_pointer
;
5492 /* Handle the OPT S option. */
5496 int arg ATTRIBUTE_UNUSED
;
5502 /* Handle the OPT T option. */
5505 opt_list_symbols (arg
, on
)
5506 int arg ATTRIBUTE_UNUSED
;
5510 listing
|= LISTING_SYMBOLS
;
5512 listing
&= ~LISTING_SYMBOLS
;
5515 /* Handle the MRI REG pseudo-op. */
5519 int ignore ATTRIBUTE_UNUSED
;
5528 if (line_label
== NULL
)
5530 as_bad (_("missing label"));
5531 ignore_rest_of_line ();
5536 stop
= mri_comment_field (&stopc
);
5540 s
= input_line_pointer
;
5541 while (ISALNUM (*input_line_pointer
)
5542 #ifdef REGISTER_PREFIX
5543 || *input_line_pointer
== REGISTER_PREFIX
5545 || *input_line_pointer
== '/'
5546 || *input_line_pointer
== '-')
5547 ++input_line_pointer
;
5548 c
= *input_line_pointer
;
5549 *input_line_pointer
= '\0';
5551 if (m68k_ip_op (s
, &rop
) != 0)
5553 if (rop
.error
== NULL
)
5554 as_bad (_("bad register list"));
5556 as_bad (_("bad register list: %s"), rop
.error
);
5557 *input_line_pointer
= c
;
5558 ignore_rest_of_line ();
5562 *input_line_pointer
= c
;
5564 if (rop
.mode
== REGLST
)
5566 else if (rop
.mode
== DREG
)
5567 mask
= 1 << (rop
.reg
- DATA0
);
5568 else if (rop
.mode
== AREG
)
5569 mask
= 1 << (rop
.reg
- ADDR0
+ 8);
5570 else if (rop
.mode
== FPREG
)
5571 mask
= 1 << (rop
.reg
- FP0
+ 16);
5572 else if (rop
.mode
== CONTROL
5575 else if (rop
.mode
== CONTROL
5578 else if (rop
.mode
== CONTROL
5583 as_bad (_("bad register list"));
5584 ignore_rest_of_line ();
5588 S_SET_SEGMENT (line_label
, reg_section
);
5589 S_SET_VALUE (line_label
, ~mask
);
5590 symbol_set_frag (line_label
, &zero_address_frag
);
5593 mri_comment_end (stop
, stopc
);
5595 demand_empty_rest_of_line ();
5598 /* This structure is used for the MRI SAVE and RESTORE pseudo-ops. */
5602 struct save_opts
*next
;
5604 int symbols_case_sensitive
;
5612 /* FIXME: We don't save OPT S. */
5615 /* This variable holds the stack of saved options. */
5617 static struct save_opts
*save_stack
;
5619 /* The MRI SAVE pseudo-op. */
5623 int ignore ATTRIBUTE_UNUSED
;
5625 struct save_opts
*s
;
5627 s
= (struct save_opts
*) xmalloc (sizeof (struct save_opts
));
5628 s
->abspcadd
= m68k_abspcadd
;
5629 s
->symbols_case_sensitive
= symbols_case_sensitive
;
5630 s
->keep_locals
= flag_keep_locals
;
5631 s
->short_refs
= flag_short_refs
;
5632 s
->architecture
= current_architecture
;
5633 s
->quick
= m68k_quick
;
5634 s
->rel32
= m68k_rel32
;
5635 s
->listing
= listing
;
5636 s
->no_warnings
= flag_no_warnings
;
5638 s
->next
= save_stack
;
5641 demand_empty_rest_of_line ();
5644 /* The MRI RESTORE pseudo-op. */
5648 int ignore ATTRIBUTE_UNUSED
;
5650 struct save_opts
*s
;
5652 if (save_stack
== NULL
)
5654 as_bad (_("restore without save"));
5655 ignore_rest_of_line ();
5660 save_stack
= s
->next
;
5662 m68k_abspcadd
= s
->abspcadd
;
5663 symbols_case_sensitive
= s
->symbols_case_sensitive
;
5664 flag_keep_locals
= s
->keep_locals
;
5665 flag_short_refs
= s
->short_refs
;
5666 current_architecture
= s
->architecture
;
5667 m68k_quick
= s
->quick
;
5668 m68k_rel32
= s
->rel32
;
5669 listing
= s
->listing
;
5670 flag_no_warnings
= s
->no_warnings
;
5674 demand_empty_rest_of_line ();
5677 /* Types of MRI structured control directives. */
5679 enum mri_control_type
5687 /* This structure is used to stack the MRI structured control
5690 struct mri_control_info
5692 /* The directive within which this one is enclosed. */
5693 struct mri_control_info
*outer
;
5695 /* The type of directive. */
5696 enum mri_control_type type
;
5698 /* Whether an ELSE has been in an IF. */
5701 /* The add or sub statement at the end of a FOR. */
5704 /* The label of the top of a FOR or REPEAT loop. */
5707 /* The label to jump to for the next iteration, or the else
5708 expression of a conditional. */
5711 /* The label to jump to to break out of the loop, or the label past
5712 the end of a conditional. */
5716 /* The stack of MRI structured control directives. */
5718 static struct mri_control_info
*mri_control_stack
;
5720 /* The current MRI structured control directive index number, used to
5721 generate label names. */
5723 static int mri_control_index
;
5725 /* Some function prototypes. */
5727 static void mri_assemble
PARAMS ((char *));
5728 static char *mri_control_label
PARAMS ((void));
5729 static struct mri_control_info
*push_mri_control
5730 PARAMS ((enum mri_control_type
));
5731 static void pop_mri_control
PARAMS ((void));
5732 static int parse_mri_condition
PARAMS ((int *));
5733 static int parse_mri_control_operand
5734 PARAMS ((int *, char **, char **, char **, char **));
5735 static int swap_mri_condition
PARAMS ((int));
5736 static int reverse_mri_condition
PARAMS ((int));
5737 static void build_mri_control_operand
5738 PARAMS ((int, int, char *, char *, char *, char *, const char *,
5739 const char *, int));
5740 static void parse_mri_control_expression
5741 PARAMS ((char *, int, const char *, const char *, int));
5743 /* Assemble an instruction for an MRI structured control directive. */
5751 /* md_assemble expects the opcode to be in lower case. */
5752 for (s
= str
; *s
!= ' ' && *s
!= '\0'; s
++)
5758 /* Generate a new MRI label structured control directive label name. */
5761 mri_control_label ()
5765 n
= (char *) xmalloc (20);
5766 sprintf (n
, "%smc%d", FAKE_LABEL_NAME
, mri_control_index
);
5767 ++mri_control_index
;
5771 /* Create a new MRI structured control directive. */
5773 static struct mri_control_info
*
5774 push_mri_control (type
)
5775 enum mri_control_type type
;
5777 struct mri_control_info
*n
;
5779 n
= (struct mri_control_info
*) xmalloc (sizeof (struct mri_control_info
));
5783 if (type
== mri_if
|| type
== mri_while
)
5786 n
->top
= mri_control_label ();
5787 n
->next
= mri_control_label ();
5788 n
->bottom
= mri_control_label ();
5790 n
->outer
= mri_control_stack
;
5791 mri_control_stack
= n
;
5796 /* Pop off the stack of MRI structured control directives. */
5801 struct mri_control_info
*n
;
5803 n
= mri_control_stack
;
5804 mri_control_stack
= n
->outer
;
5812 /* Recognize a condition code in an MRI structured control expression. */
5815 parse_mri_condition (pcc
)
5820 know (*input_line_pointer
== '<');
5822 ++input_line_pointer
;
5823 c1
= *input_line_pointer
++;
5824 c2
= *input_line_pointer
++;
5826 if (*input_line_pointer
!= '>')
5828 as_bad (_("syntax error in structured control directive"));
5832 ++input_line_pointer
;
5838 *pcc
= (c1
<< 8) | c2
;
5843 /* Parse a single operand in an MRI structured control expression. */
5846 parse_mri_control_operand (pcc
, leftstart
, leftstop
, rightstart
, rightstop
)
5863 if (*input_line_pointer
== '<')
5865 /* It's just a condition code. */
5866 return parse_mri_condition (pcc
);
5869 /* Look ahead for the condition code. */
5870 for (s
= input_line_pointer
; *s
!= '\0'; ++s
)
5872 if (*s
== '<' && s
[1] != '\0' && s
[2] != '\0' && s
[3] == '>')
5877 as_bad (_("missing condition code in structured control directive"));
5881 *leftstart
= input_line_pointer
;
5883 if (*leftstop
> *leftstart
5884 && ((*leftstop
)[-1] == ' ' || (*leftstop
)[-1] == '\t'))
5887 input_line_pointer
= s
;
5888 if (! parse_mri_condition (pcc
))
5891 /* Look ahead for AND or OR or end of line. */
5892 for (s
= input_line_pointer
; *s
!= '\0'; ++s
)
5894 /* We must make sure we don't misinterpret AND/OR at the end of labels!
5895 if d0 <eq> #FOOAND and d1 <ne> #BAROR then
5897 if ((s
== input_line_pointer
5900 && ((strncasecmp (s
, "AND", 3) == 0
5901 && (s
[3] == '.' || ! is_part_of_name (s
[3])))
5902 || (strncasecmp (s
, "OR", 2) == 0
5903 && (s
[2] == '.' || ! is_part_of_name (s
[2])))))
5907 *rightstart
= input_line_pointer
;
5909 if (*rightstop
> *rightstart
5910 && ((*rightstop
)[-1] == ' ' || (*rightstop
)[-1] == '\t'))
5913 input_line_pointer
= s
;
5918 #define MCC(b1, b2) (((b1) << 8) | (b2))
5920 /* Swap the sense of a condition. This changes the condition so that
5921 it generates the same result when the operands are swapped. */
5924 swap_mri_condition (cc
)
5929 case MCC ('h', 'i'): return MCC ('c', 's');
5930 case MCC ('l', 's'): return MCC ('c', 'c');
5931 /* <HS> is an alias for <CC>. */
5932 case MCC ('h', 's'):
5933 case MCC ('c', 'c'): return MCC ('l', 's');
5934 /* <LO> is an alias for <CS>. */
5935 case MCC ('l', 'o'):
5936 case MCC ('c', 's'): return MCC ('h', 'i');
5937 case MCC ('p', 'l'): return MCC ('m', 'i');
5938 case MCC ('m', 'i'): return MCC ('p', 'l');
5939 case MCC ('g', 'e'): return MCC ('l', 'e');
5940 case MCC ('l', 't'): return MCC ('g', 't');
5941 case MCC ('g', 't'): return MCC ('l', 't');
5942 case MCC ('l', 'e'): return MCC ('g', 'e');
5943 /* Issue a warning for conditions we can not swap. */
5944 case MCC ('n', 'e'): return MCC ('n', 'e'); // no problem here
5945 case MCC ('e', 'q'): return MCC ('e', 'q'); // also no problem
5946 case MCC ('v', 'c'):
5947 case MCC ('v', 's'):
5949 as_warn (_("Condition <%c%c> in structured control directive can not be encoded correctly"),
5950 (char) (cc
>> 8), (char) (cc
));
5956 /* Reverse the sense of a condition. */
5959 reverse_mri_condition (cc
)
5964 case MCC ('h', 'i'): return MCC ('l', 's');
5965 case MCC ('l', 's'): return MCC ('h', 'i');
5966 /* <HS> is an alias for <CC> */
5967 case MCC ('h', 's'): return MCC ('l', 'o');
5968 case MCC ('c', 'c'): return MCC ('c', 's');
5969 /* <LO> is an alias for <CS> */
5970 case MCC ('l', 'o'): return MCC ('h', 's');
5971 case MCC ('c', 's'): return MCC ('c', 'c');
5972 case MCC ('n', 'e'): return MCC ('e', 'q');
5973 case MCC ('e', 'q'): return MCC ('n', 'e');
5974 case MCC ('v', 'c'): return MCC ('v', 's');
5975 case MCC ('v', 's'): return MCC ('v', 'c');
5976 case MCC ('p', 'l'): return MCC ('m', 'i');
5977 case MCC ('m', 'i'): return MCC ('p', 'l');
5978 case MCC ('g', 'e'): return MCC ('l', 't');
5979 case MCC ('l', 't'): return MCC ('g', 'e');
5980 case MCC ('g', 't'): return MCC ('l', 'e');
5981 case MCC ('l', 'e'): return MCC ('g', 't');
5986 /* Build an MRI structured control expression. This generates test
5987 and branch instructions. It goes to TRUELAB if the condition is
5988 true, and to FALSELAB if the condition is false. Exactly one of
5989 TRUELAB and FALSELAB will be NULL, meaning to fall through. QUAL
5990 is the size qualifier for the expression. EXTENT is the size to
5991 use for the branch. */
5994 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
5995 rightstop
, truelab
, falselab
, extent
)
6002 const char *truelab
;
6003 const char *falselab
;
6009 if (leftstart
!= NULL
)
6011 struct m68k_op leftop
, rightop
;
6014 /* Swap the compare operands, if necessary, to produce a legal
6015 m68k compare instruction. Comparing a register operand with
6016 a non-register operand requires the register to be on the
6017 right (cmp, cmpa). Comparing an immediate value with
6018 anything requires the immediate value to be on the left
6023 (void) m68k_ip_op (leftstart
, &leftop
);
6028 (void) m68k_ip_op (rightstart
, &rightop
);
6031 if (rightop
.mode
== IMMED
6032 || ((leftop
.mode
== DREG
|| leftop
.mode
== AREG
)
6033 && (rightop
.mode
!= DREG
&& rightop
.mode
!= AREG
)))
6037 /* Correct conditional handling:
6038 if #1 <lt> d0 then ;means if (1 < d0)
6044 cmp #1,d0 if we do *not* swap the operands
6045 bgt true we need the swapped condition!
6052 leftstart
= rightstart
;
6055 leftstop
= rightstop
;
6060 cc
= swap_mri_condition (cc
);
6064 if (truelab
== NULL
)
6066 cc
= reverse_mri_condition (cc
);
6070 if (leftstart
!= NULL
)
6072 buf
= (char *) xmalloc (20
6073 + (leftstop
- leftstart
)
6074 + (rightstop
- rightstart
));
6080 *s
++ = TOLOWER (qual
);
6082 memcpy (s
, leftstart
, leftstop
- leftstart
);
6083 s
+= leftstop
- leftstart
;
6085 memcpy (s
, rightstart
, rightstop
- rightstart
);
6086 s
+= rightstop
- rightstart
;
6092 buf
= (char *) xmalloc (20 + strlen (truelab
));
6098 *s
++ = TOLOWER (extent
);
6100 strcpy (s
, truelab
);
6105 /* Parse an MRI structured control expression. This generates test
6106 and branch instructions. STOP is where the expression ends. It
6107 goes to TRUELAB if the condition is true, and to FALSELAB if the
6108 condition is false. Exactly one of TRUELAB and FALSELAB will be
6109 NULL, meaning to fall through. QUAL is the size qualifier for the
6110 expression. EXTENT is the size to use for the branch. */
6113 parse_mri_control_expression (stop
, qual
, truelab
, falselab
, extent
)
6116 const char *truelab
;
6117 const char *falselab
;
6130 if (! parse_mri_control_operand (&cc
, &leftstart
, &leftstop
,
6131 &rightstart
, &rightstop
))
6137 if (strncasecmp (input_line_pointer
, "AND", 3) == 0)
6141 if (falselab
!= NULL
)
6144 flab
= mri_control_label ();
6146 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6147 rightstop
, (const char *) NULL
, flab
, extent
);
6149 input_line_pointer
+= 3;
6150 if (*input_line_pointer
!= '.'
6151 || input_line_pointer
[1] == '\0')
6155 qual
= input_line_pointer
[1];
6156 input_line_pointer
+= 2;
6159 if (! parse_mri_control_operand (&cc
, &leftstart
, &leftstop
,
6160 &rightstart
, &rightstop
))
6166 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6167 rightstop
, truelab
, falselab
, extent
);
6169 if (falselab
== NULL
)
6172 else if (strncasecmp (input_line_pointer
, "OR", 2) == 0)
6176 if (truelab
!= NULL
)
6179 tlab
= mri_control_label ();
6181 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6182 rightstop
, tlab
, (const char *) NULL
, extent
);
6184 input_line_pointer
+= 2;
6185 if (*input_line_pointer
!= '.'
6186 || input_line_pointer
[1] == '\0')
6190 qual
= input_line_pointer
[1];
6191 input_line_pointer
+= 2;
6194 if (! parse_mri_control_operand (&cc
, &leftstart
, &leftstop
,
6195 &rightstart
, &rightstop
))
6201 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6202 rightstop
, truelab
, falselab
, extent
);
6204 if (truelab
== NULL
)
6209 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6210 rightstop
, truelab
, falselab
, extent
);
6214 if (input_line_pointer
!= stop
)
6215 as_bad (_("syntax error in structured control directive"));
6218 /* Handle the MRI IF pseudo-op. This may be a structured control
6219 directive, or it may be a regular assembler conditional, depending
6228 struct mri_control_info
*n
;
6230 /* A structured control directive must end with THEN with an
6231 optional qualifier. */
6232 s
= input_line_pointer
;
6233 /* We only accept '*' as introduction of comments if preceded by white space
6234 or at first column of a line (I think this can't actually happen here?)
6235 This is important when assembling:
6236 if d0 <ne> 12(a0,d0*2) then
6237 if d0 <ne> #CONST*20 then. */
6238 while ( ! ( is_end_of_line
[(unsigned char) *s
]
6241 && ( s
== input_line_pointer
6243 || *(s
-1) == '\t'))))
6246 while (s
> input_line_pointer
&& (*s
== ' ' || *s
== '\t'))
6249 if (s
- input_line_pointer
> 1
6253 if (s
- input_line_pointer
< 3
6254 || strncasecmp (s
- 3, "THEN", 4) != 0)
6258 as_bad (_("missing then"));
6259 ignore_rest_of_line ();
6263 /* It's a conditional. */
6268 /* Since this might be a conditional if, this pseudo-op will be
6269 called even if we are supported to be ignoring input. Double
6270 check now. Clobber *input_line_pointer so that ignore_input
6271 thinks that this is not a special pseudo-op. */
6272 c
= *input_line_pointer
;
6273 *input_line_pointer
= 0;
6274 if (ignore_input ())
6276 *input_line_pointer
= c
;
6277 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6278 ++input_line_pointer
;
6279 demand_empty_rest_of_line ();
6282 *input_line_pointer
= c
;
6284 n
= push_mri_control (mri_if
);
6286 parse_mri_control_expression (s
- 3, qual
, (const char *) NULL
,
6287 n
->next
, s
[1] == '.' ? s
[2] : '\0');
6290 input_line_pointer
= s
+ 3;
6292 input_line_pointer
= s
+ 1;
6296 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6297 ++input_line_pointer
;
6300 demand_empty_rest_of_line ();
6303 /* Handle the MRI else pseudo-op. If we are currently doing an MRI
6304 structured IF, associate the ELSE with the IF. Otherwise, assume
6305 it is a conditional else. */
6316 && (mri_control_stack
== NULL
6317 || mri_control_stack
->type
!= mri_if
6318 || mri_control_stack
->else_seen
))
6324 c
= *input_line_pointer
;
6325 *input_line_pointer
= 0;
6326 if (ignore_input ())
6328 *input_line_pointer
= c
;
6329 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6330 ++input_line_pointer
;
6331 demand_empty_rest_of_line ();
6334 *input_line_pointer
= c
;
6336 if (mri_control_stack
== NULL
6337 || mri_control_stack
->type
!= mri_if
6338 || mri_control_stack
->else_seen
)
6340 as_bad (_("else without matching if"));
6341 ignore_rest_of_line ();
6345 mri_control_stack
->else_seen
= 1;
6347 buf
= (char *) xmalloc (20 + strlen (mri_control_stack
->bottom
));
6348 q
[0] = TOLOWER (qual
);
6350 sprintf (buf
, "bra%s %s", q
, mri_control_stack
->bottom
);
6354 colon (mri_control_stack
->next
);
6358 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6359 ++input_line_pointer
;
6362 demand_empty_rest_of_line ();
6365 /* Handle the MRI ENDI pseudo-op. */
6369 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 (extent
)
6403 struct mri_control_info
*n
;
6407 n
= mri_control_stack
;
6409 && n
->type
!= mri_for
6410 && n
->type
!= mri_repeat
6411 && n
->type
!= mri_while
)
6415 as_bad (_("break outside of structured loop"));
6416 ignore_rest_of_line ();
6420 buf
= (char *) xmalloc (20 + strlen (n
->bottom
));
6421 ex
[0] = TOLOWER (extent
);
6423 sprintf (buf
, "bra%s %s", ex
, n
->bottom
);
6429 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6430 ++input_line_pointer
;
6433 demand_empty_rest_of_line ();
6436 /* Handle the MRI NEXT pseudo-op. */
6442 struct mri_control_info
*n
;
6446 n
= mri_control_stack
;
6448 && n
->type
!= mri_for
6449 && n
->type
!= mri_repeat
6450 && n
->type
!= mri_while
)
6454 as_bad (_("next outside of structured loop"));
6455 ignore_rest_of_line ();
6459 buf
= (char *) xmalloc (20 + strlen (n
->next
));
6460 ex
[0] = TOLOWER (extent
);
6462 sprintf (buf
, "bra%s %s", ex
, n
->next
);
6468 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6469 ++input_line_pointer
;
6472 demand_empty_rest_of_line ();
6475 /* Handle the MRI FOR pseudo-op. */
6481 const char *varstart
, *varstop
;
6482 const char *initstart
, *initstop
;
6483 const char *endstart
, *endstop
;
6484 const char *bystart
, *bystop
;
6488 struct mri_control_info
*n
;
6494 FOR.q var = init { TO | DOWNTO } end [ BY by ] DO.e
6498 varstart
= input_line_pointer
;
6500 /* Look for the '='. */
6501 while (! is_end_of_line
[(unsigned char) *input_line_pointer
]
6502 && *input_line_pointer
!= '=')
6503 ++input_line_pointer
;
6504 if (*input_line_pointer
!= '=')
6506 as_bad (_("missing ="));
6507 ignore_rest_of_line ();
6511 varstop
= input_line_pointer
;
6512 if (varstop
> varstart
6513 && (varstop
[-1] == ' ' || varstop
[-1] == '\t'))
6516 ++input_line_pointer
;
6518 initstart
= input_line_pointer
;
6520 /* Look for TO or DOWNTO. */
6523 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6525 if (strncasecmp (input_line_pointer
, "TO", 2) == 0
6526 && ! is_part_of_name (input_line_pointer
[2]))
6528 initstop
= input_line_pointer
;
6529 input_line_pointer
+= 2;
6532 if (strncasecmp (input_line_pointer
, "DOWNTO", 6) == 0
6533 && ! is_part_of_name (input_line_pointer
[6]))
6535 initstop
= input_line_pointer
;
6537 input_line_pointer
+= 6;
6540 ++input_line_pointer
;
6542 if (initstop
== NULL
)
6544 as_bad (_("missing to or downto"));
6545 ignore_rest_of_line ();
6548 if (initstop
> initstart
6549 && (initstop
[-1] == ' ' || initstop
[-1] == '\t'))
6553 endstart
= input_line_pointer
;
6555 /* Look for BY or DO. */
6558 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6560 if (strncasecmp (input_line_pointer
, "BY", 2) == 0
6561 && ! is_part_of_name (input_line_pointer
[2]))
6563 endstop
= input_line_pointer
;
6565 input_line_pointer
+= 2;
6568 if (strncasecmp (input_line_pointer
, "DO", 2) == 0
6569 && (input_line_pointer
[2] == '.'
6570 || ! is_part_of_name (input_line_pointer
[2])))
6572 endstop
= input_line_pointer
;
6573 input_line_pointer
+= 2;
6576 ++input_line_pointer
;
6578 if (endstop
== NULL
)
6580 as_bad (_("missing do"));
6581 ignore_rest_of_line ();
6584 if (endstop
> endstart
6585 && (endstop
[-1] == ' ' || endstop
[-1] == '\t'))
6591 bystop
= bystart
+ 2;
6596 bystart
= input_line_pointer
;
6600 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6602 if (strncasecmp (input_line_pointer
, "DO", 2) == 0
6603 && (input_line_pointer
[2] == '.'
6604 || ! is_part_of_name (input_line_pointer
[2])))
6606 bystop
= input_line_pointer
;
6607 input_line_pointer
+= 2;
6610 ++input_line_pointer
;
6614 as_bad (_("missing do"));
6615 ignore_rest_of_line ();
6618 if (bystop
> bystart
6619 && (bystop
[-1] == ' ' || bystop
[-1] == '\t'))
6623 if (*input_line_pointer
!= '.')
6627 extent
= input_line_pointer
[1];
6628 input_line_pointer
+= 2;
6631 /* We have fully parsed the FOR operands. Now build the loop. */
6632 n
= push_mri_control (mri_for
);
6634 buf
= (char *) xmalloc (50 + (input_line_pointer
- varstart
));
6636 /* Move init,var. */
6643 *s
++ = TOLOWER (qual
);
6645 memcpy (s
, initstart
, initstop
- initstart
);
6646 s
+= initstop
- initstart
;
6648 memcpy (s
, varstart
, varstop
- varstart
);
6649 s
+= varstop
- varstart
;
6661 *s
++ = TOLOWER (qual
);
6663 memcpy (s
, endstart
, endstop
- endstart
);
6664 s
+= endstop
- endstart
;
6666 memcpy (s
, varstart
, varstop
- varstart
);
6667 s
+= varstop
- varstart
;
6672 ex
[0] = TOLOWER (extent
);
6675 sprintf (buf
, "blt%s %s", ex
, n
->bottom
);
6677 sprintf (buf
, "bgt%s %s", ex
, n
->bottom
);
6680 /* Put together the add or sub instruction used by ENDF. */
6688 *s
++ = TOLOWER (qual
);
6690 memcpy (s
, bystart
, bystop
- bystart
);
6691 s
+= bystop
- bystart
;
6693 memcpy (s
, varstart
, varstop
- varstart
);
6694 s
+= varstop
- varstart
;
6700 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6701 ++input_line_pointer
;
6704 demand_empty_rest_of_line ();
6707 /* Handle the MRI ENDF pseudo-op. */
6711 int ignore ATTRIBUTE_UNUSED
;
6713 if (mri_control_stack
== NULL
6714 || mri_control_stack
->type
!= mri_for
)
6716 as_bad (_("endf without for"));
6717 ignore_rest_of_line ();
6721 colon (mri_control_stack
->next
);
6723 mri_assemble (mri_control_stack
->incr
);
6725 sprintf (mri_control_stack
->incr
, "bra %s", mri_control_stack
->top
);
6726 mri_assemble (mri_control_stack
->incr
);
6728 free (mri_control_stack
->incr
);
6730 colon (mri_control_stack
->bottom
);
6736 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6737 ++input_line_pointer
;
6740 demand_empty_rest_of_line ();
6743 /* Handle the MRI REPEAT pseudo-op. */
6746 s_mri_repeat (ignore
)
6747 int ignore ATTRIBUTE_UNUSED
;
6749 struct mri_control_info
*n
;
6751 n
= push_mri_control (mri_repeat
);
6755 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6756 ++input_line_pointer
;
6758 demand_empty_rest_of_line ();
6761 /* Handle the MRI UNTIL pseudo-op. */
6769 if (mri_control_stack
== NULL
6770 || mri_control_stack
->type
!= mri_repeat
)
6772 as_bad (_("until without repeat"));
6773 ignore_rest_of_line ();
6777 colon (mri_control_stack
->next
);
6779 for (s
= input_line_pointer
; ! is_end_of_line
[(unsigned char) *s
]; s
++)
6782 parse_mri_control_expression (s
, qual
, (const char *) NULL
,
6783 mri_control_stack
->top
, '\0');
6785 colon (mri_control_stack
->bottom
);
6787 input_line_pointer
= s
;
6793 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6794 ++input_line_pointer
;
6797 demand_empty_rest_of_line ();
6800 /* Handle the MRI WHILE pseudo-op. */
6808 struct mri_control_info
*n
;
6810 s
= input_line_pointer
;
6811 /* We only accept '*' as introduction of comments if preceded by white space
6812 or at first column of a line (I think this can't actually happen here?)
6813 This is important when assembling:
6814 while d0 <ne> 12(a0,d0*2) do
6815 while d0 <ne> #CONST*20 do. */
6816 while (! (is_end_of_line
[(unsigned char) *s
]
6819 && (s
== input_line_pointer
6821 || *(s
-1) == '\t'))))
6824 while (*s
== ' ' || *s
== '\t')
6826 if (s
- input_line_pointer
> 1
6829 if (s
- input_line_pointer
< 2
6830 || strncasecmp (s
- 1, "DO", 2) != 0)
6832 as_bad (_("missing do"));
6833 ignore_rest_of_line ();
6837 n
= push_mri_control (mri_while
);
6841 parse_mri_control_expression (s
- 1, qual
, (const char *) NULL
, n
->bottom
,
6842 s
[1] == '.' ? s
[2] : '\0');
6844 input_line_pointer
= s
+ 1;
6845 if (*input_line_pointer
== '.')
6846 input_line_pointer
+= 2;
6850 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6851 ++input_line_pointer
;
6854 demand_empty_rest_of_line ();
6857 /* Handle the MRI ENDW pseudo-op. */
6861 int ignore ATTRIBUTE_UNUSED
;
6865 if (mri_control_stack
== NULL
6866 || mri_control_stack
->type
!= mri_while
)
6868 as_bad (_("endw without while"));
6869 ignore_rest_of_line ();
6873 buf
= (char *) xmalloc (20 + strlen (mri_control_stack
->next
));
6874 sprintf (buf
, "bra %s", mri_control_stack
->next
);
6878 colon (mri_control_stack
->bottom
);
6884 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6885 ++input_line_pointer
;
6888 demand_empty_rest_of_line ();
6893 * Invocation line includes a switch not recognized by the base assembler.
6894 * See if it's a processor-specific option. These are:
6896 * -[A]m[c]68000, -[A]m[c]68008, -[A]m[c]68010, -[A]m[c]68020, -[A]m[c]68030, -[A]m[c]68040
6897 * -[A]m[c]68881, -[A]m[c]68882, -[A]m[c]68851
6898 * Select the architecture. Instructions or features not
6899 * supported by the selected architecture cause fatal
6900 * errors. More than one may be specified. The default is
6901 * -m68020 -m68851 -m68881. Note that -m68008 is a synonym
6902 * for -m68000, and -m68882 is a synonym for -m68881.
6903 * -[A]m[c]no-68851, -[A]m[c]no-68881
6904 * Don't accept 688?1 instructions. (The "c" is kind of silly,
6905 * so don't use or document it, but that's the way the parsing
6908 * -pic Indicates PIC.
6909 * -k Indicates PIC. (Sun 3 only.)
6910 * --pcrel Never turn PC-relative branches into absolute jumps.
6913 * Permit `|' to be used in expressions.
6918 const char *md_shortopts
= "lSA:m:kQ:V";
6920 const char *md_shortopts
= "lSA:m:k";
6923 struct option md_longopts
[] = {
6924 #define OPTION_PIC (OPTION_MD_BASE)
6925 {"pic", no_argument
, NULL
, OPTION_PIC
},
6926 #define OPTION_REGISTER_PREFIX_OPTIONAL (OPTION_MD_BASE + 1)
6927 {"register-prefix-optional", no_argument
, NULL
,
6928 OPTION_REGISTER_PREFIX_OPTIONAL
},
6929 #define OPTION_BITWISE_OR (OPTION_MD_BASE + 2)
6930 {"bitwise-or", no_argument
, NULL
, OPTION_BITWISE_OR
},
6931 #define OPTION_BASE_SIZE_DEFAULT_16 (OPTION_MD_BASE + 3)
6932 {"base-size-default-16", no_argument
, NULL
, OPTION_BASE_SIZE_DEFAULT_16
},
6933 #define OPTION_BASE_SIZE_DEFAULT_32 (OPTION_MD_BASE + 4)
6934 {"base-size-default-32", no_argument
, NULL
, OPTION_BASE_SIZE_DEFAULT_32
},
6935 #define OPTION_DISP_SIZE_DEFAULT_16 (OPTION_MD_BASE + 5)
6936 {"disp-size-default-16", no_argument
, NULL
, OPTION_DISP_SIZE_DEFAULT_16
},
6937 #define OPTION_DISP_SIZE_DEFAULT_32 (OPTION_MD_BASE + 6)
6938 {"disp-size-default-32", no_argument
, NULL
, OPTION_DISP_SIZE_DEFAULT_32
},
6939 #define OPTION_PCREL (OPTION_MD_BASE + 7)
6940 {"pcrel", no_argument
, NULL
, OPTION_PCREL
},
6941 {NULL
, no_argument
, NULL
, 0}
6943 size_t md_longopts_size
= sizeof (md_longopts
);
6946 md_parse_option (c
, arg
)
6952 case 'l': /* -l means keep external to 2 bit offset
6953 rather than 16 bit one. */
6954 flag_short_refs
= 1;
6957 case 'S': /* -S means that jbsr's always turn into
6959 flag_long_jumps
= 1;
6962 case OPTION_PCREL
: /* --pcrel means never turn PC-relative
6963 branches into absolute jumps. */
6964 flag_keep_pcrel
= 1;
6970 /* Intentional fall-through. */
6973 if (arg
[0] == 'n' && arg
[1] == 'o' && arg
[2] == '-')
6977 const char *oarg
= arg
;
6983 if (arg
[0] == 'c' && arg
[1] == '6')
6986 for (i
= 0; i
< n_archs
; i
++)
6987 if (!strcmp (arg
, archs
[i
].name
))
6992 as_bad (_("unrecognized option `%s'"), oarg
);
6995 arch
= archs
[i
].arch
;
6998 else if (arch
== m68851
)
7007 if (arg
[0] == 'c' && arg
[1] == '6')
7010 for (i
= 0; i
< n_archs
; i
++)
7011 if (!strcmp (arg
, archs
[i
].name
))
7013 unsigned long arch
= archs
[i
].arch
;
7014 if (cpu_of_arch (arch
))
7015 /* It's a cpu spec. */
7017 current_architecture
&= ~m68000up
;
7018 current_architecture
|= arch
;
7020 else if (arch
== m68881
)
7022 current_architecture
|= m68881
;
7025 else if (arch
== m68851
)
7027 current_architecture
|= m68851
;
7037 as_bad (_("unrecognized architecture specification `%s'"), arg
);
7046 break; /* -pic, Position Independent Code. */
7048 case OPTION_REGISTER_PREFIX_OPTIONAL
:
7049 flag_reg_prefix_optional
= 1;
7050 reg_prefix_optional_seen
= 1;
7053 /* -V: SVR4 argument to print version ID. */
7055 print_version_id ();
7058 /* -Qy, -Qn: SVR4 arguments controlling whether a .comment section
7059 should be emitted or not. FIXME: Not implemented. */
7063 case OPTION_BITWISE_OR
:
7068 n
= (char *) xmalloc (strlen (m68k_comment_chars
) + 1);
7070 for (s
= m68k_comment_chars
; *s
!= '\0'; s
++)
7074 m68k_comment_chars
= n
;
7078 case OPTION_BASE_SIZE_DEFAULT_16
:
7079 m68k_index_width_default
= SIZE_WORD
;
7082 case OPTION_BASE_SIZE_DEFAULT_32
:
7083 m68k_index_width_default
= SIZE_LONG
;
7086 case OPTION_DISP_SIZE_DEFAULT_16
:
7088 m68k_rel32_from_cmdline
= 1;
7091 case OPTION_DISP_SIZE_DEFAULT_32
:
7093 m68k_rel32_from_cmdline
= 1;
7104 md_show_usage (stream
)
7107 const char *default_cpu
= TARGET_CPU
;
7109 unsigned int default_arch
;
7111 /* Get the canonical name for the default target CPU. */
7112 if (*default_cpu
== 'm')
7114 for (i
= 0; i
< n_archs
; i
++)
7116 if (strcasecmp (default_cpu
, archs
[i
].name
) == 0)
7118 default_arch
= archs
[i
].arch
;
7119 for (i
= 0; i
< n_archs
; i
++)
7121 if (archs
[i
].arch
== default_arch
7124 default_cpu
= archs
[i
].name
;
7131 fprintf (stream
, _("\
7133 -l use 1 word for refs to undefined symbols [default 2]\n\
7134 -m68000 | -m68008 | -m68010 | -m68020 | -m68030 | -m68040 | -m68060 |\n\
7135 -m68302 | -m68331 | -m68332 | -m68333 | -m68340 | -m68360 | -mcpu32 |\n\
7136 -m5200 | -m5202 | -m5204 | -m5206 | -m5206e | -m528x | -m5307 |\n\
7137 -m5407 | -mcfv4 | -mcfv4e\n\
7138 specify variant of 680X0 architecture [default %s]\n\
7139 -m68881 | -m68882 | -mno-68881 | -mno-68882\n\
7140 target has/lacks floating-point coprocessor\n\
7141 [default yes for 68020, 68030, and cpu32]\n"),
7143 fprintf (stream
, _("\
7144 -m68851 | -mno-68851\n\
7145 target has/lacks memory-management unit coprocessor\n\
7146 [default yes for 68020 and up]\n\
7147 -pic, -k generate position independent code\n\
7148 -S turn jbsr into jsr\n\
7149 --pcrel never turn PC-relative branches into absolute jumps\n\
7150 --register-prefix-optional\n\
7151 recognize register names without prefix character\n\
7152 --bitwise-or do not treat `|' as a comment character\n"));
7153 fprintf (stream
, _("\
7154 --base-size-default-16 base reg without size is 16 bits\n\
7155 --base-size-default-32 base reg without size is 32 bits (default)\n\
7156 --disp-size-default-16 displacement with unknown size is 16 bits\n\
7157 --disp-size-default-32 displacement with unknown size is 32 bits (default)\n"));
7162 /* TEST2: Test md_assemble() */
7163 /* Warning, this routine probably doesn't work anymore. */
7167 struct m68k_it the_ins
;
7175 if (!gets (buf
) || !*buf
)
7177 if (buf
[0] == '|' || buf
[1] == '.')
7179 for (cp
= buf
; *cp
; cp
++)
7184 memset (&the_ins
, '\0', sizeof (the_ins
));
7185 m68k_ip (&the_ins
, buf
);
7188 printf (_("Error %s in %s\n"), the_ins
.error
, buf
);
7192 printf (_("Opcode(%d.%s): "), the_ins
.numo
, the_ins
.args
);
7193 for (n
= 0; n
< the_ins
.numo
; n
++)
7194 printf (" 0x%x", the_ins
.opcode
[n
] & 0xffff);
7196 print_the_insn (&the_ins
.opcode
[0], stdout
);
7197 (void) putchar ('\n');
7199 for (n
= 0; n
< strlen (the_ins
.args
) / 2; n
++)
7201 if (the_ins
.operands
[n
].error
)
7203 printf ("op%d Error %s in %s\n", n
, the_ins
.operands
[n
].error
, buf
);
7206 printf ("mode %d, reg %d, ", the_ins
.operands
[n
].mode
, the_ins
.operands
[n
].reg
);
7207 if (the_ins
.operands
[n
].b_const
)
7208 printf ("Constant: '%.*s', ", 1 + the_ins
.operands
[n
].e_const
- the_ins
.operands
[n
].b_const
, the_ins
.operands
[n
].b_const
);
7209 printf ("ireg %d, isiz %d, imul %d, ", the_ins
.operands
[n
].ireg
, the_ins
.operands
[n
].isiz
, the_ins
.operands
[n
].imul
);
7210 if (the_ins
.operands
[n
].b_iadd
)
7211 printf ("Iadd: '%.*s',", 1 + the_ins
.operands
[n
].e_iadd
- the_ins
.operands
[n
].b_iadd
, the_ins
.operands
[n
].b_iadd
);
7212 (void) putchar ('\n');
7224 while (*str
&& *str
!= ' ')
7226 if (str
[-1] == ':' || str
[1] == '=')
7233 /* Possible states for relaxation:
7235 0 0 branch offset byte (bra, etc)
7239 1 0 indexed offsets byte a0@(32,d4:w:1) etc
7243 2 0 two-offset index word-word a0@(32,d4)@(45) etc
7250 /* We have no need to default values of symbols. */
7253 md_undefined_symbol (name
)
7254 char *name ATTRIBUTE_UNUSED
;
7259 /* Round up a section size to the appropriate boundary. */
7261 md_section_align (segment
, size
)
7262 segT segment ATTRIBUTE_UNUSED
;
7266 #ifdef BFD_ASSEMBLER
7267 /* For a.out, force the section size to be aligned. If we don't do
7268 this, BFD will align it for us, but it will not write out the
7269 final bytes of the section. This may be a bug in BFD, but it is
7270 easier to fix it here since that is how the other a.out targets
7274 align
= bfd_get_section_alignment (stdoutput
, segment
);
7275 size
= ((size
+ (1 << align
) - 1) & ((valueT
) -1 << align
));
7282 /* Exactly what point is a PC-relative offset relative TO?
7283 On the 68k, it is relative to the address of the first extension
7284 word. The difference between the addresses of the offset and the
7285 first extension word is stored in fx_pcrel_adjust. */
7287 md_pcrel_from (fixP
)
7292 /* Because fx_pcrel_adjust is a char, and may be unsigned, we explicitly
7293 sign extend the value here. */
7294 adjust
= ((fixP
->fx_pcrel_adjust
& 0xff) ^ 0x80) - 0x80;
7297 return fixP
->fx_where
+ fixP
->fx_frag
->fr_address
- adjust
;
7300 #ifndef BFD_ASSEMBLER
7304 tc_coff_symbol_emit_hook (ignore
)
7305 symbolS
*ignore ATTRIBUTE_UNUSED
;
7310 tc_coff_sizemachdep (frag
)
7313 switch (frag
->fr_subtype
& 0x3)
7331 m68k_elf_final_processing ()
7333 /* Set file-specific flags if this is a cpu32 processor. */
7334 if (cpu_of_arch (current_architecture
) & cpu32
)
7335 elf_elfheader (stdoutput
)->e_flags
|= EF_CPU32
;
7336 else if ((cpu_of_arch (current_architecture
) & m68000up
)
7337 && !(cpu_of_arch (current_architecture
) & m68020up
))
7338 elf_elfheader (stdoutput
)->e_flags
|= EF_M68000
;
7343 tc_m68k_regname_to_dw2regnum (const char *regname
)
7345 unsigned int regnum
;
7346 static const char *const regnames
[] =
7348 "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
7349 "a0", "a1", "a2", "a3", "a4", "a5", "a6", "sp",
7350 "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7",
7354 for (regnum
= 0; regnum
< ARRAY_SIZE (regnames
); regnum
++)
7355 if (strcmp (regname
, regnames
[regnum
]) == 0)
7362 tc_m68k_frame_initial_instructions (void)
7364 static int sp_regno
= -1;
7367 sp_regno
= tc_m68k_regname_to_dw2regnum ("sp");
7369 cfi_add_CFA_def_cfa (sp_regno
, -DWARF2_CIE_DATA_ALIGNMENT
);
7370 cfi_add_CFA_offset (DWARF2_DEFAULT_RETURN_COLUMN
, DWARF2_CIE_DATA_ALIGNMENT
);