1 /* tc-m68k.c -- Assemble for the m68k family
2 Copyright (C) 1987, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
4 This file is part of GAS, the GNU Assembler.
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GAS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GAS; see the file COPYING. If not, write to the Free
18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
26 #include "opcode/m68k.h"
27 #include "m68k-parse.h"
29 /* This string holds the chars that always start a comment. If the
30 pre-processor is disabled, these aren't very useful. The macro
31 tc_comment_chars points to this. We use this, rather than the
32 usual comment_chars, so that the --bitwise-or option will work. */
33 #if (defined (OBJ_ELF) && ! defined (TE_PSOS) && ! defined (TE_LINUX)) || defined (TE_DELTA)
34 const char *m68k_comment_chars
= "|#";
36 const char *m68k_comment_chars
= "|";
39 /* This array holds the chars that only start a comment at the beginning of
40 a line. If the line seems to have the form '# 123 filename'
41 .line and .file directives will appear in the pre-processed output */
42 /* Note that input_file.c hand checks for '#' at the beginning of the
43 first line of the input file. This is because the compiler outputs
44 #NO_APP at the beginning of its output. */
45 /* Also note that comments like this one will always work. */
46 const char line_comment_chars
[] = "#";
48 const char line_separator_chars
[] = "";
50 /* Chars that can be used to separate mant from exp in floating point nums */
51 CONST
char EXP_CHARS
[] = "eE";
53 /* Chars that mean this number is a floating point constant, as
54 in "0f12.456" or "0d1.2345e12". */
56 CONST
char FLT_CHARS
[] = "rRsSfFdDxXeEpP";
58 /* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
59 changed in read.c . Ideally it shouldn't have to know about it at all,
60 but nothing is ideal around here. */
62 const int md_reloc_size
= 8; /* Size of relocation record */
64 /* Are we trying to generate PIC code? If so, absolute references
65 ought to be made into linkage table references or pc-relative
66 references. Not implemented. For ELF there are other means
67 to denote pic relocations. */
70 static int flag_short_refs
; /* -l option */
71 static int flag_long_jumps
; /* -S option */
73 #ifdef REGISTER_PREFIX_OPTIONAL
74 int flag_reg_prefix_optional
= REGISTER_PREFIX_OPTIONAL
;
76 int flag_reg_prefix_optional
;
79 /* Whether --register-prefix-optional was used on the command line. */
80 static int reg_prefix_optional_seen
;
82 /* The floating point coprocessor to use by default. */
83 static enum m68k_register m68k_float_copnum
= COP1
;
85 /* If this is non-zero, then references to number(%pc) will be taken
86 to refer to number, rather than to %pc + number. */
87 static int m68k_abspcadd
;
89 /* If this is non-zero, then the quick forms of the move, add, and sub
90 instructions are used when possible. */
91 static int m68k_quick
= 1;
93 /* If this is non-zero, then if the size is not specified for a base
94 or outer displacement, the assembler assumes that the size should
96 static int m68k_rel32
= 1;
98 /* Its an arbitrary name: This means I don't approve of it */
99 /* See flames below */
100 static struct obstack robyn
;
102 #define TAB(x,y) (((x)<<2)+(y))
103 #define TABTYPE(xy) ((xy) >> 2)
109 /* Case `g' except when BCC68000 is applicable. */
111 /* Coprocessor branches. */
113 /* Mode 7.2 -- program counter indirect with (16-bit) displacement,
114 supported on all cpus. Widens to 32-bit absolute. */
116 /* For inserting an extra jmp instruction with long offset on 68000,
117 for expanding conditional branches. (Not bsr or bra.) Since the
118 68000 doesn't support 32-bit displacements for conditional
119 branches, we fake it by reversing the condition and branching
120 around a jmp with an absolute long operand. */
122 /* For the DBcc "instructions". If the displacement requires 32 bits,
123 the branch-around-a-jump game is played here too. */
125 /* Not currently used? */
127 /* Mode AINDX (apc-relative) using PC, with variable target, might fit
133 const char *m_operands
;
134 unsigned long m_opcode
;
138 struct m68k_incant
*m_next
;
141 #define getone(x) ((((x)->m_opcode)>>16)&0xffff)
142 #define gettwo(x) (((x)->m_opcode)&0xffff)
144 static const enum m68k_register m68000_control_regs
[] = { 0 };
145 static const enum m68k_register m68010_control_regs
[] = {
149 static const enum m68k_register m68020_control_regs
[] = {
150 SFC
, DFC
, USP
, VBR
, CACR
, CAAR
, MSP
, ISP
,
153 static const enum m68k_register m68040_control_regs
[] = {
154 SFC
, DFC
, CACR
, TC
, ITT0
, ITT1
, DTT0
, DTT1
,
155 USP
, VBR
, MSP
, ISP
, MMUSR
, URP
, SRP
,
158 static const enum m68k_register m68060_control_regs
[] = {
159 SFC
, DFC
, CACR
, TC
, ITT0
, ITT1
, DTT0
, DTT1
, BUSCR
,
160 USP
, VBR
, URP
, SRP
, PCR
,
163 static const enum m68k_register mcf5200_control_regs
[] = {
164 CACR
, TC
, ITT0
, ITT1
, DTT0
, DTT1
, VBR
, ROMBAR
,
165 RAMBAR0
, RAMBAR1
, MBAR
,
168 #define cpu32_control_regs m68010_control_regs
170 static const enum m68k_register
*control_regs
;
172 /* internal form of a 68020 instruction */
176 const char *args
; /* list of opcode info */
179 int numo
; /* Number of shorts in opcode */
182 struct m68k_op operands
[6];
184 int nexp
; /* number of exprs in use */
185 struct m68k_exp exprs
[4];
187 int nfrag
; /* Number of frags we have to produce */
190 int fragoff
; /* Where in the current opcode the frag ends */
197 int nrel
; /* Num of reloc strucs in use */
204 /* In a pc relative address the difference between the address
205 of the offset and the address that the offset is relative
206 to. This depends on the addressing mode. Basically this
207 is the value to put in the offset field to address the
208 first byte of the offset, without regarding the special
209 significance of some values (in the branch instruction, for
213 /* Whether this expression needs special pic relocation, and if
215 enum pic_relocation pic_reloc
;
218 reloc
[5]; /* Five is enough??? */
221 #define cpu_of_arch(x) ((x) & (m68000up|mcf5200))
222 #define float_of_arch(x) ((x) & mfloat)
223 #define mmu_of_arch(x) ((x) & mmmu)
225 static struct m68k_it the_ins
; /* the instruction being assembled */
227 #define op(ex) ((ex)->exp.X_op)
228 #define adds(ex) ((ex)->exp.X_add_symbol)
229 #define subs(ex) ((ex)->exp.X_op_symbol)
230 #define offs(ex) ((ex)->exp.X_add_number)
232 /* Macros for adding things to the m68k_it struct */
234 #define addword(w) the_ins.opcode[the_ins.numo++]=(w)
236 /* Like addword, but goes BEFORE general operands */
240 struct m68k_incant
*opcode
;
243 for(z
=the_ins
.numo
;z
>opcode
->m_codenum
;--z
)
244 the_ins
.opcode
[z
]=the_ins
.opcode
[z
-1];
245 for(z
=0;z
<the_ins
.nrel
;z
++)
246 the_ins
.reloc
[z
].n
+=2;
247 for (z
= 0; z
< the_ins
.nfrag
; z
++)
248 the_ins
.fragb
[z
].fragoff
++;
249 the_ins
.opcode
[opcode
->m_codenum
]=w
;
253 /* The numo+1 kludge is so we can hit the low order byte of the prev word.
256 add_fix (width
, exp
, pc_rel
, pc_fix
)
258 struct m68k_exp
*exp
;
262 the_ins
.reloc
[the_ins
.nrel
].n
= (((width
)=='B')
266 : (the_ins
.numo
*2)));
267 the_ins
.reloc
[the_ins
.nrel
].exp
= exp
->exp
;
268 the_ins
.reloc
[the_ins
.nrel
].wid
= width
;
269 the_ins
.reloc
[the_ins
.nrel
].pcrel_fix
= pc_fix
;
271 the_ins
.reloc
[the_ins
.nrel
].pic_reloc
= exp
->pic_reloc
;
273 the_ins
.reloc
[the_ins
.nrel
++].pcrel
= pc_rel
;
276 /* Cause an extra frag to be generated here, inserting up to 10 bytes
277 (that value is chosen in the frag_var call in md_assemble). TYPE
278 is the subtype of the frag to be generated; its primary type is
279 rs_machine_dependent.
281 The TYPE parameter is also used by md_convert_frag_1 and
282 md_estimate_size_before_relax. The appropriate type of fixup will
283 be emitted by md_convert_frag_1.
285 ADD becomes the FR_SYMBOL field of the frag, and OFF the FR_OFFSET. */
287 add_frag(add
,off
,type
)
292 the_ins
.fragb
[the_ins
.nfrag
].fragoff
=the_ins
.numo
;
293 the_ins
.fragb
[the_ins
.nfrag
].fadd
=add
;
294 the_ins
.fragb
[the_ins
.nfrag
].foff
=off
;
295 the_ins
.fragb
[the_ins
.nfrag
++].fragty
=type
;
299 (op (ex) != O_constant && op (ex) != O_big)
301 static char *crack_operand
PARAMS ((char *str
, struct m68k_op
*opP
));
302 static int get_num
PARAMS ((struct m68k_exp
*exp
, int ok
));
303 static int reverse_16_bits
PARAMS ((int in
));
304 static int reverse_8_bits
PARAMS ((int in
));
305 static void install_gen_operand
PARAMS ((int mode
, int val
));
306 static void install_operand
PARAMS ((int mode
, int val
));
307 static void s_bss
PARAMS ((int));
308 static void s_data1
PARAMS ((int));
309 static void s_data2
PARAMS ((int));
310 static void s_even
PARAMS ((int));
311 static void s_proc
PARAMS ((int));
312 static void mri_chip
PARAMS ((void));
313 static void s_chip
PARAMS ((int));
314 static void s_fopt
PARAMS ((int));
315 static void s_opt
PARAMS ((int));
316 static void s_reg
PARAMS ((int));
317 static void s_restore
PARAMS ((int));
318 static void s_save
PARAMS ((int));
319 static void s_mri_if
PARAMS ((int));
320 static void s_mri_else
PARAMS ((int));
321 static void s_mri_endi
PARAMS ((int));
322 static void s_mri_break
PARAMS ((int));
323 static void s_mri_next
PARAMS ((int));
324 static void s_mri_for
PARAMS ((int));
325 static void s_mri_endf
PARAMS ((int));
326 static void s_mri_repeat
PARAMS ((int));
327 static void s_mri_until
PARAMS ((int));
328 static void s_mri_while
PARAMS ((int));
329 static void s_mri_endw
PARAMS ((int));
331 static int current_architecture
;
339 static const struct m68k_cpu archs
[] = {
340 { m68000
, "68000", 0 },
341 { m68010
, "68010", 0 },
342 { m68020
, "68020", 0 },
343 { m68030
, "68030", 0 },
344 { m68040
, "68040", 0 },
345 { m68060
, "68060", 0 },
346 { cpu32
, "cpu32", 0 },
347 { m68881
, "68881", 0 },
348 { m68851
, "68851", 0 },
349 { mcf5200
, "5200", 0 },
350 /* Aliases (effectively, so far as gas is concerned) for the above
352 { m68020
, "68k", 1 },
353 { m68000
, "68302", 1 },
354 { m68000
, "68008", 1 },
355 { m68000
, "68ec000", 1 },
356 { m68000
, "68hc000", 1 },
357 { m68000
, "68hc001", 1 },
358 { m68020
, "68ec020", 1 },
359 { m68030
, "68ec030", 1 },
360 { m68040
, "68ec040", 1 },
361 { m68060
, "68ec060", 1 },
362 { cpu32
, "68330", 1 },
363 { cpu32
, "68331", 1 },
364 { cpu32
, "68332", 1 },
365 { cpu32
, "68333", 1 },
366 { cpu32
, "68340", 1 },
367 { cpu32
, "68360", 1 },
368 { m68881
, "68882", 1 },
371 static const int n_archs
= sizeof (archs
) / sizeof (archs
[0]);
373 /* BCC68000 is for patching in an extra jmp instruction for long offsets
374 on the 68000. The 68000 doesn't support long branches with branchs */
376 /* This table desribes how you change sizes for the various types of variable
377 size expressions. This version only supports two kinds. */
379 /* Note that calls to frag_var need to specify the maximum expansion
380 needed; this is currently 10 bytes for DBCC. */
383 How far Forward this mode will reach:
384 How far Backward this mode will reach:
385 How many bytes this mode will add to the size of the frag
386 Which mode to go to if the offset won't fit in this one
388 relax_typeS md_relax_table
[] =
390 {1, 1, 0, 0}, /* First entries aren't used */
391 {1, 1, 0, 0}, /* For no good reason except */
392 {1, 1, 0, 0}, /* that the VAX doesn't either */
395 {(127), (-128), 0, TAB (ABRANCH
, SHORT
)},
396 {(32767), (-32768), 2, TAB (ABRANCH
, LONG
)},
400 {1, 1, 0, 0}, /* FBRANCH doesn't come BYTE */
401 {(32767), (-32768), 2, TAB (FBRANCH
, LONG
)},
405 {1, 1, 0, 0}, /* PCREL doesn't come BYTE */
406 {(32767), (-32768), 2, TAB (PCREL
, LONG
)},
410 {(127), (-128), 0, TAB (BCC68000
, SHORT
)},
411 {(32767), (-32768), 2, TAB (BCC68000
, LONG
)},
412 {0, 0, 6, 0}, /* jmp long space */
415 {1, 1, 0, 0}, /* DBCC doesn't come BYTE */
416 {(32767), (-32768), 2, TAB (DBCC
, LONG
)},
417 {0, 0, 10, 0}, /* bra/jmp long space */
420 {1, 1, 0, 0}, /* PCLEA doesn't come BYTE */
421 {32767, -32768, 2, TAB (PCLEA
, LONG
)},
425 /* For, e.g., jmp pcrel indexed. */
426 {125, -130, 0, TAB (PCINDEX
, SHORT
)},
427 {32765, -32770, 2, TAB (PCINDEX
, LONG
)},
432 /* These are the machine dependent pseudo-ops. These are included so
433 the assembler can work on the output from the SUN C compiler, which
437 /* This table describes all the machine specific pseudo-ops the assembler
438 has to support. The fields are:
439 pseudo-op name without dot
440 function to call to execute this pseudo-op
441 Integer arg to pass to the function
443 const pseudo_typeS md_pseudo_table
[] =
445 {"data1", s_data1
, 0},
446 {"data2", s_data2
, 0},
449 {"skip", s_space
, 0},
451 #if defined (TE_SUN3) || defined (OBJ_ELF)
452 {"align", s_align_bytes
, 0},
455 {"swbeg", s_ignore
, 0},
457 {"extend", float_cons
, 'x'},
458 {"ldouble", float_cons
, 'x'},
460 /* The following pseudo-ops are supported for MRI compatibility. */
462 {"comline", s_space
, 1},
464 {"mask2", s_ignore
, 0},
467 {"restore", s_restore
, 0},
471 {"if.b", s_mri_if
, 'b'},
472 {"if.w", s_mri_if
, 'w'},
473 {"if.l", s_mri_if
, 'l'},
474 {"else", s_mri_else
, 0},
475 {"else.s", s_mri_else
, 's'},
476 {"else.l", s_mri_else
, 'l'},
477 {"endi", s_mri_endi
, 0},
478 {"break", s_mri_break
, 0},
479 {"break.s", s_mri_break
, 's'},
480 {"break.l", s_mri_break
, 'l'},
481 {"next", s_mri_next
, 0},
482 {"next.s", s_mri_next
, 's'},
483 {"next.l", s_mri_next
, 'l'},
484 {"for", s_mri_for
, 0},
485 {"for.b", s_mri_for
, 'b'},
486 {"for.w", s_mri_for
, 'w'},
487 {"for.l", s_mri_for
, 'l'},
488 {"endf", s_mri_endf
, 0},
489 {"repeat", s_mri_repeat
, 0},
490 {"until", s_mri_until
, 0},
491 {"until.b", s_mri_until
, 'b'},
492 {"until.w", s_mri_until
, 'w'},
493 {"until.l", s_mri_until
, 'l'},
494 {"while", s_mri_while
, 0},
495 {"while.b", s_mri_while
, 'b'},
496 {"while.w", s_mri_while
, 'w'},
497 {"while.l", s_mri_while
, 'l'},
498 {"endw", s_mri_endw
, 0},
504 /* The mote pseudo ops are put into the opcode table, since they
505 don't start with a . they look like opcodes to gas.
507 extern void obj_coff_section ();
509 CONST pseudo_typeS mote_pseudo_table
[] =
522 {"xdef", s_globl
, 0},
524 {"align", s_align_bytes
, 0},
526 {"align", s_align_ptwo
, 0},
529 {"sect", obj_coff_section
, 0},
530 {"section", obj_coff_section
, 0},
535 #define issbyte(x) ((x)>=-128 && (x)<=127)
536 #define isubyte(x) ((x)>=0 && (x)<=255)
537 #define issword(x) ((x)>=-32768 && (x)<=32767)
538 #define isuword(x) ((x)>=0 && (x)<=65535)
540 #define isbyte(x) ((x)>= -255 && (x)<=255)
541 #define isword(x) ((x)>=-65536 && (x)<=65535)
542 #define islong(x) (1)
544 extern char *input_line_pointer
;
546 static char mklower_table
[256];
547 #define mklower(c) (mklower_table[(unsigned char)(c)])
548 static char notend_table
[256];
549 static char alt_notend_table
[256];
551 (! (notend_table[(unsigned char) *s] \
553 && alt_notend_table[(unsigned char) s[1]])))
555 #if defined (M68KCOFF) && !defined (BFD_ASSEMBLER)
557 #ifdef NO_PCREL_RELOCS
560 make_pcrel_absolute(fixP
, add_number
)
564 register unsigned char *opcode
= fixP
->fx_frag
->fr_opcode
;
566 /* rewrite the PC relative instructions to absolute address ones.
567 * these are rumoured to be faster, and the apollo linker refuses
568 * to deal with the PC relative relocations.
570 if (opcode
[0] == 0x60 && opcode
[1] == 0xff) /* BRA -> JMP */
575 else if (opcode
[0] == 0x61 && opcode
[1] == 0xff) /* BSR -> JSR */
581 as_fatal ("Unknown PC relative instruction");
586 #endif /* NO_PCREL_RELOCS */
589 tc_coff_fix2rtype (fixP
)
592 if (fixP
->fx_tcbit
&& fixP
->fx_size
== 4)
593 return R_RELLONG_NEG
;
594 #ifdef NO_PCREL_RELOCS
595 know (fixP
->fx_pcrel
== 0);
596 return (fixP
->fx_size
== 1 ? R_RELBYTE
597 : fixP
->fx_size
== 2 ? R_DIR16
600 return (fixP
->fx_pcrel
?
601 (fixP
->fx_size
== 1 ? R_PCRBYTE
:
602 fixP
->fx_size
== 2 ? R_PCRWORD
:
604 (fixP
->fx_size
== 1 ? R_RELBYTE
:
605 fixP
->fx_size
== 2 ? R_RELWORD
:
614 /* Compute the relocation code for a fixup of SIZE bytes, using pc
615 relative relocation if PCREL is non-zero. PIC says whether a special
616 pic relocation was requested. */
618 static bfd_reloc_code_real_type get_reloc_code
619 PARAMS ((int, int, enum pic_relocation
));
621 static bfd_reloc_code_real_type
622 get_reloc_code (size
, pcrel
, pic
)
625 enum pic_relocation pic
;
633 return BFD_RELOC_8_GOT_PCREL
;
635 return BFD_RELOC_16_GOT_PCREL
;
637 return BFD_RELOC_32_GOT_PCREL
;
645 return BFD_RELOC_8_GOTOFF
;
647 return BFD_RELOC_16_GOTOFF
;
649 return BFD_RELOC_32_GOTOFF
;
657 return BFD_RELOC_8_PLT_PCREL
;
659 return BFD_RELOC_16_PLT_PCREL
;
661 return BFD_RELOC_32_PLT_PCREL
;
669 return BFD_RELOC_8_PLTOFF
;
671 return BFD_RELOC_16_PLTOFF
;
673 return BFD_RELOC_32_PLTOFF
;
683 return BFD_RELOC_8_PCREL
;
685 return BFD_RELOC_16_PCREL
;
687 return BFD_RELOC_32_PCREL
;
704 as_bad ("Can not do %d byte %s%srelocation", size
,
705 pcrel
? "pc-relative " : "",
706 pic
== pic_none
? "" : "pic ");
707 return BFD_RELOC_NONE
;
710 /* Here we decide which fixups can be adjusted to make them relative
711 to the beginning of the section instead of the symbol. Basically
712 we need to make sure that the dynamic relocations are done
713 correctly, so in some cases we force the original symbol to be
716 tc_m68k_fix_adjustable (fixP
)
719 /* Prevent all adjustments to global symbols. */
720 if (S_IS_EXTERNAL (fixP
->fx_addsy
))
723 /* adjust_reloc_syms doesn't know about the GOT */
724 switch (fixP
->fx_r_type
)
726 case BFD_RELOC_8_GOT_PCREL
:
727 case BFD_RELOC_16_GOT_PCREL
:
728 case BFD_RELOC_32_GOT_PCREL
:
729 case BFD_RELOC_8_GOTOFF
:
730 case BFD_RELOC_16_GOTOFF
:
731 case BFD_RELOC_32_GOTOFF
:
732 case BFD_RELOC_8_PLT_PCREL
:
733 case BFD_RELOC_16_PLT_PCREL
:
734 case BFD_RELOC_32_PLT_PCREL
:
735 case BFD_RELOC_8_PLTOFF
:
736 case BFD_RELOC_16_PLTOFF
:
737 case BFD_RELOC_32_PLTOFF
:
747 #define get_reloc_code(SIZE,PCREL,OTHER) NO_RELOC
754 tc_gen_reloc (section
, fixp
)
759 bfd_reloc_code_real_type code
;
764 if (fixp
->fx_r_type
!= BFD_RELOC_NONE
)
765 code
= fixp
->fx_r_type
;
768 #define F(SZ,PCREL) (((SZ) << 1) + (PCREL))
769 switch (F (fixp
->fx_size
, fixp
->fx_pcrel
))
771 #define MAP(SZ,PCREL,TYPE) case F(SZ,PCREL): code = (TYPE); break
772 MAP (1, 0, BFD_RELOC_8
);
773 MAP (2, 0, BFD_RELOC_16
);
774 MAP (4, 0, BFD_RELOC_32
);
775 MAP (1, 1, BFD_RELOC_8_PCREL
);
776 MAP (2, 1, BFD_RELOC_16_PCREL
);
777 MAP (4, 1, BFD_RELOC_32_PCREL
);
785 reloc
= (arelent
*) bfd_alloc_by_size_t (stdoutput
, sizeof (arelent
));
787 reloc
->sym_ptr_ptr
= &fixp
->fx_addsy
->bsym
;
788 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
791 reloc
->addend
= fixp
->fx_addnumber
;
796 reloc
->addend
= fixp
->fx_addnumber
;
797 else if ((fixp
->fx_addsy
->bsym
->flags
& BSF_SECTION_SYM
) != 0)
798 reloc
->addend
= (section
->vma
799 + (fixp
->fx_pcrel_adjust
== 64
800 ? -1 : fixp
->fx_pcrel_adjust
)
802 + md_pcrel_from (fixp
));
804 reloc
->addend
= (fixp
->fx_offset
805 + (fixp
->fx_pcrel_adjust
== 64
806 ? -1 : fixp
->fx_pcrel_adjust
));
809 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
810 assert (reloc
->howto
!= 0);
815 #endif /* BFD_ASSEMBLER */
817 /* Handle of the OPCODE hash table. NULL means any use before
818 m68k_ip_begin() will crash. */
819 static struct hash_control
*op_hash
;
821 /* Assemble an m68k instruction. */
828 register struct m68k_op
*opP
;
829 register struct m68k_incant
*opcode
;
830 register const char *s
;
831 register int tmpreg
= 0, baseo
= 0, outro
= 0, nextword
;
832 char *pdot
, *pdotmove
;
833 enum m68k_size siz1
, siz2
;
837 char *crack_operand ();
838 LITTLENUM_TYPE words
[6];
839 LITTLENUM_TYPE
*wordp
;
840 unsigned long ok_arch
= 0;
842 if (*instring
== ' ')
843 instring
++; /* skip leading whitespace */
845 /* Scan up to end of operation-code, which MUST end in end-of-string
846 or exactly 1 space. */
848 for (p
= instring
; *p
!= '\0'; p
++)
858 the_ins
.error
= "No operator";
862 /* p now points to the end of the opcode name, probably whitespace.
863 Make sure the name is null terminated by clobbering the
864 whitespace, look it up in the hash table, then fix it back.
865 Remove a dot, first, since the opcode tables have none. */
868 for (pdotmove
= pdot
; pdotmove
< p
; pdotmove
++)
869 *pdotmove
= pdotmove
[1];
875 opcode
= (struct m68k_incant
*) hash_find (op_hash
, instring
);
880 for (pdotmove
= p
; pdotmove
> pdot
; pdotmove
--)
881 *pdotmove
= pdotmove
[-1];
888 the_ins
.error
= "Unknown operator";
892 /* found a legitimate opcode, start matching operands */
896 if (opcode
->m_operands
== 0)
898 char *old
= input_line_pointer
;
900 input_line_pointer
= p
;
901 /* Ahh - it's a motorola style psuedo op */
902 mote_pseudo_table
[opcode
->m_opnum
].poc_handler
903 (mote_pseudo_table
[opcode
->m_opnum
].poc_val
);
904 input_line_pointer
= old
;
910 if (flag_mri
&& opcode
->m_opnum
== 0)
912 /* In MRI mode, random garbage is allowed after an instruction
913 which accepts no operands. */
914 the_ins
.args
= opcode
->m_operands
;
915 the_ins
.numargs
= opcode
->m_opnum
;
916 the_ins
.numo
= opcode
->m_codenum
;
917 the_ins
.opcode
[0] = getone (opcode
);
918 the_ins
.opcode
[1] = gettwo (opcode
);
922 for (opP
= &the_ins
.operands
[0]; *p
; opP
++)
924 p
= crack_operand (p
, opP
);
928 the_ins
.error
= opP
->error
;
933 opsfound
= opP
- &the_ins
.operands
[0];
935 /* This ugly hack is to support the floating pt opcodes in their
936 standard form. Essentially, we fake a first enty of type COP#1 */
937 if (opcode
->m_operands
[0] == 'I')
941 for (n
= opsfound
; n
> 0; --n
)
942 the_ins
.operands
[n
] = the_ins
.operands
[n
- 1];
944 memset ((char *) (&the_ins
.operands
[0]), '\0',
945 sizeof (the_ins
.operands
[0]));
946 the_ins
.operands
[0].mode
= CONTROL
;
947 the_ins
.operands
[0].reg
= m68k_float_copnum
;
951 /* We've got the operands. Find an opcode that'll accept them */
954 /* If we didn't get the right number of ops, or we have no
955 common model with this pattern then reject this pattern. */
957 if (opsfound
!= opcode
->m_opnum
958 || ((opcode
->m_arch
& current_architecture
) == 0))
961 ok_arch
|= opcode
->m_arch
;
965 for (s
= opcode
->m_operands
, opP
= &the_ins
.operands
[0];
969 /* Warning: this switch is huge! */
970 /* I've tried to organize the cases into this order:
971 non-alpha first, then alpha by letter. Lower-case
972 goes directly before uppercase counterpart. */
973 /* Code with multiple case ...: gets sorted by the lowest
974 case ... it belongs to. I hope this makes sense. */
1014 if (opP
->mode
!= IMMED
)
1016 else if (s
[1] == 'b'
1017 && ! isvar (&opP
->disp
)
1018 && (opP
->disp
.exp
.X_op
!= O_constant
1019 || ! isbyte (opP
->disp
.exp
.X_add_number
)))
1021 else if (s
[1] == 'w'
1022 && ! isvar (&opP
->disp
)
1023 && (opP
->disp
.exp
.X_op
!= O_constant
1024 || ! isword (opP
->disp
.exp
.X_add_number
)))
1026 else if (s
[1] == 'W'
1027 && ! isvar (&opP
->disp
)
1028 && (opP
->disp
.exp
.X_op
!= O_constant
1029 || ! issword (opP
->disp
.exp
.X_add_number
)))
1035 if (opP
->mode
!= IMMED
)
1040 if (opP
->mode
== AREG
1041 || opP
->mode
== CONTROL
1042 || opP
->mode
== FPREG
1043 || opP
->mode
== IMMED
1044 || opP
->mode
== REGLST
1045 || (opP
->mode
!= ABSL
1047 || opP
->reg
== ZPC
)))
1052 if (opP
->mode
== CONTROL
1053 || opP
->mode
== FPREG
1054 || opP
->mode
== REGLST
1055 || opP
->mode
== IMMED
1056 || (opP
->mode
!= ABSL
1058 || opP
->reg
== ZPC
)))
1086 if (opP
->mode
== CONTROL
1087 || opP
->mode
== FPREG
1088 || opP
->mode
== REGLST
)
1093 if (opP
->mode
!= AINC
)
1098 if (opP
->mode
!= ADEC
)
1148 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
1169 case '~': /* For now! (JF FOO is this right?) */
1191 if (opP
->mode
!= CONTROL
1192 || (opP
->reg
!= TT0
&& opP
->reg
!= TT1
))
1197 if (opP
->mode
!= AREG
)
1202 if (opP
->mode
!= AINDR
)
1207 if (opP
->mode
!= ABSL
1209 && strncmp (instring
, "jbsr", 4) == 0))
1214 if (opP
->mode
!= CONTROL
|| opP
->reg
!= CCR
)
1219 if (opP
->mode
!= DISP
1221 || opP
->reg
> ADDR7
)
1226 if (opP
->mode
!= DREG
)
1231 if (opP
->mode
!= FPREG
)
1236 if (opP
->mode
!= CONTROL
1243 if (opP
->mode
!= CONTROL
1245 || opP
->reg
> last_movec_reg
)
1249 const enum m68k_register
*rp
;
1250 for (rp
= control_regs
; *rp
; rp
++)
1251 if (*rp
== opP
->reg
)
1259 if (opP
->mode
!= IMMED
)
1265 if (opP
->mode
== DREG
1266 || opP
->mode
== AREG
1267 || opP
->mode
== FPREG
)
1276 opP
->mask
= 1 << (opP
->reg
- DATA0
);
1279 opP
->mask
= 1 << (opP
->reg
- ADDR0
+ 8);
1282 opP
->mask
= 1 << (opP
->reg
- FP0
+ 16);
1290 else if (opP
->mode
== CONTROL
)
1299 opP
->mask
= 1 << 24;
1302 opP
->mask
= 1 << 25;
1305 opP
->mask
= 1 << 26;
1314 else if (opP
->mode
== ABSL
1315 && opP
->disp
.size
== SIZE_UNSPEC
1316 && opP
->disp
.exp
.X_op
== O_constant
)
1318 /* This is what the MRI REG pseudo-op generates. */
1320 opP
->mask
= opP
->disp
.exp
.X_add_number
;
1322 else if (opP
->mode
!= REGLST
)
1324 else if (s
[1] == '8' && (opP
->mask
& 0x0ffffff) != 0)
1326 else if (s
[1] == '3' && (opP
->mask
& 0x7000000) != 0)
1331 if (opP
->mode
!= IMMED
)
1333 else if (opP
->disp
.exp
.X_op
!= O_constant
1334 || ! issbyte (opP
->disp
.exp
.X_add_number
))
1336 else if (! m68k_quick
1337 && instring
[3] != 'q'
1338 && instring
[4] != 'q')
1343 if (opP
->mode
!= DREG
1344 && opP
->mode
!= IMMED
1345 && opP
->mode
!= ABSL
)
1350 if (opP
->mode
!= IMMED
)
1352 else if (opP
->disp
.exp
.X_op
!= O_constant
1353 || opP
->disp
.exp
.X_add_number
< 1
1354 || opP
->disp
.exp
.X_add_number
> 8)
1356 else if (! m68k_quick
1357 && (strncmp (instring
, "add", 3) == 0
1358 || strncmp (instring
, "sub", 3) == 0)
1359 && instring
[3] != 'q')
1364 if (opP
->mode
!= DREG
&& opP
->mode
!= AREG
)
1369 if (opP
->mode
!= AINDR
1370 && (opP
->mode
!= BASE
1372 && opP
->reg
!= ZADDR0
)
1373 || opP
->disp
.exp
.X_op
!= O_absent
1374 || ((opP
->index
.reg
< DATA0
1375 || opP
->index
.reg
> DATA7
)
1376 && (opP
->index
.reg
< ADDR0
1377 || opP
->index
.reg
> ADDR7
))
1378 || opP
->index
.size
!= SIZE_UNSPEC
1379 || opP
->index
.scale
!= 1))
1384 if (opP
->mode
!= CONTROL
1385 || ! (opP
->reg
== FPI
1387 || opP
->reg
== FPC
))
1392 if (opP
->mode
!= CONTROL
|| opP
->reg
!= SR
)
1397 if (opP
->mode
!= IMMED
)
1399 else if (opP
->disp
.exp
.X_op
!= O_constant
1400 || opP
->disp
.exp
.X_add_number
< 0
1401 || opP
->disp
.exp
.X_add_number
> 7)
1406 if (opP
->mode
!= CONTROL
|| opP
->reg
!= USP
)
1410 /* JF these are out of order. We could put them
1411 in order if we were willing to put up with
1412 bunches of #ifdef m68851s in the code.
1414 Don't forget that you need these operands
1415 to use 68030 MMU instructions. */
1417 /* Memory addressing mode used by pflushr */
1419 if (opP
->mode
== CONTROL
1420 || opP
->mode
== FPREG
1421 || opP
->mode
== DREG
1422 || opP
->mode
== AREG
1423 || opP
->mode
== REGLST
)
1425 /* We should accept immediate operands, but they
1426 supposedly have to be quad word, and we don't
1427 handle that. I would like to see what a Motorola
1428 assembler does before doing something here. */
1429 if (opP
->mode
== IMMED
)
1434 if (opP
->mode
!= CONTROL
1435 || (opP
->reg
!= SFC
&& opP
->reg
!= DFC
))
1440 if (opP
->mode
!= CONTROL
|| opP
->reg
!= TC
)
1445 if (opP
->mode
!= CONTROL
|| opP
->reg
!= AC
)
1450 if (opP
->mode
!= CONTROL
1453 && opP
->reg
!= SCC
))
1458 if (opP
->mode
!= CONTROL
1464 if (opP
->mode
!= CONTROL
1467 && opP
->reg
!= CRP
))
1472 if (opP
->mode
!= CONTROL
1473 || (!(opP
->reg
>= BAD
&& opP
->reg
<= BAD
+ 7)
1474 && !(opP
->reg
>= BAC
&& opP
->reg
<= BAC
+ 7)))
1479 if (opP
->mode
!= CONTROL
|| opP
->reg
!= PSR
)
1484 if (opP
->mode
!= CONTROL
|| opP
->reg
!= PCSR
)
1489 if (opP
->mode
!= CONTROL
1496 } /* not a cache specifier. */
1500 if (opP
->mode
!= ABSL
)
1506 } /* switch on type of operand */
1510 } /* for each operand */
1511 } /* if immediately wrong */
1518 opcode
= opcode
->m_next
;
1523 && !(ok_arch
& current_architecture
))
1528 "invalid instruction for this architecture; needs ");
1529 cp
= buf
+ strlen (buf
);
1533 strcpy (cp
, "fpu (68040, 68060 or 68881/68882)");
1536 strcpy (cp
, "mmu (68030 or 68851)");
1539 strcpy (cp
, "68020 or higher");
1542 strcpy (cp
, "68000 or higher");
1545 strcpy (cp
, "68010 or higher");
1549 int got_one
= 0, idx
;
1550 for (idx
= 0; idx
< sizeof (archs
) / sizeof (archs
[0]);
1553 if ((archs
[idx
].arch
& ok_arch
)
1554 && ! archs
[idx
].alias
)
1558 strcpy (cp
, " or ");
1562 strcpy (cp
, archs
[idx
].name
);
1574 the_ins
.error
= "operands mismatch";
1576 } /* Fell off the end */
1581 /* now assemble it */
1583 the_ins
.args
= opcode
->m_operands
;
1584 the_ins
.numargs
= opcode
->m_opnum
;
1585 the_ins
.numo
= opcode
->m_codenum
;
1586 the_ins
.opcode
[0] = getone (opcode
);
1587 the_ins
.opcode
[1] = gettwo (opcode
);
1589 for (s
= the_ins
.args
, opP
= &the_ins
.operands
[0]; *s
; s
+= 2, opP
++)
1591 /* This switch is a doozy.
1592 Watch the first step; its a big one! */
1613 tmpreg
= 0x3c; /* 7.4 */
1614 if (strchr ("bwl", s
[1]))
1615 nextword
= get_num (&opP
->disp
, 80);
1617 nextword
= get_num (&opP
->disp
, 0);
1618 if (isvar (&opP
->disp
))
1619 add_fix (s
[1], &opP
->disp
, 0, 0);
1623 if (!isbyte (nextword
))
1624 opP
->error
= "operand out of range";
1629 if (!isword (nextword
))
1630 opP
->error
= "operand out of range";
1635 if (!issword (nextword
))
1636 opP
->error
= "operand out of range";
1641 addword (nextword
>> 16);
1668 /* We gotta put out some float */
1669 if (op (&opP
->disp
) != O_big
)
1674 /* Can other cases happen here? */
1675 if (op (&opP
->disp
) != O_constant
)
1678 val
= (valueT
) offs (&opP
->disp
);
1682 generic_bignum
[gencnt
] = (LITTLENUM_TYPE
) val
;
1683 val
>>= LITTLENUM_NUMBER_OF_BITS
;
1687 offs (&opP
->disp
) = gencnt
;
1689 if (offs (&opP
->disp
) > 0)
1691 if (offs (&opP
->disp
) > baseo
)
1693 as_warn ("Bignum too big for %c format; truncated",
1695 offs (&opP
->disp
) = baseo
;
1697 baseo
-= offs (&opP
->disp
);
1700 for (wordp
= generic_bignum
+ offs (&opP
->disp
) - 1;
1701 offs (&opP
->disp
)--;
1706 gen_to_words (words
, baseo
, (long) outro
);
1707 for (wordp
= words
; baseo
--; wordp
++)
1711 tmpreg
= opP
->reg
- DATA
; /* 0.dreg */
1714 tmpreg
= 0x08 + opP
->reg
- ADDR
; /* 1.areg */
1717 tmpreg
= 0x10 + opP
->reg
- ADDR
; /* 2.areg */
1720 tmpreg
= 0x20 + opP
->reg
- ADDR
; /* 4.areg */
1723 tmpreg
= 0x18 + opP
->reg
- ADDR
; /* 3.areg */
1727 nextword
= get_num (&opP
->disp
, 80);
1730 && ! isvar (&opP
->disp
)
1733 opP
->disp
.exp
.X_op
= O_symbol
;
1734 #ifndef BFD_ASSEMBLER
1735 opP
->disp
.exp
.X_add_symbol
= &abs_symbol
;
1737 opP
->disp
.exp
.X_add_symbol
=
1738 section_symbol (absolute_section
);
1742 /* Force into index mode. Hope this works */
1744 /* We do the first bit for 32-bit displacements, and the
1745 second bit for 16 bit ones. It is possible that we
1746 should make the default be WORD instead of LONG, but
1747 I think that'd break GCC, so we put up with a little
1748 inefficiency for the sake of working output. */
1750 if (!issword (nextword
)
1751 || (isvar (&opP
->disp
)
1752 && ((opP
->disp
.size
== SIZE_UNSPEC
1753 && flag_short_refs
== 0
1754 && cpu_of_arch (current_architecture
) >= m68020
)
1755 || opP
->disp
.size
== SIZE_LONG
)))
1757 if (cpu_of_arch (current_architecture
) < m68020
)
1759 "displacement too large for this architecture; needs 68020 or higher";
1761 tmpreg
= 0x3B; /* 7.3 */
1763 tmpreg
= 0x30 + opP
->reg
- ADDR
; /* 6.areg */
1764 if (isvar (&opP
->disp
))
1768 if (opP
->disp
.size
== SIZE_LONG
1770 /* If the displacement needs pic
1771 relocation it cannot be relaxed. */
1772 || opP
->disp
.pic_reloc
!= pic_none
1777 add_fix ('l', &opP
->disp
, 1, 2);
1781 add_frag (adds (&opP
->disp
),
1783 TAB (PCLEA
, SZ_UNDEF
));
1790 add_fix ('l', &opP
->disp
, 0, 0);
1795 addword (nextword
>> 16);
1800 tmpreg
= 0x3A; /* 7.2 */
1802 tmpreg
= 0x28 + opP
->reg
- ADDR
; /* 5.areg */
1804 if (isvar (&opP
->disp
))
1808 add_fix ('w', &opP
->disp
, 1, 0);
1811 add_fix ('w', &opP
->disp
, 0, 0);
1821 baseo
= get_num (&opP
->disp
, 80);
1822 if (opP
->mode
== POST
|| opP
->mode
== PRE
)
1823 outro
= get_num (&opP
->odisp
, 80);
1824 /* Figure out the `addressing mode'.
1825 Also turn on the BASE_DISABLE bit, if needed. */
1826 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
1828 tmpreg
= 0x3b; /* 7.3 */
1829 if (opP
->reg
== ZPC
)
1832 else if (opP
->reg
== 0)
1835 tmpreg
= 0x30; /* 6.garbage */
1837 else if (opP
->reg
>= ZADDR0
&& opP
->reg
<= ZADDR7
)
1840 tmpreg
= 0x30 + opP
->reg
- ZADDR0
;
1843 tmpreg
= 0x30 + opP
->reg
- ADDR
; /* 6.areg */
1845 siz1
= opP
->disp
.size
;
1846 if (opP
->mode
== POST
|| opP
->mode
== PRE
)
1847 siz2
= opP
->odisp
.size
;
1851 /* Index register stuff */
1852 if (opP
->index
.reg
!= 0
1853 && opP
->index
.reg
>= DATA
1854 && opP
->index
.reg
<= ADDR7
)
1856 nextword
|= (opP
->index
.reg
- DATA
) << 12;
1858 if (opP
->index
.size
== SIZE_UNSPEC
1859 || opP
->index
.size
== SIZE_LONG
)
1862 if ((opP
->index
.scale
!= 1
1863 && cpu_of_arch (current_architecture
) < m68020
)
1864 || (opP
->index
.scale
== 8
1865 && current_architecture
== mcf5200
))
1868 "scale factor invalid on this architecture; needs cpu32 or 68020 or higher";
1871 switch (opP
->index
.scale
)
1888 GET US OUT OF HERE! */
1890 /* Must be INDEX, with an index register. Address
1891 register cannot be ZERO-PC, and either :b was
1892 forced, or we know it will fit. For a 68000 or
1893 68010, force this mode anyways, because the
1894 larger modes aren't supported. */
1895 if (opP
->mode
== BASE
1896 && ((opP
->reg
>= ADDR0
1897 && opP
->reg
<= ADDR7
)
1900 if (siz1
== SIZE_BYTE
1901 || cpu_of_arch (current_architecture
) < m68020
1902 || (siz1
== SIZE_UNSPEC
1903 && ! isvar (&opP
->disp
)
1904 && issbyte (baseo
)))
1906 nextword
+= baseo
& 0xff;
1908 if (isvar (&opP
->disp
))
1910 /* Do a byte relocation. If it doesn't
1911 fit (possible on m68000) let the
1912 fixup processing complain later. */
1914 add_fix ('B', &opP
->disp
, 1, 1);
1916 add_fix ('B', &opP
->disp
, 0, 0);
1918 else if (siz1
!= SIZE_BYTE
)
1920 if (siz1
!= SIZE_UNSPEC
)
1921 as_warn ("Forcing byte displacement");
1922 if (! issbyte (baseo
))
1923 opP
->error
= "byte displacement out of range";
1928 else if (siz1
== SIZE_UNSPEC
1930 && isvar (&opP
->disp
)
1931 && subs (&opP
->disp
) == NULL
1933 /* If the displacement needs pic
1934 relocation it cannot be relaxed. */
1935 && opP
->disp
.pic_reloc
== pic_none
1939 nextword
+= baseo
& 0xff;
1941 add_frag (adds (&opP
->disp
), offs (&opP
->disp
),
1942 TAB (PCINDEX
, SZ_UNDEF
));
1950 nextword
|= 0x40; /* No index reg */
1951 if (opP
->index
.reg
>= ZDATA0
1952 && opP
->index
.reg
<= ZDATA7
)
1953 nextword
|= (opP
->index
.reg
- ZDATA0
) << 12;
1954 else if (opP
->index
.reg
>= ZADDR0
1955 || opP
->index
.reg
<= ZADDR7
)
1956 nextword
|= (opP
->index
.reg
- ZADDR0
+ 8) << 12;
1959 /* It isn't simple. */
1961 if (cpu_of_arch (current_architecture
) < m68020
)
1963 "invalid operand mode for this architecture; needs 68020 or higher";
1966 /* If the guy specified a width, we assume that it is
1967 wide enough. Maybe it isn't. If so, we lose. */
1971 if (isvar (&opP
->disp
)
1973 : ! issword (baseo
))
1978 else if (! isvar (&opP
->disp
) && baseo
== 0)
1987 as_warn (":b not permitted; defaulting to :w");
1997 /* Figure out innner displacement stuff */
1998 if (opP
->mode
== POST
|| opP
->mode
== PRE
)
2000 if (cpu_of_arch (current_architecture
) & cpu32
)
2001 opP
->error
= "invalid operand mode for this architecture; needs 68020 or higher";
2005 if (isvar (&opP
->odisp
)
2007 : ! issword (outro
))
2012 else if (! isvar (&opP
->odisp
) && outro
== 0)
2021 as_warn (":b not permitted; defaulting to :w");
2030 if (opP
->mode
== POST
2031 && (nextword
& 0x40) == 0)
2036 if (siz1
!= SIZE_UNSPEC
&& isvar (&opP
->disp
))
2038 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
2039 add_fix (siz1
== SIZE_LONG
? 'l' : 'w', &opP
->disp
, 1, 2);
2041 add_fix (siz1
== SIZE_LONG
? 'l' : 'w', &opP
->disp
, 0, 0);
2043 if (siz1
== SIZE_LONG
)
2044 addword (baseo
>> 16);
2045 if (siz1
!= SIZE_UNSPEC
)
2048 if (siz2
!= SIZE_UNSPEC
&& isvar (&opP
->odisp
))
2049 add_fix (siz2
== SIZE_LONG
? 'l' : 'w', &opP
->odisp
, 0, 0);
2050 if (siz2
== SIZE_LONG
)
2051 addword (outro
>> 16);
2052 if (siz2
!= SIZE_UNSPEC
)
2058 nextword
= get_num (&opP
->disp
, 80);
2059 switch (opP
->disp
.size
)
2064 if (!isvar (&opP
->disp
) && issword (offs (&opP
->disp
)))
2066 tmpreg
= 0x38; /* 7.0 */
2070 /* Don't generate pc relative code on 68010 and
2072 if (isvar (&opP
->disp
)
2073 && !subs (&opP
->disp
)
2074 && adds (&opP
->disp
)
2076 /* If the displacement needs pic relocation it
2077 cannot be relaxed. */
2078 && opP
->disp
.pic_reloc
== pic_none
2080 && S_GET_SEGMENT (adds (&opP
->disp
)) == now_seg
2081 && cpu_of_arch (current_architecture
) >= m68020
2083 && !strchr ("~%&$?", s
[0]))
2085 tmpreg
= 0x3A; /* 7.2 */
2086 add_frag (adds (&opP
->disp
),
2088 TAB (PCREL
, SZ_UNDEF
));
2091 /* Fall through into long */
2093 if (isvar (&opP
->disp
))
2094 add_fix ('l', &opP
->disp
, 0, 0);
2096 tmpreg
= 0x39;/* 7.1 mode */
2097 addword (nextword
>> 16);
2101 case SIZE_WORD
: /* Word */
2102 if (isvar (&opP
->disp
))
2103 add_fix ('w', &opP
->disp
, 0, 0);
2105 tmpreg
= 0x38;/* 7.0 mode */
2113 as_bad ("unknown/incorrect operand");
2116 install_gen_operand (s
[1], tmpreg
);
2122 { /* JF: I hate floating point! */
2137 tmpreg
= get_num (&opP
->disp
, tmpreg
);
2138 if (isvar (&opP
->disp
))
2139 add_fix (s
[1], &opP
->disp
, 0, 0);
2142 case 'b': /* Danger: These do no check for
2143 certain types of overflow.
2145 if (!isbyte (tmpreg
))
2146 opP
->error
= "out of range";
2147 insop (tmpreg
, opcode
);
2148 if (isvar (&opP
->disp
))
2149 the_ins
.reloc
[the_ins
.nrel
- 1].n
=
2150 (opcode
->m_codenum
) * 2 + 1;
2153 if (!isword (tmpreg
))
2154 opP
->error
= "out of range";
2155 insop (tmpreg
, opcode
);
2156 if (isvar (&opP
->disp
))
2157 the_ins
.reloc
[the_ins
.nrel
- 1].n
= (opcode
->m_codenum
) * 2;
2160 if (!issword (tmpreg
))
2161 opP
->error
= "out of range";
2162 insop (tmpreg
, opcode
);
2163 if (isvar (&opP
->disp
))
2164 the_ins
.reloc
[the_ins
.nrel
- 1].n
= (opcode
->m_codenum
) * 2;
2167 /* Because of the way insop works, we put these two out
2169 insop (tmpreg
, opcode
);
2170 insop (tmpreg
>> 16, opcode
);
2171 if (isvar (&opP
->disp
))
2172 the_ins
.reloc
[the_ins
.nrel
- 1].n
= (opcode
->m_codenum
) * 2;
2178 install_operand (s
[1], tmpreg
);
2189 install_operand (s
[1], opP
->reg
- ADDR
);
2193 tmpreg
= get_num (&opP
->disp
, 80);
2197 /* The pc_fix argument winds up in fx_pcrel_adjust,
2198 which is a char, and may therefore be unsigned. We
2199 want to pass -1, but we pass 64 instead, and convert
2200 back in md_pcrel_from. */
2201 add_fix ('B', &opP
->disp
, 1, 64);
2204 add_fix ('w', &opP
->disp
, 1, 0);
2209 if (cpu_of_arch (current_architecture
) < m68020
)
2210 as_warn ("Can't use long branches on 68000/68010");
2211 the_ins
.opcode
[the_ins
.numo
- 1] |= 0xff;
2212 add_fix ('l', &opP
->disp
, 1, 0);
2217 if (subs (&opP
->disp
)) /* We can't relax it */
2221 /* If the displacement needs pic relocation it cannot be
2223 if (opP
->disp
.pic_reloc
!= pic_none
)
2227 /* This could either be a symbol, or an absolute
2228 address. No matter, the frag hacking will finger it
2229 out. Not quite: it can't switch from BRANCH to
2230 BCC68000 for the case where opnd is absolute (it
2231 needs to use the 68000 hack since no conditional abs
2233 if (((cpu_of_arch (current_architecture
) < m68020
)
2234 || (0 == adds (&opP
->disp
)))
2235 && (the_ins
.opcode
[0] >= 0x6200)
2236 && (the_ins
.opcode
[0] <= 0x6f00))
2237 add_frag (adds (&opP
->disp
), offs (&opP
->disp
),
2238 TAB (BCC68000
, SZ_UNDEF
));
2240 add_frag (adds (&opP
->disp
), offs (&opP
->disp
),
2241 TAB (ABRANCH
, SZ_UNDEF
));
2244 if (isvar (&opP
->disp
))
2247 /* check for DBcc instruction */
2248 if ((the_ins
.opcode
[0] & 0xf0f8) == 0x50c8)
2250 /* size varies if patch */
2251 /* needed for long form */
2252 add_frag (adds (&opP
->disp
), offs (&opP
->disp
),
2253 TAB (DBCC
, SZ_UNDEF
));
2257 add_fix ('w', &opP
->disp
, 1, 0);
2261 case 'C': /* Fixed size LONG coproc branches */
2262 add_fix ('l', &opP
->disp
, 1, 0);
2266 case 'c': /* Var size Coprocesssor branches */
2267 if (subs (&opP
->disp
))
2269 add_fix ('l', &opP
->disp
, 1, 0);
2270 add_frag ((symbolS
*) 0, (long) 0, TAB (FBRANCH
, LONG
));
2272 else if (adds (&opP
->disp
))
2273 add_frag (adds (&opP
->disp
), offs (&opP
->disp
),
2274 TAB (FBRANCH
, SZ_UNDEF
));
2277 /* add_frag((symbolS *) 0, offs(&opP->disp),
2278 TAB(FBRANCH,SHORT)); */
2279 the_ins
.opcode
[the_ins
.numo
- 1] |= 0x40;
2280 add_fix ('l', &opP
->disp
, 1, 0);
2290 case 'C': /* Ignore it */
2293 case 'd': /* JF this is a kludge */
2294 install_operand ('s', opP
->reg
- ADDR
);
2295 tmpreg
= get_num (&opP
->disp
, 80);
2296 if (!issword (tmpreg
))
2298 as_warn ("Expression out of range, using 0");
2305 install_operand (s
[1], opP
->reg
- DATA
);
2309 install_operand (s
[1], opP
->reg
- FP0
);
2313 tmpreg
= opP
->reg
- COP0
;
2314 install_operand (s
[1], tmpreg
);
2317 case 'J': /* JF foo */
2390 install_operand (s
[1], tmpreg
);
2394 tmpreg
= get_num (&opP
->disp
, 55);
2395 install_operand (s
[1], tmpreg
& 0x7f);
2402 if (tmpreg
& 0x7FF0000)
2403 as_bad ("Floating point register in register list");
2404 insop (reverse_16_bits (tmpreg
), opcode
);
2408 if (tmpreg
& 0x700FFFF)
2409 as_bad ("Wrong register in floating-point reglist");
2410 install_operand (s
[1], reverse_8_bits (tmpreg
>> 16));
2418 if (tmpreg
& 0x7FF0000)
2419 as_bad ("Floating point register in register list");
2420 insop (tmpreg
, opcode
);
2422 else if (s
[1] == '8')
2424 if (tmpreg
& 0x0FFFFFF)
2425 as_bad ("incorrect register in reglist");
2426 install_operand (s
[1], tmpreg
>> 24);
2430 if (tmpreg
& 0x700FFFF)
2431 as_bad ("wrong register in floating-point reglist");
2433 install_operand (s
[1], tmpreg
>> 16);
2438 install_operand (s
[1], get_num (&opP
->disp
, 60));
2442 tmpreg
= ((opP
->mode
== DREG
)
2443 ? 0x20 + opP
->reg
- DATA
2444 : (get_num (&opP
->disp
, 40) & 0x1F));
2445 install_operand (s
[1], tmpreg
);
2449 tmpreg
= get_num (&opP
->disp
, 10);
2452 install_operand (s
[1], tmpreg
);
2456 /* This depends on the fact that ADDR registers are eight
2457 more than their corresponding DATA regs, so the result
2458 will have the ADDR_REG bit set */
2459 install_operand (s
[1], opP
->reg
- DATA
);
2463 if (opP
->mode
== AINDR
)
2464 install_operand (s
[1], opP
->reg
- DATA
);
2466 install_operand (s
[1], opP
->index
.reg
- DATA
);
2470 if (opP
->reg
== FPI
)
2472 else if (opP
->reg
== FPS
)
2474 else if (opP
->reg
== FPC
)
2478 install_operand (s
[1], tmpreg
);
2481 case 'S': /* Ignore it */
2485 install_operand (s
[1], get_num (&opP
->disp
, 30));
2488 case 'U': /* Ignore it */
2507 as_fatal ("failed sanity check");
2508 } /* switch on cache token */
2509 install_operand (s
[1], tmpreg
);
2512 /* JF: These are out of order, I fear. */
2525 install_operand (s
[1], tmpreg
);
2551 install_operand (s
[1], tmpreg
);
2555 if (opP
->reg
== VAL
)
2574 install_operand (s
[1], tmpreg
);
2588 tmpreg
= (4 << 10) | ((opP
->reg
- BAD
) << 2);
2599 tmpreg
= (5 << 10) | ((opP
->reg
- BAC
) << 2);
2605 install_operand (s
[1], tmpreg
);
2608 know (opP
->reg
== PSR
);
2611 know (opP
->reg
== PCSR
);
2626 install_operand (s
[1], tmpreg
);
2629 tmpreg
= get_num (&opP
->disp
, 20);
2630 install_operand (s
[1], tmpreg
);
2632 case '_': /* used only for move16 absolute 32-bit address */
2633 tmpreg
= get_num (&opP
->disp
, 80);
2634 addword (tmpreg
>> 16);
2635 addword (tmpreg
& 0xFFFF);
2642 /* By the time whe get here (FINALLY) the_ins contains the complete
2643 instruction, ready to be emitted. . . */
2647 reverse_16_bits (in
)
2653 static int mask
[16] =
2655 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
2656 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000
2658 for (n
= 0; n
< 16; n
++)
2661 out
|= mask
[15 - n
];
2664 } /* reverse_16_bits() */
2673 static int mask
[8] =
2675 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
2678 for (n
= 0; n
< 8; n
++)
2684 } /* reverse_8_bits() */
2686 /* Cause an extra frag to be generated here, inserting up to 10 bytes
2687 (that value is chosen in the frag_var call in md_assemble). TYPE
2688 is the subtype of the frag to be generated; its primary type is
2689 rs_machine_dependent.
2691 The TYPE parameter is also used by md_convert_frag_1 and
2692 md_estimate_size_before_relax. The appropriate type of fixup will
2693 be emitted by md_convert_frag_1.
2695 ADD becomes the FR_SYMBOL field of the frag, and OFF the FR_OFFSET. */
2697 install_operand (mode
, val
)
2704 the_ins
.opcode
[0] |= val
& 0xFF; /* JF FF is for M kludge */
2707 the_ins
.opcode
[0] |= val
<< 9;
2710 the_ins
.opcode
[1] |= val
<< 12;
2713 the_ins
.opcode
[1] |= val
<< 6;
2716 the_ins
.opcode
[1] |= val
;
2719 the_ins
.opcode
[2] |= val
<< 12;
2722 the_ins
.opcode
[2] |= val
<< 6;
2725 /* DANGER! This is a hack to force cas2l and cas2w cmds to be
2726 three words long! */
2728 the_ins
.opcode
[2] |= val
;
2731 the_ins
.opcode
[1] |= val
<< 7;
2734 the_ins
.opcode
[1] |= val
<< 10;
2738 the_ins
.opcode
[1] |= val
<< 5;
2743 the_ins
.opcode
[1] |= (val
<< 10) | (val
<< 7);
2746 the_ins
.opcode
[1] |= (val
<< 12) | val
;
2749 the_ins
.opcode
[0] |= val
= 0xff;
2752 the_ins
.opcode
[0] |= val
<< 9;
2755 the_ins
.opcode
[1] |= val
;
2758 the_ins
.opcode
[1] |= val
;
2759 the_ins
.numo
++; /* What a hack */
2762 the_ins
.opcode
[1] |= val
<< 4;
2770 the_ins
.opcode
[0] |= (val
<< 6);
2773 the_ins
.opcode
[1] = (val
>> 16);
2774 the_ins
.opcode
[2] = val
& 0xffff;
2778 as_fatal ("failed sanity check.");
2780 } /* install_operand() */
2783 install_gen_operand (mode
, val
)
2790 the_ins
.opcode
[0] |= val
;
2793 /* This is a kludge!!! */
2794 the_ins
.opcode
[0] |= (val
& 0x07) << 9 | (val
& 0x38) << 3;
2803 the_ins
.opcode
[0] |= val
;
2805 /* more stuff goes here */
2807 as_fatal ("failed sanity check.");
2809 } /* install_gen_operand() */
2812 * verify that we have some number of paren pairs, do m68k_ip_op(), and
2813 * then deal with the bitfield hack.
2817 crack_operand (str
, opP
)
2819 register struct m68k_op
*opP
;
2821 register int parens
;
2823 register char *beg_str
;
2831 for (parens
= 0; *str
&& (parens
> 0 || inquote
|| notend (str
)); str
++)
2837 else if (*str
== ')')
2841 opP
->error
= "Extra )";
2847 if (flag_mri
&& *str
== '\'')
2848 inquote
= ! inquote
;
2850 if (!*str
&& parens
)
2852 opP
->error
= "Missing )";
2857 if (m68k_ip_op (beg_str
, opP
) != 0)
2864 c
= *++str
; /* JF bitfield hack */
2869 as_bad ("Missing operand");
2874 /* This is the guts of the machine-dependent assembler. STR points to a
2875 machine dependent instruction. This function is supposed to emit
2876 the frags/bytes it assembles to.
2880 insert_reg (regname
, regnum
)
2887 #ifdef REGISTER_PREFIX
2888 if (!flag_reg_prefix_optional
)
2890 buf
[0] = REGISTER_PREFIX
;
2891 strcpy (buf
+ 1, regname
);
2896 symbol_table_insert (symbol_new (regname
, reg_section
, regnum
,
2897 &zero_address_frag
));
2899 for (i
= 0; regname
[i
]; i
++)
2900 buf
[i
] = islower (regname
[i
]) ? toupper (regname
[i
]) : regname
[i
];
2903 symbol_table_insert (symbol_new (buf
, reg_section
, regnum
,
2904 &zero_address_frag
));
2913 static const struct init_entry init_table
[] =
2968 /* control registers */
2969 { "sfc", SFC
}, /* Source Function Code */
2971 { "dfc", DFC
}, /* Destination Function Code */
2973 { "cacr", CACR
}, /* Cache Control Register */
2974 { "caar", CAAR
}, /* Cache Address Register */
2976 { "usp", USP
}, /* User Stack Pointer */
2977 { "vbr", VBR
}, /* Vector Base Register */
2978 { "msp", MSP
}, /* Master Stack Pointer */
2979 { "isp", ISP
}, /* Interrupt Stack Pointer */
2981 { "itt0", ITT0
}, /* Instruction Transparent Translation Reg 0 */
2982 { "itt1", ITT1
}, /* Instruction Transparent Translation Reg 1 */
2983 { "dtt0", DTT0
}, /* Data Transparent Translation Register 0 */
2984 { "dtt1", DTT1
}, /* Data Transparent Translation Register 1 */
2986 /* 68ec040 versions of same */
2987 { "iacr0", ITT0
}, /* Instruction Access Control Register 0 */
2988 { "iacr1", ITT1
}, /* Instruction Access Control Register 0 */
2989 { "dacr0", DTT0
}, /* Data Access Control Register 0 */
2990 { "dacr1", DTT1
}, /* Data Access Control Register 0 */
2992 /* mcf5200 versions of same */
2993 { "acr2", ITT0
}, /* Access Control Unit 2 */
2994 { "acr3", ITT1
}, /* Access Control Unit 3 */
2995 { "acr0", DTT0
}, /* Access Control Unit 0 */
2996 { "acr1", DTT1
}, /* Access Control Unit 1 */
2998 { "tc", TC
}, /* MMU Translation Control Register */
3001 { "mmusr", MMUSR
}, /* MMU Status Register */
3002 { "srp", SRP
}, /* User Root Pointer */
3003 { "urp", URP
}, /* Supervisor Root Pointer */
3008 { "rombar", ROMBAR
}, /* ROM Base Address Register */
3009 { "rambar0", RAMBAR0
}, /* ROM Base Address Register */
3010 { "rambar1", RAMBAR1
}, /* ROM Base Address Register */
3011 { "mbar", MBAR
}, /* Module Base Address Register */
3012 /* end of control registers */
3046 /* 68ec030 versions of same */
3049 /* 68ec030 access control unit, identical to 030 MMU status reg */
3052 /* Suppressed data and address registers. */
3077 for (i
= 0; init_table
[i
].name
; i
++)
3078 insert_reg (init_table
[i
].name
, init_table
[i
].number
);
3081 static int no_68851
, no_68881
;
3084 /* a.out machine type. Default to 68020. */
3085 int m68k_aout_machtype
= 2;
3097 int shorts_this_frag
;
3100 /* In MRI mode, the instruction and operands are separated by a
3101 space. Anything following the operands is a comment. The label
3102 has already been removed. */
3110 for (s
= str
; *s
!= '\0'; s
++)
3112 if ((*s
== ' ' || *s
== '\t') && ! inquote
)
3130 inquote
= ! inquote
;
3135 memset ((char *) (&the_ins
), '\0', sizeof (the_ins
));
3140 for (n
= 0; n
< the_ins
.numargs
; n
++)
3141 if (the_ins
.operands
[n
].error
)
3143 er
= the_ins
.operands
[n
].error
;
3149 as_bad ("%s -- statement `%s' ignored", er
, str
);
3153 if (the_ins
.nfrag
== 0)
3155 /* No frag hacking involved; just put it out */
3156 toP
= frag_more (2 * the_ins
.numo
);
3157 fromP
= &the_ins
.opcode
[0];
3158 for (m
= the_ins
.numo
; m
; --m
)
3160 md_number_to_chars (toP
, (long) (*fromP
), 2);
3164 /* put out symbol-dependent info */
3165 for (m
= 0; m
< the_ins
.nrel
; m
++)
3167 switch (the_ins
.reloc
[m
].wid
)
3185 as_fatal ("Don't know how to figure width of %c in md_assemble()",
3186 the_ins
.reloc
[m
].wid
);
3189 fixP
= fix_new_exp (frag_now
,
3190 ((toP
- frag_now
->fr_literal
)
3191 - the_ins
.numo
* 2 + the_ins
.reloc
[m
].n
),
3193 &the_ins
.reloc
[m
].exp
,
3194 the_ins
.reloc
[m
].pcrel
,
3195 get_reloc_code (n
, the_ins
.reloc
[m
].pcrel
,
3196 the_ins
.reloc
[m
].pic_reloc
));
3197 fixP
->fx_pcrel_adjust
= the_ins
.reloc
[m
].pcrel_fix
;
3202 /* There's some frag hacking */
3203 for (n
= 0, fromP
= &the_ins
.opcode
[0]; n
< the_ins
.nfrag
; n
++)
3208 wid
= 2 * the_ins
.fragb
[n
].fragoff
;
3210 wid
= 2 * (the_ins
.numo
- the_ins
.fragb
[n
- 1].fragoff
);
3211 toP
= frag_more (wid
);
3213 shorts_this_frag
= 0;
3214 for (m
= wid
/ 2; m
; --m
)
3216 md_number_to_chars (toP
, (long) (*fromP
), 2);
3221 for (m
= 0; m
< the_ins
.nrel
; m
++)
3223 if ((the_ins
.reloc
[m
].n
) >= 2 * shorts_this_frag
)
3225 the_ins
.reloc
[m
].n
-= 2 * shorts_this_frag
;
3228 wid
= the_ins
.reloc
[m
].wid
;
3231 the_ins
.reloc
[m
].wid
= 0;
3232 wid
= (wid
== 'b') ? 1 : (wid
== 'w') ? 2 : (wid
== 'l') ? 4 : 4000;
3234 fixP
= fix_new_exp (frag_now
,
3235 ((toP
- frag_now
->fr_literal
)
3236 - the_ins
.numo
* 2 + the_ins
.reloc
[m
].n
),
3238 &the_ins
.reloc
[m
].exp
,
3239 the_ins
.reloc
[m
].pcrel
,
3240 get_reloc_code (wid
, the_ins
.reloc
[m
].pcrel
,
3241 the_ins
.reloc
[m
].pic_reloc
));
3242 fixP
->fx_pcrel_adjust
= the_ins
.reloc
[m
].pcrel_fix
;
3244 (void) frag_var (rs_machine_dependent
, 10, 0,
3245 (relax_substateT
) (the_ins
.fragb
[n
].fragty
),
3246 the_ins
.fragb
[n
].fadd
, the_ins
.fragb
[n
].foff
, to_beg_P
);
3248 n
= (the_ins
.numo
- the_ins
.fragb
[n
- 1].fragoff
);
3249 shorts_this_frag
= 0;
3252 toP
= frag_more (n
* sizeof (short));
3255 md_number_to_chars (toP
, (long) (*fromP
), 2);
3261 for (m
= 0; m
< the_ins
.nrel
; m
++)
3265 wid
= the_ins
.reloc
[m
].wid
;
3268 the_ins
.reloc
[m
].wid
= 0;
3269 wid
= (wid
== 'b') ? 1 : (wid
== 'w') ? 2 : (wid
== 'l') ? 4 : 4000;
3271 fixP
= fix_new_exp (frag_now
,
3272 ((the_ins
.reloc
[m
].n
+ toP
- frag_now
->fr_literal
)
3273 - shorts_this_frag
* 2),
3275 &the_ins
.reloc
[m
].exp
,
3276 the_ins
.reloc
[m
].pcrel
,
3277 get_reloc_code (wid
, the_ins
.reloc
[m
].pcrel
,
3278 the_ins
.reloc
[m
].pic_reloc
));
3279 fixP
->fx_pcrel_adjust
= the_ins
.reloc
[m
].pcrel_fix
;
3287 * md_begin -- set up hash tables with 68000 instructions.
3288 * similar to what the vax assembler does. ---phr
3290 /* RMS claims the thing to do is take the m68k-opcode.h table, and make
3291 a copy of it at runtime, adding in the information we want but isn't
3292 there. I think it'd be better to have an awk script hack the table
3293 at compile time. Or even just xstr the table and use it as-is. But
3294 my lord ghod hath spoken, so we do it this way. Excuse the ugly var
3297 register const struct m68k_opcode
*ins
;
3298 register struct m68k_incant
*hack
, *slak
;
3299 register const char *retval
= 0; /* empty string, or error msg text */
3300 register unsigned int i
;
3305 flag_reg_prefix_optional
= 1;
3310 op_hash
= hash_new ();
3312 obstack_begin (&robyn
, 4000);
3313 for (i
= 0; i
< m68k_numopcodes
; i
++)
3315 hack
= slak
= (struct m68k_incant
*) obstack_alloc (&robyn
, sizeof (struct m68k_incant
));
3318 ins
= &m68k_opcodes
[i
];
3319 /* We *could* ignore insns that don't match our arch here
3320 but just leaving them out of the hash. */
3321 slak
->m_operands
= ins
->args
;
3322 slak
->m_opnum
= strlen (slak
->m_operands
) / 2;
3323 slak
->m_arch
= ins
->arch
;
3324 slak
->m_opcode
= ins
->opcode
;
3325 /* This is kludgey */
3326 slak
->m_codenum
= ((ins
->match
) & 0xffffL
) ? 2 : 1;
3327 if (i
+ 1 != m68k_numopcodes
3328 && !strcmp (ins
->name
, m68k_opcodes
[i
+ 1].name
))
3330 slak
->m_next
= (struct m68k_incant
*) obstack_alloc (&robyn
, sizeof (struct m68k_incant
));
3335 slak
= slak
->m_next
;
3339 retval
= hash_insert (op_hash
, ins
->name
, (char *) hack
);
3341 as_fatal ("Internal Error: Can't hash %s: %s", ins
->name
, retval
);
3344 for (i
= 0; i
< m68k_numaliases
; i
++)
3346 const char *name
= m68k_opcode_aliases
[i
].primary
;
3347 const char *alias
= m68k_opcode_aliases
[i
].alias
;
3348 PTR val
= hash_find (op_hash
, name
);
3350 as_fatal ("Internal Error: Can't find %s in hash table", name
);
3351 retval
= hash_insert (op_hash
, alias
, val
);
3353 as_fatal ("Internal Error: Can't hash %s: %s", alias
, retval
);
3356 /* In MRI mode, all unsized branches are variable sized. Normally,
3357 they are word sized. */
3360 static struct m68k_opcode_alias mri_aliases
[] =
3380 for (i
= 0; i
< sizeof mri_aliases
/ sizeof mri_aliases
[0]; i
++)
3382 const char *name
= mri_aliases
[i
].primary
;
3383 const char *alias
= mri_aliases
[i
].alias
;
3384 PTR val
= hash_find (op_hash
, name
);
3386 as_fatal ("Internal Error: Can't find %s in hash table", name
);
3387 retval
= hash_jam (op_hash
, alias
, val
);
3389 as_fatal ("Internal Error: Can't hash %s: %s", alias
, retval
);
3393 for (i
= 0; i
< sizeof (mklower_table
); i
++)
3394 mklower_table
[i
] = (isupper (c
= (char) i
)) ? tolower (c
) : c
;
3396 for (i
= 0; i
< sizeof (notend_table
); i
++)
3398 notend_table
[i
] = 0;
3399 alt_notend_table
[i
] = 0;
3401 notend_table
[','] = 1;
3402 notend_table
['{'] = 1;
3403 notend_table
['}'] = 1;
3404 alt_notend_table
['a'] = 1;
3405 alt_notend_table
['A'] = 1;
3406 alt_notend_table
['d'] = 1;
3407 alt_notend_table
['D'] = 1;
3408 alt_notend_table
['#'] = 1;
3409 alt_notend_table
['&'] = 1;
3410 alt_notend_table
['f'] = 1;
3411 alt_notend_table
['F'] = 1;
3412 #ifdef REGISTER_PREFIX
3413 alt_notend_table
[REGISTER_PREFIX
] = 1;
3416 /* We need to put '(' in alt_notend_table to handle
3417 cas2 %d0:%d2,%d3:%d4,(%a0):(%a1)
3419 alt_notend_table
['('] = 1;
3421 /* We need to put '@' in alt_notend_table to handle
3422 cas2 %d0:%d2,%d3:%d4,@(%d0):@(%d1)
3424 alt_notend_table
['@'] = 1;
3426 /* We need to put digits in alt_notend_table to handle
3427 bfextu %d0{24:1},%d0
3429 alt_notend_table
['0'] = 1;
3430 alt_notend_table
['1'] = 1;
3431 alt_notend_table
['2'] = 1;
3432 alt_notend_table
['3'] = 1;
3433 alt_notend_table
['4'] = 1;
3434 alt_notend_table
['5'] = 1;
3435 alt_notend_table
['6'] = 1;
3436 alt_notend_table
['7'] = 1;
3437 alt_notend_table
['8'] = 1;
3438 alt_notend_table
['9'] = 1;
3440 #ifndef MIT_SYNTAX_ONLY
3441 /* Insert pseudo ops, these have to go into the opcode table since
3442 gas expects pseudo ops to start with a dot */
3445 while (mote_pseudo_table
[n
].poc_name
)
3447 hack
= (struct m68k_incant
*)
3448 obstack_alloc (&robyn
, sizeof (struct m68k_incant
));
3449 hash_insert (op_hash
,
3450 mote_pseudo_table
[n
].poc_name
, (char *) hack
);
3451 hack
->m_operands
= 0;
3461 record_alignment (text_section
, 2);
3462 record_alignment (data_section
, 2);
3463 record_alignment (bss_section
, 2);
3468 m68k_init_after_args ()
3470 if (cpu_of_arch (current_architecture
) == 0)
3473 const char *default_cpu
= TARGET_CPU
;
3475 if (*default_cpu
== 'm')
3477 for (i
= 0; i
< n_archs
; i
++)
3478 if (strcasecmp (default_cpu
, archs
[i
].name
) == 0)
3482 as_bad ("unrecognized default cpu `%s' ???", TARGET_CPU
);
3483 current_architecture
|= m68020
;
3486 current_architecture
|= archs
[i
].arch
;
3488 /* Permit m68881 specification with all cpus; those that can't work
3489 with a coprocessor could be doing emulation. */
3490 if (current_architecture
& m68851
)
3492 if (current_architecture
& m68040
)
3494 as_warn ("68040 and 68851 specified; mmu instructions may assemble incorrectly");
3497 /* What other incompatibilities could we check for? */
3499 /* Toss in some default assumptions about coprocessors. */
3501 && (cpu_of_arch (current_architecture
)
3502 /* Can CPU32 have a 68881 coprocessor?? */
3503 & (m68020
| m68030
| cpu32
)))
3505 current_architecture
|= m68881
;
3508 && (cpu_of_arch (current_architecture
) & m68020up
) != 0
3509 && (cpu_of_arch (current_architecture
) & m68040up
) == 0)
3511 current_architecture
|= m68851
;
3513 if (no_68881
&& (current_architecture
& m68881
))
3514 as_bad ("options for 68881 and no-68881 both given");
3515 if (no_68851
&& (current_architecture
& m68851
))
3516 as_bad ("options for 68851 and no-68851 both given");
3519 /* Work out the magic number. This isn't very general. */
3520 if (current_architecture
& m68000
)
3521 m68k_aout_machtype
= 0;
3522 else if (current_architecture
& m68010
)
3523 m68k_aout_machtype
= 1;
3524 else if (current_architecture
& m68020
)
3525 m68k_aout_machtype
= 2;
3527 m68k_aout_machtype
= 2;
3530 /* Note which set of "movec" control registers is available. */
3531 switch (cpu_of_arch (current_architecture
))
3534 control_regs
= m68000_control_regs
;
3537 control_regs
= m68010_control_regs
;
3541 control_regs
= m68020_control_regs
;
3544 control_regs
= m68040_control_regs
;
3547 control_regs
= m68060_control_regs
;
3550 control_regs
= cpu32_control_regs
;
3553 control_regs
= mcf5200_control_regs
;
3559 if (cpu_of_arch (current_architecture
) < m68020
)
3560 md_relax_table
[TAB (PCINDEX
, BYTE
)].rlx_more
= 0;
3563 /* This is called if we go in or out of MRI mode because of the .mri
3567 m68k_mri_mode_change (on
)
3572 if (! flag_reg_prefix_optional
)
3574 flag_reg_prefix_optional
= 1;
3575 #ifdef REGISTER_PREFIX
3584 if (! reg_prefix_optional_seen
)
3586 #ifdef REGISTER_PREFIX_OPTIONAL
3587 flag_reg_prefix_optional
= REGISTER_PREFIX_OPTIONAL
;
3589 flag_reg_prefix_optional
= 0;
3591 #ifdef REGISTER_PREFIX
3600 /* Equal to MAX_PRECISION in atof-ieee.c */
3601 #define MAX_LITTLENUMS 6
3603 /* Turn a string in input_line_pointer into a floating point constant
3604 of type type, and store the appropriate bytes in *litP. The number
3605 of LITTLENUMS emitted is stored in *sizeP . An error message is
3606 returned, or NULL on OK. */
3609 md_atof (type
, litP
, sizeP
)
3615 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
3616 LITTLENUM_TYPE
*wordP
;
3648 return "Bad call to MD_ATOF()";
3650 t
= atof_ieee (input_line_pointer
, type
, words
);
3652 input_line_pointer
= t
;
3654 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
3655 for (wordP
= words
; prec
--;)
3657 md_number_to_chars (litP
, (long) (*wordP
++), sizeof (LITTLENUM_TYPE
));
3658 litP
+= sizeof (LITTLENUM_TYPE
);
3664 md_number_to_chars (buf
, val
, n
)
3669 number_to_chars_bigendian (buf
, val
, n
);
3673 md_apply_fix_2 (fixP
, val
)
3677 addressT upper_limit
;
3678 offsetT lower_limit
;
3680 /* This is unnecessary but it convinces the native rs6000 compiler
3681 to generate the code we want. */
3682 char *buf
= fixP
->fx_frag
->fr_literal
;
3683 buf
+= fixP
->fx_where
;
3684 /* end ibm compiler workaround */
3686 if (val
& 0x80000000)
3687 val
|= ~(addressT
)0x7fffffff;
3694 memset (buf
, 0, fixP
->fx_size
);
3695 fixP
->fx_addnumber
= val
; /* Remember value for emit_reloc */
3700 switch (fixP
->fx_size
)
3702 /* The cast to offsetT below are necessary to make code correct for
3703 machines where ints are smaller than offsetT */
3707 lower_limit
= - (offsetT
) 0x80;
3710 *buf
++ = (val
>> 8);
3712 upper_limit
= 0x7fff;
3713 lower_limit
= - (offsetT
) 0x8000;
3716 *buf
++ = (val
>> 24);
3717 *buf
++ = (val
>> 16);
3718 *buf
++ = (val
>> 8);
3720 upper_limit
= 0x7fffffff;
3721 lower_limit
= - (offsetT
) 0x7fffffff - 1; /* avoid constant overflow */
3724 BAD_CASE (fixP
->fx_size
);
3727 /* Fix up a negative reloc. */
3728 if (fixP
->fx_addsy
== NULL
&& fixP
->fx_subsy
!= NULL
)
3730 fixP
->fx_addsy
= fixP
->fx_subsy
;
3731 fixP
->fx_subsy
= NULL
;
3735 /* For non-pc-relative values, it's conceivable we might get something
3736 like "0xff" for a byte field. So extend the upper part of the range
3737 to accept such numbers. We arbitrarily disallow "-0xff" or "0xff+0xff",
3738 so that we can do any range checking at all. */
3739 if (!fixP
->fx_pcrel
)
3740 upper_limit
= upper_limit
* 2 + 1;
3742 if ((addressT
) val
> upper_limit
3743 && (val
> 0 || val
< lower_limit
))
3744 as_bad_where (fixP
->fx_file
, fixP
->fx_line
, "value out of range");
3746 /* A one byte PC-relative reloc means a short branch. We can't use
3747 a short branch with a value of 0 or -1, because those indicate
3748 different opcodes (branches with longer offsets). */
3750 && fixP
->fx_size
== 1
3751 && (fixP
->fx_addsy
== NULL
3752 || S_IS_DEFINED (fixP
->fx_addsy
))
3753 && (val
== 0 || val
== -1))
3754 as_bad_where (fixP
->fx_file
, fixP
->fx_line
, "invalid byte branch offset");
3757 #ifdef BFD_ASSEMBLER
3759 md_apply_fix (fixP
, valp
)
3763 md_apply_fix_2 (fixP
, (addressT
) *valp
);
3767 void md_apply_fix (fixP
, val
)
3771 md_apply_fix_2 (fixP
, (addressT
) val
);
3775 /* *fragP has been relaxed to its final size, and now needs to have
3776 the bytes inside it modified to conform to the new size There is UGLY
3780 md_convert_frag_1 (fragP
)
3781 register fragS
*fragP
;
3787 /* Address in object code of the displacement. */
3788 register int object_address
= fragP
->fr_fix
+ fragP
->fr_address
;
3790 /* Address in gas core of the place to store the displacement. */
3791 /* This convinces the native rs6000 compiler to generate the code we
3793 register char *buffer_address
= fragP
->fr_literal
;
3794 buffer_address
+= fragP
->fr_fix
;
3795 /* end ibm compiler workaround */
3797 /* The displacement of the address, from current location. */
3798 disp
= fragP
->fr_symbol
? S_GET_VALUE (fragP
->fr_symbol
) : 0;
3799 disp
= (disp
+ fragP
->fr_offset
) - object_address
;
3801 #ifdef BFD_ASSEMBLER
3802 disp
+= fragP
->fr_symbol
->sy_frag
->fr_address
;
3805 switch (fragP
->fr_subtype
)
3807 case TAB (BCC68000
, BYTE
):
3808 case TAB (ABRANCH
, BYTE
):
3809 know (issbyte (disp
));
3811 as_bad ("short branch with zero offset: use :w");
3812 fragP
->fr_opcode
[1] = disp
;
3815 case TAB (DBCC
, SHORT
):
3816 know (issword (disp
));
3819 case TAB (BCC68000
, SHORT
):
3820 case TAB (ABRANCH
, SHORT
):
3821 know (issword (disp
));
3822 fragP
->fr_opcode
[1] = 0x00;
3825 case TAB (ABRANCH
, LONG
):
3826 if (cpu_of_arch (current_architecture
) < m68020
)
3828 if (fragP
->fr_opcode
[0] == 0x61)
3831 fragP
->fr_opcode
[0] = 0x4E;
3832 fragP
->fr_opcode
[1] = (char) 0xB9; /* JBSR with ABSL LONG offset */
3846 else if (fragP
->fr_opcode
[0] == 0x60)
3848 fragP
->fr_opcode
[0] = 0x4E;
3849 fragP
->fr_opcode
[1] = (char) 0xF9; /* JMP with ABSL LONG offset */
3850 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
,
3851 fragP
->fr_offset
, 0, NO_RELOC
);
3857 as_bad ("Long branch offset not supported.");
3862 fragP
->fr_opcode
[1] = (char) 0xff;
3866 case TAB (BCC68000
, LONG
):
3867 /* only Bcc 68000 instructions can come here */
3868 /* change bcc into b!cc/jmp absl long */
3869 fragP
->fr_opcode
[0] ^= 0x01; /* invert bcc */
3870 fragP
->fr_opcode
[1] = 0x6;/* branch offset = 6 */
3872 /* JF: these used to be fr_opcode[2,3], but they may be in a
3873 different frag, in which case refering to them is a no-no.
3874 Only fr_opcode[0,1] are guaranteed to work. */
3875 *buffer_address
++ = 0x4e; /* put in jmp long (0x4ef9) */
3876 *buffer_address
++ = (char) 0xf9;
3877 fragP
->fr_fix
+= 2; /* account for jmp instruction */
3878 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
,
3879 fragP
->fr_offset
, 0, NO_RELOC
);
3883 case TAB (DBCC
, LONG
):
3884 /* only DBcc 68000 instructions can come here */
3885 /* change dbcc into dbcc/jmp absl long */
3886 /* JF: these used to be fr_opcode[2-7], but that's wrong */
3887 *buffer_address
++ = 0x00; /* branch offset = 4 */
3888 *buffer_address
++ = 0x04;
3889 *buffer_address
++ = 0x60; /* put in bra pc+6 */
3890 *buffer_address
++ = 0x06;
3891 *buffer_address
++ = 0x4e; /* put in jmp long (0x4ef9) */
3892 *buffer_address
++ = (char) 0xf9;
3894 fragP
->fr_fix
+= 6; /* account for bra/jmp instructions */
3895 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
,
3896 fragP
->fr_offset
, 0, NO_RELOC
);
3900 case TAB (FBRANCH
, SHORT
):
3901 know ((fragP
->fr_opcode
[1] & 0x40) == 0);
3904 case TAB (FBRANCH
, LONG
):
3905 fragP
->fr_opcode
[1] |= 0x40; /* Turn on LONG bit */
3908 case TAB (PCREL
, SHORT
):
3911 case TAB (PCREL
, LONG
):
3912 /* The thing to do here is force it to ABSOLUTE LONG, since
3913 PCREL is really trying to shorten an ABSOLUTE address anyway */
3914 /* JF FOO This code has not been tested */
3915 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
3917 if ((fragP
->fr_opcode
[1] & 0x3F) != 0x3A)
3918 as_bad ("Internal error (long PC-relative operand) for insn 0x%04x at 0x%lx",
3919 (unsigned) fragP
->fr_opcode
[0],
3920 (unsigned long) fragP
->fr_address
);
3921 fragP
->fr_opcode
[1] &= ~0x3F;
3922 fragP
->fr_opcode
[1] |= 0x39; /* Mode 7.1 */
3926 case TAB (PCLEA
, SHORT
):
3927 fix_new (fragP
, (int) (fragP
->fr_fix
), 2, fragP
->fr_symbol
,
3928 fragP
->fr_offset
, 1, NO_RELOC
);
3929 fragP
->fr_opcode
[1] &= ~0x3F;
3930 fragP
->fr_opcode
[1] |= 0x3A; /* 072 - mode 7.2 */
3933 case TAB (PCLEA
, LONG
):
3934 fixP
= fix_new (fragP
, (int) (fragP
->fr_fix
) + 2, 4, fragP
->fr_symbol
,
3935 fragP
->fr_offset
, 1, NO_RELOC
);
3936 fixP
->fx_pcrel_adjust
= 2;
3937 /* Already set to mode 7.3; this indicates: PC indirect with
3938 suppressed index, 32-bit displacement. */
3939 *buffer_address
++ = 0x01;
3940 *buffer_address
++ = 0x70;
3945 case TAB (PCINDEX
, BYTE
):
3947 if (!issbyte (disp
))
3949 as_bad ("displacement doesn't fit in one byte");
3952 assert (fragP
->fr_fix
>= 2);
3953 buffer_address
[-2] &= ~1;
3954 buffer_address
[-1] = disp
;
3957 case TAB (PCINDEX
, SHORT
):
3959 assert (issword (disp
));
3960 assert (fragP
->fr_fix
>= 2);
3961 buffer_address
[-2] |= 0x1;
3962 buffer_address
[-1] = 0x20;
3963 fixP
= fix_new (fragP
, (int) (fragP
->fr_fix
), 2, fragP
->fr_symbol
,
3964 fragP
->fr_offset
, (fragP
->fr_opcode
[1] & 077) == 073,
3966 fixP
->fx_pcrel_adjust
= 2;
3969 case TAB (PCINDEX
, LONG
):
3971 fixP
= fix_new (fragP
, (int) (fragP
->fr_fix
), 4, fragP
->fr_symbol
,
3972 fragP
->fr_offset
, (fragP
->fr_opcode
[1] & 077) == 073,
3974 fixP
->fx_pcrel_adjust
= 2;
3975 assert (fragP
->fr_fix
>= 2);
3976 buffer_address
[-2] |= 0x1;
3977 buffer_address
[-1] = 0x30;
3984 md_number_to_chars (buffer_address
, (long) disp
, (int) ext
);
3985 fragP
->fr_fix
+= ext
;
3989 #ifndef BFD_ASSEMBLER
3992 md_convert_frag (headers
, sec
, fragP
)
3993 object_headers
*headers
;
3997 md_convert_frag_1 (fragP
);
4003 md_convert_frag (abfd
, sec
, fragP
)
4008 md_convert_frag_1 (fragP
);
4012 /* Force truly undefined symbols to their maximum size, and generally set up
4013 the frag list to be relaxed
4016 md_estimate_size_before_relax (fragP
, segment
)
4017 register fragS
*fragP
;
4021 register char *buffer_address
= fragP
->fr_fix
+ fragP
->fr_literal
;
4023 old_fix
= fragP
->fr_fix
;
4025 /* handle SZ_UNDEF first, it can be changed to BYTE or SHORT */
4026 switch (fragP
->fr_subtype
)
4029 case TAB (ABRANCH
, SZ_UNDEF
):
4031 if ((fragP
->fr_symbol
!= NULL
) /* Not absolute */
4032 && S_GET_SEGMENT (fragP
->fr_symbol
) == segment
)
4034 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), BYTE
);
4037 else if ((fragP
->fr_symbol
== 0) || (cpu_of_arch (current_architecture
) < m68020
))
4039 /* On 68000, or for absolute value, switch to abs long */
4040 /* FIXME, we should check abs val, pick short or long */
4041 if (fragP
->fr_opcode
[0] == 0x61)
4043 fragP
->fr_opcode
[0] = 0x4E;
4044 fragP
->fr_opcode
[1] = (char) 0xB9; /* JBSR with ABSL LONG offset */
4045 fix_new (fragP
, fragP
->fr_fix
, 4,
4046 fragP
->fr_symbol
, fragP
->fr_offset
, 0, NO_RELOC
);
4050 else if (fragP
->fr_opcode
[0] == 0x60)
4052 fragP
->fr_opcode
[0] = 0x4E;
4053 fragP
->fr_opcode
[1] = (char) 0xF9; /* JMP with ABSL LONG offset */
4054 fix_new (fragP
, fragP
->fr_fix
, 4,
4055 fragP
->fr_symbol
, fragP
->fr_offset
, 0, NO_RELOC
);
4061 as_warn ("Long branch offset to extern symbol not supported.");
4065 { /* Symbol is still undefined. Make it simple */
4066 fix_new (fragP
, (int) (fragP
->fr_fix
), 4, fragP
->fr_symbol
,
4067 fragP
->fr_offset
, 1, NO_RELOC
);
4069 fragP
->fr_opcode
[1] = (char) 0xff;
4075 } /* case TAB(ABRANCH,SZ_UNDEF) */
4077 case TAB (FBRANCH
, SZ_UNDEF
):
4079 if (S_GET_SEGMENT (fragP
->fr_symbol
) == segment
|| flag_short_refs
)
4081 fragP
->fr_subtype
= TAB (FBRANCH
, SHORT
);
4086 fix_new (fragP
, (int) fragP
->fr_fix
, 4, fragP
->fr_symbol
,
4087 fragP
->fr_offset
, 1, NO_RELOC
);
4089 fragP
->fr_opcode
[1] |= 0x40; /* Turn on LONG bit */
4093 } /* TAB(FBRANCH,SZ_UNDEF) */
4095 case TAB (PCREL
, SZ_UNDEF
):
4097 if (S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4099 || cpu_of_arch (current_architecture
) < m68020
)
4101 fragP
->fr_subtype
= TAB (PCREL
, SHORT
);
4106 fragP
->fr_subtype
= TAB (PCREL
, LONG
);
4110 } /* TAB(PCREL,SZ_UNDEF) */
4112 case TAB (BCC68000
, SZ_UNDEF
):
4114 if ((fragP
->fr_symbol
!= NULL
)
4115 && S_GET_SEGMENT (fragP
->fr_symbol
) == segment
)
4117 fragP
->fr_subtype
= TAB (BCC68000
, BYTE
);
4120 /* only Bcc 68000 instructions can come here */
4121 /* change bcc into b!cc/jmp absl long */
4122 fragP
->fr_opcode
[0] ^= 0x01; /* invert bcc */
4123 if (flag_short_refs
)
4125 fragP
->fr_opcode
[1] = 0x04; /* branch offset = 6 */
4126 /* JF: these were fr_opcode[2,3] */
4127 buffer_address
[0] = 0x4e; /* put in jmp long (0x4ef9) */
4128 buffer_address
[1] = (char) 0xf8;
4129 fragP
->fr_fix
+= 2; /* account for jmp instruction */
4130 fix_new (fragP
, fragP
->fr_fix
, 2, fragP
->fr_symbol
,
4131 fragP
->fr_offset
, 0, NO_RELOC
);
4136 fragP
->fr_opcode
[1] = 0x06; /* branch offset = 6 */
4137 /* JF: these were fr_opcode[2,3] */
4138 buffer_address
[0] = 0x4e; /* put in jmp long (0x4ef9) */
4139 buffer_address
[1] = (char) 0xf9;
4140 fragP
->fr_fix
+= 2; /* account for jmp instruction */
4141 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
,
4142 fragP
->fr_offset
, 0, NO_RELOC
);
4147 } /* case TAB(BCC68000,SZ_UNDEF) */
4149 case TAB (DBCC
, SZ_UNDEF
):
4151 if (fragP
->fr_symbol
!= NULL
&& S_GET_SEGMENT (fragP
->fr_symbol
) == segment
)
4153 fragP
->fr_subtype
= TAB (DBCC
, SHORT
);
4157 /* only DBcc 68000 instructions can come here */
4158 /* change dbcc into dbcc/jmp absl long */
4159 /* JF: these used to be fr_opcode[2-4], which is wrong. */
4160 buffer_address
[0] = 0x00; /* branch offset = 4 */
4161 buffer_address
[1] = 0x04;
4162 buffer_address
[2] = 0x60; /* put in bra pc + ... */
4164 if (flag_short_refs
)
4166 /* JF: these were fr_opcode[5-7] */
4167 buffer_address
[3] = 0x04; /* plus 4 */
4168 buffer_address
[4] = 0x4e; /* Put in Jump Word */
4169 buffer_address
[5] = (char) 0xf8;
4170 fragP
->fr_fix
+= 6; /* account for bra/jmp instruction */
4171 fix_new (fragP
, fragP
->fr_fix
, 2, fragP
->fr_symbol
,
4172 fragP
->fr_offset
, 0, NO_RELOC
);
4177 /* JF: these were fr_opcode[5-7] */
4178 buffer_address
[3] = 0x06; /* Plus 6 */
4179 buffer_address
[4] = 0x4e; /* put in jmp long (0x4ef9) */
4180 buffer_address
[5] = (char) 0xf9;
4181 fragP
->fr_fix
+= 6; /* account for bra/jmp instruction */
4182 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
,
4183 fragP
->fr_offset
, 0, NO_RELOC
);
4189 } /* case TAB(DBCC,SZ_UNDEF) */
4191 case TAB (PCLEA
, SZ_UNDEF
):
4193 if ((S_GET_SEGMENT (fragP
->fr_symbol
)) == segment
4195 || cpu_of_arch (current_architecture
) < m68020
)
4197 fragP
->fr_subtype
= TAB (PCLEA
, SHORT
);
4202 fragP
->fr_subtype
= TAB (PCLEA
, LONG
);
4206 } /* TAB(PCLEA,SZ_UNDEF) */
4208 case TAB (PCINDEX
, SZ_UNDEF
):
4209 if (S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4210 || cpu_of_arch (current_architecture
) < m68020
)
4212 fragP
->fr_subtype
= TAB (PCINDEX
, BYTE
);
4216 fragP
->fr_subtype
= TAB (PCINDEX
, LONG
);
4225 /* now that SZ_UNDEF are taken care of, check others */
4226 switch (fragP
->fr_subtype
)
4228 case TAB (BCC68000
, BYTE
):
4229 case TAB (ABRANCH
, BYTE
):
4230 /* We can't do a short jump to the next instruction, so in that
4231 case we force word mode. At this point S_GET_VALUE should
4232 return the offset of the symbol within its frag. If the
4233 symbol is at the start of a frag, and it is the next frag
4234 with any data in it (usually this is just the next frag, but
4235 assembler listings may introduce empty frags), we must use
4237 if (fragP
->fr_symbol
&& S_GET_VALUE (fragP
->fr_symbol
) == 0)
4241 for (l
= fragP
->fr_next
;
4242 l
!= fragP
->fr_symbol
->sy_frag
;
4244 if (l
->fr_fix
+ l
->fr_var
!= 0)
4246 if (l
== fragP
->fr_symbol
->sy_frag
)
4248 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), SHORT
);
4256 return fragP
->fr_var
+ fragP
->fr_fix
- old_fix
;
4259 #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
4260 /* the bit-field entries in the relocation_info struct plays hell
4261 with the byte-order problems of cross-assembly. So as a hack,
4262 I added this mach. dependent ri twiddler. Ugly, but it gets
4264 /* on m68k: first 4 bytes are normal unsigned long, next three bytes
4265 are symbolnum, most sig. byte first. Last byte is broken up with
4266 bit 7 as pcrel, bits 6 & 5 as length, bit 4 as pcrel, and the lower
4267 nibble as nuthin. (on Sun 3 at least) */
4268 /* Translate the internal relocation information into target-specific
4272 md_ri_to_chars (the_bytes
, ri
)
4274 struct reloc_info_generic
*ri
;
4277 md_number_to_chars (the_bytes
, ri
->r_address
, 4);
4278 /* now the fun stuff */
4279 the_bytes
[4] = (ri
->r_symbolnum
>> 16) & 0x0ff;
4280 the_bytes
[5] = (ri
->r_symbolnum
>> 8) & 0x0ff;
4281 the_bytes
[6] = ri
->r_symbolnum
& 0x0ff;
4282 the_bytes
[7] = (((ri
->r_pcrel
<< 7) & 0x80) | ((ri
->r_length
<< 5) & 0x60) |
4283 ((ri
->r_extern
<< 4) & 0x10));
4286 #endif /* comment */
4288 #ifndef BFD_ASSEMBLER
4290 tc_aout_fix_to_chars (where
, fixP
, segment_address_in_file
)
4293 relax_addressT segment_address_in_file
;
4296 * In: length of relocation (or of address) in chars: 1, 2 or 4.
4297 * Out: GNU LD relocation length code: 0, 1, or 2.
4300 static CONST
unsigned char nbytes_r_length
[] = {42, 0, 1, 42, 2};
4303 know (fixP
->fx_addsy
!= NULL
);
4305 md_number_to_chars (where
,
4306 fixP
->fx_frag
->fr_address
+ fixP
->fx_where
- segment_address_in_file
,
4309 r_symbolnum
= (S_IS_DEFINED (fixP
->fx_addsy
)
4310 ? S_GET_TYPE (fixP
->fx_addsy
)
4311 : fixP
->fx_addsy
->sy_number
);
4313 where
[4] = (r_symbolnum
>> 16) & 0x0ff;
4314 where
[5] = (r_symbolnum
>> 8) & 0x0ff;
4315 where
[6] = r_symbolnum
& 0x0ff;
4316 where
[7] = (((fixP
->fx_pcrel
<< 7) & 0x80) | ((nbytes_r_length
[fixP
->fx_size
] << 5) & 0x60) |
4317 (((!S_IS_DEFINED (fixP
->fx_addsy
)) << 4) & 0x10));
4321 #endif /* OBJ_AOUT or OBJ_BOUT */
4323 #ifndef WORKING_DOT_WORD
4324 CONST
int md_short_jump_size
= 4;
4325 CONST
int md_long_jump_size
= 6;
4328 md_create_short_jump (ptr
, from_addr
, to_addr
, frag
, to_symbol
)
4330 addressT from_addr
, to_addr
;
4336 offset
= to_addr
- (from_addr
+ 2);
4338 md_number_to_chars (ptr
, (valueT
) 0x6000, 2);
4339 md_number_to_chars (ptr
+ 2, (valueT
) offset
, 2);
4343 md_create_long_jump (ptr
, from_addr
, to_addr
, frag
, to_symbol
)
4345 addressT from_addr
, to_addr
;
4351 if (cpu_of_arch (current_architecture
) < m68020
)
4353 offset
= to_addr
- S_GET_VALUE (to_symbol
);
4354 md_number_to_chars (ptr
, (valueT
) 0x4EF9, 2);
4355 md_number_to_chars (ptr
+ 2, (valueT
) offset
, 4);
4356 fix_new (frag
, (ptr
+ 2) - frag
->fr_literal
, 4, to_symbol
, (offsetT
) 0,
4361 offset
= to_addr
- (from_addr
+ 2);
4362 md_number_to_chars (ptr
, (valueT
) 0x60ff, 2);
4363 md_number_to_chars (ptr
+ 2, (valueT
) offset
, 4);
4369 /* Different values of OK tell what its OK to return. Things that
4370 aren't OK are an error (what a shock, no?)
4373 10: Absolute 1:8 only
4374 20: Absolute 0:7 only
4375 30: absolute 0:15 only
4376 40: Absolute 0:31 only
4377 50: absolute 0:127 only
4378 55: absolute -64:63 only
4379 60: absolute -128:127 only
4380 70: absolute 0:4095 only
4387 struct m68k_exp
*exp
;
4390 if (exp
->exp
.X_op
== O_absent
)
4392 /* Do the same thing the VAX asm does */
4393 op (exp
) = O_constant
;
4399 as_warn ("expression out of range: defaulting to 1");
4403 else if (exp
->exp
.X_op
== O_constant
)
4408 if (offs (exp
) < 1 || offs (exp
) > 8)
4410 as_warn ("expression out of range: defaulting to 1");
4415 if (offs (exp
) < 0 || offs (exp
) > 7)
4419 if (offs (exp
) < 0 || offs (exp
) > 15)
4423 if (offs (exp
) < 0 || offs (exp
) > 32)
4427 if (offs (exp
) < 0 || offs (exp
) > 127)
4431 if (offs (exp
) < -64 || offs (exp
) > 63)
4435 if (offs (exp
) < -128 || offs (exp
) > 127)
4439 if (offs (exp
) < 0 || offs (exp
) > 4095)
4442 as_warn ("expression out of range: defaulting to 0");
4450 else if (exp
->exp
.X_op
== O_big
)
4452 if (offs (exp
) <= 0 /* flonum */
4453 && (ok
== 80 /* no bignums */
4454 || (ok
> 10 /* small-int ranges including 0 ok */
4455 /* If we have a flonum zero, a zero integer should
4456 do as well (e.g., in moveq). */
4457 && generic_floating_point_number
.exponent
== 0
4458 && generic_floating_point_number
.low
[0] == 0)))
4460 /* HACK! Turn it into a long */
4461 LITTLENUM_TYPE words
[6];
4463 gen_to_words (words
, 2, 8L); /* These numbers are magic! */
4464 op (exp
) = O_constant
;
4467 offs (exp
) = words
[1] | (words
[0] << 16);
4471 op (exp
) = O_constant
;
4474 offs (exp
) = (ok
== 10) ? 1 : 0;
4475 as_warn ("Can't deal with expression; defaulting to %ld",
4481 if (ok
>= 10 && ok
<= 70)
4483 op (exp
) = O_constant
;
4486 offs (exp
) = (ok
== 10) ? 1 : 0;
4487 as_warn ("Can't deal with expression; defaulting to %ld",
4492 if (exp
->size
!= SIZE_UNSPEC
)
4500 if (!isbyte (offs (exp
)))
4501 as_warn ("expression doesn't fit in BYTE");
4504 if (!isword (offs (exp
)))
4505 as_warn ("expression doesn't fit in WORD");
4513 /* These are the back-ends for the various machine dependent pseudo-ops. */
4514 void demand_empty_rest_of_line (); /* Hate those extra verbose names */
4520 subseg_set (data_section
, 1);
4521 demand_empty_rest_of_line ();
4528 subseg_set (data_section
, 2);
4529 demand_empty_rest_of_line ();
4536 /* We don't support putting frags in the BSS segment, we fake it
4537 by marking in_bss, then looking at s_skip for clues. */
4539 subseg_set (bss_section
, 0);
4540 demand_empty_rest_of_line ();
4548 register long temp_fill
;
4550 temp
= 1; /* JF should be 2? */
4551 temp_fill
= get_absolute_expression ();
4552 if (!need_pass_2
) /* Never make frag if expect extra pass. */
4553 frag_align (temp
, (int) temp_fill
);
4554 demand_empty_rest_of_line ();
4561 demand_empty_rest_of_line ();
4564 /* Pseudo-ops handled for MRI compatibility. */
4566 /* Handle an MRI style chip specification. */
4575 s
= input_line_pointer
;
4576 c
= get_symbol_end ();
4577 for (i
= 0; i
< n_archs
; i
++)
4578 if (strcasecmp (s
, archs
[i
].name
) == 0)
4582 as_bad ("%s: unrecognized processor name", s
);
4583 *input_line_pointer
= c
;
4584 ignore_rest_of_line ();
4587 *input_line_pointer
= c
;
4589 if (*input_line_pointer
== '/')
4590 current_architecture
= 0;
4592 current_architecture
&= m68881
| m68851
;
4593 current_architecture
|= archs
[i
].arch
;
4595 while (*input_line_pointer
== '/')
4597 ++input_line_pointer
;
4598 s
= input_line_pointer
;
4599 c
= get_symbol_end ();
4600 if (strcmp (s
, "68881") == 0)
4601 current_architecture
|= m68881
;
4602 else if (strcmp (s
, "68851") == 0)
4603 current_architecture
|= m68851
;
4604 *input_line_pointer
= c
;
4608 /* The MRI CHIP pseudo-op. */
4618 stop
= mri_comment_field (&stopc
);
4621 mri_comment_end (stop
, stopc
);
4622 demand_empty_rest_of_line ();
4625 /* The MRI FOPT pseudo-op. */
4633 if (strncasecmp (input_line_pointer
, "ID=", 3) == 0)
4637 input_line_pointer
+= 3;
4638 temp
= get_absolute_expression ();
4639 if (temp
< 0 || temp
> 7)
4640 as_bad ("bad coprocessor id");
4642 m68k_float_copnum
= COP0
+ temp
;
4646 as_bad ("unrecognized fopt option");
4647 ignore_rest_of_line ();
4651 demand_empty_rest_of_line ();
4654 /* The structure used to handle the MRI OPT pseudo-op. */
4658 /* The name of the option. */
4661 /* If this is not NULL, just call this function. The first argument
4662 is the ARG field of this structure, the second argument is
4663 whether the option was negated. */
4664 void (*pfn
) PARAMS ((int arg
, int on
));
4666 /* If this is not NULL, and the PFN field is NULL, set the variable
4667 this points to. Set it to the ARG field if the option was not
4668 negated, and the NOTARG field otherwise. */
4671 /* The value to pass to PFN or to assign to *PVAR. */
4674 /* The value to assign to *PVAR if the option is negated. If PFN is
4675 NULL, and PVAR is not NULL, and ARG and NOTARG are the same, then
4676 the option may not be negated. */
4680 /* The table used to handle the MRI OPT pseudo-op. */
4682 static void skip_to_comma
PARAMS ((int, int));
4683 static void opt_nest
PARAMS ((int, int));
4684 static void opt_chip
PARAMS ((int, int));
4685 static void opt_list
PARAMS ((int, int));
4686 static void opt_list_symbols
PARAMS ((int, int));
4688 static const struct opt_action opt_table
[] =
4690 { "abspcadd", 0, &m68k_abspcadd
, 1, 0 },
4692 /* We do relaxing, so there is little use for these options. */
4693 { "b", 0, 0, 0, 0 },
4694 { "brs", 0, 0, 0, 0 },
4695 { "brb", 0, 0, 0, 0 },
4696 { "brl", 0, 0, 0, 0 },
4697 { "brw", 0, 0, 0, 0 },
4699 { "c", 0, 0, 0, 0 },
4700 { "cex", 0, 0, 0, 0 },
4701 { "case", 0, &symbols_case_sensitive
, 1, 0 },
4702 { "cl", 0, 0, 0, 0 },
4703 { "cre", 0, 0, 0, 0 },
4704 { "d", 0, &flag_keep_locals
, 1, 0 },
4705 { "e", 0, 0, 0, 0 },
4706 { "f", 0, &flag_short_refs
, 1, 0 },
4707 { "frs", 0, &flag_short_refs
, 1, 0 },
4708 { "frl", 0, &flag_short_refs
, 0, 1 },
4709 { "g", 0, 0, 0, 0 },
4710 { "i", 0, 0, 0, 0 },
4711 { "m", 0, 0, 0, 0 },
4712 { "mex", 0, 0, 0, 0 },
4713 { "mc", 0, 0, 0, 0 },
4714 { "md", 0, 0, 0, 0 },
4715 { "nest", opt_nest
, 0, 0, 0 },
4716 { "next", skip_to_comma
, 0, 0, 0 },
4717 { "o", 0, 0, 0, 0 },
4718 { "old", 0, 0, 0, 0 },
4719 { "op", skip_to_comma
, 0, 0, 0 },
4720 { "pco", 0, 0, 0, 0 },
4721 { "p", opt_chip
, 0, 0, 0 },
4722 { "pcr", 0, 0, 0, 0 },
4723 { "pcs", 0, 0, 0, 0 },
4724 { "r", 0, 0, 0, 0 },
4725 { "quick", 0, &m68k_quick
, 1, 0 },
4726 { "rel32", 0, &m68k_rel32
, 1, 0 },
4727 { "s", opt_list
, 0, 0, 0 },
4728 { "t", opt_list_symbols
, 0, 0, 0 },
4729 { "w", 0, &flag_no_warnings
, 0, 1 },
4733 #define OPTCOUNT (sizeof opt_table / sizeof opt_table[0])
4735 /* The MRI OPT pseudo-op. */
4747 const struct opt_action
*o
;
4752 if (*input_line_pointer
== '-')
4754 ++input_line_pointer
;
4757 else if (strncasecmp (input_line_pointer
, "NO", 2) == 0)
4759 input_line_pointer
+= 2;
4763 s
= input_line_pointer
;
4764 c
= get_symbol_end ();
4766 for (i
= 0, o
= opt_table
; i
< OPTCOUNT
; i
++, o
++)
4768 if (strcasecmp (s
, o
->name
) == 0)
4772 /* Restore input_line_pointer now in case the option
4774 *input_line_pointer
= c
;
4775 (*o
->pfn
) (o
->arg
, t
);
4777 else if (o
->pvar
!= NULL
)
4779 if (! t
&& o
->arg
== o
->notarg
)
4780 as_bad ("option `%s' may not be negated", s
);
4781 *input_line_pointer
= c
;
4782 *o
->pvar
= t
? o
->arg
: o
->notarg
;
4785 *input_line_pointer
= c
;
4791 as_bad ("option `%s' not recognized", s
);
4792 *input_line_pointer
= c
;
4795 while (*input_line_pointer
++ == ',');
4797 /* Move back to terminating character. */
4798 --input_line_pointer
;
4799 demand_empty_rest_of_line ();
4802 /* Skip ahead to a comma. This is used for OPT options which we do
4803 not suppor tand which take arguments. */
4806 skip_to_comma (arg
, on
)
4810 while (*input_line_pointer
!= ','
4811 && ! is_end_of_line
[(unsigned char) *input_line_pointer
])
4812 ++input_line_pointer
;
4815 /* Handle the OPT NEST=depth option. */
4822 if (*input_line_pointer
!= '=')
4824 as_bad ("bad format of OPT NEST=depth");
4828 ++input_line_pointer
;
4829 max_macro_nest
= get_absolute_expression ();
4832 /* Handle the OPT P=chip option. */
4839 if (*input_line_pointer
!= '=')
4841 /* This is just OPT P, which we do not support. */
4845 ++input_line_pointer
;
4849 /* Handle the OPT S option. */
4859 /* Handle the OPT T option. */
4862 opt_list_symbols (arg
, on
)
4867 listing
|= LISTING_SYMBOLS
;
4869 listing
&=~ LISTING_SYMBOLS
;
4872 /* Handle the MRI REG pseudo-op. */
4885 if (line_label
== NULL
)
4887 as_bad ("missing label");
4888 ignore_rest_of_line ();
4893 stop
= mri_comment_field (&stopc
);
4897 s
= input_line_pointer
;
4898 while (isalnum ((unsigned char) *input_line_pointer
)
4899 #ifdef REGISTER_PREFIX
4900 || *input_line_pointer
== REGISTER_PREFIX
4902 || *input_line_pointer
== '/'
4903 || *input_line_pointer
== '-')
4904 ++input_line_pointer
;
4905 c
= *input_line_pointer
;
4906 *input_line_pointer
= '\0';
4908 if (m68k_ip_op (s
, &rop
) != 0)
4910 if (rop
.error
== NULL
)
4911 as_bad ("bad register list");
4913 as_bad ("bad register list: %s", rop
.error
);
4914 *input_line_pointer
= c
;
4915 ignore_rest_of_line ();
4919 *input_line_pointer
= c
;
4921 if (rop
.mode
== REGLST
)
4923 else if (rop
.mode
== DREG
)
4924 mask
= 1 << (rop
.reg
- DATA0
);
4925 else if (rop
.mode
== AREG
)
4926 mask
= 1 << (rop
.reg
- ADDR0
+ 8);
4927 else if (rop
.mode
== FPREG
)
4928 mask
= 1 << (rop
.reg
- FP0
+ 16);
4929 else if (rop
.mode
== CONTROL
4932 else if (rop
.mode
== CONTROL
4935 else if (rop
.mode
== CONTROL
4940 as_bad ("bad register list");
4941 ignore_rest_of_line ();
4945 S_SET_SEGMENT (line_label
, absolute_section
);
4946 S_SET_VALUE (line_label
, mask
);
4947 line_label
->sy_frag
= &zero_address_frag
;
4950 mri_comment_end (stop
, stopc
);
4952 demand_empty_rest_of_line ();
4955 /* This structure is used for the MRI SAVE and RESTORE pseudo-ops. */
4959 struct save_opts
*next
;
4961 int symbols_case_sensitive
;
4969 /* FIXME: We don't save OPT S. */
4972 /* This variable holds the stack of saved options. */
4974 static struct save_opts
*save_stack
;
4976 /* The MRI SAVE pseudo-op. */
4982 struct save_opts
*s
;
4984 s
= (struct save_opts
*) xmalloc (sizeof (struct save_opts
));
4985 s
->abspcadd
= m68k_abspcadd
;
4986 s
->symbols_case_sensitive
= symbols_case_sensitive
;
4987 s
->keep_locals
= flag_keep_locals
;
4988 s
->short_refs
= flag_short_refs
;
4989 s
->architecture
= current_architecture
;
4990 s
->quick
= m68k_quick
;
4991 s
->rel32
= m68k_rel32
;
4992 s
->listing
= listing
;
4993 s
->no_warnings
= flag_no_warnings
;
4995 s
->next
= save_stack
;
4998 demand_empty_rest_of_line ();
5001 /* The MRI RESTORE pseudo-op. */
5007 struct save_opts
*s
;
5009 if (save_stack
== NULL
)
5011 as_bad ("restore without save");
5012 ignore_rest_of_line ();
5017 save_stack
= s
->next
;
5019 m68k_abspcadd
= s
->abspcadd
;
5020 symbols_case_sensitive
= s
->symbols_case_sensitive
;
5021 flag_keep_locals
= s
->keep_locals
;
5022 flag_short_refs
= s
->short_refs
;
5023 current_architecture
= s
->architecture
;
5024 m68k_quick
= s
->quick
;
5025 m68k_rel32
= s
->rel32
;
5026 listing
= s
->listing
;
5027 flag_no_warnings
= s
->no_warnings
;
5031 demand_empty_rest_of_line ();
5034 /* Types of MRI structured control directives. */
5036 enum mri_control_type
5044 /* This structure is used to stack the MRI structured control
5047 struct mri_control_info
5049 /* The directive within which this one is enclosed. */
5050 struct mri_control_info
*outer
;
5052 /* The type of directive. */
5053 enum mri_control_type type
;
5055 /* Whether an ELSE has been in an IF. */
5058 /* The add or sub statement at the end of a FOR. */
5061 /* The label of the top of a FOR or REPEAT loop. */
5064 /* The label to jump to for the next iteration, or the else
5065 expression of a conditional. */
5068 /* The label to jump to to break out of the loop, or the label past
5069 the end of a conditional. */
5073 /* The stack of MRI structured control directives. */
5075 static struct mri_control_info
*mri_control_stack
;
5077 /* The current MRI structured control directive index number, used to
5078 generate label names. */
5080 static int mri_control_index
;
5082 /* Some function prototypes. */
5084 static char *mri_control_label
PARAMS ((void));
5085 static struct mri_control_info
*push_mri_control
5086 PARAMS ((enum mri_control_type
));
5087 static void pop_mri_control
PARAMS ((void));
5088 static int parse_mri_condition
PARAMS ((int *));
5089 static int parse_mri_control_operand
5090 PARAMS ((int *, char **, char **, char **, char **));
5091 static int swap_mri_condition
PARAMS ((int));
5092 static int reverse_mri_condition
PARAMS ((int));
5093 static void build_mri_control_operand
5094 PARAMS ((int, int, char *, char *, char *, char *, const char *,
5095 const char *, int));
5096 static void parse_mri_control_expression
5097 PARAMS ((char *, int, const char *, const char *, int));
5099 /* Generate a new MRI label structured control directive label name. */
5102 mri_control_label ()
5106 n
= (char *) xmalloc (20);
5107 sprintf (n
, "%smc%d", FAKE_LABEL_NAME
, mri_control_index
);
5108 ++mri_control_index
;
5112 /* Create a new MRI structured control directive. */
5114 static struct mri_control_info
*
5115 push_mri_control (type
)
5116 enum mri_control_type type
;
5118 struct mri_control_info
*n
;
5120 n
= (struct mri_control_info
*) xmalloc (sizeof (struct mri_control_info
));
5124 if (type
== mri_if
|| type
== mri_while
)
5127 n
->top
= mri_control_label ();
5128 n
->next
= mri_control_label ();
5129 n
->bottom
= mri_control_label ();
5131 n
->outer
= mri_control_stack
;
5132 mri_control_stack
= n
;
5137 /* Pop off the stack of MRI structured control directives. */
5142 struct mri_control_info
*n
;
5144 n
= mri_control_stack
;
5145 mri_control_stack
= n
->outer
;
5153 /* Recognize a condition code in an MRI structured control expression. */
5156 parse_mri_condition (pcc
)
5161 know (*input_line_pointer
== '<');
5163 ++input_line_pointer
;
5164 c1
= *input_line_pointer
++;
5165 c2
= *input_line_pointer
++;
5167 if (*input_line_pointer
!= '>')
5169 as_bad ("syntax error in structured control directive");
5173 ++input_line_pointer
;
5181 *pcc
= (c1
<< 8) | c2
;
5186 /* Parse a single operand in an MRI structured control expression. */
5189 parse_mri_control_operand (pcc
, leftstart
, leftstop
, rightstart
, rightstop
)
5206 if (*input_line_pointer
== '<')
5208 /* It's just a condition code. */
5209 return parse_mri_condition (pcc
);
5212 /* Look ahead for the condition code. */
5213 for (s
= input_line_pointer
; *s
!= '\0'; ++s
)
5215 if (*s
== '<' && s
[1] != '\0' && s
[2] != '\0' && s
[3] == '>')
5220 as_bad ("missing condition code in structured control directive");
5224 *leftstart
= input_line_pointer
;
5226 if (*leftstop
> *leftstart
5227 && ((*leftstop
)[-1] == ' ' || (*leftstop
)[-1] == '\t'))
5230 input_line_pointer
= s
;
5231 if (! parse_mri_condition (pcc
))
5234 /* Look ahead for AND or OR or end of line. */
5235 for (s
= input_line_pointer
; *s
!= '\0'; ++s
)
5237 if ((strncasecmp (s
, "AND", 3) == 0
5238 && (s
[3] == '.' || ! is_part_of_name (s
[3])))
5239 || (strncasecmp (s
, "OR", 2) == 0
5240 && (s
[2] == '.' || ! is_part_of_name (s
[2]))))
5244 *rightstart
= input_line_pointer
;
5246 if (*rightstop
> *rightstart
5247 && ((*rightstop
)[-1] == ' ' || (*rightstop
)[-1] == '\t'))
5250 input_line_pointer
= s
;
5255 #define MCC(b1, b2) (((b1) << 8) | (b2))
5257 /* Swap the sense of a condition. This changes the condition so that
5258 it generates the same result when the operands are swapped. */
5261 swap_mri_condition (cc
)
5266 case MCC ('h', 'i'): return MCC ('c', 's');
5267 case MCC ('l', 's'): return MCC ('c', 'c');
5268 case MCC ('c', 'c'): return MCC ('l', 's');
5269 case MCC ('c', 's'): return MCC ('h', 'i');
5270 case MCC ('p', 'l'): return MCC ('m', 'i');
5271 case MCC ('m', 'i'): return MCC ('p', 'l');
5272 case MCC ('g', 'e'): return MCC ('l', 'e');
5273 case MCC ('l', 't'): return MCC ('g', 't');
5274 case MCC ('g', 't'): return MCC ('l', 't');
5275 case MCC ('l', 'e'): return MCC ('g', 'e');
5280 /* Reverse the sense of a condition. */
5283 reverse_mri_condition (cc
)
5288 case MCC ('h', 'i'): return MCC ('l', 's');
5289 case MCC ('l', 's'): return MCC ('h', 'i');
5290 case MCC ('c', 'c'): return MCC ('c', 's');
5291 case MCC ('c', 's'): return MCC ('c', 'c');
5292 case MCC ('n', 'e'): return MCC ('e', 'q');
5293 case MCC ('e', 'q'): return MCC ('n', 'e');
5294 case MCC ('v', 'c'): return MCC ('v', 's');
5295 case MCC ('v', 's'): return MCC ('v', 'c');
5296 case MCC ('p', 'l'): return MCC ('m', 'i');
5297 case MCC ('m', 'i'): return MCC ('p', 'l');
5298 case MCC ('g', 'e'): return MCC ('l', 't');
5299 case MCC ('l', 't'): return MCC ('g', 'e');
5300 case MCC ('g', 't'): return MCC ('l', 'e');
5301 case MCC ('l', 'e'): return MCC ('g', 't');
5306 /* Build an MRI structured control expression. This generates test
5307 and branch instructions. It goes to TRUELAB if the condition is
5308 true, and to FALSELAB if the condition is false. Exactly one of
5309 TRUELAB and FALSELAB will be NULL, meaning to fall through. QUAL
5310 is the size qualifier for the expression. EXTENT is the size to
5311 use for the branch. */
5314 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
5315 rightstop
, truelab
, falselab
, extent
)
5322 const char *truelab
;
5323 const char *falselab
;
5329 if (leftstart
!= NULL
)
5331 struct m68k_op leftop
, rightop
;
5334 /* Swap the compare operands, if necessary, to produce a legal
5335 m68k compare instruction. Comparing a register operand with
5336 a non-register operand requires the register to be on the
5337 right (cmp, cmpa). Comparing an immediate value with
5338 anything requires the immediate value to be on the left
5343 (void) m68k_ip_op (leftstart
, &leftop
);
5348 (void) m68k_ip_op (rightstart
, &rightop
);
5351 if (rightop
.mode
== IMMED
5352 || ((leftop
.mode
== DREG
|| leftop
.mode
== AREG
)
5353 && (rightop
.mode
!= DREG
&& rightop
.mode
!= AREG
)))
5357 cc
= swap_mri_condition (cc
);
5359 leftstart
= rightstart
;
5362 leftstop
= rightstop
;
5367 if (truelab
== NULL
)
5369 cc
= reverse_mri_condition (cc
);
5373 if (leftstart
!= NULL
)
5375 buf
= (char *) xmalloc (20
5376 + (leftstop
- leftstart
)
5377 + (rightstop
- rightstart
));
5385 memcpy (s
, leftstart
, leftstop
- leftstart
);
5386 s
+= leftstop
- leftstart
;
5388 memcpy (s
, rightstart
, rightstop
- rightstart
);
5389 s
+= rightstop
- rightstart
;
5395 buf
= (char *) xmalloc (20 + strlen (truelab
));
5403 strcpy (s
, truelab
);
5408 /* Parse an MRI structured control expression. This generates test
5409 and branch instructions. STOP is where the expression ends. It
5410 goes to TRUELAB if the condition is true, and to FALSELAB if the
5411 condition is false. Exactly one of TRUELAB and FALSELAB will be
5412 NULL, meaning to fall through. QUAL is the size qualifier for the
5413 expression. EXTENT is the size to use for the branch. */
5416 parse_mri_control_expression (stop
, qual
, truelab
, falselab
, extent
)
5419 const char *truelab
;
5420 const char *falselab
;
5433 if (! parse_mri_control_operand (&cc
, &leftstart
, &leftstop
,
5434 &rightstart
, &rightstop
))
5440 if (strncasecmp (input_line_pointer
, "AND", 3) == 0)
5444 if (falselab
!= NULL
)
5447 flab
= mri_control_label ();
5449 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
5450 rightstop
, (const char *) NULL
, flab
, extent
);
5452 input_line_pointer
+= 3;
5453 if (*input_line_pointer
!= '.'
5454 || input_line_pointer
[1] == '\0')
5458 qual
= input_line_pointer
[1];
5459 input_line_pointer
+= 2;
5462 if (! parse_mri_control_operand (&cc
, &leftstart
, &leftstop
,
5463 &rightstart
, &rightstop
))
5469 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
5470 rightstop
, truelab
, falselab
, extent
);
5472 if (falselab
== NULL
)
5475 else if (strncasecmp (input_line_pointer
, "OR", 2) == 0)
5479 if (truelab
!= NULL
)
5482 tlab
= mri_control_label ();
5484 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
5485 rightstop
, tlab
, (const char *) NULL
, extent
);
5487 input_line_pointer
+= 2;
5488 if (*input_line_pointer
!= '.'
5489 || input_line_pointer
[1] == '\0')
5493 qual
= input_line_pointer
[1];
5494 input_line_pointer
+= 2;
5497 if (! parse_mri_control_operand (&cc
, &leftstart
, &leftstop
,
5498 &rightstart
, &rightstop
))
5504 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
5505 rightstop
, truelab
, falselab
, extent
);
5507 if (truelab
== NULL
)
5512 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
5513 rightstop
, truelab
, falselab
, extent
);
5517 if (input_line_pointer
!= stop
)
5518 as_bad ("syntax error in structured control directive");
5521 /* Handle the MRI IF pseudo-op. This may be a structured control
5522 directive, or it may be a regular assembler conditional, depending
5531 struct mri_control_info
*n
;
5533 /* A structured control directive must end with THEN with an
5534 optional qualifier. */
5535 s
= input_line_pointer
;
5536 while (! is_end_of_line
[(unsigned char) *s
]
5537 && (! flag_mri
|| *s
!= '*'))
5540 while (s
> input_line_pointer
&& (*s
== ' ' || *s
== '\t'))
5543 if (s
- input_line_pointer
> 1
5547 if (s
- input_line_pointer
< 3
5548 || strncasecmp (s
- 3, "THEN", 4) != 0)
5552 as_bad ("missing then");
5553 ignore_rest_of_line ();
5557 /* It's a conditional. */
5562 /* Since this might be a conditional if, this pseudo-op will be
5563 called even if we are supported to be ignoring input. Double
5564 check now. Clobber *input_line_pointer so that ignore_input
5565 thinks that this is not a special pseudo-op. */
5566 c
= *input_line_pointer
;
5567 *input_line_pointer
= 0;
5568 if (ignore_input ())
5570 *input_line_pointer
= c
;
5571 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
5572 ++input_line_pointer
;
5573 demand_empty_rest_of_line ();
5576 *input_line_pointer
= c
;
5578 n
= push_mri_control (mri_if
);
5580 parse_mri_control_expression (s
- 3, qual
, (const char *) NULL
,
5581 n
->next
, s
[1] == '.' ? s
[2] : '\0');
5584 input_line_pointer
= s
+ 3;
5586 input_line_pointer
= s
+ 1;
5590 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
5591 ++input_line_pointer
;
5594 demand_empty_rest_of_line ();
5597 /* Handle the MRI else pseudo-op. If we are currently doing an MRI
5598 structured IF, associate the ELSE with the IF. Otherwise, assume
5599 it is a conditional else. */
5610 && (mri_control_stack
== NULL
5611 || mri_control_stack
->type
!= mri_if
5612 || mri_control_stack
->else_seen
))
5618 c
= *input_line_pointer
;
5619 *input_line_pointer
= 0;
5620 if (ignore_input ())
5622 *input_line_pointer
= c
;
5623 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
5624 ++input_line_pointer
;
5625 demand_empty_rest_of_line ();
5628 *input_line_pointer
= c
;
5630 if (mri_control_stack
== NULL
5631 || mri_control_stack
->type
!= mri_if
5632 || mri_control_stack
->else_seen
)
5634 as_bad ("else without matching if");
5635 ignore_rest_of_line ();
5639 mri_control_stack
->else_seen
= 1;
5641 buf
= (char *) xmalloc (20 + strlen (mri_control_stack
->bottom
));
5644 sprintf (buf
, "bra%s %s", q
, mri_control_stack
->bottom
);
5648 colon (mri_control_stack
->next
);
5652 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
5653 ++input_line_pointer
;
5656 demand_empty_rest_of_line ();
5659 /* Handle the MRI ENDI pseudo-op. */
5665 if (mri_control_stack
== NULL
5666 || mri_control_stack
->type
!= mri_if
)
5668 as_bad ("endi without matching if");
5669 ignore_rest_of_line ();
5673 /* ignore_input will not return true for ENDI, so we don't need to
5674 worry about checking it again here. */
5676 if (! mri_control_stack
->else_seen
)
5677 colon (mri_control_stack
->next
);
5678 colon (mri_control_stack
->bottom
);
5684 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
5685 ++input_line_pointer
;
5688 demand_empty_rest_of_line ();
5691 /* Handle the MRI BREAK pseudo-op. */
5694 s_mri_break (extent
)
5697 struct mri_control_info
*n
;
5701 n
= mri_control_stack
;
5703 && n
->type
!= mri_for
5704 && n
->type
!= mri_repeat
5705 && n
->type
!= mri_while
)
5709 as_bad ("break outside of structured loop");
5710 ignore_rest_of_line ();
5714 buf
= (char *) xmalloc (20 + strlen (n
->bottom
));
5717 sprintf (buf
, "bra%s %s", ex
, n
->bottom
);
5723 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
5724 ++input_line_pointer
;
5727 demand_empty_rest_of_line ();
5730 /* Handle the MRI NEXT pseudo-op. */
5736 struct mri_control_info
*n
;
5740 n
= mri_control_stack
;
5742 && n
->type
!= mri_for
5743 && n
->type
!= mri_repeat
5744 && n
->type
!= mri_while
)
5748 as_bad ("next outside of structured loop");
5749 ignore_rest_of_line ();
5753 buf
= (char *) xmalloc (20 + strlen (n
->next
));
5756 sprintf (buf
, "bra%s %s", ex
, n
->next
);
5762 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
5763 ++input_line_pointer
;
5766 demand_empty_rest_of_line ();
5769 /* Handle the MRI FOR pseudo-op. */
5775 const char *varstart
, *varstop
;
5776 const char *initstart
, *initstop
;
5777 const char *endstart
, *endstop
;
5778 const char *bystart
, *bystop
;
5782 struct mri_control_info
*n
;
5788 FOR.q var = init { TO | DOWNTO } end [ BY by ] DO.e
5792 varstart
= input_line_pointer
;
5794 /* Look for the '='. */
5795 while (! is_end_of_line
[(unsigned char) *input_line_pointer
]
5796 && *input_line_pointer
!= '=')
5797 ++input_line_pointer
;
5798 if (*input_line_pointer
!= '=')
5800 as_bad ("missing =");
5801 ignore_rest_of_line ();
5805 varstop
= input_line_pointer
;
5806 if (varstop
> varstart
5807 && (varstop
[-1] == ' ' || varstop
[-1] == '\t'))
5810 ++input_line_pointer
;
5812 initstart
= input_line_pointer
;
5814 /* Look for TO or DOWNTO. */
5817 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
5819 if (strncasecmp (input_line_pointer
, "TO", 2) == 0
5820 && ! is_part_of_name (input_line_pointer
[2]))
5822 initstop
= input_line_pointer
;
5823 input_line_pointer
+= 2;
5826 if (strncasecmp (input_line_pointer
, "DOWNTO", 6) == 0
5827 && ! is_part_of_name (input_line_pointer
[6]))
5829 initstop
= input_line_pointer
;
5831 input_line_pointer
+= 6;
5834 ++input_line_pointer
;
5836 if (initstop
== NULL
)
5838 as_bad ("missing to or downto");
5839 ignore_rest_of_line ();
5842 if (initstop
> initstart
5843 && (initstop
[-1] == ' ' || initstop
[-1] == '\t'))
5847 endstart
= input_line_pointer
;
5849 /* Look for BY or DO. */
5852 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
5854 if (strncasecmp (input_line_pointer
, "BY", 2) == 0
5855 && ! is_part_of_name (input_line_pointer
[2]))
5857 endstop
= input_line_pointer
;
5859 input_line_pointer
+= 2;
5862 if (strncasecmp (input_line_pointer
, "DO", 2) == 0
5863 && (input_line_pointer
[2] == '.'
5864 || ! is_part_of_name (input_line_pointer
[2])))
5866 endstop
= input_line_pointer
;
5867 input_line_pointer
+= 2;
5870 ++input_line_pointer
;
5872 if (endstop
== NULL
)
5874 as_bad ("missing do");
5875 ignore_rest_of_line ();
5878 if (endstop
> endstart
5879 && (endstop
[-1] == ' ' || endstop
[-1] == '\t'))
5885 bystop
= bystart
+ 2;
5890 bystart
= input_line_pointer
;
5894 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
5896 if (strncasecmp (input_line_pointer
, "DO", 2) == 0
5897 && (input_line_pointer
[2] == '.'
5898 || ! is_part_of_name (input_line_pointer
[2])))
5900 bystop
= input_line_pointer
;
5901 input_line_pointer
+= 2;
5904 ++input_line_pointer
;
5908 as_bad ("missing do");
5909 ignore_rest_of_line ();
5912 if (bystop
> bystart
5913 && (bystop
[-1] == ' ' || bystop
[-1] == '\t'))
5917 if (*input_line_pointer
!= '.')
5921 extent
= input_line_pointer
[1];
5922 input_line_pointer
+= 2;
5925 /* We have fully parsed the FOR operands. Now build the loop. */
5927 n
= push_mri_control (mri_for
);
5929 buf
= (char *) xmalloc (50 + (input_line_pointer
- varstart
));
5940 memcpy (s
, initstart
, initstop
- initstart
);
5941 s
+= initstop
- initstart
;
5943 memcpy (s
, varstart
, varstop
- varstart
);
5944 s
+= varstop
- varstart
;
5958 memcpy (s
, endstart
, endstop
- endstart
);
5959 s
+= endstop
- endstart
;
5961 memcpy (s
, varstart
, varstop
- varstart
);
5962 s
+= varstop
- varstart
;
5970 sprintf (buf
, "blt%s %s", ex
, n
->bottom
);
5972 sprintf (buf
, "bgt%s %s", ex
, n
->bottom
);
5975 /* Put together the add or sub instruction used by ENDF. */
5985 memcpy (s
, bystart
, bystop
- bystart
);
5986 s
+= bystop
- bystart
;
5988 memcpy (s
, varstart
, varstop
- varstart
);
5989 s
+= varstop
- varstart
;
5995 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
5996 ++input_line_pointer
;
5999 demand_empty_rest_of_line ();
6002 /* Handle the MRI ENDF pseudo-op. */
6008 if (mri_control_stack
== NULL
6009 || mri_control_stack
->type
!= mri_for
)
6011 as_bad ("endf without for");
6012 ignore_rest_of_line ();
6016 colon (mri_control_stack
->next
);
6018 md_assemble (mri_control_stack
->incr
);
6020 sprintf (mri_control_stack
->incr
, "bra %s", mri_control_stack
->top
);
6021 md_assemble (mri_control_stack
->incr
);
6023 free (mri_control_stack
->incr
);
6025 colon (mri_control_stack
->bottom
);
6031 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6032 ++input_line_pointer
;
6035 demand_empty_rest_of_line ();
6038 /* Handle the MRI REPEAT pseudo-op. */
6041 s_mri_repeat (ignore
)
6044 struct mri_control_info
*n
;
6046 n
= push_mri_control (mri_repeat
);
6050 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6051 ++input_line_pointer
;
6053 demand_empty_rest_of_line ();
6056 /* Handle the MRI UNTIL pseudo-op. */
6064 if (mri_control_stack
== NULL
6065 || mri_control_stack
->type
!= mri_repeat
)
6067 as_bad ("until without repeat");
6068 ignore_rest_of_line ();
6072 colon (mri_control_stack
->next
);
6074 for (s
= input_line_pointer
; ! is_end_of_line
[(unsigned char) *s
]; s
++)
6077 parse_mri_control_expression (s
, qual
, (const char *) NULL
,
6078 mri_control_stack
->top
, '\0');
6080 colon (mri_control_stack
->bottom
);
6082 input_line_pointer
= s
;
6088 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6089 ++input_line_pointer
;
6092 demand_empty_rest_of_line ();
6095 /* Handle the MRI WHILE pseudo-op. */
6103 struct mri_control_info
*n
;
6105 s
= input_line_pointer
;
6106 while (! is_end_of_line
[(unsigned char) *s
]
6107 && (! flag_mri
|| *s
!= '*'))
6110 while (*s
== ' ' || *s
== '\t')
6112 if (s
- input_line_pointer
> 1
6115 if (s
- input_line_pointer
< 2
6116 || strncasecmp (s
- 1, "DO", 2) != 0)
6118 as_bad ("missing do");
6119 ignore_rest_of_line ();
6123 n
= push_mri_control (mri_while
);
6127 parse_mri_control_expression (s
- 1, qual
, (const char *) NULL
, n
->bottom
,
6128 s
[1] == '.' ? s
[2] : '\0');
6130 input_line_pointer
= s
+ 1;
6131 if (*input_line_pointer
== '.')
6132 input_line_pointer
+= 2;
6136 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6137 ++input_line_pointer
;
6140 demand_empty_rest_of_line ();
6143 /* Handle the MRI ENDW pseudo-op. */
6151 if (mri_control_stack
== NULL
6152 || mri_control_stack
->type
!= mri_while
)
6154 as_bad ("endw without while");
6155 ignore_rest_of_line ();
6159 buf
= (char *) xmalloc (20 + strlen (mri_control_stack
->next
));
6160 sprintf (buf
, "bra %s", mri_control_stack
->next
);
6164 colon (mri_control_stack
->bottom
);
6170 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6171 ++input_line_pointer
;
6174 demand_empty_rest_of_line ();
6179 * Invocation line includes a switch not recognized by the base assembler.
6180 * See if it's a processor-specific option. These are:
6182 * -[A]m[c]68000, -[A]m[c]68008, -[A]m[c]68010, -[A]m[c]68020, -[A]m[c]68030, -[A]m[c]68040
6183 * -[A]m[c]68881, -[A]m[c]68882, -[A]m[c]68851
6184 * Select the architecture. Instructions or features not
6185 * supported by the selected architecture cause fatal
6186 * errors. More than one may be specified. The default is
6187 * -m68020 -m68851 -m68881. Note that -m68008 is a synonym
6188 * for -m68000, and -m68882 is a synonym for -m68881.
6189 * -[A]m[c]no-68851, -[A]m[c]no-68881
6190 * Don't accept 688?1 instructions. (The "c" is kind of silly,
6191 * so don't use or document it, but that's the way the parsing
6194 * -pic Indicates PIC.
6195 * -k Indicates PIC. (Sun 3 only.)
6198 * Permit `|' to be used in expressions.
6203 CONST
char *md_shortopts
= "lSA:m:kQ:V";
6205 CONST
char *md_shortopts
= "lSA:m:k";
6208 struct option md_longopts
[] = {
6209 #define OPTION_PIC (OPTION_MD_BASE)
6210 {"pic", no_argument
, NULL
, OPTION_PIC
},
6211 #define OPTION_REGISTER_PREFIX_OPTIONAL (OPTION_MD_BASE + 1)
6212 {"register-prefix-optional", no_argument
, NULL
,
6213 OPTION_REGISTER_PREFIX_OPTIONAL
},
6214 #define OPTION_BITWISE_OR (OPTION_MD_BASE + 2)
6215 {"bitwise-or", no_argument
, NULL
, OPTION_BITWISE_OR
},
6216 {NULL
, no_argument
, NULL
, 0}
6218 size_t md_longopts_size
= sizeof(md_longopts
);
6221 md_parse_option (c
, arg
)
6227 case 'l': /* -l means keep external to 2 bit offset
6228 rather than 16 bit one */
6229 flag_short_refs
= 1;
6232 case 'S': /* -S means that jbsr's always turn into
6234 flag_long_jumps
= 1;
6240 /* intentional fall-through */
6243 if (arg
[0] == 'n' && arg
[1] == 'o' && arg
[2] == '-')
6247 const char *oarg
= arg
;
6253 if (arg
[0] == 'c' && arg
[1] == '6')
6256 for (i
= 0; i
< n_archs
; i
++)
6257 if (!strcmp (arg
, archs
[i
].name
))
6262 as_bad ("unrecognized option `%s'", oarg
);
6265 arch
= archs
[i
].arch
;
6268 else if (arch
== m68851
)
6277 if (arg
[0] == 'c' && arg
[1] == '6')
6280 for (i
= 0; i
< n_archs
; i
++)
6281 if (!strcmp (arg
, archs
[i
].name
))
6283 unsigned long arch
= archs
[i
].arch
;
6284 if (cpu_of_arch (arch
))
6285 /* It's a cpu spec. */
6287 current_architecture
&= ~m68000up
;
6288 current_architecture
|= arch
;
6290 else if (arch
== m68881
)
6292 current_architecture
|= m68881
;
6295 else if (arch
== m68851
)
6297 current_architecture
|= m68851
;
6307 as_bad ("unrecognized architecture specification `%s'", arg
);
6316 break; /* -pic, Position Independent Code */
6318 case OPTION_REGISTER_PREFIX_OPTIONAL
:
6319 flag_reg_prefix_optional
= 1;
6320 reg_prefix_optional_seen
= 1;
6323 /* -V: SVR4 argument to print version ID. */
6325 print_version_id ();
6328 /* -Qy, -Qn: SVR4 arguments controlling whether a .comment section
6329 should be emitted or not. FIXME: Not implemented. */
6333 case OPTION_BITWISE_OR
:
6338 n
= (char *) xmalloc (strlen (m68k_comment_chars
) + 1);
6340 for (s
= m68k_comment_chars
; *s
!= '\0'; s
++)
6344 m68k_comment_chars
= n
;
6356 md_show_usage (stream
)
6361 -l use 1 word for refs to undefined symbols [default 2]\n\
6362 -m68000 | -m68008 | -m68010 | -m68020 | -m68030 | -m68040 | -m68060\n\
6363 | -m68302 | -m68331 | -m68332 | -m68333 | -m68340 | -m68360\n\
6364 | -mcpu32 | -mcf5200\n\
6365 specify variant of 680X0 architecture [default 68020]\n\
6366 -m68881 | -m68882 | -mno-68881 | -mno-68882\n\
6367 target has/lacks floating-point coprocessor\n\
6368 [default yes for 68020, 68030, and cpu32]\n");
6370 -m68851 | -mno-68851\n\
6371 target has/lacks memory-management unit coprocessor\n\
6372 [default yes for 68020 and up]\n\
6373 -pic, -k generate position independent code\n\
6374 -S turn jbsr into jsr\n\
6375 --register-prefix-optional\n\
6376 recognize register names without prefix character\n\
6377 --bitwise-or do not treat `|' as a comment character\n");
6382 /* TEST2: Test md_assemble() */
6383 /* Warning, this routine probably doesn't work anymore */
6387 struct m68k_it the_ins
;
6395 if (!gets (buf
) || !*buf
)
6397 if (buf
[0] == '|' || buf
[1] == '.')
6399 for (cp
= buf
; *cp
; cp
++)
6404 memset (&the_ins
, '\0', sizeof (the_ins
));
6405 m68k_ip (&the_ins
, buf
);
6408 printf ("Error %s in %s\n", the_ins
.error
, buf
);
6412 printf ("Opcode(%d.%s): ", the_ins
.numo
, the_ins
.args
);
6413 for (n
= 0; n
< the_ins
.numo
; n
++)
6414 printf (" 0x%x", the_ins
.opcode
[n
] & 0xffff);
6416 print_the_insn (&the_ins
.opcode
[0], stdout
);
6417 (void) putchar ('\n');
6419 for (n
= 0; n
< strlen (the_ins
.args
) / 2; n
++)
6421 if (the_ins
.operands
[n
].error
)
6423 printf ("op%d Error %s in %s\n", n
, the_ins
.operands
[n
].error
, buf
);
6426 printf ("mode %d, reg %d, ", the_ins
.operands
[n
].mode
, the_ins
.operands
[n
].reg
);
6427 if (the_ins
.operands
[n
].b_const
)
6428 printf ("Constant: '%.*s', ", 1 + the_ins
.operands
[n
].e_const
- the_ins
.operands
[n
].b_const
, the_ins
.operands
[n
].b_const
);
6429 printf ("ireg %d, isiz %d, imul %d, ", the_ins
.operands
[n
].ireg
, the_ins
.operands
[n
].isiz
, the_ins
.operands
[n
].imul
);
6430 if (the_ins
.operands
[n
].b_iadd
)
6431 printf ("Iadd: '%.*s',", 1 + the_ins
.operands
[n
].e_iadd
- the_ins
.operands
[n
].b_iadd
, the_ins
.operands
[n
].b_iadd
);
6432 (void) putchar ('\n');
6444 while (*str
&& *str
!= ' ')
6446 if (str
[-1] == ':' || str
[1] == '=')
6453 /* Possible states for relaxation:
6455 0 0 branch offset byte (bra, etc)
6459 1 0 indexed offsets byte a0@(32,d4:w:1) etc
6463 2 0 two-offset index word-word a0@(32,d4)@(45) etc
6470 /* We have no need to default values of symbols. */
6474 md_undefined_symbol (name
)
6480 /* Round up a section size to the appropriate boundary. */
6482 md_section_align (segment
, size
)
6486 return size
; /* Byte alignment is fine */
6489 /* Exactly what point is a PC-relative offset relative TO?
6490 On the 68k, it is relative to the address of the first extension
6491 word. The difference between the addresses of the offset and the
6492 first extension word is stored in fx_pcrel_adjust. */
6494 md_pcrel_from (fixP
)
6499 /* Because fx_pcrel_adjust is a char, and may be unsigned, we store
6501 adjust
= fixP
->fx_pcrel_adjust
;
6504 return fixP
->fx_where
+ fixP
->fx_frag
->fr_address
- adjust
;
6507 #ifndef BFD_ASSEMBLER
6510 tc_coff_symbol_emit_hook (ignore
)
6516 tc_coff_sizemachdep (frag
)
6519 switch (frag
->fr_subtype
& 0x3)
6534 /* end of tc-m68k.c */