1 /* tc-m68k.c -- Assemble for the m68k family
2 Copyright 1987, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
23 #include "safe-ctype.h"
26 #include "dwarf2dbg.h"
27 #include "dw2gencfi.h"
29 #include "opcode/m68k.h"
30 #include "m68k-parse.h"
40 /* This string holds the chars that always start a comment. If the
41 pre-processor is disabled, these aren't very useful. The macro
42 tc_comment_chars points to this. We use this, rather than the
43 usual comment_chars, so that the --bitwise-or option will work. */
44 #if defined (TE_SVR4) || defined (TE_DELTA)
45 const char *m68k_comment_chars
= "|#";
47 const char *m68k_comment_chars
= "|";
50 /* This array holds the chars that only start a comment at the beginning of
51 a line. If the line seems to have the form '# 123 filename'
52 .line and .file directives will appear in the pre-processed output */
53 /* Note that input_file.c hand checks for '#' at the beginning of the
54 first line of the input file. This is because the compiler outputs
55 #NO_APP at the beginning of its output. */
56 /* Also note that comments like this one will always work. */
57 const char line_comment_chars
[] = "#*";
59 const char line_separator_chars
[] = ";";
61 /* Chars that can be used to separate mant from exp in floating point nums. */
62 const char EXP_CHARS
[] = "eE";
64 /* Chars that mean this number is a floating point constant, as
65 in "0f12.456" or "0d1.2345e12". */
67 const char FLT_CHARS
[] = "rRsSfFdDxXeEpP";
69 /* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
70 changed in read.c . Ideally it shouldn't have to know about it at all,
71 but nothing is ideal around here. */
73 /* Are we trying to generate PIC code? If so, absolute references
74 ought to be made into linkage table references or pc-relative
75 references. Not implemented. For ELF there are other means
76 to denote pic relocations. */
79 static int flag_short_refs
; /* -l option. */
80 static int flag_long_jumps
; /* -S option. */
81 static int flag_keep_pcrel
; /* --pcrel option. */
83 #ifdef REGISTER_PREFIX_OPTIONAL
84 int flag_reg_prefix_optional
= REGISTER_PREFIX_OPTIONAL
;
86 int flag_reg_prefix_optional
;
89 /* Whether --register-prefix-optional was used on the command line. */
90 static int reg_prefix_optional_seen
;
92 /* The floating point coprocessor to use by default. */
93 static enum m68k_register m68k_float_copnum
= COP1
;
95 /* If this is non-zero, then references to number(%pc) will be taken
96 to refer to number, rather than to %pc + number. */
97 static int m68k_abspcadd
;
99 /* If this is non-zero, then the quick forms of the move, add, and sub
100 instructions are used when possible. */
101 static int m68k_quick
= 1;
103 /* If this is non-zero, then if the size is not specified for a base
104 or outer displacement, the assembler assumes that the size should
106 static int m68k_rel32
= 1;
108 /* This is non-zero if m68k_rel32 was set from the command line. */
109 static int m68k_rel32_from_cmdline
;
111 /* The default width to use for an index register when using a base
113 static enum m68k_size m68k_index_width_default
= SIZE_LONG
;
115 /* We want to warn if any text labels are misaligned. In order to get
116 the right line number, we need to record the line number for each
120 struct label_line
*next
;
127 /* The list of labels. */
129 static struct label_line
*labels
;
131 /* The current label. */
133 static struct label_line
*current_label
;
135 /* Pointer to list holding the opcodes sorted by name. */
136 static struct m68k_opcode
const ** m68k_sorted_opcodes
;
138 /* Its an arbitrary name: This means I don't approve of it.
140 static struct obstack robyn
;
144 const char *m_operands
;
145 unsigned long m_opcode
;
149 struct m68k_incant
*m_next
;
152 #define getone(x) ((((x)->m_opcode)>>16)&0xffff)
153 #define gettwo(x) (((x)->m_opcode)&0xffff)
155 static const enum m68k_register m68000_control_regs
[] = { 0 };
156 static const enum m68k_register m68010_control_regs
[] = {
160 static const enum m68k_register m68020_control_regs
[] = {
161 SFC
, DFC
, USP
, VBR
, CACR
, CAAR
, MSP
, ISP
,
164 static const enum m68k_register m68040_control_regs
[] = {
165 SFC
, DFC
, CACR
, TC
, ITT0
, ITT1
, DTT0
, DTT1
,
166 USP
, VBR
, MSP
, ISP
, MMUSR
, URP
, SRP
,
169 static const enum m68k_register m68060_control_regs
[] = {
170 SFC
, DFC
, CACR
, TC
, ITT0
, ITT1
, DTT0
, DTT1
, BUSCR
,
171 USP
, VBR
, URP
, SRP
, PCR
,
174 static const enum m68k_register mcf_control_regs
[] = {
175 CACR
, TC
, ACR0
, ACR1
, ACR2
, ACR3
, VBR
, ROMBAR
,
176 RAMBAR0
, RAMBAR1
, MBAR
,
179 static const enum m68k_register mcf5208_control_regs
[] = {
180 CACR
, ACR0
, ACR1
, VBR
, RAMBAR1
,
183 static const enum m68k_register mcf5213_control_regs
[] = {
184 VBR
, RAMBAR
, FLASHBAR
,
187 static const enum m68k_register mcf5329_control_regs
[] = {
188 CACR
, ACR0
, ACR1
, VBR
, RAMBAR
,
191 static const enum m68k_register mcf5249_control_regs
[] = {
192 CACR
, ACR0
, ACR1
, VBR
, RAMBAR0
, RAMBAR1
, MBAR
, MBAR2
,
195 static const enum m68k_register mcf528x_control_regs
[] = {
196 CACR
, ACR0
, ACR1
, VBR
, FLASHBAR
, RAMBAR
,
199 static const enum m68k_register mcfv4e_control_regs
[] = {
200 CACR
, TC
, ITT0
, ITT1
, DTT0
, DTT1
, BUSCR
, VBR
, PC
, ROMBAR
,
201 ROMBAR1
, RAMBAR0
, RAMBAR1
, MPCR
, EDRAMBAR
, SECMBAR
, MBAR
, MBAR0
, MBAR1
,
202 PCR1U0
, PCR1L0
, PCR1U1
, PCR1L1
, PCR2U0
, PCR2L0
, PCR2U1
, PCR2L1
,
203 PCR3U0
, PCR3L0
, PCR3U1
, PCR3L1
,
206 #define cpu32_control_regs m68010_control_regs
208 static const enum m68k_register
*control_regs
;
210 /* Internal form of a 68020 instruction. */
214 const char *args
; /* List of opcode info. */
217 int numo
; /* Number of shorts in opcode. */
220 struct m68k_op operands
[6];
222 int nexp
; /* Number of exprs in use. */
223 struct m68k_exp exprs
[4];
225 int nfrag
; /* Number of frags we have to produce. */
228 int fragoff
; /* Where in the current opcode the frag ends. */
235 int nrel
; /* Num of reloc strucs in use. */
242 /* In a pc relative address the difference between the address
243 of the offset and the address that the offset is relative
244 to. This depends on the addressing mode. Basically this
245 is the value to put in the offset field to address the
246 first byte of the offset, without regarding the special
247 significance of some values (in the branch instruction, for
251 /* Whether this expression needs special pic relocation, and if
253 enum pic_relocation pic_reloc
;
256 reloc
[5]; /* Five is enough??? */
259 #define cpu_of_arch(x) ((x) & (m68000up | mcfisa_a))
260 #define float_of_arch(x) ((x) & mfloat)
261 #define mmu_of_arch(x) ((x) & mmmu)
262 #define arch_coldfire_p(x) ((x) & mcfisa_a)
263 #define arch_coldfire_fpu(x) ((x) & cfloat)
265 /* Macros for determining if cpu supports a specific addressing mode. */
266 #define HAVE_LONG_BRANCH(x) ((x) & (m68020|m68030|m68040|m68060|cpu32|mcfisa_b))
268 static struct m68k_it the_ins
; /* The instruction being assembled. */
270 #define op(ex) ((ex)->exp.X_op)
271 #define adds(ex) ((ex)->exp.X_add_symbol)
272 #define subs(ex) ((ex)->exp.X_op_symbol)
273 #define offs(ex) ((ex)->exp.X_add_number)
275 /* Macros for adding things to the m68k_it struct. */
276 #define addword(w) (the_ins.opcode[the_ins.numo++] = (w))
278 /* Like addword, but goes BEFORE general operands. */
281 insop (int w
, const struct m68k_incant
*opcode
)
284 for (z
= the_ins
.numo
; z
> opcode
->m_codenum
; --z
)
285 the_ins
.opcode
[z
] = the_ins
.opcode
[z
- 1];
286 for (z
= 0; z
< the_ins
.nrel
; z
++)
287 the_ins
.reloc
[z
].n
+= 2;
288 for (z
= 0; z
< the_ins
.nfrag
; z
++)
289 the_ins
.fragb
[z
].fragoff
++;
290 the_ins
.opcode
[opcode
->m_codenum
] = w
;
294 /* The numo+1 kludge is so we can hit the low order byte of the prev word.
297 add_fix (int width
, struct m68k_exp
*exp
, int pc_rel
, int pc_fix
)
299 the_ins
.reloc
[the_ins
.nrel
].n
= (width
== 'B' || width
== '3'
300 ? the_ins
.numo
* 2 - 1
302 ? the_ins
.numo
* 2 + 1
303 : the_ins
.numo
* 2));
304 the_ins
.reloc
[the_ins
.nrel
].exp
= exp
->exp
;
305 the_ins
.reloc
[the_ins
.nrel
].wid
= width
;
306 the_ins
.reloc
[the_ins
.nrel
].pcrel_fix
= pc_fix
;
308 the_ins
.reloc
[the_ins
.nrel
].pic_reloc
= exp
->pic_reloc
;
310 the_ins
.reloc
[the_ins
.nrel
++].pcrel
= pc_rel
;
313 /* Cause an extra frag to be generated here, inserting up to 10 bytes
314 (that value is chosen in the frag_var call in md_assemble). TYPE
315 is the subtype of the frag to be generated; its primary type is
316 rs_machine_dependent.
318 The TYPE parameter is also used by md_convert_frag_1 and
319 md_estimate_size_before_relax. The appropriate type of fixup will
320 be emitted by md_convert_frag_1.
322 ADD becomes the FR_SYMBOL field of the frag, and OFF the FR_OFFSET. */
324 add_frag (symbolS
*add
, offsetT off
, int type
)
326 the_ins
.fragb
[the_ins
.nfrag
].fragoff
= the_ins
.numo
;
327 the_ins
.fragb
[the_ins
.nfrag
].fadd
= add
;
328 the_ins
.fragb
[the_ins
.nfrag
].foff
= off
;
329 the_ins
.fragb
[the_ins
.nfrag
++].fragty
= type
;
333 (op (ex) != O_constant && op (ex) != O_big)
335 static char *crack_operand (char *str
, struct m68k_op
*opP
);
336 static int get_num (struct m68k_exp
*exp
, int ok
);
337 static int reverse_16_bits (int in
);
338 static int reverse_8_bits (int in
);
339 static void install_gen_operand (int mode
, int val
);
340 static void install_operand (int mode
, int val
);
341 static void s_bss (int);
342 static void s_data1 (int);
343 static void s_data2 (int);
344 static void s_even (int);
345 static void s_proc (int);
346 static void s_chip (int);
347 static void s_fopt (int);
348 static void s_opt (int);
349 static void s_reg (int);
350 static void s_restore (int);
351 static void s_save (int);
352 static void s_mri_if (int);
353 static void s_mri_else (int);
354 static void s_mri_endi (int);
355 static void s_mri_break (int);
356 static void s_mri_next (int);
357 static void s_mri_for (int);
358 static void s_mri_endf (int);
359 static void s_mri_repeat (int);
360 static void s_mri_until (int);
361 static void s_mri_while (int);
362 static void s_mri_endw (int);
363 static void s_m68k_cpu (int);
364 static void s_m68k_arch (int);
368 unsigned long arch
; /* Architecture features. */
369 unsigned long chip
; /* Specific chip */
370 const char *name
; /* Name */
371 int alias
; /* Alias for a cannonical name. If 1, then
372 succeeds canonical name, if -1 then
373 succeeds canonical name, if <-1 ||>1 this is a
374 deprecated name, and the next/previous name
378 /* We hold flags for features explicitly enabled and explicitly
380 static int current_architecture
;
381 static int not_current_architecture
;
382 static int current_chip
;
383 static const struct m68k_cpu
*selected_arch
;
384 static const struct m68k_cpu
*selected_cpu
;
385 static int initialized
;
387 /* Architecture models. */
388 static const struct m68k_cpu m68k_archs
[] =
390 {m68000
, cpu_m68000
, "68000", 0},
391 {m68010
, cpu_m68010
, "68010", 0},
392 {m68020
|m68881
|m68851
, cpu_m68020
, "68020", 0},
393 {m68030
|m68881
|m68851
, cpu_m68030
, "68030", 0},
394 {m68040
, cpu_m68040
, "68040", 0},
395 {m68060
, cpu_m68060
, "68060", 0},
396 {cpu32
|m68881
, cpu_cpu32
, "cpu32", 0},
397 {mcfisa_a
|mcfhwdiv
, 0, "isaa", 0},
398 {mcfisa_a
|mcfhwdiv
|mcfisa_aa
|mcfusp
, 0, "isaaplus", 0},
399 {mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfusp
, 0, "isab", 0},
400 {mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfemac
|mcfusp
|cfloat
,
401 cpu_cf547x
, "cfv4e", 0},
405 /* Architecture extensions, here 'alias' -1 for m68k, +1 for cf and 0
407 static const struct m68k_cpu m68k_extensions
[] =
409 {m68851
, 0, "68851", -1},
410 {m68881
, 0, "68881", -1},
411 {m68881
, 0, "68882", -1},
413 {cfloat
|m68881
, 0, "float", 0},
415 {mcfhwdiv
, 0, "div", 1},
416 {mcfusp
, 0, "usp", 1},
417 {mcfmac
, 0, "mac", 1},
418 {mcfemac
, 0, "emac", 1},
424 static const struct m68k_cpu m68k_cpus
[] =
426 { m68000
, cpu_m68000
, "68000", 0},
427 { m68010
, cpu_m68010
, "68010", 0},
428 { m68020
|m68881
|m68851
, cpu_m68020
, "68020", 0},
429 { m68030
|m68881
|m68851
, cpu_m68030
, "68030", 0},
430 { m68040
, cpu_m68040
, "68040", 0},
431 { m68060
, cpu_m68060
, "68060", 0},
432 { cpu32
|m68881
, cpu_cpu32
, "cpu32", 0},
433 { mcfisa_a
, cpu_cf5200
, "5200", 0},
434 { mcfisa_a
|mcfhwdiv
|mcfmac
, cpu_cf5206e
, "5206e", 0},
435 { mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfmac
|mcfusp
, cpu_cf5208
, "5208", 0},
436 { mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfmac
|mcfusp
, cpu_cf5213
, "5213", 0},
437 { mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
,cpu_cf521x
, "521x", 0},
438 { mcfisa_a
|mcfhwdiv
|mcfemac
, cpu_cf5249
, "5249", 0},
439 { mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
,cpu_cf528x
, "528x", 0},
440 { mcfisa_a
|mcfhwdiv
|mcfmac
, cpu_cf5307
, "5307", 0},
441 { mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, cpu_cf5329
, "5329", 0},
442 { mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfmac
, cpu_cf5407
, "5407",0},
443 { mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfemac
|mcfusp
|cfloat
,
444 cpu_cf547x
, "547x", 0},
445 { mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfemac
|mcfusp
|cfloat
,
446 cpu_cf548x
, "548x", 0},
447 /* Aliases (effectively, so far as gas is concerned) for the above
449 { m68020
|m68881
|m68851
, cpu_m68020
, "68k", 1},
450 { m68000
, cpu_m68000
, "68008", 1},
451 { m68000
, cpu_m68000
, "68302", 1},
452 { m68000
, cpu_m68000
, "68306", 1},
453 { m68000
, cpu_m68000
, "68307", 1},
454 { m68000
, cpu_m68000
, "68322", 1},
455 { m68000
, cpu_m68000
, "68356", 1},
456 { m68000
, cpu_m68000
, "68ec000", 1},
457 { m68000
, cpu_m68000
, "68hc000", 1},
458 { m68000
, cpu_m68000
, "68hc001", 1},
459 { m68020
|m68881
|m68851
, cpu_m68020
, "68ec020", 1},
460 { m68030
|m68881
|m68851
, cpu_m68030
, "68ec030", 1},
461 { m68040
, cpu_m68040
, "68ec040", 1},
462 { m68060
, cpu_m68060
, "68ec060", 1},
463 { cpu32
|m68881
, cpu_cpu32
, "68330", 1},
464 { cpu32
|m68881
, cpu_cpu32
, "68331", 1},
465 { cpu32
|m68881
, cpu_cpu32
, "68332", 1},
466 { cpu32
|m68881
, cpu_cpu32
, "68333", 1},
467 { cpu32
|m68881
, cpu_cpu32
, "68334", 1},
468 { cpu32
|m68881
, cpu_cpu32
, "68336", 1},
469 { cpu32
|m68881
, cpu_cpu32
, "68340", 1},
470 { cpu32
|m68881
, cpu_cpu32
, "68341", 1},
471 { cpu32
|m68881
, cpu_cpu32
, "68349", 1},
472 { cpu32
|m68881
, cpu_cpu32
, "68360", 1},
473 { mcfisa_a
, cpu_cf5200
, "5202", 1},
474 { mcfisa_a
, cpu_cf5200
, "5204", 1},
475 { mcfisa_a
, cpu_cf5200
, "5206", 1},
476 { mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfmac
|mcfusp
, cpu_cf5208
, "5207", 1},
477 { mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfmac
|mcfusp
, cpu_cf5213
, "5211", 1},
478 { mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfmac
|mcfusp
, cpu_cf5213
, "5212", 1},
479 { mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, cpu_cf521x
, "5214", 1},
480 { mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, cpu_cf521x
, "5216", 1},
481 { mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, cpu_cf5329
, "5327", 1},
482 { mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, cpu_cf5329
, "5328", 1},
483 { mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, cpu_cf528x
, "5280", 1},
484 { mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, cpu_cf528x
, "5281", 1},
485 { mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfemac
|mcfusp
, cpu_cf528x
, "5282", 1},
486 { mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfmac
, cpu_cf5407
, "cfv4", 1 },
487 { mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfemac
|mcfusp
|cfloat
,
488 cpu_cf547x
, "cfv4e", 1 },
489 { mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfemac
|mcfusp
|cfloat
,
490 cpu_cf547x
, "5470", 1 },
491 { mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfemac
|mcfusp
|cfloat
,
492 cpu_cf547x
, "5471", 1 },
493 { mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfemac
|mcfusp
|cfloat
,
494 cpu_cf547x
, "5472", 1 },
495 { mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfemac
|mcfusp
|cfloat
,
496 cpu_cf547x
, "5473", 1 },
497 { mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfemac
|mcfusp
|cfloat
,
498 cpu_cf547x
, "5474", 1 },
499 { mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfemac
|mcfusp
|cfloat
,
500 cpu_cf547x
, "5475", 1 },
501 { mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfemac
|mcfusp
|cfloat
,
502 cpu_cf548x
, "5480", 1 },
503 { mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfemac
|mcfusp
|cfloat
,
504 cpu_cf548x
, "5481", 1 },
505 { mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfemac
|mcfusp
|cfloat
,
506 cpu_cf548x
, "5482", 1 },
507 { mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfemac
|mcfusp
|cfloat
,
508 cpu_cf548x
, "5483", 1 },
509 { mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfemac
|mcfusp
|cfloat
,
510 cpu_cf548x
, "5484", 1 },
511 { mcfisa_a
|mcfhwdiv
|mcfisa_b
|mcfemac
|mcfusp
|cfloat
,
512 cpu_cf548x
, "5485", 1 },
516 #define CPU_ALLOW_MC 1
517 #define CPU_ALLOW_NEGATION 4
519 static const struct m68k_cpu
*m68k_lookup_cpu
520 (const char *, const struct m68k_cpu
*, int, int *);
521 static int m68k_set_arch (const char *, int, int);
522 static int m68k_set_cpu (const char *, int, int);
523 static int m68k_set_extension (const char *, int, int);
524 static void m68k_init_arch (void);
526 /* This is the assembler relaxation table for m68k. m68k is a rich CISC
527 architecture and we have a lot of relaxation modes. */
529 /* Macros used in the relaxation code. */
530 #define TAB(x,y) (((x) << 2) + (y))
531 #define TABTYPE(x) ((x) >> 2)
533 /* Relaxation states. */
539 /* Here are all the relaxation modes we support. First we can relax ordinary
540 branches. On 68020 and higher and on CPU32 all branch instructions take
541 three forms, so on these CPUs all branches always remain as such. When we
542 have to expand to the LONG form on a 68000, though, we substitute an
543 absolute jump instead. This is a direct replacement for unconditional
544 branches and a branch over a jump for conditional branches. However, if the
545 user requires PIC and disables this with --pcrel, we can only relax between
546 BYTE and SHORT forms, punting if that isn't enough. This gives us four
547 different relaxation modes for branches: */
549 #define BRANCHBWL 0 /* Branch byte, word, or long. */
550 #define BRABSJUNC 1 /* Absolute jump for LONG, unconditional. */
551 #define BRABSJCOND 2 /* Absolute jump for LONG, conditional. */
552 #define BRANCHBW 3 /* Branch byte or word. */
554 /* We also relax coprocessor branches and DBcc's. All CPUs that support
555 coprocessor branches support them in word and long forms, so we have only
556 one relaxation mode for them. DBcc's are word only on all CPUs. We can
557 relax them to the LONG form with a branch-around sequence. This sequence
558 can use a long branch (if available) or an absolute jump (if acceptable).
559 This gives us two relaxation modes. If long branches are not available and
560 absolute jumps are not acceptable, we don't relax DBcc's. */
562 #define FBRANCH 4 /* Coprocessor branch. */
563 #define DBCCLBR 5 /* DBcc relaxable with a long branch. */
564 #define DBCCABSJ 6 /* DBcc relaxable with an absolute jump. */
566 /* That's all for instruction relaxation. However, we also relax PC-relative
567 operands. Specifically, we have three operand relaxation modes. On the
568 68000 PC-relative operands can only be 16-bit, but on 68020 and higher and
569 on CPU32 they may be 16-bit or 32-bit. For the latter we relax between the
570 two. Also PC+displacement+index operands in their simple form (with a non-
571 suppressed index without memory indirection) are supported on all CPUs, but
572 on the 68000 the displacement can be 8-bit only, whereas on 68020 and higher
573 and on CPU32 we relax it to SHORT and LONG forms as well using the extended
574 form of the PC+displacement+index operand. Finally, some absolute operands
575 can be relaxed down to 16-bit PC-relative. */
577 #define PCREL1632 7 /* 16-bit or 32-bit PC-relative. */
578 #define PCINDEX 8 /* PC + displacement + index. */
579 #define ABSTOPCREL 9 /* Absolute relax down to 16-bit PC-relative. */
581 /* Note that calls to frag_var need to specify the maximum expansion
582 needed; this is currently 10 bytes for DBCC. */
585 How far Forward this mode will reach:
586 How far Backward this mode will reach:
587 How many bytes this mode will add to the size of the frag
588 Which mode to go to if the offset won't fit in this one
590 Please check tc-m68k.h:md_prepare_relax_scan if changing this table. */
591 relax_typeS md_relax_table
[] =
593 { 127, -128, 0, TAB (BRANCHBWL
, SHORT
) },
594 { 32767, -32768, 2, TAB (BRANCHBWL
, LONG
) },
598 { 127, -128, 0, TAB (BRABSJUNC
, SHORT
) },
599 { 32767, -32768, 2, TAB (BRABSJUNC
, LONG
) },
603 { 127, -128, 0, TAB (BRABSJCOND
, SHORT
) },
604 { 32767, -32768, 2, TAB (BRABSJCOND
, LONG
) },
608 { 127, -128, 0, TAB (BRANCHBW
, SHORT
) },
613 { 1, 1, 0, 0 }, /* FBRANCH doesn't come BYTE. */
614 { 32767, -32768, 2, TAB (FBRANCH
, LONG
) },
618 { 1, 1, 0, 0 }, /* DBCC doesn't come BYTE. */
619 { 32767, -32768, 2, TAB (DBCCLBR
, LONG
) },
623 { 1, 1, 0, 0 }, /* DBCC doesn't come BYTE. */
624 { 32767, -32768, 2, TAB (DBCCABSJ
, LONG
) },
628 { 1, 1, 0, 0 }, /* PCREL1632 doesn't come BYTE. */
629 { 32767, -32768, 2, TAB (PCREL1632
, LONG
) },
633 { 125, -130, 0, TAB (PCINDEX
, SHORT
) },
634 { 32765, -32770, 2, TAB (PCINDEX
, LONG
) },
638 { 1, 1, 0, 0 }, /* ABSTOPCREL doesn't come BYTE. */
639 { 32767, -32768, 2, TAB (ABSTOPCREL
, LONG
) },
644 /* These are the machine dependent pseudo-ops. These are included so
645 the assembler can work on the output from the SUN C compiler, which
648 /* This table describes all the machine specific pseudo-ops the assembler
649 has to support. The fields are:
650 pseudo-op name without dot
651 function to call to execute this pseudo-op
652 Integer arg to pass to the function. */
653 const pseudo_typeS md_pseudo_table
[] =
655 {"data1", s_data1
, 0},
656 {"data2", s_data2
, 0},
659 {"skip", s_space
, 0},
661 #if defined (TE_SUN3) || defined (OBJ_ELF)
662 {"align", s_align_bytes
, 0},
665 {"swbeg", s_ignore
, 0},
667 {"extend", float_cons
, 'x'},
668 {"ldouble", float_cons
, 'x'},
670 {"arch", s_m68k_arch
, 0},
671 {"cpu", s_m68k_cpu
, 0},
673 /* The following pseudo-ops are supported for MRI compatibility. */
675 {"comline", s_space
, 1},
677 {"mask2", s_ignore
, 0},
680 {"restore", s_restore
, 0},
684 {"if.b", s_mri_if
, 'b'},
685 {"if.w", s_mri_if
, 'w'},
686 {"if.l", s_mri_if
, 'l'},
687 {"else", s_mri_else
, 0},
688 {"else.s", s_mri_else
, 's'},
689 {"else.l", s_mri_else
, 'l'},
690 {"endi", s_mri_endi
, 0},
691 {"break", s_mri_break
, 0},
692 {"break.s", s_mri_break
, 's'},
693 {"break.l", s_mri_break
, 'l'},
694 {"next", s_mri_next
, 0},
695 {"next.s", s_mri_next
, 's'},
696 {"next.l", s_mri_next
, 'l'},
697 {"for", s_mri_for
, 0},
698 {"for.b", s_mri_for
, 'b'},
699 {"for.w", s_mri_for
, 'w'},
700 {"for.l", s_mri_for
, 'l'},
701 {"endf", s_mri_endf
, 0},
702 {"repeat", s_mri_repeat
, 0},
703 {"until", s_mri_until
, 0},
704 {"until.b", s_mri_until
, 'b'},
705 {"until.w", s_mri_until
, 'w'},
706 {"until.l", s_mri_until
, 'l'},
707 {"while", s_mri_while
, 0},
708 {"while.b", s_mri_while
, 'b'},
709 {"while.w", s_mri_while
, 'w'},
710 {"while.l", s_mri_while
, 'l'},
711 {"endw", s_mri_endw
, 0},
716 /* The mote pseudo ops are put into the opcode table, since they
717 don't start with a . they look like opcodes to gas. */
719 const pseudo_typeS mote_pseudo_table
[] =
732 {"xdef", s_globl
, 0},
734 {"align", s_align_bytes
, 0},
736 {"align", s_align_ptwo
, 0},
739 {"sect", obj_coff_section
, 0},
740 {"section", obj_coff_section
, 0},
745 /* Truncate and sign-extend at 32 bits, so that building on a 64-bit host
746 gives identical results to a 32-bit host. */
747 #define TRUNC(X) ((valueT) (X) & 0xffffffff)
748 #define SEXT(X) ((TRUNC (X) ^ 0x80000000) - 0x80000000)
750 #define issbyte(x) ((valueT) SEXT (x) + 0x80 < 0x100)
751 #define isubyte(x) ((valueT) TRUNC (x) < 0x100)
752 #define issword(x) ((valueT) SEXT (x) + 0x8000 < 0x10000)
753 #define isuword(x) ((valueT) TRUNC (x) < 0x10000)
755 #define isbyte(x) ((valueT) SEXT (x) + 0xff < 0x1ff)
756 #define isword(x) ((valueT) SEXT (x) + 0xffff < 0x1ffff)
757 #define islong(x) (1)
759 static char notend_table
[256];
760 static char alt_notend_table
[256];
762 (! (notend_table[(unsigned char) *s] \
764 && alt_notend_table[(unsigned char) s[1]])))
766 /* Return a human readable string holding the list of chips that are
767 valid for a particular architecture, suppressing aliases (unless
768 there is only one of them). */
771 find_cf_chip (int architecture
)
773 static char buf
[1024];
774 int i
, j
, n_chips
, n_alias
;
778 cp
= buf
+ strlen (buf
);
780 for (i
= 0, n_chips
= 0, n_alias
= 0; m68k_cpus
[i
].name
; ++i
)
781 if (m68k_cpus
[i
].arch
& architecture
)
784 if (m68k_cpus
[i
].alias
)
789 as_fatal (_("no matching ColdFire architectures found"));
794 for (i
= 0, j
= 0; m68k_cpus
[i
].name
&& j
< n_chips
; ++i
)
795 if (m68k_cpus
[i
].arch
& architecture
)
799 if ((j
== n_chips
- 1 && !(n_alias
> 1)) || ! n_alias
)
803 strncpy (cp
, _(" or "), (sizeof (buf
) - (cp
- buf
)));
808 strncpy (cp
, _(", or "), (sizeof (buf
) - (cp
- buf
)));
814 strncpy (cp
, ", ", (sizeof (buf
) - (cp
- buf
)));
818 strncpy (cp
, m68k_cpus
[i
].name
, (sizeof (buf
) - (cp
- buf
)));
825 strncpy (cp
, _(", or aliases"), (sizeof (buf
) - (cp
- buf
)));
829 strncpy (cp
, ")", (sizeof (buf
) - (cp
- buf
)));
836 /* Return zero if the reference to SYMBOL from within the same segment may
839 /* On an ELF system, we can't relax an externally visible symbol,
840 because it may be overridden by a shared library. However, if
841 TARGET_OS is "elf", then we presume that we are assembling for an
842 embedded system, in which case we don't have to worry about shared
843 libraries, and we can relax any external sym. */
845 #define relaxable_symbol(symbol) \
846 (!((S_IS_EXTERNAL (symbol) && EXTERN_FORCE_RELOC) \
847 || S_IS_WEAK (symbol)))
849 /* Compute the relocation code for a fixup of SIZE bytes, using pc
850 relative relocation if PCREL is non-zero. PIC says whether a special
851 pic relocation was requested. */
853 static bfd_reloc_code_real_type
854 get_reloc_code (int size
, int pcrel
, enum pic_relocation pic
)
862 return BFD_RELOC_8_GOT_PCREL
;
864 return BFD_RELOC_16_GOT_PCREL
;
866 return BFD_RELOC_32_GOT_PCREL
;
874 return BFD_RELOC_8_GOTOFF
;
876 return BFD_RELOC_16_GOTOFF
;
878 return BFD_RELOC_32_GOTOFF
;
886 return BFD_RELOC_8_PLT_PCREL
;
888 return BFD_RELOC_16_PLT_PCREL
;
890 return BFD_RELOC_32_PLT_PCREL
;
898 return BFD_RELOC_8_PLTOFF
;
900 return BFD_RELOC_16_PLTOFF
;
902 return BFD_RELOC_32_PLTOFF
;
912 return BFD_RELOC_8_PCREL
;
914 return BFD_RELOC_16_PCREL
;
916 return BFD_RELOC_32_PCREL
;
936 as_bad (_("Can not do %d byte pc-relative relocation"), size
);
938 as_bad (_("Can not do %d byte pc-relative pic relocation"), size
);
943 as_bad (_("Can not do %d byte relocation"), size
);
945 as_bad (_("Can not do %d byte pic relocation"), size
);
948 return BFD_RELOC_NONE
;
951 /* Here we decide which fixups can be adjusted to make them relative
952 to the beginning of the section instead of the symbol. Basically
953 we need to make sure that the dynamic relocations are done
954 correctly, so in some cases we force the original symbol to be
957 tc_m68k_fix_adjustable (fixS
*fixP
)
959 /* Adjust_reloc_syms doesn't know about the GOT. */
960 switch (fixP
->fx_r_type
)
962 case BFD_RELOC_8_GOT_PCREL
:
963 case BFD_RELOC_16_GOT_PCREL
:
964 case BFD_RELOC_32_GOT_PCREL
:
965 case BFD_RELOC_8_GOTOFF
:
966 case BFD_RELOC_16_GOTOFF
:
967 case BFD_RELOC_32_GOTOFF
:
968 case BFD_RELOC_8_PLT_PCREL
:
969 case BFD_RELOC_16_PLT_PCREL
:
970 case BFD_RELOC_32_PLT_PCREL
:
971 case BFD_RELOC_8_PLTOFF
:
972 case BFD_RELOC_16_PLTOFF
:
973 case BFD_RELOC_32_PLTOFF
:
976 case BFD_RELOC_VTABLE_INHERIT
:
977 case BFD_RELOC_VTABLE_ENTRY
:
987 #define get_reloc_code(SIZE,PCREL,OTHER) NO_RELOC
989 #define relaxable_symbol(symbol) 1
994 tc_gen_reloc (asection
*section ATTRIBUTE_UNUSED
, fixS
*fixp
)
997 bfd_reloc_code_real_type code
;
999 /* If the tcbit is set, then this was a fixup of a negative value
1000 that was never resolved. We do not have a reloc to handle this,
1001 so just return. We assume that other code will have detected this
1002 situation and produced a helpful error message, so we just tell the
1003 user that the reloc cannot be produced. */
1007 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1008 _("Unable to produce reloc against symbol '%s'"),
1009 S_GET_NAME (fixp
->fx_addsy
));
1013 if (fixp
->fx_r_type
!= BFD_RELOC_NONE
)
1015 code
= fixp
->fx_r_type
;
1017 /* Since DIFF_EXPR_OK is defined in tc-m68k.h, it is possible
1018 that fixup_segment converted a non-PC relative reloc into a
1019 PC relative reloc. In such a case, we need to convert the
1026 code
= BFD_RELOC_8_PCREL
;
1029 code
= BFD_RELOC_16_PCREL
;
1032 code
= BFD_RELOC_32_PCREL
;
1034 case BFD_RELOC_8_PCREL
:
1035 case BFD_RELOC_16_PCREL
:
1036 case BFD_RELOC_32_PCREL
:
1037 case BFD_RELOC_8_GOT_PCREL
:
1038 case BFD_RELOC_16_GOT_PCREL
:
1039 case BFD_RELOC_32_GOT_PCREL
:
1040 case BFD_RELOC_8_GOTOFF
:
1041 case BFD_RELOC_16_GOTOFF
:
1042 case BFD_RELOC_32_GOTOFF
:
1043 case BFD_RELOC_8_PLT_PCREL
:
1044 case BFD_RELOC_16_PLT_PCREL
:
1045 case BFD_RELOC_32_PLT_PCREL
:
1046 case BFD_RELOC_8_PLTOFF
:
1047 case BFD_RELOC_16_PLTOFF
:
1048 case BFD_RELOC_32_PLTOFF
:
1051 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1052 _("Cannot make %s relocation PC relative"),
1053 bfd_get_reloc_code_name (code
));
1059 #define F(SZ,PCREL) (((SZ) << 1) + (PCREL))
1060 switch (F (fixp
->fx_size
, fixp
->fx_pcrel
))
1062 #define MAP(SZ,PCREL,TYPE) case F(SZ,PCREL): code = (TYPE); break
1063 MAP (1, 0, BFD_RELOC_8
);
1064 MAP (2, 0, BFD_RELOC_16
);
1065 MAP (4, 0, BFD_RELOC_32
);
1066 MAP (1, 1, BFD_RELOC_8_PCREL
);
1067 MAP (2, 1, BFD_RELOC_16_PCREL
);
1068 MAP (4, 1, BFD_RELOC_32_PCREL
);
1076 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
1077 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
1078 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
1079 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
1082 reloc
->addend
= fixp
->fx_addnumber
;
1086 if (!fixp
->fx_pcrel
)
1087 reloc
->addend
= fixp
->fx_addnumber
;
1089 reloc
->addend
= (section
->vma
1090 /* Explicit sign extension in case char is
1092 + ((fixp
->fx_pcrel_adjust
& 0xff) ^ 0x80) - 0x80
1093 + fixp
->fx_addnumber
1094 + md_pcrel_from (fixp
));
1097 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
1098 assert (reloc
->howto
!= 0);
1103 /* Handle of the OPCODE hash table. NULL means any use before
1104 m68k_ip_begin() will crash. */
1105 static struct hash_control
*op_hash
;
1107 /* Assemble an m68k instruction. */
1110 m68k_ip (char *instring
)
1113 register struct m68k_op
*opP
;
1114 register const struct m68k_incant
*opcode
;
1115 register const char *s
;
1116 register int tmpreg
= 0, baseo
= 0, outro
= 0, nextword
;
1117 char *pdot
, *pdotmove
;
1118 enum m68k_size siz1
, siz2
;
1122 struct m68k_op operands_backup
[6];
1123 LITTLENUM_TYPE words
[6];
1124 LITTLENUM_TYPE
*wordp
;
1125 unsigned long ok_arch
= 0;
1127 if (*instring
== ' ')
1128 instring
++; /* Skip leading whitespace. */
1130 /* Scan up to end of operation-code, which MUST end in end-of-string
1131 or exactly 1 space. */
1133 for (p
= instring
; *p
!= '\0'; p
++)
1143 the_ins
.error
= _("No operator");
1147 /* p now points to the end of the opcode name, probably whitespace.
1148 Make sure the name is null terminated by clobbering the
1149 whitespace, look it up in the hash table, then fix it back.
1150 Remove a dot, first, since the opcode tables have none. */
1153 for (pdotmove
= pdot
; pdotmove
< p
; pdotmove
++)
1154 *pdotmove
= pdotmove
[1];
1160 opcode
= (const struct m68k_incant
*) hash_find (op_hash
, instring
);
1165 for (pdotmove
= p
; pdotmove
> pdot
; pdotmove
--)
1166 *pdotmove
= pdotmove
[-1];
1173 the_ins
.error
= _("Unknown operator");
1177 /* Found a legitimate opcode, start matching operands. */
1181 if (opcode
->m_operands
== 0)
1183 char *old
= input_line_pointer
;
1185 input_line_pointer
= p
;
1186 /* Ahh - it's a motorola style psuedo op. */
1187 mote_pseudo_table
[opcode
->m_opnum
].poc_handler
1188 (mote_pseudo_table
[opcode
->m_opnum
].poc_val
);
1189 input_line_pointer
= old
;
1195 if (flag_mri
&& opcode
->m_opnum
== 0)
1197 /* In MRI mode, random garbage is allowed after an instruction
1198 which accepts no operands. */
1199 the_ins
.args
= opcode
->m_operands
;
1200 the_ins
.numargs
= opcode
->m_opnum
;
1201 the_ins
.numo
= opcode
->m_codenum
;
1202 the_ins
.opcode
[0] = getone (opcode
);
1203 the_ins
.opcode
[1] = gettwo (opcode
);
1207 for (opP
= &the_ins
.operands
[0]; *p
; opP
++)
1209 p
= crack_operand (p
, opP
);
1213 the_ins
.error
= opP
->error
;
1218 opsfound
= opP
- &the_ins
.operands
[0];
1220 /* This ugly hack is to support the floating pt opcodes in their
1221 standard form. Essentially, we fake a first enty of type COP#1 */
1222 if (opcode
->m_operands
[0] == 'I')
1226 for (n
= opsfound
; n
> 0; --n
)
1227 the_ins
.operands
[n
] = the_ins
.operands
[n
- 1];
1229 memset (&the_ins
.operands
[0], '\0', sizeof (the_ins
.operands
[0]));
1230 the_ins
.operands
[0].mode
= CONTROL
;
1231 the_ins
.operands
[0].reg
= m68k_float_copnum
;
1235 /* We've got the operands. Find an opcode that'll accept them. */
1238 /* If we didn't get the right number of ops, or we have no
1239 common model with this pattern then reject this pattern. */
1241 ok_arch
|= opcode
->m_arch
;
1242 if (opsfound
!= opcode
->m_opnum
1243 || ((opcode
->m_arch
& current_architecture
) == 0))
1249 /* Make a copy of the operands of this insn so that
1250 we can modify them safely, should we want to. */
1251 assert (opsfound
<= (int) ARRAY_SIZE (operands_backup
));
1252 for (i
= 0; i
< opsfound
; i
++)
1253 operands_backup
[i
] = the_ins
.operands
[i
];
1255 for (s
= opcode
->m_operands
, opP
= &operands_backup
[0];
1259 /* Warning: this switch is huge! */
1260 /* I've tried to organize the cases into this order:
1261 non-alpha first, then alpha by letter. Lower-case
1262 goes directly before uppercase counterpart. */
1263 /* Code with multiple case ...: gets sorted by the lowest
1264 case ... it belongs to. I hope this makes sense. */
1370 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
1387 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
1406 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
1416 if (opP
->mode
!= IMMED
)
1418 else if (s
[1] == 'b'
1419 && ! isvar (&opP
->disp
)
1420 && (opP
->disp
.exp
.X_op
!= O_constant
1421 || ! isbyte (opP
->disp
.exp
.X_add_number
)))
1423 else if (s
[1] == 'B'
1424 && ! isvar (&opP
->disp
)
1425 && (opP
->disp
.exp
.X_op
!= O_constant
1426 || ! issbyte (opP
->disp
.exp
.X_add_number
)))
1428 else if (s
[1] == 'w'
1429 && ! isvar (&opP
->disp
)
1430 && (opP
->disp
.exp
.X_op
!= O_constant
1431 || ! isword (opP
->disp
.exp
.X_add_number
)))
1433 else if (s
[1] == 'W'
1434 && ! isvar (&opP
->disp
)
1435 && (opP
->disp
.exp
.X_op
!= O_constant
1436 || ! issword (opP
->disp
.exp
.X_add_number
)))
1442 if (opP
->mode
!= IMMED
)
1447 if (opP
->mode
== AREG
1448 || opP
->mode
== CONTROL
1449 || opP
->mode
== FPREG
1450 || opP
->mode
== IMMED
1451 || opP
->mode
== REGLST
1452 || (opP
->mode
!= ABSL
1454 || opP
->reg
== ZPC
)))
1459 if (opP
->mode
== CONTROL
1460 || opP
->mode
== FPREG
1461 || opP
->mode
== REGLST
1462 || opP
->mode
== IMMED
1463 || (opP
->mode
!= ABSL
1465 || opP
->reg
== ZPC
)))
1493 if (opP
->mode
== CONTROL
1494 || opP
->mode
== FPREG
1495 || opP
->mode
== REGLST
)
1500 if (opP
->mode
!= AINC
)
1505 if (opP
->mode
!= ADEC
)
1555 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
1576 case '~': /* For now! (JF FOO is this right?) */
1598 if (opP
->mode
!= CONTROL
1599 || (opP
->reg
!= TT0
&& opP
->reg
!= TT1
))
1604 if (opP
->mode
!= AREG
)
1609 if (opP
->mode
!= AINDR
)
1614 if (opP
->mode
!= AINDR
&& opP
->mode
!= AINC
&& opP
->mode
!= ADEC
1615 && (opP
->mode
!= DISP
1617 || opP
->reg
> ADDR7
))
1622 if (opP
->mode
!= ABSL
1624 && strncmp (instring
, "jbsr", 4) == 0))
1647 if (opP
->mode
!= CONTROL
|| opP
->reg
!= CCR
)
1652 if (opP
->mode
!= DISP
1654 || opP
->reg
> ADDR7
)
1659 if (opP
->mode
!= DREG
)
1664 if (opP
->reg
!= ACC
)
1669 if (opP
->reg
!= ACC
&& opP
->reg
!= ACC1
1670 && opP
->reg
!= ACC2
&& opP
->reg
!= ACC3
)
1675 if (opP
->mode
!= FPREG
)
1680 if (opP
->reg
!= MACSR
)
1685 if (opP
->reg
!= ACCEXT01
&& opP
->reg
!= ACCEXT23
)
1690 if (opP
->reg
!= MASK
)
1695 if (opP
->mode
!= CONTROL
1702 if (opP
->mode
!= LSH
&& opP
->mode
!= RSH
)
1707 if (opP
->mode
!= CONTROL
1709 || opP
->reg
> last_movec_reg
1714 const enum m68k_register
*rp
;
1716 for (rp
= control_regs
; *rp
; rp
++)
1717 if (*rp
== opP
->reg
)
1725 if (opP
->mode
!= IMMED
)
1731 if (opP
->mode
== DREG
1732 || opP
->mode
== AREG
1733 || opP
->mode
== FPREG
)
1742 opP
->mask
= 1 << (opP
->reg
- DATA0
);
1745 opP
->mask
= 1 << (opP
->reg
- ADDR0
+ 8);
1748 opP
->mask
= 1 << (opP
->reg
- FP0
+ 16);
1756 else if (opP
->mode
== CONTROL
)
1765 opP
->mask
= 1 << 24;
1768 opP
->mask
= 1 << 25;
1771 opP
->mask
= 1 << 26;
1780 else if (opP
->mode
!= REGLST
)
1782 else if (s
[1] == '8' && (opP
->mask
& 0x0ffffff) != 0)
1784 else if (s
[1] == '3' && (opP
->mask
& 0x7000000) != 0)
1789 if (opP
->mode
!= IMMED
)
1791 else if (opP
->disp
.exp
.X_op
!= O_constant
1792 || ! issbyte (opP
->disp
.exp
.X_add_number
))
1794 else if (! m68k_quick
1795 && instring
[3] != 'q'
1796 && instring
[4] != 'q')
1801 if (opP
->mode
!= DREG
1802 && opP
->mode
!= IMMED
1803 && opP
->mode
!= ABSL
)
1808 if (opP
->mode
!= IMMED
)
1810 else if (opP
->disp
.exp
.X_op
!= O_constant
1811 || TRUNC (opP
->disp
.exp
.X_add_number
) - 1 > 7)
1813 else if (! m68k_quick
1814 && (strncmp (instring
, "add", 3) == 0
1815 || strncmp (instring
, "sub", 3) == 0)
1816 && instring
[3] != 'q')
1821 if (opP
->mode
!= DREG
&& opP
->mode
!= AREG
)
1826 if (opP
->mode
!= AINDR
1827 && (opP
->mode
!= BASE
1829 && opP
->reg
!= ZADDR0
)
1830 || opP
->disp
.exp
.X_op
!= O_absent
1831 || ((opP
->index
.reg
< DATA0
1832 || opP
->index
.reg
> DATA7
)
1833 && (opP
->index
.reg
< ADDR0
1834 || opP
->index
.reg
> ADDR7
))
1835 || opP
->index
.size
!= SIZE_UNSPEC
1836 || opP
->index
.scale
!= 1))
1841 if (opP
->mode
!= CONTROL
1842 || ! (opP
->reg
== FPI
1844 || opP
->reg
== FPC
))
1849 if (opP
->mode
!= CONTROL
|| opP
->reg
!= SR
)
1854 if (opP
->mode
!= IMMED
)
1856 else if (opP
->disp
.exp
.X_op
!= O_constant
1857 || TRUNC (opP
->disp
.exp
.X_add_number
) > 7)
1862 if (opP
->mode
!= CONTROL
|| opP
->reg
!= USP
)
1867 if (opP
->mode
!= IMMED
)
1869 else if (opP
->disp
.exp
.X_op
!= O_constant
1870 || (TRUNC (opP
->disp
.exp
.X_add_number
) != 0xffffffff
1871 && TRUNC (opP
->disp
.exp
.X_add_number
) - 1 > 6))
1875 /* JF these are out of order. We could put them
1876 in order if we were willing to put up with
1877 bunches of #ifdef m68851s in the code.
1879 Don't forget that you need these operands
1880 to use 68030 MMU instructions. */
1882 /* Memory addressing mode used by pflushr. */
1884 if (opP
->mode
== CONTROL
1885 || opP
->mode
== FPREG
1886 || opP
->mode
== DREG
1887 || opP
->mode
== AREG
1888 || opP
->mode
== REGLST
)
1890 /* We should accept immediate operands, but they
1891 supposedly have to be quad word, and we don't
1892 handle that. I would like to see what a Motorola
1893 assembler does before doing something here. */
1894 if (opP
->mode
== IMMED
)
1899 if (opP
->mode
!= CONTROL
1900 || (opP
->reg
!= SFC
&& opP
->reg
!= DFC
))
1905 if (opP
->mode
!= CONTROL
|| opP
->reg
!= TC
)
1910 if (opP
->mode
!= CONTROL
|| opP
->reg
!= AC
)
1915 if (opP
->mode
!= CONTROL
1918 && opP
->reg
!= SCC
))
1923 if (opP
->mode
!= CONTROL
1929 if (opP
->mode
!= CONTROL
1932 && opP
->reg
!= CRP
))
1956 if (opP
->mode
!= CONTROL
1957 || (!(opP
->reg
>= BAD
&& opP
->reg
<= BAD
+ 7)
1958 && !(opP
->reg
>= BAC
&& opP
->reg
<= BAC
+ 7)))
1963 if (opP
->mode
!= CONTROL
|| opP
->reg
!= PSR
)
1968 if (opP
->mode
!= CONTROL
|| opP
->reg
!= PCSR
)
1973 if (opP
->mode
!= CONTROL
1982 if (opP
->mode
!= ABSL
)
1987 if (opP
->reg
< DATA0L
|| opP
->reg
> ADDR7U
)
1989 /* FIXME: kludge instead of fixing parser:
1990 upper/lower registers are *not* CONTROL
1991 registers, but ordinary ones. */
1992 if ((opP
->reg
>= DATA0L
&& opP
->reg
<= DATA7L
)
1993 || (opP
->reg
>= DATA0U
&& opP
->reg
<= DATA7U
))
2000 if (!(opP
->mode
== AINDR
2001 || (opP
->mode
== DISP
2002 && !(opP
->reg
== PC
|| opP
->reg
== ZPC
))))
2007 if (!(opP
->mode
== AINDR
|| opP
->mode
== DISP
))
2019 /* Since we have found the correct instruction, copy
2020 in the modifications that we may have made. */
2022 for (i
= 0; i
< opsfound
; i
++)
2023 the_ins
.operands
[i
] = operands_backup
[i
];
2029 opcode
= opcode
->m_next
;
2034 && !(ok_arch
& current_architecture
))
2039 _("invalid instruction for this architecture; needs "),
2041 cp
= buf
+ strlen (buf
);
2045 strncpy (cp
, _("ColdFire ISA_A"),
2046 sizeof (buf
) - (cp
- buf
));
2048 strncpy (cp
, find_cf_chip (ok_arch
),
2049 sizeof (buf
) - (cp
- buf
));
2053 strncpy (cp
, _("ColdFire hardware divide"),
2054 sizeof (buf
) - (cp
- buf
));
2056 strncpy (cp
, find_cf_chip (ok_arch
),
2057 sizeof (buf
) - (cp
- buf
));
2061 strncpy (cp
, _("ColdFire ISA_A+"),
2062 sizeof (buf
) - (cp
- buf
));
2064 strncpy (cp
, find_cf_chip (ok_arch
),
2065 sizeof (buf
) - (cp
- buf
));
2069 strncpy (cp
, _("ColdFire ISA_B"),
2070 sizeof (buf
) - (cp
- buf
));
2072 strncpy (cp
, find_cf_chip (ok_arch
),
2073 sizeof (buf
) - (cp
- buf
));
2077 strncpy (cp
, _("ColdFire fpu"), sizeof (buf
) - (cp
- buf
));
2079 strncpy (cp
, find_cf_chip (ok_arch
),
2080 sizeof (buf
) - (cp
- buf
));
2084 strcpy (cp
, _("fpu (68040, 68060 or 68881/68882)"));
2087 strcpy (cp
, _("mmu (68030 or 68851)"));
2090 strcpy (cp
, _("68020 or higher"));
2093 strcpy (cp
, _("68000 or higher"));
2096 strcpy (cp
, _("68010 or higher"));
2100 int got_one
= 0, idx
;
2102 for (idx
= 0; m68k_cpus
[idx
].name
; idx
++)
2104 if ((m68k_cpus
[idx
].arch
& ok_arch
)
2105 && ! m68k_cpus
[idx
].alias
)
2109 strcpy (cp
, " or ");
2113 strcpy (cp
, m68k_cpus
[idx
].name
);
2119 cp
= xmalloc (strlen (buf
) + 1);
2124 the_ins
.error
= _("operands mismatch");
2131 /* Now assemble it. */
2132 the_ins
.args
= opcode
->m_operands
;
2133 the_ins
.numargs
= opcode
->m_opnum
;
2134 the_ins
.numo
= opcode
->m_codenum
;
2135 the_ins
.opcode
[0] = getone (opcode
);
2136 the_ins
.opcode
[1] = gettwo (opcode
);
2138 for (s
= the_ins
.args
, opP
= &the_ins
.operands
[0]; *s
; s
+= 2, opP
++)
2140 /* This switch is a doozy.
2141 Watch the first step; its a big one! */
2174 tmpreg
= 0x3c; /* 7.4 */
2175 if (strchr ("bwl", s
[1]))
2176 nextword
= get_num (&opP
->disp
, 90);
2178 nextword
= get_num (&opP
->disp
, 0);
2179 if (isvar (&opP
->disp
))
2180 add_fix (s
[1], &opP
->disp
, 0, 0);
2184 if (!isbyte (nextword
))
2185 opP
->error
= _("operand out of range");
2190 if (!isword (nextword
))
2191 opP
->error
= _("operand out of range");
2196 if (!issword (nextword
))
2197 opP
->error
= _("operand out of range");
2202 addword (nextword
>> 16);
2229 /* We gotta put out some float. */
2230 if (op (&opP
->disp
) != O_big
)
2235 /* Can other cases happen here? */
2236 if (op (&opP
->disp
) != O_constant
)
2239 val
= (valueT
) offs (&opP
->disp
);
2243 generic_bignum
[gencnt
] = (LITTLENUM_TYPE
) val
;
2244 val
>>= LITTLENUM_NUMBER_OF_BITS
;
2248 offs (&opP
->disp
) = gencnt
;
2250 if (offs (&opP
->disp
) > 0)
2252 if (offs (&opP
->disp
) > baseo
)
2254 as_warn (_("Bignum too big for %c format; truncated"),
2256 offs (&opP
->disp
) = baseo
;
2258 baseo
-= offs (&opP
->disp
);
2261 for (wordp
= generic_bignum
+ offs (&opP
->disp
) - 1;
2262 offs (&opP
->disp
)--;
2267 gen_to_words (words
, baseo
, (long) outro
);
2268 for (wordp
= words
; baseo
--; wordp
++)
2272 tmpreg
= opP
->reg
- DATA
; /* 0.dreg */
2275 tmpreg
= 0x08 + opP
->reg
- ADDR
; /* 1.areg */
2278 tmpreg
= 0x10 + opP
->reg
- ADDR
; /* 2.areg */
2281 tmpreg
= 0x20 + opP
->reg
- ADDR
; /* 4.areg */
2284 tmpreg
= 0x18 + opP
->reg
- ADDR
; /* 3.areg */
2288 nextword
= get_num (&opP
->disp
, 90);
2290 /* Convert mode 5 addressing with a zero offset into
2291 mode 2 addressing to reduce the instruction size by a
2293 if (! isvar (&opP
->disp
)
2295 && (opP
->disp
.size
== SIZE_UNSPEC
)
2296 && (opP
->reg
>= ADDR0
)
2297 && (opP
->reg
<= ADDR7
))
2299 tmpreg
= 0x10 + opP
->reg
- ADDR
; /* 2.areg */
2304 && ! isvar (&opP
->disp
)
2307 opP
->disp
.exp
.X_op
= O_symbol
;
2308 opP
->disp
.exp
.X_add_symbol
=
2309 section_symbol (absolute_section
);
2312 /* Force into index mode. Hope this works. */
2314 /* We do the first bit for 32-bit displacements, and the
2315 second bit for 16 bit ones. It is possible that we
2316 should make the default be WORD instead of LONG, but
2317 I think that'd break GCC, so we put up with a little
2318 inefficiency for the sake of working output. */
2320 if (!issword (nextword
)
2321 || (isvar (&opP
->disp
)
2322 && ((opP
->disp
.size
== SIZE_UNSPEC
2323 && flag_short_refs
== 0
2324 && cpu_of_arch (current_architecture
) >= m68020
2325 && ! arch_coldfire_p (current_architecture
))
2326 || opP
->disp
.size
== SIZE_LONG
)))
2328 if (cpu_of_arch (current_architecture
) < m68020
2329 || arch_coldfire_p (current_architecture
))
2331 _("displacement too large for this architecture; needs 68020 or higher");
2333 tmpreg
= 0x3B; /* 7.3 */
2335 tmpreg
= 0x30 + opP
->reg
- ADDR
; /* 6.areg */
2336 if (isvar (&opP
->disp
))
2340 if (opP
->disp
.size
== SIZE_LONG
2342 /* If the displacement needs pic
2343 relocation it cannot be relaxed. */
2344 || opP
->disp
.pic_reloc
!= pic_none
2349 add_fix ('l', &opP
->disp
, 1, 2);
2353 add_frag (adds (&opP
->disp
),
2354 SEXT (offs (&opP
->disp
)),
2355 TAB (PCREL1632
, SZ_UNDEF
));
2362 add_fix ('l', &opP
->disp
, 0, 0);
2367 addword (nextword
>> 16);
2372 tmpreg
= 0x3A; /* 7.2 */
2374 tmpreg
= 0x28 + opP
->reg
- ADDR
; /* 5.areg */
2376 if (isvar (&opP
->disp
))
2380 add_fix ('w', &opP
->disp
, 1, 0);
2383 add_fix ('w', &opP
->disp
, 0, 0);
2393 baseo
= get_num (&opP
->disp
, 90);
2394 if (opP
->mode
== POST
|| opP
->mode
== PRE
)
2395 outro
= get_num (&opP
->odisp
, 90);
2396 /* Figure out the `addressing mode'.
2397 Also turn on the BASE_DISABLE bit, if needed. */
2398 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
2400 tmpreg
= 0x3b; /* 7.3 */
2401 if (opP
->reg
== ZPC
)
2404 else if (opP
->reg
== 0)
2407 tmpreg
= 0x30; /* 6.garbage */
2409 else if (opP
->reg
>= ZADDR0
&& opP
->reg
<= ZADDR7
)
2412 tmpreg
= 0x30 + opP
->reg
- ZADDR0
;
2415 tmpreg
= 0x30 + opP
->reg
- ADDR
; /* 6.areg */
2417 siz1
= opP
->disp
.size
;
2418 if (opP
->mode
== POST
|| opP
->mode
== PRE
)
2419 siz2
= opP
->odisp
.size
;
2423 /* Index register stuff. */
2424 if (opP
->index
.reg
!= 0
2425 && opP
->index
.reg
>= DATA
2426 && opP
->index
.reg
<= ADDR7
)
2428 nextword
|= (opP
->index
.reg
- DATA
) << 12;
2430 if (opP
->index
.size
== SIZE_LONG
2431 || (opP
->index
.size
== SIZE_UNSPEC
2432 && m68k_index_width_default
== SIZE_LONG
))
2435 if ((opP
->index
.scale
!= 1
2436 && cpu_of_arch (current_architecture
) < m68020
)
2437 || (opP
->index
.scale
== 8
2438 && (arch_coldfire_p (current_architecture
)
2439 && !arch_coldfire_fpu (current_architecture
))))
2442 _("scale factor invalid on this architecture; needs cpu32 or 68020 or higher");
2445 if (arch_coldfire_p (current_architecture
)
2446 && opP
->index
.size
== SIZE_WORD
)
2447 opP
->error
= _("invalid index size for coldfire");
2449 switch (opP
->index
.scale
)
2466 GET US OUT OF HERE! */
2468 /* Must be INDEX, with an index register. Address
2469 register cannot be ZERO-PC, and either :b was
2470 forced, or we know it will fit. For a 68000 or
2471 68010, force this mode anyways, because the
2472 larger modes aren't supported. */
2473 if (opP
->mode
== BASE
2474 && ((opP
->reg
>= ADDR0
2475 && opP
->reg
<= ADDR7
)
2478 if (siz1
== SIZE_BYTE
2479 || cpu_of_arch (current_architecture
) < m68020
2480 || arch_coldfire_p (current_architecture
)
2481 || (siz1
== SIZE_UNSPEC
2482 && ! isvar (&opP
->disp
)
2483 && issbyte (baseo
)))
2485 nextword
+= baseo
& 0xff;
2487 if (isvar (&opP
->disp
))
2489 /* Do a byte relocation. If it doesn't
2490 fit (possible on m68000) let the
2491 fixup processing complain later. */
2493 add_fix ('B', &opP
->disp
, 1, 1);
2495 add_fix ('B', &opP
->disp
, 0, 0);
2497 else if (siz1
!= SIZE_BYTE
)
2499 if (siz1
!= SIZE_UNSPEC
)
2500 as_warn (_("Forcing byte displacement"));
2501 if (! issbyte (baseo
))
2502 opP
->error
= _("byte displacement out of range");
2507 else if (siz1
== SIZE_UNSPEC
2509 && isvar (&opP
->disp
)
2510 && subs (&opP
->disp
) == NULL
2512 /* If the displacement needs pic
2513 relocation it cannot be relaxed. */
2514 && opP
->disp
.pic_reloc
== pic_none
2518 /* The code in md_convert_frag_1 needs to be
2519 able to adjust nextword. Call frag_grow
2520 to ensure that we have enough space in
2521 the frag obstack to make all the bytes
2524 nextword
+= baseo
& 0xff;
2526 add_frag (adds (&opP
->disp
),
2527 SEXT (offs (&opP
->disp
)),
2528 TAB (PCINDEX
, SZ_UNDEF
));
2536 nextword
|= 0x40; /* No index reg. */
2537 if (opP
->index
.reg
>= ZDATA0
2538 && opP
->index
.reg
<= ZDATA7
)
2539 nextword
|= (opP
->index
.reg
- ZDATA0
) << 12;
2540 else if (opP
->index
.reg
>= ZADDR0
2541 || opP
->index
.reg
<= ZADDR7
)
2542 nextword
|= (opP
->index
.reg
- ZADDR0
+ 8) << 12;
2545 /* It isn't simple. */
2547 if (cpu_of_arch (current_architecture
) < m68020
2548 || arch_coldfire_p (current_architecture
))
2550 _("invalid operand mode for this architecture; needs 68020 or higher");
2553 /* If the guy specified a width, we assume that it is
2554 wide enough. Maybe it isn't. If so, we lose. */
2558 if (isvar (&opP
->disp
)
2560 : ! issword (baseo
))
2565 else if (! isvar (&opP
->disp
) && baseo
== 0)
2574 as_warn (_(":b not permitted; defaulting to :w"));
2584 /* Figure out inner displacement stuff. */
2585 if (opP
->mode
== POST
|| opP
->mode
== PRE
)
2587 if (cpu_of_arch (current_architecture
) & cpu32
)
2588 opP
->error
= _("invalid operand mode for this architecture; needs 68020 or higher");
2592 if (isvar (&opP
->odisp
)
2594 : ! issword (outro
))
2599 else if (! isvar (&opP
->odisp
) && outro
== 0)
2608 as_warn (_(":b not permitted; defaulting to :w"));
2617 if (opP
->mode
== POST
2618 && (nextword
& 0x40) == 0)
2623 if (siz1
!= SIZE_UNSPEC
&& isvar (&opP
->disp
))
2625 if (opP
->reg
== PC
|| opP
->reg
== ZPC
)
2626 add_fix (siz1
== SIZE_LONG
? 'l' : 'w', &opP
->disp
, 1, 2);
2628 add_fix (siz1
== SIZE_LONG
? 'l' : 'w', &opP
->disp
, 0, 0);
2630 if (siz1
== SIZE_LONG
)
2631 addword (baseo
>> 16);
2632 if (siz1
!= SIZE_UNSPEC
)
2635 if (siz2
!= SIZE_UNSPEC
&& isvar (&opP
->odisp
))
2636 add_fix (siz2
== SIZE_LONG
? 'l' : 'w', &opP
->odisp
, 0, 0);
2637 if (siz2
== SIZE_LONG
)
2638 addword (outro
>> 16);
2639 if (siz2
!= SIZE_UNSPEC
)
2645 nextword
= get_num (&opP
->disp
, 90);
2646 switch (opP
->disp
.size
)
2651 if (!isvar (&opP
->disp
) && issword (offs (&opP
->disp
)))
2653 tmpreg
= 0x38; /* 7.0 */
2657 if (isvar (&opP
->disp
)
2658 && !subs (&opP
->disp
)
2659 && adds (&opP
->disp
)
2661 /* If the displacement needs pic relocation it
2662 cannot be relaxed. */
2663 && opP
->disp
.pic_reloc
== pic_none
2666 && !strchr ("~%&$?", s
[0]))
2668 tmpreg
= 0x3A; /* 7.2 */
2669 add_frag (adds (&opP
->disp
),
2670 SEXT (offs (&opP
->disp
)),
2671 TAB (ABSTOPCREL
, SZ_UNDEF
));
2674 /* Fall through into long. */
2676 if (isvar (&opP
->disp
))
2677 add_fix ('l', &opP
->disp
, 0, 0);
2679 tmpreg
= 0x39;/* 7.1 mode */
2680 addword (nextword
>> 16);
2685 as_bad (_("unsupported byte value; use a different suffix"));
2689 if (isvar (&opP
->disp
))
2690 add_fix ('w', &opP
->disp
, 0, 0);
2692 tmpreg
= 0x38;/* 7.0 mode */
2700 as_bad (_("unknown/incorrect operand"));
2704 /* If s[0] is '4', then this is for the mac instructions
2705 that can have a trailing_ampersand set. If so, set 0x100
2706 bit on tmpreg so install_gen_operand can check for it and
2707 set the appropriate bit (word2, bit 5). */
2710 if (opP
->trailing_ampersand
)
2713 install_gen_operand (s
[1], tmpreg
);
2719 { /* JF: I hate floating point! */
2734 tmpreg
= get_num (&opP
->disp
, tmpreg
);
2735 if (isvar (&opP
->disp
))
2736 add_fix (s
[1], &opP
->disp
, 0, 0);
2739 case 'b': /* Danger: These do no check for
2740 certain types of overflow.
2742 if (!isbyte (tmpreg
))
2743 opP
->error
= _("out of range");
2744 insop (tmpreg
, opcode
);
2745 if (isvar (&opP
->disp
))
2746 the_ins
.reloc
[the_ins
.nrel
- 1].n
=
2747 (opcode
->m_codenum
) * 2 + 1;
2750 if (!issbyte (tmpreg
))
2751 opP
->error
= _("out of range");
2752 the_ins
.opcode
[the_ins
.numo
- 1] |= tmpreg
& 0xff;
2753 if (isvar (&opP
->disp
))
2754 the_ins
.reloc
[the_ins
.nrel
- 1].n
= opcode
->m_codenum
* 2 - 1;
2757 if (!isword (tmpreg
))
2758 opP
->error
= _("out of range");
2759 insop (tmpreg
, opcode
);
2760 if (isvar (&opP
->disp
))
2761 the_ins
.reloc
[the_ins
.nrel
- 1].n
= (opcode
->m_codenum
) * 2;
2764 if (!issword (tmpreg
))
2765 opP
->error
= _("out of range");
2766 insop (tmpreg
, opcode
);
2767 if (isvar (&opP
->disp
))
2768 the_ins
.reloc
[the_ins
.nrel
- 1].n
= (opcode
->m_codenum
) * 2;
2771 /* Because of the way insop works, we put these two out
2773 insop (tmpreg
, opcode
);
2774 insop (tmpreg
>> 16, opcode
);
2775 if (isvar (&opP
->disp
))
2776 the_ins
.reloc
[the_ins
.nrel
- 1].n
= (opcode
->m_codenum
) * 2;
2783 install_operand (s
[1], tmpreg
);
2794 install_operand (s
[1], opP
->reg
- ADDR
);
2798 tmpreg
= get_num (&opP
->disp
, 90);
2802 add_fix ('B', &opP
->disp
, 1, -1);
2805 add_fix ('w', &opP
->disp
, 1, 0);
2810 if (! HAVE_LONG_BRANCH (current_architecture
))
2811 as_warn (_("Can't use long branches on 68000/68010/5200"));
2812 the_ins
.opcode
[0] |= 0xff;
2813 add_fix ('l', &opP
->disp
, 1, 0);
2818 if (subs (&opP
->disp
)) /* We can't relax it. */
2822 /* If the displacement needs pic relocation it cannot be
2824 if (opP
->disp
.pic_reloc
!= pic_none
)
2827 /* This could either be a symbol, or an absolute
2828 address. If it's an absolute address, turn it into
2829 an absolute jump right here and keep it out of the
2831 if (adds (&opP
->disp
) == 0)
2833 if (the_ins
.opcode
[0] == 0x6000) /* jbra */
2834 the_ins
.opcode
[0] = 0x4EF9;
2835 else if (the_ins
.opcode
[0] == 0x6100) /* jbsr */
2836 the_ins
.opcode
[0] = 0x4EB9;
2839 the_ins
.opcode
[0] ^= 0x0100;
2840 the_ins
.opcode
[0] |= 0x0006;
2843 add_fix ('l', &opP
->disp
, 0, 0);
2849 /* Now we know it's going into the relaxer. Now figure
2850 out which mode. We try in this order of preference:
2851 long branch, absolute jump, byte/word branches only. */
2852 if (HAVE_LONG_BRANCH (current_architecture
))
2853 add_frag (adds (&opP
->disp
),
2854 SEXT (offs (&opP
->disp
)),
2855 TAB (BRANCHBWL
, SZ_UNDEF
));
2856 else if (! flag_keep_pcrel
)
2858 if ((the_ins
.opcode
[0] == 0x6000)
2859 || (the_ins
.opcode
[0] == 0x6100))
2860 add_frag (adds (&opP
->disp
),
2861 SEXT (offs (&opP
->disp
)),
2862 TAB (BRABSJUNC
, SZ_UNDEF
));
2864 add_frag (adds (&opP
->disp
),
2865 SEXT (offs (&opP
->disp
)),
2866 TAB (BRABSJCOND
, SZ_UNDEF
));
2869 add_frag (adds (&opP
->disp
),
2870 SEXT (offs (&opP
->disp
)),
2871 TAB (BRANCHBW
, SZ_UNDEF
));
2874 if (isvar (&opP
->disp
))
2876 /* Check for DBcc instructions. We can relax them,
2877 but only if we have long branches and/or absolute
2879 if (((the_ins
.opcode
[0] & 0xf0f8) == 0x50c8)
2880 && (HAVE_LONG_BRANCH (current_architecture
)
2881 || (! flag_keep_pcrel
)))
2883 if (HAVE_LONG_BRANCH (current_architecture
))
2884 add_frag (adds (&opP
->disp
),
2885 SEXT (offs (&opP
->disp
)),
2886 TAB (DBCCLBR
, SZ_UNDEF
));
2888 add_frag (adds (&opP
->disp
),
2889 SEXT (offs (&opP
->disp
)),
2890 TAB (DBCCABSJ
, SZ_UNDEF
));
2893 add_fix ('w', &opP
->disp
, 1, 0);
2897 case 'C': /* Fixed size LONG coproc branches. */
2898 add_fix ('l', &opP
->disp
, 1, 0);
2902 case 'c': /* Var size Coprocesssor branches. */
2903 if (subs (&opP
->disp
) || (adds (&opP
->disp
) == 0))
2905 the_ins
.opcode
[the_ins
.numo
- 1] |= 0x40;
2906 add_fix ('l', &opP
->disp
, 1, 0);
2911 add_frag (adds (&opP
->disp
),
2912 SEXT (offs (&opP
->disp
)),
2913 TAB (FBRANCH
, SZ_UNDEF
));
2920 case 'C': /* Ignore it. */
2923 case 'd': /* JF this is a kludge. */
2924 install_operand ('s', opP
->reg
- ADDR
);
2925 tmpreg
= get_num (&opP
->disp
, 90);
2926 if (!issword (tmpreg
))
2928 as_warn (_("Expression out of range, using 0"));
2935 install_operand (s
[1], opP
->reg
- DATA
);
2938 case 'e': /* EMAC ACCx, reg/reg. */
2939 install_operand (s
[1], opP
->reg
- ACC
);
2942 case 'E': /* Ignore it. */
2946 install_operand (s
[1], opP
->reg
- FP0
);
2949 case 'g': /* EMAC ACCEXTx. */
2950 install_operand (s
[1], opP
->reg
- ACCEXT01
);
2953 case 'G': /* Ignore it. */
2958 tmpreg
= opP
->reg
- COP0
;
2959 install_operand (s
[1], tmpreg
);
2962 case 'i': /* MAC/EMAC scale factor. */
2963 install_operand (s
[1], opP
->mode
== LSH
? 0x1 : 0x3);
2966 case 'J': /* JF foo. */
3096 install_operand (s
[1], tmpreg
);
3100 tmpreg
= get_num (&opP
->disp
, 55);
3101 install_operand (s
[1], tmpreg
& 0x7f);
3108 if (tmpreg
& 0x7FF0000)
3109 as_bad (_("Floating point register in register list"));
3110 insop (reverse_16_bits (tmpreg
), opcode
);
3114 if (tmpreg
& 0x700FFFF)
3115 as_bad (_("Wrong register in floating-point reglist"));
3116 install_operand (s
[1], reverse_8_bits (tmpreg
>> 16));
3124 if (tmpreg
& 0x7FF0000)
3125 as_bad (_("Floating point register in register list"));
3126 insop (tmpreg
, opcode
);
3128 else if (s
[1] == '8')
3130 if (tmpreg
& 0x0FFFFFF)
3131 as_bad (_("incorrect register in reglist"));
3132 install_operand (s
[1], tmpreg
>> 24);
3136 if (tmpreg
& 0x700FFFF)
3137 as_bad (_("wrong register in floating-point reglist"));
3139 install_operand (s
[1], tmpreg
>> 16);
3144 install_operand (s
[1], get_num (&opP
->disp
, 60));
3148 tmpreg
= ((opP
->mode
== DREG
)
3149 ? 0x20 + (int) (opP
->reg
- DATA
)
3150 : (get_num (&opP
->disp
, 40) & 0x1F));
3151 install_operand (s
[1], tmpreg
);
3155 tmpreg
= get_num (&opP
->disp
, 10);
3158 install_operand (s
[1], tmpreg
);
3162 /* This depends on the fact that ADDR registers are eight
3163 more than their corresponding DATA regs, so the result
3164 will have the ADDR_REG bit set. */
3165 install_operand (s
[1], opP
->reg
- DATA
);
3169 if (opP
->mode
== AINDR
)
3170 install_operand (s
[1], opP
->reg
- DATA
);
3172 install_operand (s
[1], opP
->index
.reg
- DATA
);
3176 if (opP
->reg
== FPI
)
3178 else if (opP
->reg
== FPS
)
3180 else if (opP
->reg
== FPC
)
3184 install_operand (s
[1], tmpreg
);
3187 case 'S': /* Ignore it. */
3191 install_operand (s
[1], get_num (&opP
->disp
, 30));
3194 case 'U': /* Ignore it. */
3213 as_fatal (_("failed sanity check"));
3214 } /* switch on cache token. */
3215 install_operand (s
[1], tmpreg
);
3218 /* JF: These are out of order, I fear. */
3231 install_operand (s
[1], tmpreg
);
3257 install_operand (s
[1], tmpreg
);
3261 if (opP
->reg
== VAL
)
3280 install_operand (s
[1], tmpreg
);
3294 tmpreg
= (4 << 10) | ((opP
->reg
- BAD
) << 2);
3305 tmpreg
= (5 << 10) | ((opP
->reg
- BAC
) << 2);
3311 install_operand (s
[1], tmpreg
);
3314 know (opP
->reg
== PSR
);
3317 know (opP
->reg
== PCSR
);
3332 install_operand (s
[1], tmpreg
);
3335 tmpreg
= get_num (&opP
->disp
, 20);
3336 install_operand (s
[1], tmpreg
);
3338 case '_': /* used only for move16 absolute 32-bit address. */
3339 if (isvar (&opP
->disp
))
3340 add_fix ('l', &opP
->disp
, 0, 0);
3341 tmpreg
= get_num (&opP
->disp
, 90);
3342 addword (tmpreg
>> 16);
3343 addword (tmpreg
& 0xFFFF);
3346 install_operand (s
[1], opP
->reg
- DATA0L
);
3347 opP
->reg
-= (DATA0L
);
3348 opP
->reg
&= 0x0F; /* remove upper/lower bit. */
3351 tmpreg
= get_num (&opP
->disp
, 80);
3354 install_operand (s
[1], tmpreg
);
3361 /* By the time whe get here (FINALLY) the_ins contains the complete
3362 instruction, ready to be emitted. . . */
3366 reverse_16_bits (int in
)
3371 static int mask
[16] =
3373 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
3374 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000
3376 for (n
= 0; n
< 16; n
++)
3379 out
|= mask
[15 - n
];
3382 } /* reverse_16_bits() */
3385 reverse_8_bits (int in
)
3390 static int mask
[8] =
3392 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
3395 for (n
= 0; n
< 8; n
++)
3401 } /* reverse_8_bits() */
3403 /* Cause an extra frag to be generated here, inserting up to 10 bytes
3404 (that value is chosen in the frag_var call in md_assemble). TYPE
3405 is the subtype of the frag to be generated; its primary type is
3406 rs_machine_dependent.
3408 The TYPE parameter is also used by md_convert_frag_1 and
3409 md_estimate_size_before_relax. The appropriate type of fixup will
3410 be emitted by md_convert_frag_1.
3412 ADD becomes the FR_SYMBOL field of the frag, and OFF the FR_OFFSET. */
3414 install_operand (int mode
, int val
)
3419 the_ins
.opcode
[0] |= val
& 0xFF; /* JF FF is for M kludge. */
3422 the_ins
.opcode
[0] |= val
<< 9;
3425 the_ins
.opcode
[1] |= val
<< 12;
3428 the_ins
.opcode
[1] |= val
<< 6;
3431 the_ins
.opcode
[1] |= val
;
3434 the_ins
.opcode
[2] |= val
<< 12;
3437 the_ins
.opcode
[2] |= val
<< 6;
3440 /* DANGER! This is a hack to force cas2l and cas2w cmds to be
3441 three words long! */
3443 the_ins
.opcode
[2] |= val
;
3446 the_ins
.opcode
[1] |= val
<< 7;
3449 the_ins
.opcode
[1] |= val
<< 10;
3453 the_ins
.opcode
[1] |= val
<< 5;
3458 the_ins
.opcode
[1] |= (val
<< 10) | (val
<< 7);
3461 the_ins
.opcode
[1] |= (val
<< 12) | val
;
3464 the_ins
.opcode
[0] |= val
= 0xff;
3467 the_ins
.opcode
[0] |= val
<< 9;
3470 the_ins
.opcode
[1] |= val
;
3473 the_ins
.opcode
[1] |= val
;
3474 the_ins
.numo
++; /* What a hack. */
3477 the_ins
.opcode
[1] |= val
<< 4;
3485 the_ins
.opcode
[0] |= (val
<< 6);
3488 the_ins
.opcode
[1] = (val
>> 16);
3489 the_ins
.opcode
[2] = val
& 0xffff;
3492 the_ins
.opcode
[0] |= ((val
& 0x8) << (6 - 3));
3493 the_ins
.opcode
[0] |= ((val
& 0x7) << 9);
3494 the_ins
.opcode
[1] |= ((val
& 0x10) << (7 - 4));
3496 case 'n': /* MAC/EMAC Rx on !load. */
3497 the_ins
.opcode
[0] |= ((val
& 0x8) << (6 - 3));
3498 the_ins
.opcode
[0] |= ((val
& 0x7) << 9);
3499 the_ins
.opcode
[1] |= ((val
& 0x10) << (7 - 4));
3501 case 'o': /* MAC/EMAC Rx on load. */
3502 the_ins
.opcode
[1] |= val
<< 12;
3503 the_ins
.opcode
[1] |= ((val
& 0x10) << (7 - 4));
3505 case 'M': /* MAC/EMAC Ry on !load. */
3506 the_ins
.opcode
[0] |= (val
& 0xF);
3507 the_ins
.opcode
[1] |= ((val
& 0x10) << (6 - 4));
3509 case 'N': /* MAC/EMAC Ry on load. */
3510 the_ins
.opcode
[1] |= (val
& 0xF);
3511 the_ins
.opcode
[1] |= ((val
& 0x10) << (6 - 4));
3514 the_ins
.opcode
[1] |= ((val
!= 1) << 10);
3517 the_ins
.opcode
[0] |= ((val
& 0x3) << 9);
3520 the_ins
.opcode
[0] |= ((val
& 0x3) << 0);
3522 case 'G': /* EMAC accumulator in a EMAC load instruction. */
3523 the_ins
.opcode
[0] |= ((~val
& 0x1) << 7);
3524 the_ins
.opcode
[1] |= ((val
& 0x2) << (4 - 1));
3526 case 'H': /* EMAC accumulator in a EMAC non-load instruction. */
3527 the_ins
.opcode
[0] |= ((val
& 0x1) << 7);
3528 the_ins
.opcode
[1] |= ((val
& 0x2) << (4 - 1));
3531 the_ins
.opcode
[1] |= ((val
& 0x3) << 9);
3534 the_ins
.opcode
[0] |= (val
& 0x1) <<10;
3538 as_fatal (_("failed sanity check."));
3543 install_gen_operand (int mode
, int val
)
3547 case '/': /* Special for mask loads for mac/msac insns with
3548 possible mask; trailing_ampersend set in bit 8. */
3549 the_ins
.opcode
[0] |= (val
& 0x3f);
3550 the_ins
.opcode
[1] |= (((val
& 0x100) >> 8) << 5);
3553 the_ins
.opcode
[0] |= val
;
3556 /* This is a kludge!!! */
3557 the_ins
.opcode
[0] |= (val
& 0x07) << 9 | (val
& 0x38) << 3;
3566 the_ins
.opcode
[0] |= val
;
3568 /* more stuff goes here. */
3570 as_fatal (_("failed sanity check."));
3574 /* Verify that we have some number of paren pairs, do m68k_ip_op(), and
3575 then deal with the bitfield hack. */
3578 crack_operand (char *str
, struct m68k_op
*opP
)
3580 register int parens
;
3582 register char *beg_str
;
3590 for (parens
= 0; *str
&& (parens
> 0 || inquote
|| notend (str
)); str
++)
3596 else if (*str
== ')')
3600 opP
->error
= _("Extra )");
3606 if (flag_mri
&& *str
== '\'')
3607 inquote
= ! inquote
;
3609 if (!*str
&& parens
)
3611 opP
->error
= _("Missing )");
3616 if (m68k_ip_op (beg_str
, opP
) != 0)
3623 c
= *++str
; /* JF bitfield hack. */
3628 as_bad (_("Missing operand"));
3631 /* Detect MRI REG symbols and convert them to REGLSTs. */
3632 if (opP
->mode
== CONTROL
&& (int)opP
->reg
< 0)
3635 opP
->mask
= ~(int)opP
->reg
;
3642 /* This is the guts of the machine-dependent assembler. STR points to a
3643 machine dependent instruction. This function is supposed to emit
3644 the frags/bytes it assembles to.
3648 insert_reg (const char *regname
, int regnum
)
3653 #ifdef REGISTER_PREFIX
3654 if (!flag_reg_prefix_optional
)
3656 buf
[0] = REGISTER_PREFIX
;
3657 strcpy (buf
+ 1, regname
);
3662 symbol_table_insert (symbol_new (regname
, reg_section
, regnum
,
3663 &zero_address_frag
));
3665 for (i
= 0; regname
[i
]; i
++)
3666 buf
[i
] = TOUPPER (regname
[i
]);
3669 symbol_table_insert (symbol_new (buf
, reg_section
, regnum
,
3670 &zero_address_frag
));
3679 static const struct init_entry init_table
[] =
3739 { "accext01", ACCEXT01
},
3740 { "accext23", ACCEXT23
},
3744 /* Control registers. */
3745 { "sfc", SFC
}, /* Source Function Code. */
3747 { "dfc", DFC
}, /* Destination Function Code. */
3749 { "cacr", CACR
}, /* Cache Control Register. */
3750 { "caar", CAAR
}, /* Cache Address Register. */
3752 { "usp", USP
}, /* User Stack Pointer. */
3753 { "vbr", VBR
}, /* Vector Base Register. */
3754 { "msp", MSP
}, /* Master Stack Pointer. */
3755 { "isp", ISP
}, /* Interrupt Stack Pointer. */
3757 { "itt0", ITT0
}, /* Instruction Transparent Translation Reg 0. */
3758 { "itt1", ITT1
}, /* Instruction Transparent Translation Reg 1. */
3759 { "dtt0", DTT0
}, /* Data Transparent Translation Register 0. */
3760 { "dtt1", DTT1
}, /* Data Transparent Translation Register 1. */
3762 /* 68ec040 versions of same */
3763 { "iacr0", ITT0
}, /* Instruction Access Control Register 0. */
3764 { "iacr1", ITT1
}, /* Instruction Access Control Register 0. */
3765 { "dacr0", DTT0
}, /* Data Access Control Register 0. */
3766 { "dacr1", DTT1
}, /* Data Access Control Register 0. */
3768 /* mcf5200 versions of same. The ColdFire programmer's reference
3769 manual indicated that the order is 2,3,0,1, but Ken Rose
3770 <rose@netcom.com> says that 0,1,2,3 is the correct order. */
3771 { "acr0", ACR0
}, /* Access Control Unit 0. */
3772 { "acr1", ACR1
}, /* Access Control Unit 1. */
3773 { "acr2", ACR2
}, /* Access Control Unit 2. */
3774 { "acr3", ACR3
}, /* Access Control Unit 3. */
3776 { "tc", TC
}, /* MMU Translation Control Register. */
3779 { "mmusr", MMUSR
}, /* MMU Status Register. */
3780 { "srp", SRP
}, /* User Root Pointer. */
3781 { "urp", URP
}, /* Supervisor Root Pointer. */
3786 { "rombar", ROMBAR
}, /* ROM Base Address Register. */
3787 { "rambar0", RAMBAR0
}, /* ROM Base Address Register. */
3788 { "rambar1", RAMBAR1
}, /* ROM Base Address Register. */
3789 { "mbar", MBAR
}, /* Module Base Address Register. */
3791 { "mbar0", MBAR0
}, /* mcfv4e registers. */
3792 { "mbar1", MBAR1
}, /* mcfv4e registers. */
3793 { "rombar0", ROMBAR
}, /* mcfv4e registers. */
3794 { "rombar1", ROMBAR1
}, /* mcfv4e registers. */
3795 { "mpcr", MPCR
}, /* mcfv4e registers. */
3796 { "edrambar", EDRAMBAR
}, /* mcfv4e registers. */
3797 { "secmbar", SECMBAR
}, /* mcfv4e registers. */
3798 { "asid", TC
}, /* mcfv4e registers. */
3799 { "mmubar", BUSCR
}, /* mcfv4e registers. */
3800 { "pcr1u0", PCR1U0
}, /* mcfv4e registers. */
3801 { "pcr1l0", PCR1L0
}, /* mcfv4e registers. */
3802 { "pcr2u0", PCR2U0
}, /* mcfv4e registers. */
3803 { "pcr2l0", PCR2L0
}, /* mcfv4e registers. */
3804 { "pcr3u0", PCR3U0
}, /* mcfv4e registers. */
3805 { "pcr3l0", PCR3L0
}, /* mcfv4e registers. */
3806 { "pcr1u1", PCR1U1
}, /* mcfv4e registers. */
3807 { "pcr1l1", PCR1L1
}, /* mcfv4e registers. */
3808 { "pcr2u1", PCR2U1
}, /* mcfv4e registers. */
3809 { "pcr2l1", PCR2L1
}, /* mcfv4e registers. */
3810 { "pcr3u1", PCR3U1
}, /* mcfv4e registers. */
3811 { "pcr3l1", PCR3L1
}, /* mcfv4e registers. */
3813 { "flashbar", FLASHBAR
}, /* mcf528x registers. */
3814 { "rambar", RAMBAR
}, /* mcf528x registers. */
3816 { "mbar2", MBAR2
}, /* mcf5249 registers. */
3817 /* End of control registers. */
3851 /* 68ec030 versions of same. */
3854 /* 68ec030 access control unit, identical to 030 MMU status reg. */
3857 /* Suppressed data and address registers. */
3875 /* Upper and lower data and address registers, used by macw and msacw. */
3916 init_regtable (void)
3919 for (i
= 0; init_table
[i
].name
; i
++)
3920 insert_reg (init_table
[i
].name
, init_table
[i
].number
);
3924 md_assemble (char *str
)
3931 int shorts_this_frag
;
3934 if (!selected_cpu
&& !selected_arch
)
3936 /* We've not selected an architecture yet. Set the default
3937 now. We do this lazily so that an initial .cpu or .arch directive
3939 if (!m68k_set_cpu (TARGET_CPU
, 1, 1))
3940 as_bad (_("unrecognized default cpu `%s'"), TARGET_CPU
);
3945 /* In MRI mode, the instruction and operands are separated by a
3946 space. Anything following the operands is a comment. The label
3947 has already been removed. */
3955 for (s
= str
; *s
!= '\0'; s
++)
3957 if ((*s
== ' ' || *s
== '\t') && ! inquote
)
3975 inquote
= ! inquote
;
3980 memset (&the_ins
, '\0', sizeof (the_ins
));
3985 for (n
= 0; n
< the_ins
.numargs
; n
++)
3986 if (the_ins
.operands
[n
].error
)
3988 er
= the_ins
.operands
[n
].error
;
3994 as_bad (_("%s -- statement `%s' ignored"), er
, str
);
3998 /* If there is a current label, record that it marks an instruction. */
3999 if (current_label
!= NULL
)
4001 current_label
->text
= 1;
4002 current_label
= NULL
;
4006 /* Tie dwarf2 debug info to the address at the start of the insn. */
4007 dwarf2_emit_insn (0);
4010 if (the_ins
.nfrag
== 0)
4012 /* No frag hacking involved; just put it out. */
4013 toP
= frag_more (2 * the_ins
.numo
);
4014 fromP
= &the_ins
.opcode
[0];
4015 for (m
= the_ins
.numo
; m
; --m
)
4017 md_number_to_chars (toP
, (long) (*fromP
), 2);
4021 /* Put out symbol-dependent info. */
4022 for (m
= 0; m
< the_ins
.nrel
; m
++)
4024 switch (the_ins
.reloc
[m
].wid
)
4043 as_fatal (_("Don't know how to figure width of %c in md_assemble()"),
4044 the_ins
.reloc
[m
].wid
);
4047 fixP
= fix_new_exp (frag_now
,
4048 ((toP
- frag_now
->fr_literal
)
4049 - the_ins
.numo
* 2 + the_ins
.reloc
[m
].n
),
4051 &the_ins
.reloc
[m
].exp
,
4052 the_ins
.reloc
[m
].pcrel
,
4053 get_reloc_code (n
, the_ins
.reloc
[m
].pcrel
,
4054 the_ins
.reloc
[m
].pic_reloc
));
4055 fixP
->fx_pcrel_adjust
= the_ins
.reloc
[m
].pcrel_fix
;
4056 if (the_ins
.reloc
[m
].wid
== 'B')
4057 fixP
->fx_signed
= 1;
4062 /* There's some frag hacking. */
4064 /* Calculate the max frag size. */
4067 wid
= 2 * the_ins
.fragb
[0].fragoff
;
4068 for (n
= 1; n
< the_ins
.nfrag
; n
++)
4069 wid
+= 2 * (the_ins
.numo
- the_ins
.fragb
[n
- 1].fragoff
);
4070 /* frag_var part. */
4072 /* Make sure the whole insn fits in one chunk, in particular that
4073 the var part is attached, as we access one byte before the
4074 variable frag for byte branches. */
4078 for (n
= 0, fromP
= &the_ins
.opcode
[0]; n
< the_ins
.nfrag
; n
++)
4083 wid
= 2 * the_ins
.fragb
[n
].fragoff
;
4085 wid
= 2 * (the_ins
.numo
- the_ins
.fragb
[n
- 1].fragoff
);
4086 toP
= frag_more (wid
);
4088 shorts_this_frag
= 0;
4089 for (m
= wid
/ 2; m
; --m
)
4091 md_number_to_chars (toP
, (long) (*fromP
), 2);
4096 for (m
= 0; m
< the_ins
.nrel
; m
++)
4098 if ((the_ins
.reloc
[m
].n
) >= 2 * shorts_this_frag
)
4100 the_ins
.reloc
[m
].n
-= 2 * shorts_this_frag
;
4103 wid
= the_ins
.reloc
[m
].wid
;
4106 the_ins
.reloc
[m
].wid
= 0;
4107 wid
= (wid
== 'b') ? 1 : (wid
== 'w') ? 2 : (wid
== 'l') ? 4 : 4000;
4109 fixP
= fix_new_exp (frag_now
,
4110 ((toP
- frag_now
->fr_literal
)
4111 - the_ins
.numo
* 2 + the_ins
.reloc
[m
].n
),
4113 &the_ins
.reloc
[m
].exp
,
4114 the_ins
.reloc
[m
].pcrel
,
4115 get_reloc_code (wid
, the_ins
.reloc
[m
].pcrel
,
4116 the_ins
.reloc
[m
].pic_reloc
));
4117 fixP
->fx_pcrel_adjust
= the_ins
.reloc
[m
].pcrel_fix
;
4119 (void) frag_var (rs_machine_dependent
, 10, 0,
4120 (relax_substateT
) (the_ins
.fragb
[n
].fragty
),
4121 the_ins
.fragb
[n
].fadd
, the_ins
.fragb
[n
].foff
, to_beg_P
);
4123 n
= (the_ins
.numo
- the_ins
.fragb
[n
- 1].fragoff
);
4124 shorts_this_frag
= 0;
4127 toP
= frag_more (n
* 2);
4130 md_number_to_chars (toP
, (long) (*fromP
), 2);
4136 for (m
= 0; m
< the_ins
.nrel
; m
++)
4140 wid
= the_ins
.reloc
[m
].wid
;
4143 the_ins
.reloc
[m
].wid
= 0;
4144 wid
= (wid
== 'b') ? 1 : (wid
== 'w') ? 2 : (wid
== 'l') ? 4 : 4000;
4146 fixP
= fix_new_exp (frag_now
,
4147 ((the_ins
.reloc
[m
].n
+ toP
- frag_now
->fr_literal
)
4148 - shorts_this_frag
* 2),
4150 &the_ins
.reloc
[m
].exp
,
4151 the_ins
.reloc
[m
].pcrel
,
4152 get_reloc_code (wid
, the_ins
.reloc
[m
].pcrel
,
4153 the_ins
.reloc
[m
].pic_reloc
));
4154 fixP
->fx_pcrel_adjust
= the_ins
.reloc
[m
].pcrel_fix
;
4158 /* Comparison function used by qsort to rank the opcode entries by name. */
4161 m68k_compare_opcode (const void * v1
, const void * v2
)
4163 struct m68k_opcode
* op1
, * op2
;
4169 op1
= *(struct m68k_opcode
**) v1
;
4170 op2
= *(struct m68k_opcode
**) v2
;
4172 /* Compare the two names. If different, return the comparison.
4173 If the same, return the order they are in the opcode table. */
4174 ret
= strcmp (op1
->name
, op2
->name
);
4185 const struct m68k_opcode
*ins
;
4186 struct m68k_incant
*hack
, *slak
;
4187 const char *retval
= 0; /* Empty string, or error msg text. */
4190 /* Set up hash tables with 68000 instructions.
4191 similar to what the vax assembler does. */
4192 /* RMS claims the thing to do is take the m68k-opcode.h table, and make
4193 a copy of it at runtime, adding in the information we want but isn't
4194 there. I think it'd be better to have an awk script hack the table
4195 at compile time. Or even just xstr the table and use it as-is. But
4196 my lord ghod hath spoken, so we do it this way. Excuse the ugly var
4201 flag_reg_prefix_optional
= 1;
4203 if (! m68k_rel32_from_cmdline
)
4207 /* First sort the opcode table into alphabetical order to seperate
4208 the order that the assembler wants to see the opcodes from the
4209 order that the disassembler wants to see them. */
4210 m68k_sorted_opcodes
= xmalloc (m68k_numopcodes
* sizeof (* m68k_sorted_opcodes
));
4211 if (!m68k_sorted_opcodes
)
4212 as_fatal (_("Internal Error: Can't allocate m68k_sorted_opcodes of size %d"),
4213 m68k_numopcodes
* ((int) sizeof (* m68k_sorted_opcodes
)));
4215 for (i
= m68k_numopcodes
; i
--;)
4216 m68k_sorted_opcodes
[i
] = m68k_opcodes
+ i
;
4218 qsort (m68k_sorted_opcodes
, m68k_numopcodes
,
4219 sizeof (m68k_sorted_opcodes
[0]), m68k_compare_opcode
);
4221 op_hash
= hash_new ();
4223 obstack_begin (&robyn
, 4000);
4224 for (i
= 0; i
< m68k_numopcodes
; i
++)
4226 hack
= slak
= (struct m68k_incant
*) obstack_alloc (&robyn
, sizeof (struct m68k_incant
));
4229 ins
= m68k_sorted_opcodes
[i
];
4231 /* We *could* ignore insns that don't match our
4232 arch here by just leaving them out of the hash. */
4233 slak
->m_operands
= ins
->args
;
4234 slak
->m_opnum
= strlen (slak
->m_operands
) / 2;
4235 slak
->m_arch
= ins
->arch
;
4236 slak
->m_opcode
= ins
->opcode
;
4237 /* This is kludgey. */
4238 slak
->m_codenum
= ((ins
->match
) & 0xffffL
) ? 2 : 1;
4239 if (i
+ 1 != m68k_numopcodes
4240 && !strcmp (ins
->name
, m68k_sorted_opcodes
[i
+ 1]->name
))
4242 slak
->m_next
= obstack_alloc (&robyn
, sizeof (struct m68k_incant
));
4247 slak
= slak
->m_next
;
4251 retval
= hash_insert (op_hash
, ins
->name
, (char *) hack
);
4253 as_fatal (_("Internal Error: Can't hash %s: %s"), ins
->name
, retval
);
4256 for (i
= 0; i
< m68k_numaliases
; i
++)
4258 const char *name
= m68k_opcode_aliases
[i
].primary
;
4259 const char *alias
= m68k_opcode_aliases
[i
].alias
;
4260 PTR val
= hash_find (op_hash
, name
);
4263 as_fatal (_("Internal Error: Can't find %s in hash table"), name
);
4264 retval
= hash_insert (op_hash
, alias
, val
);
4266 as_fatal (_("Internal Error: Can't hash %s: %s"), alias
, retval
);
4269 /* In MRI mode, all unsized branches are variable sized. Normally,
4270 they are word sized. */
4273 static struct m68k_opcode_alias mri_aliases
[] =
4294 i
< (int) (sizeof mri_aliases
/ sizeof mri_aliases
[0]);
4297 const char *name
= mri_aliases
[i
].primary
;
4298 const char *alias
= mri_aliases
[i
].alias
;
4299 PTR val
= hash_find (op_hash
, name
);
4302 as_fatal (_("Internal Error: Can't find %s in hash table"), name
);
4303 retval
= hash_jam (op_hash
, alias
, val
);
4305 as_fatal (_("Internal Error: Can't hash %s: %s"), alias
, retval
);
4309 for (i
= 0; i
< (int) sizeof (notend_table
); i
++)
4311 notend_table
[i
] = 0;
4312 alt_notend_table
[i
] = 0;
4315 notend_table
[','] = 1;
4316 notend_table
['{'] = 1;
4317 notend_table
['}'] = 1;
4318 alt_notend_table
['a'] = 1;
4319 alt_notend_table
['A'] = 1;
4320 alt_notend_table
['d'] = 1;
4321 alt_notend_table
['D'] = 1;
4322 alt_notend_table
['#'] = 1;
4323 alt_notend_table
['&'] = 1;
4324 alt_notend_table
['f'] = 1;
4325 alt_notend_table
['F'] = 1;
4326 #ifdef REGISTER_PREFIX
4327 alt_notend_table
[REGISTER_PREFIX
] = 1;
4330 /* We need to put '(' in alt_notend_table to handle
4331 cas2 %d0:%d2,%d3:%d4,(%a0):(%a1) */
4332 alt_notend_table
['('] = 1;
4334 /* We need to put '@' in alt_notend_table to handle
4335 cas2 %d0:%d2,%d3:%d4,@(%d0):@(%d1) */
4336 alt_notend_table
['@'] = 1;
4338 /* We need to put digits in alt_notend_table to handle
4339 bfextu %d0{24:1},%d0 */
4340 alt_notend_table
['0'] = 1;
4341 alt_notend_table
['1'] = 1;
4342 alt_notend_table
['2'] = 1;
4343 alt_notend_table
['3'] = 1;
4344 alt_notend_table
['4'] = 1;
4345 alt_notend_table
['5'] = 1;
4346 alt_notend_table
['6'] = 1;
4347 alt_notend_table
['7'] = 1;
4348 alt_notend_table
['8'] = 1;
4349 alt_notend_table
['9'] = 1;
4351 #ifndef MIT_SYNTAX_ONLY
4352 /* Insert pseudo ops, these have to go into the opcode table since
4353 gas expects pseudo ops to start with a dot. */
4357 while (mote_pseudo_table
[n
].poc_name
)
4359 hack
= obstack_alloc (&robyn
, sizeof (struct m68k_incant
));
4360 hash_insert (op_hash
,
4361 mote_pseudo_table
[n
].poc_name
, (char *) hack
);
4362 hack
->m_operands
= 0;
4372 record_alignment (text_section
, 2);
4373 record_alignment (data_section
, 2);
4374 record_alignment (bss_section
, 2);
4379 select_control_regs (void)
4381 /* Note which set of "movec" control registers is available. */
4382 switch (current_chip
)
4386 as_warn (_("architecture not yet selected: defaulting to 68020"));
4387 control_regs
= m68020_control_regs
;
4391 control_regs
= m68000_control_regs
;
4394 control_regs
= m68010_control_regs
;
4398 control_regs
= m68020_control_regs
;
4401 control_regs
= m68040_control_regs
;
4404 control_regs
= m68060_control_regs
;
4407 control_regs
= cpu32_control_regs
;
4413 control_regs
= mcf_control_regs
;
4416 control_regs
= mcf5249_control_regs
;
4420 control_regs
= mcf528x_control_regs
;
4424 control_regs
= mcfv4e_control_regs
;
4427 control_regs
= mcf5208_control_regs
;
4430 control_regs
= mcf5213_control_regs
;
4433 control_regs
= mcf5329_control_regs
;
4441 /* This is called when a label is defined. */
4444 m68k_frob_label (symbolS
*sym
)
4446 struct label_line
*n
;
4448 n
= (struct label_line
*) xmalloc (sizeof *n
);
4451 as_where (&n
->file
, &n
->line
);
4457 dwarf2_emit_label (sym
);
4461 /* This is called when a value that is not an instruction is emitted. */
4464 m68k_flush_pending_output (void)
4466 current_label
= NULL
;
4469 /* This is called at the end of the assembly, when the final value of
4470 the label is known. We warn if this is a text symbol aligned at an
4474 m68k_frob_symbol (symbolS
*sym
)
4476 if (S_GET_SEGMENT (sym
) == reg_section
4477 && (int) S_GET_VALUE (sym
) < 0)
4479 S_SET_SEGMENT (sym
, absolute_section
);
4480 S_SET_VALUE (sym
, ~(int)S_GET_VALUE (sym
));
4482 else if ((S_GET_VALUE (sym
) & 1) != 0)
4484 struct label_line
*l
;
4486 for (l
= labels
; l
!= NULL
; l
= l
->next
)
4488 if (l
->label
== sym
)
4491 as_warn_where (l
->file
, l
->line
,
4492 _("text label `%s' aligned to odd boundary"),
4500 /* This is called if we go in or out of MRI mode because of the .mri
4504 m68k_mri_mode_change (int on
)
4508 if (! flag_reg_prefix_optional
)
4510 flag_reg_prefix_optional
= 1;
4511 #ifdef REGISTER_PREFIX
4516 if (! m68k_rel32_from_cmdline
)
4521 if (! reg_prefix_optional_seen
)
4523 #ifdef REGISTER_PREFIX_OPTIONAL
4524 flag_reg_prefix_optional
= REGISTER_PREFIX_OPTIONAL
;
4526 flag_reg_prefix_optional
= 0;
4528 #ifdef REGISTER_PREFIX
4533 if (! m68k_rel32_from_cmdline
)
4538 /* Equal to MAX_PRECISION in atof-ieee.c. */
4539 #define MAX_LITTLENUMS 6
4541 /* Turn a string in input_line_pointer into a floating point constant
4542 of type TYPE, and store the appropriate bytes in *LITP. The number
4543 of LITTLENUMS emitted is stored in *SIZEP. An error message is
4544 returned, or NULL on OK. */
4547 md_atof (int type
, char *litP
, int *sizeP
)
4550 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
4551 LITTLENUM_TYPE
*wordP
;
4582 return _("Bad call to MD_ATOF()");
4584 t
= atof_ieee (input_line_pointer
, type
, words
);
4586 input_line_pointer
= t
;
4588 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
4589 for (wordP
= words
; prec
--;)
4591 md_number_to_chars (litP
, (long) (*wordP
++), sizeof (LITTLENUM_TYPE
));
4592 litP
+= sizeof (LITTLENUM_TYPE
);
4598 md_number_to_chars (char *buf
, valueT val
, int n
)
4600 number_to_chars_bigendian (buf
, val
, n
);
4604 md_apply_fix (fixS
*fixP
, valueT
*valP
, segT seg ATTRIBUTE_UNUSED
)
4606 offsetT val
= *valP
;
4607 addressT upper_limit
;
4608 offsetT lower_limit
;
4610 /* This is unnecessary but it convinces the native rs6000 compiler
4611 to generate the code we want. */
4612 char *buf
= fixP
->fx_frag
->fr_literal
;
4613 buf
+= fixP
->fx_where
;
4614 /* End ibm compiler workaround. */
4618 if (fixP
->fx_addsy
== NULL
&& fixP
->fx_pcrel
== 0)
4624 memset (buf
, 0, fixP
->fx_size
);
4625 fixP
->fx_addnumber
= val
; /* Remember value for emit_reloc. */
4627 if (fixP
->fx_r_type
== BFD_RELOC_VTABLE_INHERIT
4628 && !S_IS_DEFINED (fixP
->fx_addsy
)
4629 && !S_IS_WEAK (fixP
->fx_addsy
))
4630 S_SET_WEAK (fixP
->fx_addsy
);
4635 if (fixP
->fx_r_type
== BFD_RELOC_VTABLE_INHERIT
4636 || fixP
->fx_r_type
== BFD_RELOC_VTABLE_ENTRY
)
4639 switch (fixP
->fx_size
)
4641 /* The cast to offsetT below are necessary to make code
4642 correct for machines where ints are smaller than offsetT. */
4646 lower_limit
= - (offsetT
) 0x80;
4649 *buf
++ = (val
>> 8);
4651 upper_limit
= 0x7fff;
4652 lower_limit
= - (offsetT
) 0x8000;
4655 *buf
++ = (val
>> 24);
4656 *buf
++ = (val
>> 16);
4657 *buf
++ = (val
>> 8);
4659 upper_limit
= 0x7fffffff;
4660 lower_limit
= - (offsetT
) 0x7fffffff - 1; /* Avoid constant overflow. */
4663 BAD_CASE (fixP
->fx_size
);
4666 /* Fix up a negative reloc. */
4667 if (fixP
->fx_addsy
== NULL
&& fixP
->fx_subsy
!= NULL
)
4669 fixP
->fx_addsy
= fixP
->fx_subsy
;
4670 fixP
->fx_subsy
= NULL
;
4674 /* For non-pc-relative values, it's conceivable we might get something
4675 like "0xff" for a byte field. So extend the upper part of the range
4676 to accept such numbers. We arbitrarily disallow "-0xff" or "0xff+0xff",
4677 so that we can do any range checking at all. */
4678 if (! fixP
->fx_pcrel
&& ! fixP
->fx_signed
)
4679 upper_limit
= upper_limit
* 2 + 1;
4681 if ((addressT
) val
> upper_limit
4682 && (val
> 0 || val
< lower_limit
))
4683 as_bad_where (fixP
->fx_file
, fixP
->fx_line
, _("value out of range"));
4685 /* A one byte PC-relative reloc means a short branch. We can't use
4686 a short branch with a value of 0 or -1, because those indicate
4687 different opcodes (branches with longer offsets). fixup_segment
4688 in write.c may have clobbered fx_pcrel, so we need to examine the
4691 || fixP
->fx_r_type
== BFD_RELOC_8_PCREL
)
4692 && fixP
->fx_size
== 1
4693 && (fixP
->fx_addsy
== NULL
4694 || S_IS_DEFINED (fixP
->fx_addsy
))
4695 && (val
== 0 || val
== -1))
4696 as_bad_where (fixP
->fx_file
, fixP
->fx_line
, _("invalid byte branch offset"));
4699 /* *fragP has been relaxed to its final size, and now needs to have
4700 the bytes inside it modified to conform to the new size There is UGLY
4704 md_convert_frag_1 (fragS
*fragP
)
4709 /* Address in object code of the displacement. */
4710 register int object_address
= fragP
->fr_fix
+ fragP
->fr_address
;
4712 /* Address in gas core of the place to store the displacement. */
4713 /* This convinces the native rs6000 compiler to generate the code we
4715 register char *buffer_address
= fragP
->fr_literal
;
4716 buffer_address
+= fragP
->fr_fix
;
4717 /* End ibm compiler workaround. */
4719 /* The displacement of the address, from current location. */
4720 disp
= fragP
->fr_symbol
? S_GET_VALUE (fragP
->fr_symbol
) : 0;
4721 disp
= (disp
+ fragP
->fr_offset
) - object_address
;
4723 switch (fragP
->fr_subtype
)
4725 case TAB (BRANCHBWL
, BYTE
):
4726 case TAB (BRABSJUNC
, BYTE
):
4727 case TAB (BRABSJCOND
, BYTE
):
4728 case TAB (BRANCHBW
, BYTE
):
4729 know (issbyte (disp
));
4731 as_bad_where (fragP
->fr_file
, fragP
->fr_line
,
4732 _("short branch with zero offset: use :w"));
4733 fixP
= fix_new (fragP
, fragP
->fr_fix
- 1, 1, fragP
->fr_symbol
,
4734 fragP
->fr_offset
, 1, RELAX_RELOC_PC8
);
4735 fixP
->fx_pcrel_adjust
= -1;
4737 case TAB (BRANCHBWL
, SHORT
):
4738 case TAB (BRABSJUNC
, SHORT
):
4739 case TAB (BRABSJCOND
, SHORT
):
4740 case TAB (BRANCHBW
, SHORT
):
4741 fragP
->fr_opcode
[1] = 0x00;
4742 fix_new (fragP
, fragP
->fr_fix
, 2, fragP
->fr_symbol
, fragP
->fr_offset
,
4743 1, RELAX_RELOC_PC16
);
4746 case TAB (BRANCHBWL
, LONG
):
4747 fragP
->fr_opcode
[1] = (char) 0xFF;
4748 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4749 1, RELAX_RELOC_PC32
);
4752 case TAB (BRABSJUNC
, LONG
):
4753 if (fragP
->fr_opcode
[0] == 0x61) /* jbsr */
4755 if (flag_keep_pcrel
)
4756 as_fatal (_("Tried to convert PC relative BSR to absolute JSR"));
4757 fragP
->fr_opcode
[0] = 0x4E;
4758 fragP
->fr_opcode
[1] = (char) 0xB9; /* JSR with ABSL LONG operand. */
4759 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4760 0, RELAX_RELOC_ABS32
);
4763 else if (fragP
->fr_opcode
[0] == 0x60) /* jbra */
4765 if (flag_keep_pcrel
)
4766 as_fatal (_("Tried to convert PC relative branch to absolute jump"));
4767 fragP
->fr_opcode
[0] = 0x4E;
4768 fragP
->fr_opcode
[1] = (char) 0xF9; /* JMP with ABSL LONG operand. */
4769 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4770 0, RELAX_RELOC_ABS32
);
4775 /* This cannot happen, because jbsr and jbra are the only two
4776 unconditional branches. */
4780 case TAB (BRABSJCOND
, LONG
):
4781 if (flag_keep_pcrel
)
4782 as_fatal (_("Tried to convert PC relative conditional branch to absolute jump"));
4784 /* Only Bcc 68000 instructions can come here
4785 Change bcc into b!cc/jmp absl long. */
4786 fragP
->fr_opcode
[0] ^= 0x01; /* Invert bcc. */
4787 fragP
->fr_opcode
[1] = 0x06; /* Branch offset = 6. */
4789 /* JF: these used to be fr_opcode[2,3], but they may be in a
4790 different frag, in which case referring to them is a no-no.
4791 Only fr_opcode[0,1] are guaranteed to work. */
4792 *buffer_address
++ = 0x4e; /* put in jmp long (0x4ef9) */
4793 *buffer_address
++ = (char) 0xf9;
4794 fragP
->fr_fix
+= 2; /* Account for jmp instruction. */
4795 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
,
4796 fragP
->fr_offset
, 0, RELAX_RELOC_ABS32
);
4799 case TAB (FBRANCH
, SHORT
):
4800 know ((fragP
->fr_opcode
[1] & 0x40) == 0);
4801 fix_new (fragP
, fragP
->fr_fix
, 2, fragP
->fr_symbol
, fragP
->fr_offset
,
4802 1, RELAX_RELOC_PC16
);
4805 case TAB (FBRANCH
, LONG
):
4806 fragP
->fr_opcode
[1] |= 0x40; /* Turn on LONG bit. */
4807 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4808 1, RELAX_RELOC_PC32
);
4811 case TAB (DBCCLBR
, SHORT
):
4812 case TAB (DBCCABSJ
, SHORT
):
4813 fix_new (fragP
, fragP
->fr_fix
, 2, fragP
->fr_symbol
, fragP
->fr_offset
,
4814 1, RELAX_RELOC_PC16
);
4817 case TAB (DBCCLBR
, LONG
):
4818 /* Only DBcc instructions can come here.
4819 Change dbcc into dbcc/bral.
4820 JF: these used to be fr_opcode[2-7], but that's wrong. */
4821 if (flag_keep_pcrel
)
4822 as_fatal (_("Tried to convert DBcc to absolute jump"));
4824 *buffer_address
++ = 0x00; /* Branch offset = 4. */
4825 *buffer_address
++ = 0x04;
4826 *buffer_address
++ = 0x60; /* Put in bra pc+6. */
4827 *buffer_address
++ = 0x06;
4828 *buffer_address
++ = 0x60; /* Put in bral (0x60ff). */
4829 *buffer_address
++ = (char) 0xff;
4831 fragP
->fr_fix
+= 6; /* Account for bra/jmp instructions. */
4832 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
, 1,
4836 case TAB (DBCCABSJ
, LONG
):
4837 /* Only DBcc instructions can come here.
4838 Change dbcc into dbcc/jmp.
4839 JF: these used to be fr_opcode[2-7], but that's wrong. */
4840 if (flag_keep_pcrel
)
4841 as_fatal (_("Tried to convert PC relative conditional branch to absolute jump"));
4843 *buffer_address
++ = 0x00; /* Branch offset = 4. */
4844 *buffer_address
++ = 0x04;
4845 *buffer_address
++ = 0x60; /* Put in bra pc + 6. */
4846 *buffer_address
++ = 0x06;
4847 *buffer_address
++ = 0x4e; /* Put in jmp long (0x4ef9). */
4848 *buffer_address
++ = (char) 0xf9;
4850 fragP
->fr_fix
+= 6; /* Account for bra/jmp instructions. */
4851 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
, 0,
4855 case TAB (PCREL1632
, SHORT
):
4856 fragP
->fr_opcode
[1] &= ~0x3F;
4857 fragP
->fr_opcode
[1] |= 0x3A; /* 072 - mode 7.2 */
4858 fix_new (fragP
, (int) (fragP
->fr_fix
), 2, fragP
->fr_symbol
,
4859 fragP
->fr_offset
, 1, RELAX_RELOC_PC16
);
4862 case TAB (PCREL1632
, LONG
):
4863 /* Already set to mode 7.3; this indicates: PC indirect with
4864 suppressed index, 32-bit displacement. */
4865 *buffer_address
++ = 0x01;
4866 *buffer_address
++ = 0x70;
4868 fixP
= fix_new (fragP
, (int) (fragP
->fr_fix
), 4, fragP
->fr_symbol
,
4869 fragP
->fr_offset
, 1, RELAX_RELOC_PC32
);
4870 fixP
->fx_pcrel_adjust
= 2;
4873 case TAB (PCINDEX
, BYTE
):
4874 assert (fragP
->fr_fix
>= 2);
4875 buffer_address
[-2] &= ~1;
4876 fixP
= fix_new (fragP
, fragP
->fr_fix
- 1, 1, fragP
->fr_symbol
,
4877 fragP
->fr_offset
, 1, RELAX_RELOC_PC8
);
4878 fixP
->fx_pcrel_adjust
= 1;
4880 case TAB (PCINDEX
, SHORT
):
4881 assert (fragP
->fr_fix
>= 2);
4882 buffer_address
[-2] |= 0x1;
4883 buffer_address
[-1] = 0x20;
4884 fixP
= fix_new (fragP
, (int) (fragP
->fr_fix
), 2, fragP
->fr_symbol
,
4885 fragP
->fr_offset
, 1, RELAX_RELOC_PC16
);
4886 fixP
->fx_pcrel_adjust
= 2;
4889 case TAB (PCINDEX
, LONG
):
4890 assert (fragP
->fr_fix
>= 2);
4891 buffer_address
[-2] |= 0x1;
4892 buffer_address
[-1] = 0x30;
4893 fixP
= fix_new (fragP
, (int) (fragP
->fr_fix
), 4, fragP
->fr_symbol
,
4894 fragP
->fr_offset
, 1, RELAX_RELOC_PC32
);
4895 fixP
->fx_pcrel_adjust
= 2;
4898 case TAB (ABSTOPCREL
, SHORT
):
4899 fix_new (fragP
, fragP
->fr_fix
, 2, fragP
->fr_symbol
, fragP
->fr_offset
,
4900 1, RELAX_RELOC_PC16
);
4903 case TAB (ABSTOPCREL
, LONG
):
4904 if (flag_keep_pcrel
)
4905 as_fatal (_("Tried to convert PC relative conditional branch to absolute jump"));
4906 /* The thing to do here is force it to ABSOLUTE LONG, since
4907 ABSTOPCREL is really trying to shorten an ABSOLUTE address anyway. */
4908 if ((fragP
->fr_opcode
[1] & 0x3F) != 0x3A)
4910 fragP
->fr_opcode
[1] &= ~0x3F;
4911 fragP
->fr_opcode
[1] |= 0x39; /* Mode 7.1 */
4912 fix_new (fragP
, fragP
->fr_fix
, 4, fragP
->fr_symbol
, fragP
->fr_offset
,
4913 0, RELAX_RELOC_ABS32
);
4920 md_convert_frag (bfd
*abfd ATTRIBUTE_UNUSED
,
4921 segT sec ATTRIBUTE_UNUSED
,
4924 md_convert_frag_1 (fragP
);
4927 /* Force truly undefined symbols to their maximum size, and generally set up
4928 the frag list to be relaxed
4931 md_estimate_size_before_relax (fragS
*fragP
, segT segment
)
4933 /* Handle SZ_UNDEF first, it can be changed to BYTE or SHORT. */
4934 switch (fragP
->fr_subtype
)
4936 case TAB (BRANCHBWL
, SZ_UNDEF
):
4937 case TAB (BRABSJUNC
, SZ_UNDEF
):
4938 case TAB (BRABSJCOND
, SZ_UNDEF
):
4940 if (S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4941 && relaxable_symbol (fragP
->fr_symbol
))
4943 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), BYTE
);
4945 else if (flag_short_refs
)
4947 /* Symbol is undefined and we want short ref. */
4948 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), SHORT
);
4952 /* Symbol is still undefined. Make it LONG. */
4953 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), LONG
);
4958 case TAB (BRANCHBW
, SZ_UNDEF
):
4960 if (S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4961 && relaxable_symbol (fragP
->fr_symbol
))
4963 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), BYTE
);
4967 /* Symbol is undefined and we don't have long branches. */
4968 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), SHORT
);
4973 case TAB (FBRANCH
, SZ_UNDEF
):
4974 case TAB (DBCCLBR
, SZ_UNDEF
):
4975 case TAB (DBCCABSJ
, SZ_UNDEF
):
4976 case TAB (PCREL1632
, SZ_UNDEF
):
4978 if ((S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4979 && relaxable_symbol (fragP
->fr_symbol
))
4982 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), SHORT
);
4986 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), LONG
);
4991 case TAB (PCINDEX
, SZ_UNDEF
):
4992 if ((S_GET_SEGMENT (fragP
->fr_symbol
) == segment
4993 && relaxable_symbol (fragP
->fr_symbol
)))
4995 fragP
->fr_subtype
= TAB (PCINDEX
, BYTE
);
4999 fragP
->fr_subtype
= TAB (PCINDEX
, LONG
);
5003 case TAB (ABSTOPCREL
, SZ_UNDEF
):
5005 if ((S_GET_SEGMENT (fragP
->fr_symbol
) == segment
5006 && relaxable_symbol (fragP
->fr_symbol
)))
5008 fragP
->fr_subtype
= TAB (ABSTOPCREL
, SHORT
);
5012 fragP
->fr_subtype
= TAB (ABSTOPCREL
, LONG
);
5021 /* Now that SZ_UNDEF are taken care of, check others. */
5022 switch (fragP
->fr_subtype
)
5024 case TAB (BRANCHBWL
, BYTE
):
5025 case TAB (BRABSJUNC
, BYTE
):
5026 case TAB (BRABSJCOND
, BYTE
):
5027 case TAB (BRANCHBW
, BYTE
):
5028 /* We can't do a short jump to the next instruction, so in that
5029 case we force word mode. If the symbol is at the start of a
5030 frag, and it is the next frag with any data in it (usually
5031 this is just the next frag, but assembler listings may
5032 introduce empty frags), we must use word mode. */
5033 if (fragP
->fr_symbol
)
5037 sym_frag
= symbol_get_frag (fragP
->fr_symbol
);
5038 if (S_GET_VALUE (fragP
->fr_symbol
) == sym_frag
->fr_address
)
5042 for (l
= fragP
->fr_next
; l
&& l
!= sym_frag
; l
= l
->fr_next
)
5046 fragP
->fr_subtype
= TAB (TABTYPE (fragP
->fr_subtype
), SHORT
);
5053 return md_relax_table
[fragP
->fr_subtype
].rlx_length
;
5056 #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
5057 /* the bit-field entries in the relocation_info struct plays hell
5058 with the byte-order problems of cross-assembly. So as a hack,
5059 I added this mach. dependent ri twiddler. Ugly, but it gets
5061 /* on m68k: first 4 bytes are normal unsigned long, next three bytes
5062 are symbolnum, most sig. byte first. Last byte is broken up with
5063 bit 7 as pcrel, bits 6 & 5 as length, bit 4 as pcrel, and the lower
5064 nibble as nuthin. (on Sun 3 at least) */
5065 /* Translate the internal relocation information into target-specific
5069 md_ri_to_chars (char *the_bytes
, struct reloc_info_generic
*ri
)
5072 md_number_to_chars (the_bytes
, ri
->r_address
, 4);
5073 /* Now the fun stuff. */
5074 the_bytes
[4] = (ri
->r_symbolnum
>> 16) & 0x0ff;
5075 the_bytes
[5] = (ri
->r_symbolnum
>> 8) & 0x0ff;
5076 the_bytes
[6] = ri
->r_symbolnum
& 0x0ff;
5077 the_bytes
[7] = (((ri
->r_pcrel
<< 7) & 0x80)
5078 | ((ri
->r_length
<< 5) & 0x60)
5079 | ((ri
->r_extern
<< 4) & 0x10));
5084 #endif /* OBJ_AOUT or OBJ_BOUT */
5086 #ifndef WORKING_DOT_WORD
5087 int md_short_jump_size
= 4;
5088 int md_long_jump_size
= 6;
5091 md_create_short_jump (char *ptr
, addressT from_addr
, addressT to_addr
,
5092 fragS
*frag ATTRIBUTE_UNUSED
,
5093 symbolS
*to_symbol ATTRIBUTE_UNUSED
)
5097 offset
= to_addr
- (from_addr
+ 2);
5099 md_number_to_chars (ptr
, (valueT
) 0x6000, 2);
5100 md_number_to_chars (ptr
+ 2, (valueT
) offset
, 2);
5104 md_create_long_jump (char *ptr
, addressT from_addr
, addressT to_addr
,
5105 fragS
*frag
, symbolS
*to_symbol
)
5109 if (!HAVE_LONG_BRANCH (current_architecture
))
5111 if (flag_keep_pcrel
)
5112 as_fatal (_("Tried to convert PC relative branch to absolute jump"));
5113 offset
= to_addr
- S_GET_VALUE (to_symbol
);
5114 md_number_to_chars (ptr
, (valueT
) 0x4EF9, 2);
5115 md_number_to_chars (ptr
+ 2, (valueT
) offset
, 4);
5116 fix_new (frag
, (ptr
+ 2) - frag
->fr_literal
, 4, to_symbol
, (offsetT
) 0,
5121 offset
= to_addr
- (from_addr
+ 2);
5122 md_number_to_chars (ptr
, (valueT
) 0x60ff, 2);
5123 md_number_to_chars (ptr
+ 2, (valueT
) offset
, 4);
5129 /* Different values of OK tell what its OK to return. Things that
5130 aren't OK are an error (what a shock, no?)
5133 10: Absolute 1:8 only
5134 20: Absolute 0:7 only
5135 30: absolute 0:15 only
5136 40: Absolute 0:31 only
5137 50: absolute 0:127 only
5138 55: absolute -64:63 only
5139 60: absolute -128:127 only
5140 70: absolute 0:4095 only
5141 80: absolute -1, 1:7 only
5145 get_num (struct m68k_exp
*exp
, int ok
)
5147 if (exp
->exp
.X_op
== O_absent
)
5149 /* Do the same thing the VAX asm does. */
5150 op (exp
) = O_constant
;
5156 as_warn (_("expression out of range: defaulting to 1"));
5160 else if (exp
->exp
.X_op
== O_constant
)
5165 if ((valueT
) TRUNC (offs (exp
)) - 1 > 7)
5167 as_warn (_("expression out of range: defaulting to 1"));
5172 if ((valueT
) TRUNC (offs (exp
)) > 7)
5176 if ((valueT
) TRUNC (offs (exp
)) > 15)
5180 if ((valueT
) TRUNC (offs (exp
)) > 32)
5184 if ((valueT
) TRUNC (offs (exp
)) > 127)
5188 if ((valueT
) SEXT (offs (exp
)) + 64 > 127)
5192 if ((valueT
) SEXT (offs (exp
)) + 128 > 255)
5196 if ((valueT
) TRUNC (offs (exp
)) > 4095)
5199 as_warn (_("expression out of range: defaulting to 0"));
5204 if ((valueT
) TRUNC (offs (exp
)) != 0xffffffff
5205 && (valueT
) TRUNC (offs (exp
)) - 1 > 6)
5207 as_warn (_("expression out of range: defaulting to 1"));
5215 else if (exp
->exp
.X_op
== O_big
)
5217 if (offs (exp
) <= 0 /* flonum. */
5218 && (ok
== 90 /* no bignums */
5219 || (ok
> 10 /* Small-int ranges including 0 ok. */
5220 /* If we have a flonum zero, a zero integer should
5221 do as well (e.g., in moveq). */
5222 && generic_floating_point_number
.exponent
== 0
5223 && generic_floating_point_number
.low
[0] == 0)))
5225 /* HACK! Turn it into a long. */
5226 LITTLENUM_TYPE words
[6];
5228 gen_to_words (words
, 2, 8L); /* These numbers are magic! */
5229 op (exp
) = O_constant
;
5232 offs (exp
) = words
[1] | (words
[0] << 16);
5236 op (exp
) = O_constant
;
5239 offs (exp
) = (ok
== 10) ? 1 : 0;
5240 as_warn (_("Can't deal with expression; defaulting to %ld"),
5246 if (ok
>= 10 && ok
<= 80)
5248 op (exp
) = O_constant
;
5251 offs (exp
) = (ok
== 10) ? 1 : 0;
5252 as_warn (_("Can't deal with expression; defaulting to %ld"),
5257 if (exp
->size
!= SIZE_UNSPEC
)
5265 if (!isbyte (offs (exp
)))
5266 as_warn (_("expression doesn't fit in BYTE"));
5269 if (!isword (offs (exp
)))
5270 as_warn (_("expression doesn't fit in WORD"));
5278 /* These are the back-ends for the various machine dependent pseudo-ops. */
5281 s_data1 (int ignore ATTRIBUTE_UNUSED
)
5283 subseg_set (data_section
, 1);
5284 demand_empty_rest_of_line ();
5288 s_data2 (int ignore ATTRIBUTE_UNUSED
)
5290 subseg_set (data_section
, 2);
5291 demand_empty_rest_of_line ();
5295 s_bss (int ignore ATTRIBUTE_UNUSED
)
5297 /* We don't support putting frags in the BSS segment, we fake it
5298 by marking in_bss, then looking at s_skip for clues. */
5300 subseg_set (bss_section
, 0);
5301 demand_empty_rest_of_line ();
5305 s_even (int ignore ATTRIBUTE_UNUSED
)
5308 register long temp_fill
;
5310 temp
= 1; /* JF should be 2? */
5311 temp_fill
= get_absolute_expression ();
5312 if (!need_pass_2
) /* Never make frag if expect extra pass. */
5313 frag_align (temp
, (int) temp_fill
, 0);
5314 demand_empty_rest_of_line ();
5315 record_alignment (now_seg
, temp
);
5319 s_proc (int ignore ATTRIBUTE_UNUSED
)
5321 demand_empty_rest_of_line ();
5324 /* Pseudo-ops handled for MRI compatibility. */
5326 /* This function returns non-zero if the argument is a conditional
5327 pseudo-op. This is called when checking whether a pending
5328 alignment is needed. */
5331 m68k_conditional_pseudoop (pseudo_typeS
*pop
)
5333 return (pop
->poc_handler
== s_mri_if
5334 || pop
->poc_handler
== s_mri_else
);
5337 /* Handle an MRI style chip specification. */
5346 s
= input_line_pointer
;
5347 /* We can't use get_symbol_end since the processor names are not proper
5349 while (is_part_of_name (c
= *input_line_pointer
++))
5351 *--input_line_pointer
= 0;
5352 for (i
= 0; m68k_cpus
[i
].name
; i
++)
5353 if (strcasecmp (s
, m68k_cpus
[i
].name
) == 0)
5355 if (!m68k_cpus
[i
].name
)
5357 as_bad (_("%s: unrecognized processor name"), s
);
5358 *input_line_pointer
= c
;
5359 ignore_rest_of_line ();
5362 *input_line_pointer
= c
;
5364 if (*input_line_pointer
== '/')
5365 current_architecture
= 0;
5367 current_architecture
&= m68881
| m68851
;
5368 current_architecture
|= m68k_cpus
[i
].arch
& ~(m68881
| m68851
);
5369 current_chip
= m68k_cpus
[i
].chip
;
5371 while (*input_line_pointer
== '/')
5373 ++input_line_pointer
;
5374 s
= input_line_pointer
;
5375 /* We can't use get_symbol_end since the processor names are not
5377 while (is_part_of_name (c
= *input_line_pointer
++))
5379 *--input_line_pointer
= 0;
5380 if (strcmp (s
, "68881") == 0)
5381 current_architecture
|= m68881
;
5382 else if (strcmp (s
, "68851") == 0)
5383 current_architecture
|= m68851
;
5384 *input_line_pointer
= c
;
5387 /* Update info about available control registers. */
5388 select_control_regs ();
5391 /* The MRI CHIP pseudo-op. */
5394 s_chip (int ignore ATTRIBUTE_UNUSED
)
5400 stop
= mri_comment_field (&stopc
);
5403 mri_comment_end (stop
, stopc
);
5404 demand_empty_rest_of_line ();
5407 /* The MRI FOPT pseudo-op. */
5410 s_fopt (int ignore ATTRIBUTE_UNUSED
)
5414 if (strncasecmp (input_line_pointer
, "ID=", 3) == 0)
5418 input_line_pointer
+= 3;
5419 temp
= get_absolute_expression ();
5420 if (temp
< 0 || temp
> 7)
5421 as_bad (_("bad coprocessor id"));
5423 m68k_float_copnum
= COP0
+ temp
;
5427 as_bad (_("unrecognized fopt option"));
5428 ignore_rest_of_line ();
5432 demand_empty_rest_of_line ();
5435 /* The structure used to handle the MRI OPT pseudo-op. */
5439 /* The name of the option. */
5442 /* If this is not NULL, just call this function. The first argument
5443 is the ARG field of this structure, the second argument is
5444 whether the option was negated. */
5445 void (*pfn
) (int arg
, int on
);
5447 /* If this is not NULL, and the PFN field is NULL, set the variable
5448 this points to. Set it to the ARG field if the option was not
5449 negated, and the NOTARG field otherwise. */
5452 /* The value to pass to PFN or to assign to *PVAR. */
5455 /* The value to assign to *PVAR if the option is negated. If PFN is
5456 NULL, and PVAR is not NULL, and ARG and NOTARG are the same, then
5457 the option may not be negated. */
5461 /* The table used to handle the MRI OPT pseudo-op. */
5463 static void skip_to_comma (int, int);
5464 static void opt_nest (int, int);
5465 static void opt_chip (int, int);
5466 static void opt_list (int, int);
5467 static void opt_list_symbols (int, int);
5469 static const struct opt_action opt_table
[] =
5471 { "abspcadd", 0, &m68k_abspcadd
, 1, 0 },
5473 /* We do relaxing, so there is little use for these options. */
5474 { "b", 0, 0, 0, 0 },
5475 { "brs", 0, 0, 0, 0 },
5476 { "brb", 0, 0, 0, 0 },
5477 { "brl", 0, 0, 0, 0 },
5478 { "brw", 0, 0, 0, 0 },
5480 { "c", 0, 0, 0, 0 },
5481 { "cex", 0, 0, 0, 0 },
5482 { "case", 0, &symbols_case_sensitive
, 1, 0 },
5483 { "cl", 0, 0, 0, 0 },
5484 { "cre", 0, 0, 0, 0 },
5485 { "d", 0, &flag_keep_locals
, 1, 0 },
5486 { "e", 0, 0, 0, 0 },
5487 { "f", 0, &flag_short_refs
, 1, 0 },
5488 { "frs", 0, &flag_short_refs
, 1, 0 },
5489 { "frl", 0, &flag_short_refs
, 0, 1 },
5490 { "g", 0, 0, 0, 0 },
5491 { "i", 0, 0, 0, 0 },
5492 { "m", 0, 0, 0, 0 },
5493 { "mex", 0, 0, 0, 0 },
5494 { "mc", 0, 0, 0, 0 },
5495 { "md", 0, 0, 0, 0 },
5496 { "nest", opt_nest
, 0, 0, 0 },
5497 { "next", skip_to_comma
, 0, 0, 0 },
5498 { "o", 0, 0, 0, 0 },
5499 { "old", 0, 0, 0, 0 },
5500 { "op", skip_to_comma
, 0, 0, 0 },
5501 { "pco", 0, 0, 0, 0 },
5502 { "p", opt_chip
, 0, 0, 0 },
5503 { "pcr", 0, 0, 0, 0 },
5504 { "pcs", 0, 0, 0, 0 },
5505 { "r", 0, 0, 0, 0 },
5506 { "quick", 0, &m68k_quick
, 1, 0 },
5507 { "rel32", 0, &m68k_rel32
, 1, 0 },
5508 { "s", opt_list
, 0, 0, 0 },
5509 { "t", opt_list_symbols
, 0, 0, 0 },
5510 { "w", 0, &flag_no_warnings
, 0, 1 },
5514 #define OPTCOUNT ((int) (sizeof opt_table / sizeof opt_table[0]))
5516 /* The MRI OPT pseudo-op. */
5519 s_opt (int ignore ATTRIBUTE_UNUSED
)
5527 const struct opt_action
*o
;
5532 if (*input_line_pointer
== '-')
5534 ++input_line_pointer
;
5537 else if (strncasecmp (input_line_pointer
, "NO", 2) == 0)
5539 input_line_pointer
+= 2;
5543 s
= input_line_pointer
;
5544 c
= get_symbol_end ();
5546 for (i
= 0, o
= opt_table
; i
< OPTCOUNT
; i
++, o
++)
5548 if (strcasecmp (s
, o
->name
) == 0)
5552 /* Restore input_line_pointer now in case the option
5554 *input_line_pointer
= c
;
5555 (*o
->pfn
) (o
->arg
, t
);
5557 else if (o
->pvar
!= NULL
)
5559 if (! t
&& o
->arg
== o
->notarg
)
5560 as_bad (_("option `%s' may not be negated"), s
);
5561 *input_line_pointer
= c
;
5562 *o
->pvar
= t
? o
->arg
: o
->notarg
;
5565 *input_line_pointer
= c
;
5571 as_bad (_("option `%s' not recognized"), s
);
5572 *input_line_pointer
= c
;
5575 while (*input_line_pointer
++ == ',');
5577 /* Move back to terminating character. */
5578 --input_line_pointer
;
5579 demand_empty_rest_of_line ();
5582 /* Skip ahead to a comma. This is used for OPT options which we do
5583 not support and which take arguments. */
5586 skip_to_comma (int arg ATTRIBUTE_UNUSED
, int on ATTRIBUTE_UNUSED
)
5588 while (*input_line_pointer
!= ','
5589 && ! is_end_of_line
[(unsigned char) *input_line_pointer
])
5590 ++input_line_pointer
;
5593 /* Handle the OPT NEST=depth option. */
5596 opt_nest (int arg ATTRIBUTE_UNUSED
, int on ATTRIBUTE_UNUSED
)
5598 if (*input_line_pointer
!= '=')
5600 as_bad (_("bad format of OPT NEST=depth"));
5604 ++input_line_pointer
;
5605 max_macro_nest
= get_absolute_expression ();
5608 /* Handle the OPT P=chip option. */
5611 opt_chip (int arg ATTRIBUTE_UNUSED
, int on ATTRIBUTE_UNUSED
)
5613 if (*input_line_pointer
!= '=')
5615 /* This is just OPT P, which we do not support. */
5619 ++input_line_pointer
;
5623 /* Handle the OPT S option. */
5626 opt_list (int arg ATTRIBUTE_UNUSED
, int on
)
5631 /* Handle the OPT T option. */
5634 opt_list_symbols (int arg ATTRIBUTE_UNUSED
, int on
)
5637 listing
|= LISTING_SYMBOLS
;
5639 listing
&= ~LISTING_SYMBOLS
;
5642 /* Handle the MRI REG pseudo-op. */
5645 s_reg (int ignore ATTRIBUTE_UNUSED
)
5654 if (line_label
== NULL
)
5656 as_bad (_("missing label"));
5657 ignore_rest_of_line ();
5662 stop
= mri_comment_field (&stopc
);
5666 s
= input_line_pointer
;
5667 while (ISALNUM (*input_line_pointer
)
5668 #ifdef REGISTER_PREFIX
5669 || *input_line_pointer
== REGISTER_PREFIX
5671 || *input_line_pointer
== '/'
5672 || *input_line_pointer
== '-')
5673 ++input_line_pointer
;
5674 c
= *input_line_pointer
;
5675 *input_line_pointer
= '\0';
5677 if (m68k_ip_op (s
, &rop
) != 0)
5679 if (rop
.error
== NULL
)
5680 as_bad (_("bad register list"));
5682 as_bad (_("bad register list: %s"), rop
.error
);
5683 *input_line_pointer
= c
;
5684 ignore_rest_of_line ();
5688 *input_line_pointer
= c
;
5690 if (rop
.mode
== REGLST
)
5692 else if (rop
.mode
== DREG
)
5693 mask
= 1 << (rop
.reg
- DATA0
);
5694 else if (rop
.mode
== AREG
)
5695 mask
= 1 << (rop
.reg
- ADDR0
+ 8);
5696 else if (rop
.mode
== FPREG
)
5697 mask
= 1 << (rop
.reg
- FP0
+ 16);
5698 else if (rop
.mode
== CONTROL
5701 else if (rop
.mode
== CONTROL
5704 else if (rop
.mode
== CONTROL
5709 as_bad (_("bad register list"));
5710 ignore_rest_of_line ();
5714 S_SET_SEGMENT (line_label
, reg_section
);
5715 S_SET_VALUE (line_label
, ~mask
);
5716 symbol_set_frag (line_label
, &zero_address_frag
);
5719 mri_comment_end (stop
, stopc
);
5721 demand_empty_rest_of_line ();
5724 /* This structure is used for the MRI SAVE and RESTORE pseudo-ops. */
5728 struct save_opts
*next
;
5730 int symbols_case_sensitive
;
5739 /* FIXME: We don't save OPT S. */
5742 /* This variable holds the stack of saved options. */
5744 static struct save_opts
*save_stack
;
5746 /* The MRI SAVE pseudo-op. */
5749 s_save (int ignore ATTRIBUTE_UNUSED
)
5751 struct save_opts
*s
;
5753 s
= (struct save_opts
*) xmalloc (sizeof (struct save_opts
));
5754 s
->abspcadd
= m68k_abspcadd
;
5755 s
->symbols_case_sensitive
= symbols_case_sensitive
;
5756 s
->keep_locals
= flag_keep_locals
;
5757 s
->short_refs
= flag_short_refs
;
5758 s
->architecture
= current_architecture
;
5759 s
->chip
= current_chip
;
5760 s
->quick
= m68k_quick
;
5761 s
->rel32
= m68k_rel32
;
5762 s
->listing
= listing
;
5763 s
->no_warnings
= flag_no_warnings
;
5765 s
->next
= save_stack
;
5768 demand_empty_rest_of_line ();
5771 /* The MRI RESTORE pseudo-op. */
5774 s_restore (int ignore ATTRIBUTE_UNUSED
)
5776 struct save_opts
*s
;
5778 if (save_stack
== NULL
)
5780 as_bad (_("restore without save"));
5781 ignore_rest_of_line ();
5786 save_stack
= s
->next
;
5788 m68k_abspcadd
= s
->abspcadd
;
5789 symbols_case_sensitive
= s
->symbols_case_sensitive
;
5790 flag_keep_locals
= s
->keep_locals
;
5791 flag_short_refs
= s
->short_refs
;
5792 current_architecture
= s
->architecture
;
5793 current_chip
= s
->chip
;
5794 m68k_quick
= s
->quick
;
5795 m68k_rel32
= s
->rel32
;
5796 listing
= s
->listing
;
5797 flag_no_warnings
= s
->no_warnings
;
5801 demand_empty_rest_of_line ();
5804 /* Types of MRI structured control directives. */
5806 enum mri_control_type
5814 /* This structure is used to stack the MRI structured control
5817 struct mri_control_info
5819 /* The directive within which this one is enclosed. */
5820 struct mri_control_info
*outer
;
5822 /* The type of directive. */
5823 enum mri_control_type type
;
5825 /* Whether an ELSE has been in an IF. */
5828 /* The add or sub statement at the end of a FOR. */
5831 /* The label of the top of a FOR or REPEAT loop. */
5834 /* The label to jump to for the next iteration, or the else
5835 expression of a conditional. */
5838 /* The label to jump to to break out of the loop, or the label past
5839 the end of a conditional. */
5843 /* The stack of MRI structured control directives. */
5845 static struct mri_control_info
*mri_control_stack
;
5847 /* The current MRI structured control directive index number, used to
5848 generate label names. */
5850 static int mri_control_index
;
5852 /* Assemble an instruction for an MRI structured control directive. */
5855 mri_assemble (char *str
)
5859 /* md_assemble expects the opcode to be in lower case. */
5860 for (s
= str
; *s
!= ' ' && *s
!= '\0'; s
++)
5866 /* Generate a new MRI label structured control directive label name. */
5869 mri_control_label (void)
5873 n
= (char *) xmalloc (20);
5874 sprintf (n
, "%smc%d", FAKE_LABEL_NAME
, mri_control_index
);
5875 ++mri_control_index
;
5879 /* Create a new MRI structured control directive. */
5881 static struct mri_control_info
*
5882 push_mri_control (enum mri_control_type type
)
5884 struct mri_control_info
*n
;
5886 n
= (struct mri_control_info
*) xmalloc (sizeof (struct mri_control_info
));
5890 if (type
== mri_if
|| type
== mri_while
)
5893 n
->top
= mri_control_label ();
5894 n
->next
= mri_control_label ();
5895 n
->bottom
= mri_control_label ();
5897 n
->outer
= mri_control_stack
;
5898 mri_control_stack
= n
;
5903 /* Pop off the stack of MRI structured control directives. */
5906 pop_mri_control (void)
5908 struct mri_control_info
*n
;
5910 n
= mri_control_stack
;
5911 mri_control_stack
= n
->outer
;
5919 /* Recognize a condition code in an MRI structured control expression. */
5922 parse_mri_condition (int *pcc
)
5926 know (*input_line_pointer
== '<');
5928 ++input_line_pointer
;
5929 c1
= *input_line_pointer
++;
5930 c2
= *input_line_pointer
++;
5932 if (*input_line_pointer
!= '>')
5934 as_bad (_("syntax error in structured control directive"));
5938 ++input_line_pointer
;
5944 *pcc
= (c1
<< 8) | c2
;
5949 /* Parse a single operand in an MRI structured control expression. */
5952 parse_mri_control_operand (int *pcc
, char **leftstart
, char **leftstop
,
5953 char **rightstart
, char **rightstop
)
5965 if (*input_line_pointer
== '<')
5967 /* It's just a condition code. */
5968 return parse_mri_condition (pcc
);
5971 /* Look ahead for the condition code. */
5972 for (s
= input_line_pointer
; *s
!= '\0'; ++s
)
5974 if (*s
== '<' && s
[1] != '\0' && s
[2] != '\0' && s
[3] == '>')
5979 as_bad (_("missing condition code in structured control directive"));
5983 *leftstart
= input_line_pointer
;
5985 if (*leftstop
> *leftstart
5986 && ((*leftstop
)[-1] == ' ' || (*leftstop
)[-1] == '\t'))
5989 input_line_pointer
= s
;
5990 if (! parse_mri_condition (pcc
))
5993 /* Look ahead for AND or OR or end of line. */
5994 for (s
= input_line_pointer
; *s
!= '\0'; ++s
)
5996 /* We must make sure we don't misinterpret AND/OR at the end of labels!
5997 if d0 <eq> #FOOAND and d1 <ne> #BAROR then
5999 if ((s
== input_line_pointer
6002 && ((strncasecmp (s
, "AND", 3) == 0
6003 && (s
[3] == '.' || ! is_part_of_name (s
[3])))
6004 || (strncasecmp (s
, "OR", 2) == 0
6005 && (s
[2] == '.' || ! is_part_of_name (s
[2])))))
6009 *rightstart
= input_line_pointer
;
6011 if (*rightstop
> *rightstart
6012 && ((*rightstop
)[-1] == ' ' || (*rightstop
)[-1] == '\t'))
6015 input_line_pointer
= s
;
6020 #define MCC(b1, b2) (((b1) << 8) | (b2))
6022 /* Swap the sense of a condition. This changes the condition so that
6023 it generates the same result when the operands are swapped. */
6026 swap_mri_condition (int cc
)
6030 case MCC ('h', 'i'): return MCC ('c', 's');
6031 case MCC ('l', 's'): return MCC ('c', 'c');
6032 /* <HS> is an alias for <CC>. */
6033 case MCC ('h', 's'):
6034 case MCC ('c', 'c'): return MCC ('l', 's');
6035 /* <LO> is an alias for <CS>. */
6036 case MCC ('l', 'o'):
6037 case MCC ('c', 's'): return MCC ('h', 'i');
6038 case MCC ('p', 'l'): return MCC ('m', 'i');
6039 case MCC ('m', 'i'): return MCC ('p', 'l');
6040 case MCC ('g', 'e'): return MCC ('l', 'e');
6041 case MCC ('l', 't'): return MCC ('g', 't');
6042 case MCC ('g', 't'): return MCC ('l', 't');
6043 case MCC ('l', 'e'): return MCC ('g', 'e');
6044 /* Issue a warning for conditions we can not swap. */
6045 case MCC ('n', 'e'): return MCC ('n', 'e'); // no problem here
6046 case MCC ('e', 'q'): return MCC ('e', 'q'); // also no problem
6047 case MCC ('v', 'c'):
6048 case MCC ('v', 's'):
6050 as_warn (_("Condition <%c%c> in structured control directive can not be encoded correctly"),
6051 (char) (cc
>> 8), (char) (cc
));
6057 /* Reverse the sense of a condition. */
6060 reverse_mri_condition (int cc
)
6064 case MCC ('h', 'i'): return MCC ('l', 's');
6065 case MCC ('l', 's'): return MCC ('h', 'i');
6066 /* <HS> is an alias for <CC> */
6067 case MCC ('h', 's'): return MCC ('l', 'o');
6068 case MCC ('c', 'c'): return MCC ('c', 's');
6069 /* <LO> is an alias for <CS> */
6070 case MCC ('l', 'o'): return MCC ('h', 's');
6071 case MCC ('c', 's'): return MCC ('c', 'c');
6072 case MCC ('n', 'e'): return MCC ('e', 'q');
6073 case MCC ('e', 'q'): return MCC ('n', 'e');
6074 case MCC ('v', 'c'): return MCC ('v', 's');
6075 case MCC ('v', 's'): return MCC ('v', 'c');
6076 case MCC ('p', 'l'): return MCC ('m', 'i');
6077 case MCC ('m', 'i'): return MCC ('p', 'l');
6078 case MCC ('g', 'e'): return MCC ('l', 't');
6079 case MCC ('l', 't'): return MCC ('g', 'e');
6080 case MCC ('g', 't'): return MCC ('l', 'e');
6081 case MCC ('l', 'e'): return MCC ('g', 't');
6086 /* Build an MRI structured control expression. This generates test
6087 and branch instructions. It goes to TRUELAB if the condition is
6088 true, and to FALSELAB if the condition is false. Exactly one of
6089 TRUELAB and FALSELAB will be NULL, meaning to fall through. QUAL
6090 is the size qualifier for the expression. EXTENT is the size to
6091 use for the branch. */
6094 build_mri_control_operand (int qual
, int cc
, char *leftstart
, char *leftstop
,
6095 char *rightstart
, char *rightstop
,
6096 const char *truelab
, const char *falselab
,
6102 if (leftstart
!= NULL
)
6104 struct m68k_op leftop
, rightop
;
6107 /* Swap the compare operands, if necessary, to produce a legal
6108 m68k compare instruction. Comparing a register operand with
6109 a non-register operand requires the register to be on the
6110 right (cmp, cmpa). Comparing an immediate value with
6111 anything requires the immediate value to be on the left
6116 (void) m68k_ip_op (leftstart
, &leftop
);
6121 (void) m68k_ip_op (rightstart
, &rightop
);
6124 if (rightop
.mode
== IMMED
6125 || ((leftop
.mode
== DREG
|| leftop
.mode
== AREG
)
6126 && (rightop
.mode
!= DREG
&& rightop
.mode
!= AREG
)))
6130 /* Correct conditional handling:
6131 if #1 <lt> d0 then ;means if (1 < d0)
6137 cmp #1,d0 if we do *not* swap the operands
6138 bgt true we need the swapped condition!
6145 leftstart
= rightstart
;
6148 leftstop
= rightstop
;
6153 cc
= swap_mri_condition (cc
);
6157 if (truelab
== NULL
)
6159 cc
= reverse_mri_condition (cc
);
6163 if (leftstart
!= NULL
)
6165 buf
= (char *) xmalloc (20
6166 + (leftstop
- leftstart
)
6167 + (rightstop
- rightstart
));
6173 *s
++ = TOLOWER (qual
);
6175 memcpy (s
, leftstart
, leftstop
- leftstart
);
6176 s
+= leftstop
- leftstart
;
6178 memcpy (s
, rightstart
, rightstop
- rightstart
);
6179 s
+= rightstop
- rightstart
;
6185 buf
= (char *) xmalloc (20 + strlen (truelab
));
6191 *s
++ = TOLOWER (extent
);
6193 strcpy (s
, truelab
);
6198 /* Parse an MRI structured control expression. This generates test
6199 and branch instructions. STOP is where the expression ends. It
6200 goes to TRUELAB if the condition is true, and to FALSELAB if the
6201 condition is false. Exactly one of TRUELAB and FALSELAB will be
6202 NULL, meaning to fall through. QUAL is the size qualifier for the
6203 expression. EXTENT is the size to use for the branch. */
6206 parse_mri_control_expression (char *stop
, int qual
, const char *truelab
,
6207 const char *falselab
, int extent
)
6219 if (! parse_mri_control_operand (&cc
, &leftstart
, &leftstop
,
6220 &rightstart
, &rightstop
))
6226 if (strncasecmp (input_line_pointer
, "AND", 3) == 0)
6230 if (falselab
!= NULL
)
6233 flab
= mri_control_label ();
6235 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6236 rightstop
, (const char *) NULL
, flab
, extent
);
6238 input_line_pointer
+= 3;
6239 if (*input_line_pointer
!= '.'
6240 || input_line_pointer
[1] == '\0')
6244 qual
= input_line_pointer
[1];
6245 input_line_pointer
+= 2;
6248 if (! parse_mri_control_operand (&cc
, &leftstart
, &leftstop
,
6249 &rightstart
, &rightstop
))
6255 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6256 rightstop
, truelab
, falselab
, extent
);
6258 if (falselab
== NULL
)
6261 else if (strncasecmp (input_line_pointer
, "OR", 2) == 0)
6265 if (truelab
!= NULL
)
6268 tlab
= mri_control_label ();
6270 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6271 rightstop
, tlab
, (const char *) NULL
, extent
);
6273 input_line_pointer
+= 2;
6274 if (*input_line_pointer
!= '.'
6275 || input_line_pointer
[1] == '\0')
6279 qual
= input_line_pointer
[1];
6280 input_line_pointer
+= 2;
6283 if (! parse_mri_control_operand (&cc
, &leftstart
, &leftstop
,
6284 &rightstart
, &rightstop
))
6290 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6291 rightstop
, truelab
, falselab
, extent
);
6293 if (truelab
== NULL
)
6298 build_mri_control_operand (qual
, cc
, leftstart
, leftstop
, rightstart
,
6299 rightstop
, truelab
, falselab
, extent
);
6303 if (input_line_pointer
!= stop
)
6304 as_bad (_("syntax error in structured control directive"));
6307 /* Handle the MRI IF pseudo-op. This may be a structured control
6308 directive, or it may be a regular assembler conditional, depending
6316 struct mri_control_info
*n
;
6318 /* A structured control directive must end with THEN with an
6319 optional qualifier. */
6320 s
= input_line_pointer
;
6321 /* We only accept '*' as introduction of comments if preceded by white space
6322 or at first column of a line (I think this can't actually happen here?)
6323 This is important when assembling:
6324 if d0 <ne> 12(a0,d0*2) then
6325 if d0 <ne> #CONST*20 then. */
6326 while (! (is_end_of_line
[(unsigned char) *s
]
6329 && (s
== input_line_pointer
6331 || *(s
-1) == '\t'))))
6334 while (s
> input_line_pointer
&& (*s
== ' ' || *s
== '\t'))
6337 if (s
- input_line_pointer
> 1
6341 if (s
- input_line_pointer
< 3
6342 || strncasecmp (s
- 3, "THEN", 4) != 0)
6346 as_bad (_("missing then"));
6347 ignore_rest_of_line ();
6351 /* It's a conditional. */
6356 /* Since this might be a conditional if, this pseudo-op will be
6357 called even if we are supported to be ignoring input. Double
6358 check now. Clobber *input_line_pointer so that ignore_input
6359 thinks that this is not a special pseudo-op. */
6360 c
= *input_line_pointer
;
6361 *input_line_pointer
= 0;
6362 if (ignore_input ())
6364 *input_line_pointer
= c
;
6365 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6366 ++input_line_pointer
;
6367 demand_empty_rest_of_line ();
6370 *input_line_pointer
= c
;
6372 n
= push_mri_control (mri_if
);
6374 parse_mri_control_expression (s
- 3, qual
, (const char *) NULL
,
6375 n
->next
, s
[1] == '.' ? s
[2] : '\0');
6378 input_line_pointer
= s
+ 3;
6380 input_line_pointer
= s
+ 1;
6384 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6385 ++input_line_pointer
;
6388 demand_empty_rest_of_line ();
6391 /* Handle the MRI else pseudo-op. If we are currently doing an MRI
6392 structured IF, associate the ELSE with the IF. Otherwise, assume
6393 it is a conditional else. */
6396 s_mri_else (int qual
)
6403 && (mri_control_stack
== NULL
6404 || mri_control_stack
->type
!= mri_if
6405 || mri_control_stack
->else_seen
))
6411 c
= *input_line_pointer
;
6412 *input_line_pointer
= 0;
6413 if (ignore_input ())
6415 *input_line_pointer
= c
;
6416 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6417 ++input_line_pointer
;
6418 demand_empty_rest_of_line ();
6421 *input_line_pointer
= c
;
6423 if (mri_control_stack
== NULL
6424 || mri_control_stack
->type
!= mri_if
6425 || mri_control_stack
->else_seen
)
6427 as_bad (_("else without matching if"));
6428 ignore_rest_of_line ();
6432 mri_control_stack
->else_seen
= 1;
6434 buf
= (char *) xmalloc (20 + strlen (mri_control_stack
->bottom
));
6435 q
[0] = TOLOWER (qual
);
6437 sprintf (buf
, "bra%s %s", q
, mri_control_stack
->bottom
);
6441 colon (mri_control_stack
->next
);
6445 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6446 ++input_line_pointer
;
6449 demand_empty_rest_of_line ();
6452 /* Handle the MRI ENDI pseudo-op. */
6455 s_mri_endi (int ignore ATTRIBUTE_UNUSED
)
6457 if (mri_control_stack
== NULL
6458 || mri_control_stack
->type
!= mri_if
)
6460 as_bad (_("endi without matching if"));
6461 ignore_rest_of_line ();
6465 /* ignore_input will not return true for ENDI, so we don't need to
6466 worry about checking it again here. */
6468 if (! mri_control_stack
->else_seen
)
6469 colon (mri_control_stack
->next
);
6470 colon (mri_control_stack
->bottom
);
6476 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6477 ++input_line_pointer
;
6480 demand_empty_rest_of_line ();
6483 /* Handle the MRI BREAK pseudo-op. */
6486 s_mri_break (int extent
)
6488 struct mri_control_info
*n
;
6492 n
= mri_control_stack
;
6494 && n
->type
!= mri_for
6495 && n
->type
!= mri_repeat
6496 && n
->type
!= mri_while
)
6500 as_bad (_("break outside of structured loop"));
6501 ignore_rest_of_line ();
6505 buf
= (char *) xmalloc (20 + strlen (n
->bottom
));
6506 ex
[0] = TOLOWER (extent
);
6508 sprintf (buf
, "bra%s %s", ex
, n
->bottom
);
6514 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6515 ++input_line_pointer
;
6518 demand_empty_rest_of_line ();
6521 /* Handle the MRI NEXT pseudo-op. */
6524 s_mri_next (int extent
)
6526 struct mri_control_info
*n
;
6530 n
= mri_control_stack
;
6532 && n
->type
!= mri_for
6533 && n
->type
!= mri_repeat
6534 && n
->type
!= mri_while
)
6538 as_bad (_("next outside of structured loop"));
6539 ignore_rest_of_line ();
6543 buf
= (char *) xmalloc (20 + strlen (n
->next
));
6544 ex
[0] = TOLOWER (extent
);
6546 sprintf (buf
, "bra%s %s", ex
, n
->next
);
6552 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6553 ++input_line_pointer
;
6556 demand_empty_rest_of_line ();
6559 /* Handle the MRI FOR pseudo-op. */
6562 s_mri_for (int qual
)
6564 const char *varstart
, *varstop
;
6565 const char *initstart
, *initstop
;
6566 const char *endstart
, *endstop
;
6567 const char *bystart
, *bystop
;
6571 struct mri_control_info
*n
;
6577 FOR.q var = init { TO | DOWNTO } end [ BY by ] DO.e
6581 varstart
= input_line_pointer
;
6583 /* Look for the '='. */
6584 while (! is_end_of_line
[(unsigned char) *input_line_pointer
]
6585 && *input_line_pointer
!= '=')
6586 ++input_line_pointer
;
6587 if (*input_line_pointer
!= '=')
6589 as_bad (_("missing ="));
6590 ignore_rest_of_line ();
6594 varstop
= input_line_pointer
;
6595 if (varstop
> varstart
6596 && (varstop
[-1] == ' ' || varstop
[-1] == '\t'))
6599 ++input_line_pointer
;
6601 initstart
= input_line_pointer
;
6603 /* Look for TO or DOWNTO. */
6606 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6608 if (strncasecmp (input_line_pointer
, "TO", 2) == 0
6609 && ! is_part_of_name (input_line_pointer
[2]))
6611 initstop
= input_line_pointer
;
6612 input_line_pointer
+= 2;
6615 if (strncasecmp (input_line_pointer
, "DOWNTO", 6) == 0
6616 && ! is_part_of_name (input_line_pointer
[6]))
6618 initstop
= input_line_pointer
;
6620 input_line_pointer
+= 6;
6623 ++input_line_pointer
;
6625 if (initstop
== NULL
)
6627 as_bad (_("missing to or downto"));
6628 ignore_rest_of_line ();
6631 if (initstop
> initstart
6632 && (initstop
[-1] == ' ' || initstop
[-1] == '\t'))
6636 endstart
= input_line_pointer
;
6638 /* Look for BY or DO. */
6641 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6643 if (strncasecmp (input_line_pointer
, "BY", 2) == 0
6644 && ! is_part_of_name (input_line_pointer
[2]))
6646 endstop
= input_line_pointer
;
6648 input_line_pointer
+= 2;
6651 if (strncasecmp (input_line_pointer
, "DO", 2) == 0
6652 && (input_line_pointer
[2] == '.'
6653 || ! is_part_of_name (input_line_pointer
[2])))
6655 endstop
= input_line_pointer
;
6656 input_line_pointer
+= 2;
6659 ++input_line_pointer
;
6661 if (endstop
== NULL
)
6663 as_bad (_("missing do"));
6664 ignore_rest_of_line ();
6667 if (endstop
> endstart
6668 && (endstop
[-1] == ' ' || endstop
[-1] == '\t'))
6674 bystop
= bystart
+ 2;
6679 bystart
= input_line_pointer
;
6683 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6685 if (strncasecmp (input_line_pointer
, "DO", 2) == 0
6686 && (input_line_pointer
[2] == '.'
6687 || ! is_part_of_name (input_line_pointer
[2])))
6689 bystop
= input_line_pointer
;
6690 input_line_pointer
+= 2;
6693 ++input_line_pointer
;
6697 as_bad (_("missing do"));
6698 ignore_rest_of_line ();
6701 if (bystop
> bystart
6702 && (bystop
[-1] == ' ' || bystop
[-1] == '\t'))
6706 if (*input_line_pointer
!= '.')
6710 extent
= input_line_pointer
[1];
6711 input_line_pointer
+= 2;
6714 /* We have fully parsed the FOR operands. Now build the loop. */
6715 n
= push_mri_control (mri_for
);
6717 buf
= (char *) xmalloc (50 + (input_line_pointer
- varstart
));
6719 /* Move init,var. */
6726 *s
++ = TOLOWER (qual
);
6728 memcpy (s
, initstart
, initstop
- initstart
);
6729 s
+= initstop
- initstart
;
6731 memcpy (s
, varstart
, varstop
- varstart
);
6732 s
+= varstop
- varstart
;
6744 *s
++ = TOLOWER (qual
);
6746 memcpy (s
, endstart
, endstop
- endstart
);
6747 s
+= endstop
- endstart
;
6749 memcpy (s
, varstart
, varstop
- varstart
);
6750 s
+= varstop
- varstart
;
6755 ex
[0] = TOLOWER (extent
);
6758 sprintf (buf
, "blt%s %s", ex
, n
->bottom
);
6760 sprintf (buf
, "bgt%s %s", ex
, n
->bottom
);
6763 /* Put together the add or sub instruction used by ENDF. */
6771 *s
++ = TOLOWER (qual
);
6773 memcpy (s
, bystart
, bystop
- bystart
);
6774 s
+= bystop
- bystart
;
6776 memcpy (s
, varstart
, varstop
- varstart
);
6777 s
+= varstop
- varstart
;
6783 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6784 ++input_line_pointer
;
6787 demand_empty_rest_of_line ();
6790 /* Handle the MRI ENDF pseudo-op. */
6793 s_mri_endf (int ignore ATTRIBUTE_UNUSED
)
6795 if (mri_control_stack
== NULL
6796 || mri_control_stack
->type
!= mri_for
)
6798 as_bad (_("endf without for"));
6799 ignore_rest_of_line ();
6803 colon (mri_control_stack
->next
);
6805 mri_assemble (mri_control_stack
->incr
);
6807 sprintf (mri_control_stack
->incr
, "bra %s", mri_control_stack
->top
);
6808 mri_assemble (mri_control_stack
->incr
);
6810 free (mri_control_stack
->incr
);
6812 colon (mri_control_stack
->bottom
);
6818 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6819 ++input_line_pointer
;
6822 demand_empty_rest_of_line ();
6825 /* Handle the MRI REPEAT pseudo-op. */
6828 s_mri_repeat (int ignore ATTRIBUTE_UNUSED
)
6830 struct mri_control_info
*n
;
6832 n
= push_mri_control (mri_repeat
);
6836 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6837 ++input_line_pointer
;
6839 demand_empty_rest_of_line ();
6842 /* Handle the MRI UNTIL pseudo-op. */
6845 s_mri_until (int qual
)
6849 if (mri_control_stack
== NULL
6850 || mri_control_stack
->type
!= mri_repeat
)
6852 as_bad (_("until without repeat"));
6853 ignore_rest_of_line ();
6857 colon (mri_control_stack
->next
);
6859 for (s
= input_line_pointer
; ! is_end_of_line
[(unsigned char) *s
]; s
++)
6862 parse_mri_control_expression (s
, qual
, (const char *) NULL
,
6863 mri_control_stack
->top
, '\0');
6865 colon (mri_control_stack
->bottom
);
6867 input_line_pointer
= s
;
6873 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6874 ++input_line_pointer
;
6877 demand_empty_rest_of_line ();
6880 /* Handle the MRI WHILE pseudo-op. */
6883 s_mri_while (int qual
)
6887 struct mri_control_info
*n
;
6889 s
= input_line_pointer
;
6890 /* We only accept '*' as introduction of comments if preceded by white space
6891 or at first column of a line (I think this can't actually happen here?)
6892 This is important when assembling:
6893 while d0 <ne> 12(a0,d0*2) do
6894 while d0 <ne> #CONST*20 do. */
6895 while (! (is_end_of_line
[(unsigned char) *s
]
6898 && (s
== input_line_pointer
6900 || *(s
-1) == '\t'))))
6903 while (*s
== ' ' || *s
== '\t')
6905 if (s
- input_line_pointer
> 1
6908 if (s
- input_line_pointer
< 2
6909 || strncasecmp (s
- 1, "DO", 2) != 0)
6911 as_bad (_("missing do"));
6912 ignore_rest_of_line ();
6916 n
= push_mri_control (mri_while
);
6920 parse_mri_control_expression (s
- 1, qual
, (const char *) NULL
, n
->bottom
,
6921 s
[1] == '.' ? s
[2] : '\0');
6923 input_line_pointer
= s
+ 1;
6924 if (*input_line_pointer
== '.')
6925 input_line_pointer
+= 2;
6929 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6930 ++input_line_pointer
;
6933 demand_empty_rest_of_line ();
6936 /* Handle the MRI ENDW pseudo-op. */
6939 s_mri_endw (int ignore ATTRIBUTE_UNUSED
)
6943 if (mri_control_stack
== NULL
6944 || mri_control_stack
->type
!= mri_while
)
6946 as_bad (_("endw without while"));
6947 ignore_rest_of_line ();
6951 buf
= (char *) xmalloc (20 + strlen (mri_control_stack
->next
));
6952 sprintf (buf
, "bra %s", mri_control_stack
->next
);
6956 colon (mri_control_stack
->bottom
);
6962 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
6963 ++input_line_pointer
;
6966 demand_empty_rest_of_line ();
6969 /* Parse a .cpu directive. */
6972 s_m68k_cpu (int ignored ATTRIBUTE_UNUSED
)
6979 as_bad (_("already assembled instructions"));
6980 ignore_rest_of_line ();
6984 name
= input_line_pointer
;
6985 while (*input_line_pointer
&& !ISSPACE(*input_line_pointer
))
6986 input_line_pointer
++;
6987 saved_char
= *input_line_pointer
;
6988 *input_line_pointer
= 0;
6990 m68k_set_cpu (name
, 1, 0);
6992 *input_line_pointer
= saved_char
;
6993 demand_empty_rest_of_line ();
6997 /* Parse a .arch directive. */
7000 s_m68k_arch (int ignored ATTRIBUTE_UNUSED
)
7007 as_bad (_("already assembled instructions"));
7008 ignore_rest_of_line ();
7012 name
= input_line_pointer
;
7013 while (*input_line_pointer
&& *input_line_pointer
!= ','
7014 && !ISSPACE (*input_line_pointer
))
7015 input_line_pointer
++;
7016 saved_char
= *input_line_pointer
;
7017 *input_line_pointer
= 0;
7019 if (m68k_set_arch (name
, 1, 0))
7021 /* Scan extensions. */
7024 *input_line_pointer
++ = saved_char
;
7025 if (!*input_line_pointer
|| ISSPACE (*input_line_pointer
))
7027 name
= input_line_pointer
;
7028 while (*input_line_pointer
&& *input_line_pointer
!= ','
7029 && !ISSPACE (*input_line_pointer
))
7030 input_line_pointer
++;
7031 saved_char
= *input_line_pointer
;
7032 *input_line_pointer
= 0;
7034 while (m68k_set_extension (name
, 1, 0));
7037 *input_line_pointer
= saved_char
;
7038 demand_empty_rest_of_line ();
7042 /* Lookup a cpu name in TABLE and return the slot found. Return NULL
7043 if none is found, the caller is responsible for emitting an error
7044 message. If ALLOW_M is non-zero, we allow an initial 'm' on the
7045 cpu name, if it begins with a '6' (possibly skipping an intervening
7046 'c'. We also allow a 'c' in the same place. if NEGATED is
7047 non-zero, we accept a leading 'no-' and *NEGATED is set to true, if
7048 the option is indeed negated. */
7050 static const struct m68k_cpu
*
7051 m68k_lookup_cpu (const char *arg
, const struct m68k_cpu
*table
,
7052 int allow_m
, int *negated
)
7054 /* allow negated value? */
7059 if (arg
[0] == 'n' && arg
[1] == 'o' && arg
[2] == '-')
7066 /* Remove 'm' or 'mc' prefix from 68k variants. */
7073 else if (arg
[1] == 'c' && arg
[2] == '6')
7077 else if (arg
[0] == 'c' && arg
[1] == '6')
7080 for (; table
->name
; table
++)
7081 if (!strcmp (arg
, table
->name
))
7086 /* Set the cpu, issuing errors if it is unrecognized, or invalid */
7089 m68k_set_cpu (char const *name
, int allow_m
, int silent
)
7091 const struct m68k_cpu
*cpu
;
7093 cpu
= m68k_lookup_cpu (name
, m68k_cpus
, allow_m
, NULL
);
7098 as_bad (_("cpu `%s' unrecognized"), name
);
7102 if (selected_cpu
&& selected_cpu
!= cpu
)
7104 as_bad (_("already selected `%s' processor"),
7105 selected_cpu
->name
);
7112 /* Set the architecture, issuing errors if it is unrecognized, or invalid */
7115 m68k_set_arch (char const *name
, int allow_m
, int silent
)
7117 const struct m68k_cpu
*arch
;
7119 arch
= m68k_lookup_cpu (name
, m68k_archs
, allow_m
, NULL
);
7124 as_bad (_("architecture `%s' unrecognized"), name
);
7128 if (selected_arch
&& selected_arch
!= arch
)
7130 as_bad (_("already selected `%s' architecture"),
7131 selected_arch
->name
);
7135 selected_arch
= arch
;
7139 /* Set the architecture extension, issuing errors if it is
7140 unrecognized, or invalid */
7143 m68k_set_extension (char const *name
, int allow_m
, int silent
)
7146 const struct m68k_cpu
*ext
;
7148 ext
= m68k_lookup_cpu (name
, m68k_extensions
, allow_m
, &negated
);
7153 as_bad (_("extension `%s' unrecognized"), name
);
7158 not_current_architecture
|= ext
->arch
;
7160 current_architecture
|= ext
->arch
;
7165 Invocation line includes a switch not recognized by the base assembler.
7169 const char *md_shortopts
= "lSA:m:kQ:V";
7171 const char *md_shortopts
= "lSA:m:k";
7174 struct option md_longopts
[] = {
7175 #define OPTION_PIC (OPTION_MD_BASE)
7176 {"pic", no_argument
, NULL
, OPTION_PIC
},
7177 #define OPTION_REGISTER_PREFIX_OPTIONAL (OPTION_MD_BASE + 1)
7178 {"register-prefix-optional", no_argument
, NULL
,
7179 OPTION_REGISTER_PREFIX_OPTIONAL
},
7180 #define OPTION_BITWISE_OR (OPTION_MD_BASE + 2)
7181 {"bitwise-or", no_argument
, NULL
, OPTION_BITWISE_OR
},
7182 #define OPTION_BASE_SIZE_DEFAULT_16 (OPTION_MD_BASE + 3)
7183 {"base-size-default-16", no_argument
, NULL
, OPTION_BASE_SIZE_DEFAULT_16
},
7184 #define OPTION_BASE_SIZE_DEFAULT_32 (OPTION_MD_BASE + 4)
7185 {"base-size-default-32", no_argument
, NULL
, OPTION_BASE_SIZE_DEFAULT_32
},
7186 #define OPTION_DISP_SIZE_DEFAULT_16 (OPTION_MD_BASE + 5)
7187 {"disp-size-default-16", no_argument
, NULL
, OPTION_DISP_SIZE_DEFAULT_16
},
7188 #define OPTION_DISP_SIZE_DEFAULT_32 (OPTION_MD_BASE + 6)
7189 {"disp-size-default-32", no_argument
, NULL
, OPTION_DISP_SIZE_DEFAULT_32
},
7190 #define OPTION_PCREL (OPTION_MD_BASE + 7)
7191 {"pcrel", no_argument
, NULL
, OPTION_PCREL
},
7192 {NULL
, no_argument
, NULL
, 0}
7194 size_t md_longopts_size
= sizeof (md_longopts
);
7197 md_parse_option (int c
, char *arg
)
7201 case 'l': /* -l means keep external to 2 bit offset
7202 rather than 16 bit one. */
7203 flag_short_refs
= 1;
7206 case 'S': /* -S means that jbsr's always turn into
7208 flag_long_jumps
= 1;
7211 case OPTION_PCREL
: /* --pcrel means never turn PC-relative
7212 branches into absolute jumps. */
7213 flag_keep_pcrel
= 1;
7219 break; /* -pic, Position Independent Code. */
7221 case OPTION_REGISTER_PREFIX_OPTIONAL
:
7222 flag_reg_prefix_optional
= 1;
7223 reg_prefix_optional_seen
= 1;
7226 /* -V: SVR4 argument to print version ID. */
7228 print_version_id ();
7231 /* -Qy, -Qn: SVR4 arguments controlling whether a .comment section
7232 should be emitted or not. FIXME: Not implemented. */
7236 case OPTION_BITWISE_OR
:
7241 n
= (char *) xmalloc (strlen (m68k_comment_chars
) + 1);
7243 for (s
= m68k_comment_chars
; *s
!= '\0'; s
++)
7247 m68k_comment_chars
= n
;
7251 case OPTION_BASE_SIZE_DEFAULT_16
:
7252 m68k_index_width_default
= SIZE_WORD
;
7255 case OPTION_BASE_SIZE_DEFAULT_32
:
7256 m68k_index_width_default
= SIZE_LONG
;
7259 case OPTION_DISP_SIZE_DEFAULT_16
:
7261 m68k_rel32_from_cmdline
= 1;
7264 case OPTION_DISP_SIZE_DEFAULT_32
:
7266 m68k_rel32_from_cmdline
= 1;
7271 as_tsktsk (_ ("option `-A%s' is deprecated: use `-%s'",
7274 /* Intentional fall-through. */
7276 if (!strncmp (arg
, "arch=", 5))
7277 m68k_set_arch (arg
+ 5, 1, 0);
7278 else if (!strncmp (arg
, "cpu=", 4))
7279 m68k_set_cpu (arg
+ 4, 1, 0);
7280 else if (m68k_set_extension (arg
, 0, 1))
7282 else if (m68k_set_arch (arg
, 0, 1))
7284 else if (m68k_set_cpu (arg
, 0, 1))
7297 /* Setup tables from the selected arch and/or cpu */
7300 m68k_init_arch (void)
7302 if (not_current_architecture
& current_architecture
)
7304 as_bad (_("architecture features both enabled and disabled"));
7305 not_current_architecture
&= ~current_architecture
;
7308 current_architecture
|= selected_arch
->arch
;
7310 current_architecture
|= selected_cpu
->arch
;
7312 current_architecture
&= ~not_current_architecture
;
7316 if (current_architecture
& ~selected_cpu
->arch
)
7318 as_bad (_("selected processor does not have all features of selected architecture"));
7319 current_architecture
7320 = selected_cpu
->arch
& ~not_current_architecture
;
7324 if ((current_architecture
& (cfloat
| m68881
)) == (cfloat
| m68881
))
7326 /* Determine which float is really meant. */
7327 if (current_architecture
& (m68k_mask
& ~m68881
))
7328 current_architecture
^= cfloat
;
7330 current_architecture
^= m68881
;
7333 if ((current_architecture
& m68k_mask
)
7334 && (current_architecture
& ~m68k_mask
))
7336 as_bad (_ ("m68k and cf features both selected"));
7337 if (current_architecture
& m68k_mask
)
7338 current_architecture
&= m68k_mask
;
7340 current_architecture
&= ~m68k_mask
;
7343 /* Permit m68881 specification with all cpus; those that can't work
7344 with a coprocessor could be doing emulation. */
7345 if (current_architecture
& m68851
)
7347 if (current_architecture
& m68040
)
7348 as_warn (_("68040 and 68851 specified; mmu instructions may assemble incorrectly"));
7350 /* What other incompatibilities could we check for? */
7352 /* Note which set of "movec" control registers is available. */
7353 select_control_regs ();
7355 if (cpu_of_arch (current_architecture
) < m68020
7356 || arch_coldfire_p (current_architecture
))
7357 md_relax_table
[TAB (PCINDEX
, BYTE
)].rlx_more
= 0;
7363 md_show_usage (FILE *stream
)
7365 const char *default_cpu
= TARGET_CPU
;
7367 unsigned int default_arch
;
7369 /* Get the canonical name for the default target CPU. */
7370 if (*default_cpu
== 'm')
7372 for (i
= 0; m68k_cpus
[i
].name
; i
++)
7374 if (strcasecmp (default_cpu
, m68k_cpus
[i
].name
) == 0)
7376 default_arch
= m68k_cpus
[i
].arch
;
7377 for (i
= 0; m68k_cpus
[i
].name
; i
++)
7379 if (m68k_cpus
[i
].arch
== default_arch
7380 && !m68k_cpus
[i
].alias
)
7382 default_cpu
= m68k_cpus
[i
].name
;
7389 fprintf (stream
, _("\
7390 -march=<arch> set architecture\n\
7391 -mcpu=<cpu> set cpu [default %s]\n\
7393 for (i
= 0; m68k_extensions
[i
].name
; i
++)
7394 fprintf (stream
, _("\
7395 -m[no-]%-16s enable/disable%s architecture extension\n\
7396 "), m68k_extensions
[i
].name
,
7397 m68k_extensions
[i
].alias
> 0 ? " ColdFire"
7398 : m68k_extensions
[i
].alias
< 0 ? " m68k" : "");
7400 fprintf (stream
, _("\
7401 -l use 1 word for refs to undefined symbols [default 2]\n\
7402 -pic, -k generate position independent code\n\
7403 -S turn jbsr into jsr\n\
7404 --pcrel never turn PC-relative branches into absolute jumps\n\
7405 --register-prefix-optional\n\
7406 recognize register names without prefix character\n\
7407 --bitwise-or do not treat `|' as a comment character\n\
7408 --base-size-default-16 base reg without size is 16 bits\n\
7409 --base-size-default-32 base reg without size is 32 bits (default)\n\
7410 --disp-size-default-16 displacement with unknown size is 16 bits\n\
7411 --disp-size-default-32 displacement with unknown size is 32 bits (default)\n\
7414 fprintf (stream
, _("Architecture variants are: "));
7415 for (i
= 0; m68k_archs
[i
].name
; i
++)
7418 fprintf (stream
, " | ");
7419 fprintf (stream
, m68k_archs
[i
].name
);
7421 fprintf (stream
, "\n");
7423 fprintf (stream
, _("Processor variants are: "));
7424 for (i
= 0; m68k_cpus
[i
].name
; i
++)
7427 fprintf (stream
, " | ");
7428 fprintf (stream
, m68k_cpus
[i
].name
);
7430 fprintf (stream
, _("\n"));
7435 /* TEST2: Test md_assemble() */
7436 /* Warning, this routine probably doesn't work anymore. */
7440 struct m68k_it the_ins
;
7448 if (!gets (buf
) || !*buf
)
7450 if (buf
[0] == '|' || buf
[1] == '.')
7452 for (cp
= buf
; *cp
; cp
++)
7457 memset (&the_ins
, '\0', sizeof (the_ins
));
7458 m68k_ip (&the_ins
, buf
);
7461 printf (_("Error %s in %s\n"), the_ins
.error
, buf
);
7465 printf (_("Opcode(%d.%s): "), the_ins
.numo
, the_ins
.args
);
7466 for (n
= 0; n
< the_ins
.numo
; n
++)
7467 printf (" 0x%x", the_ins
.opcode
[n
] & 0xffff);
7469 print_the_insn (&the_ins
.opcode
[0], stdout
);
7470 (void) putchar ('\n');
7472 for (n
= 0; n
< strlen (the_ins
.args
) / 2; n
++)
7474 if (the_ins
.operands
[n
].error
)
7476 printf ("op%d Error %s in %s\n", n
, the_ins
.operands
[n
].error
, buf
);
7479 printf ("mode %d, reg %d, ", the_ins
.operands
[n
].mode
,
7480 the_ins
.operands
[n
].reg
);
7481 if (the_ins
.operands
[n
].b_const
)
7482 printf ("Constant: '%.*s', ",
7483 1 + the_ins
.operands
[n
].e_const
- the_ins
.operands
[n
].b_const
,
7484 the_ins
.operands
[n
].b_const
);
7485 printf ("ireg %d, isiz %d, imul %d, ", the_ins
.operands
[n
].ireg
,
7486 the_ins
.operands
[n
].isiz
, the_ins
.operands
[n
].imul
);
7487 if (the_ins
.operands
[n
].b_iadd
)
7488 printf ("Iadd: '%.*s',",
7489 1 + the_ins
.operands
[n
].e_iadd
- the_ins
.operands
[n
].b_iadd
,
7490 the_ins
.operands
[n
].b_iadd
);
7499 is_label (char *str
)
7503 while (*str
&& *str
!= ' ')
7505 if (str
[-1] == ':' || str
[1] == '=')
7512 /* Possible states for relaxation:
7514 0 0 branch offset byte (bra, etc)
7518 1 0 indexed offsets byte a0@(32,d4:w:1) etc
7522 2 0 two-offset index word-word a0@(32,d4)@(45) etc
7529 /* We have no need to default values of symbols. */
7532 md_undefined_symbol (char *name ATTRIBUTE_UNUSED
)
7537 /* Round up a section size to the appropriate boundary. */
7539 md_section_align (segT segment ATTRIBUTE_UNUSED
, valueT size
)
7542 /* For a.out, force the section size to be aligned. If we don't do
7543 this, BFD will align it for us, but it will not write out the
7544 final bytes of the section. This may be a bug in BFD, but it is
7545 easier to fix it here since that is how the other a.out targets
7549 align
= bfd_get_section_alignment (stdoutput
, segment
);
7550 size
= ((size
+ (1 << align
) - 1) & ((valueT
) -1 << align
));
7556 /* Exactly what point is a PC-relative offset relative TO?
7557 On the 68k, it is relative to the address of the first extension
7558 word. The difference between the addresses of the offset and the
7559 first extension word is stored in fx_pcrel_adjust. */
7561 md_pcrel_from (fixS
*fixP
)
7565 /* Because fx_pcrel_adjust is a char, and may be unsigned, we explicitly
7566 sign extend the value here. */
7567 adjust
= ((fixP
->fx_pcrel_adjust
& 0xff) ^ 0x80) - 0x80;
7570 return fixP
->fx_where
+ fixP
->fx_frag
->fr_address
- adjust
;
7575 m68k_elf_final_processing (void)
7579 if (arch_coldfire_fpu (current_architecture
))
7580 flags
|= EF_M68K_CFV4E
;
7581 /* Set file-specific flags if this is a cpu32 processor. */
7582 if (cpu_of_arch (current_architecture
) & cpu32
)
7583 flags
|= EF_M68K_CPU32
;
7584 else if ((cpu_of_arch (current_architecture
) & m68000up
)
7585 && !(cpu_of_arch (current_architecture
) & m68020up
))
7586 flags
|= EF_M68K_M68000
;
7588 if (current_architecture
& mcfisa_a
)
7590 static const unsigned isa_features
[][2] =
7592 {EF_M68K_ISA_A_NODIV
, mcfisa_a
},
7593 {EF_M68K_ISA_A
, mcfisa_a
|mcfhwdiv
},
7594 {EF_M68K_ISA_A_PLUS
,mcfisa_a
|mcfisa_aa
|mcfhwdiv
|mcfusp
},
7595 {EF_M68K_ISA_B_NOUSP
,mcfisa_a
|mcfisa_b
|mcfhwdiv
},
7596 {EF_M68K_ISA_B
, mcfisa_a
|mcfisa_b
|mcfhwdiv
|mcfusp
},
7599 static const unsigned mac_features
[][2] =
7601 {EF_M68K_MAC
, mcfmac
},
7602 {EF_M68K_EMAC
, mcfemac
},
7608 pattern
= (current_architecture
7609 & (mcfisa_a
|mcfisa_aa
|mcfisa_b
|mcfhwdiv
|mcfusp
));
7610 for (ix
= 0; isa_features
[ix
][1]; ix
++)
7612 if (pattern
== isa_features
[ix
][1])
7614 flags
|= isa_features
[ix
][0];
7618 if (!isa_features
[ix
][1])
7621 as_warn (_("Not a defined coldfire architecture"));
7625 if (current_architecture
& cfloat
)
7626 flags
|= EF_M68K_FLOAT
| EF_M68K_CFV4E
;
7628 pattern
= current_architecture
& (mcfmac
|mcfemac
);
7631 for (ix
= 0; mac_features
[ix
][1]; ix
++)
7633 if (pattern
== mac_features
[ix
][1])
7635 flags
|= mac_features
[ix
][0];
7639 if (!mac_features
[ix
][1])
7644 elf_elfheader (stdoutput
)->e_flags
|= flags
;
7649 tc_m68k_regname_to_dw2regnum (const char *regname
)
7651 unsigned int regnum
;
7652 static const char *const regnames
[] =
7654 "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
7655 "a0", "a1", "a2", "a3", "a4", "a5", "a6", "sp",
7656 "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7",
7660 for (regnum
= 0; regnum
< ARRAY_SIZE (regnames
); regnum
++)
7661 if (strcmp (regname
, regnames
[regnum
]) == 0)
7668 tc_m68k_frame_initial_instructions (void)
7670 static int sp_regno
= -1;
7673 sp_regno
= tc_m68k_regname_to_dw2regnum ("sp");
7675 cfi_add_CFA_def_cfa (sp_regno
, -DWARF2_CIE_DATA_ALIGNMENT
);
7676 cfi_add_CFA_offset (DWARF2_DEFAULT_RETURN_COLUMN
, DWARF2_CIE_DATA_ALIGNMENT
);