1 /* tc-tic54x.c -- Assembly code for the Texas Instruments TMS320C54X
2 Copyright (C) 1999-2019 Free Software Foundation, Inc.
3 Contributed by Timothy Wall (twall@cygnus.com)
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 3, 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
22 /* Texas Instruments TMS320C54X machine specific gas.
23 Written by Timothy Wall (twall@alum.mit.edu).
25 Valuable things to do:
26 Pipeline conflict warnings
27 We encode/decode "ld #_label, dp" differently in relocatable files
28 This means we're not compatible with TI output containing those
29 expressions. We store the upper nine bits; TI stores the lower nine
30 bits. How they recover the original upper nine bits is beyond me.
32 Tests to add to expect testsuite:
33 '=' and '==' with .if, .elseif, and .break
35 Incompatibilities (mostly trivial):
37 We fill text section with zeroes instead of "nop"s
38 We don't convert '' or "" to a single instance
39 We don't convert '' to '\0'
40 We don't allow strings with .byte/.half/.short/.long
41 Probably details of the subsym stuff are different
42 TI sets labels to be data type 4 (T_INT); GAS uses T_NULL.
44 COFF1 limits section names to 8 characters.
45 Some of the default behavior changed from COFF1 to COFF2. */
49 #include "safe-ctype.h"
53 #include "opcode/tic54x.h"
60 symbolS
*sym
; /* Symbol for this stag; value is offset. */
61 const char *name
; /* Shortcut to symbol name. */
62 bfd_vma size
; /* Size of struct/union. */
63 int current_bitfield_offset
; /* Temporary for tracking fields. */
65 struct stag_field
/* List of fields. */
68 bfd_vma offset
; /* Of start of this field. */
69 int bitfield_offset
; /* Of start of this field. */
70 struct stag
*stag
; /* If field is struct/union. */
71 struct stag_field
*next
;
73 /* For nesting; used only in stag construction. */
74 struct stag
*inner
; /* Enclosed .struct. */
75 struct stag
*outer
; /* Enclosing .struct. */
76 } *current_stag
= NULL
;
78 #define MAX_LINE 256 /* Lines longer than this are truncated by TI's asm. */
80 typedef struct _tic54x_insn
82 const insn_template
*tm
; /* Opcode template. */
84 char mnemonic
[MAX_LINE
]; /* Opcode name/mnemonic. */
85 char parmnemonic
[MAX_LINE
]; /* 2nd mnemonic of parallel insn. */
93 } operands
[MAX_OPERANDS
];
96 struct opstruct paroperands
[MAX_OPERANDS
];
100 int words
; /* Size of insn in 16-bit words. */
101 int using_default_dst
; /* Do we need to explicitly set an
102 omitted OP_DST operand? */
105 unsigned short word
; /* Final encoded opcode data. */
107 int r_nchars
; /* Relocation size. */
108 bfd_reloc_code_real_type r_type
; /* Relocation type. */
109 expressionS addr_expr
; /* Storage for unresolved expressions. */
115 VNONE
= 0, V541
= 1, V542
= 2, V543
= 3, V545
= 5, V548
= 8, V549
= 9,
116 V545LP
= 15, V546LP
= 16
121 c_mode
, /* 16-bit addresses. */
122 far_mode
/* >16-bit addresses. */
125 static segT stag_saved_seg
;
126 static subsegT stag_saved_subseg
;
128 const char comment_chars
[] = ";";
129 const char line_comment_chars
[] = ";*#"; /* At column zero only. */
130 const char line_separator_chars
[] = ""; /* Not permitted. */
132 int emitting_long
= 0;
134 /* Characters which indicate that this is a floating point constant. */
135 const char FLT_CHARS
[] = "fF";
137 /* Characters that can be used to separate mantissa from exp in FP
139 const char EXP_CHARS
[] = "eE";
141 const char *md_shortopts
= "";
143 #define OPTION_ADDRESS_MODE (OPTION_MD_BASE)
144 #define OPTION_CPU_VERSION (OPTION_ADDRESS_MODE + 1)
145 #define OPTION_COFF_VERSION (OPTION_CPU_VERSION + 1)
146 #define OPTION_STDERR_TO_FILE (OPTION_COFF_VERSION + 1)
148 struct option md_longopts
[] =
150 { "mfar-mode", no_argument
, NULL
, OPTION_ADDRESS_MODE
},
151 { "mf", no_argument
, NULL
, OPTION_ADDRESS_MODE
},
152 { "mcpu", required_argument
, NULL
, OPTION_CPU_VERSION
},
153 { "merrors-to-file", required_argument
, NULL
, OPTION_STDERR_TO_FILE
},
154 { "me", required_argument
, NULL
, OPTION_STDERR_TO_FILE
},
155 { NULL
, no_argument
, NULL
, 0},
158 size_t md_longopts_size
= sizeof (md_longopts
);
160 static int assembly_begun
= 0;
161 /* Addressing mode is not entirely implemented; the latest rev of the Other
162 assembler doesn't seem to make any distinction whatsoever; all relocations
163 are stored as extended relocations. Older versions used REL16 vs RELEXT16,
164 but now it seems all relocations are RELEXT16. We use all RELEXT16.
166 The cpu version is kind of a waste of time as well. There is one
167 instruction (RND) for LP devices only, and several for devices with
168 extended addressing only. We include it for compatibility. */
169 static enum address_mode amode
= c_mode
;
170 static enum cpu_version cpu
= VNONE
;
172 /* Include string substitutions in listing? */
173 static int listing_sslist
= 0;
175 /* Did we do subsym substitutions on the line? */
176 static int substitution_line
= 0;
178 /* Last label seen. */
179 static symbolS
*last_label_seen
= NULL
;
181 /* This ensures that all new labels are unique. */
182 static int local_label_id
;
184 static struct hash_control
*subsym_recurse_hash
; /* Prevent infinite recurse. */
185 static struct hash_control
*math_hash
; /* Built-in math functions. */
186 /* Allow maximum levels of macro nesting; level 0 is the main substitution
187 symbol table. The other assembler only does 32 levels, so there! */
188 #define MAX_SUBSYM_HASH 100
189 static struct hash_control
*subsym_hash
[MAX_SUBSYM_HASH
];
191 /* Keep track of local labels so we can substitute them before GAS sees them
192 since macros use their own 'namespace' for local labels, use a separate hash
194 We do our own local label handling 'cuz it's subtly different from the
197 We use our own macro nesting counter, since GAS overloads it when expanding
198 other things (like conditionals and repeat loops). */
199 static int macro_level
= 0;
200 static struct hash_control
*local_label_hash
[100];
201 /* Keep track of struct/union tags. */
202 static struct hash_control
*stag_hash
;
203 static struct hash_control
*op_hash
;
204 static struct hash_control
*parop_hash
;
205 static struct hash_control
*reg_hash
;
206 static struct hash_control
*mmreg_hash
;
207 static struct hash_control
*cc_hash
;
208 static struct hash_control
*cc2_hash
;
209 static struct hash_control
*cc3_hash
;
210 static struct hash_control
*sbit_hash
;
211 static struct hash_control
*misc_symbol_hash
;
213 /* Only word (et al.), align, or conditionals are allowed within
215 #define ILLEGAL_WITHIN_STRUCT() \
217 if (current_stag != NULL) \
219 as_bad (_("pseudo-op illegal within .struct/.union")); \
225 static void subsym_create_or_replace (char *, char *);
226 static char *subsym_lookup (char *, int);
227 static char *subsym_substitute (char *, int);
231 md_show_usage (FILE *stream
)
233 fprintf (stream
, _("C54x-specific command line options:\n"));
234 fprintf (stream
, _("-mfar-mode | -mf Use extended addressing\n"));
235 fprintf (stream
, _("-mcpu=<CPU version> Specify the CPU version\n"));
236 fprintf (stream
, _("-merrors-to-file <filename>\n"));
237 fprintf (stream
, _("-me <filename> Redirect errors to a file\n"));
240 /* Output a single character (upper octet is zero). */
243 tic54x_emit_char (char c
)
247 expn
.X_op
= O_constant
;
248 expn
.X_add_number
= c
;
249 emit_expr (&expn
, 2);
252 /* Walk backwards in the frag chain. */
255 frag_prev (fragS
*frag
, segT seg
)
257 segment_info_type
*seginfo
= seg_info (seg
);
260 for (fragp
= seginfo
->frchainP
->frch_root
; fragp
; fragp
= fragp
->fr_next
)
261 if (fragp
->fr_next
== frag
)
268 bit_offset_frag (fragS
*frag
, segT seg
)
272 if (frag
->fr_fix
== 0
273 && frag
->fr_opcode
== NULL
274 && frag
->tc_frag_data
== 0)
275 frag
= frag_prev (frag
, seg
);
282 /* Return the number of bits allocated in the most recent word, or zero if
283 none. .field/.space/.bes may leave words partially allocated. */
286 frag_bit_offset (fragS
*frag
, segT seg
)
288 frag
= bit_offset_frag (frag
, seg
);
291 return frag
->fr_opcode
!= NULL
? -1 : frag
->tc_frag_data
;
296 /* Read an expression from a C string; returns a pointer past the end of the
300 parse_expression (char *str
, expressionS
*expn
)
305 tmp
= input_line_pointer
; /* Save line pointer. */
306 input_line_pointer
= str
;
308 s
= input_line_pointer
;
309 input_line_pointer
= tmp
; /* Restore line pointer. */
310 return s
; /* Return pointer to where parsing stopped. */
313 /* .asg "character-string"|character-string, symbol
315 .eval is the only pseudo-op allowed to perform arithmetic on substitution
316 symbols. all other use of symbols defined with .asg are currently
320 tic54x_asg (int x ATTRIBUTE_UNUSED
)
325 int quoted
= *input_line_pointer
== '"';
327 ILLEGAL_WITHIN_STRUCT ();
332 str
= demand_copy_C_string (&len
);
333 c
= *input_line_pointer
;
337 str
= input_line_pointer
;
338 while ((c
= *input_line_pointer
) != ',')
340 if (is_end_of_line
[(unsigned char) c
])
342 ++input_line_pointer
;
344 *input_line_pointer
= 0;
348 as_bad (_("Comma and symbol expected for '.asg STRING, SYMBOL'"));
349 ignore_rest_of_line ();
353 ++input_line_pointer
;
354 c
= get_symbol_name (&name
); /* Get terminator. */
355 if (!ISALPHA (*name
))
357 as_bad (_("symbols assigned with .asg must begin with a letter"));
358 ignore_rest_of_line ();
363 name
= xstrdup (name
);
364 subsym_create_or_replace (name
, str
);
365 (void) restore_line_pointer (c
);
366 demand_empty_rest_of_line ();
369 /* .eval expression, symbol
370 There's something screwy about this. The other assembler sometimes does and
371 sometimes doesn't substitute symbols defined with .eval.
372 We'll put the symbols into the subsym table as well as the normal symbol
373 table, since that's what works best. */
376 tic54x_eval (int x ATTRIBUTE_UNUSED
)
382 char valuestr
[32], *tmp
;
385 ILLEGAL_WITHIN_STRUCT ();
389 quoted
= *input_line_pointer
== '"';
391 ++input_line_pointer
;
392 value
= get_absolute_expression ();
395 if (*input_line_pointer
!= '"')
397 as_bad (_("Unterminated string after absolute expression"));
398 ignore_rest_of_line ();
401 ++input_line_pointer
;
403 if (*input_line_pointer
++ != ',')
405 as_bad (_("Comma and symbol expected for '.eval EXPR, SYMBOL'"));
406 ignore_rest_of_line ();
409 c
= get_symbol_name (&name
); /* Get terminator. */
410 name
= xstrdup (name
);
411 (void) restore_line_pointer (c
);
413 if (!ISALPHA (*name
))
415 as_bad (_("symbols assigned with .eval must begin with a letter"));
416 ignore_rest_of_line ();
419 symbolP
= symbol_new (name
, absolute_section
,
420 (valueT
) value
, &zero_address_frag
);
421 SF_SET_LOCAL (symbolP
);
422 symbol_table_insert (symbolP
);
424 /* The "other" assembler sometimes doesn't put .eval's in the subsym table
425 But since there's not written rule as to when, don't even bother trying
426 to match their behavior. */
427 sprintf (valuestr
, "%d", value
);
428 tmp
= xstrdup (valuestr
);
429 subsym_create_or_replace (name
, tmp
);
431 demand_empty_rest_of_line ();
434 /* .bss symbol, size [, [blocking flag] [, alignment flag]
436 alignment is to a longword boundary; blocking is to 128-word boundary.
438 1) if there is a hole in memory, this directive should attempt to fill it
439 (not yet implemented).
441 2) if the blocking flag is not set, allocate at the current SPC
442 otherwise, check to see if the current SPC plus the space to be
443 allocated crosses the page boundary (128 words).
444 if there's not enough space, create a hole and align with the next page
446 (not yet implemented). */
449 tic54x_bss (int x ATTRIBUTE_UNUSED
)
456 subsegT current_subseg
;
461 ILLEGAL_WITHIN_STRUCT ();
463 current_seg
= now_seg
; /* Save current seg. */
464 current_subseg
= now_subseg
; /* Save current subseg. */
466 c
= get_symbol_name (&name
); /* Get terminator. */
468 c
= * ++ input_line_pointer
;
471 as_bad (_(".bss size argument missing\n"));
472 ignore_rest_of_line ();
476 ++input_line_pointer
;
477 words
= get_absolute_expression ();
480 as_bad (_(".bss size %d < 0!"), words
);
481 ignore_rest_of_line ();
485 if (*input_line_pointer
== ',')
487 /* The blocking flag may be missing. */
488 ++input_line_pointer
;
489 if (*input_line_pointer
!= ',')
490 block
= get_absolute_expression ();
494 if (*input_line_pointer
== ',')
496 ++input_line_pointer
;
497 align
= get_absolute_expression ();
505 subseg_set (bss_section
, 0);
506 symbolP
= symbol_find_or_make (name
);
508 if (S_GET_SEGMENT (symbolP
) == bss_section
)
509 symbol_get_frag (symbolP
)->fr_symbol
= (symbolS
*) NULL
;
511 symbol_set_frag (symbolP
, frag_now
);
512 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, symbolP
,
513 (offsetT
) (words
* OCTETS_PER_BYTE
), (char *) 0);
514 *p
= 0; /* Fill char. */
516 S_SET_SEGMENT (symbolP
, bss_section
);
518 /* The symbol may already have been created with a preceding
519 ".globl" directive -- be careful not to step on storage class
520 in that case. Otherwise, set it to static. */
521 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
522 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
526 /* s_align eats end of line; restore it */
528 --input_line_pointer
;
532 bss_section
->flags
|= SEC_TIC54X_BLOCK
;
534 subseg_set (current_seg
, current_subseg
); /* Restore current seg. */
535 demand_empty_rest_of_line ();
539 stag_add_field_symbols (struct stag
*stag
,
543 const char *root_stag_name
)
546 struct stag_field
*field
= stag
->field
;
548 /* Construct a symbol for every field contained within this structure
549 including fields within structure fields. */
550 prefix
= concat (path
, *path
? "." : "", NULL
);
552 while (field
!= NULL
)
554 char *name
= concat (prefix
, field
->name
, NULL
);
559 sym
= symbol_new (name
, absolute_section
,
560 (field
->stag
? field
->offset
:
561 (valueT
) (base_offset
+ field
->offset
)),
564 symbol_table_insert (sym
);
570 replacement
= concat (S_GET_NAME (rootsym
), "+", root_stag_name
,
571 name
+ strlen (S_GET_NAME (rootsym
)), NULL
);
572 hash_insert (subsym_hash
[0], name
, replacement
);
575 /* Recurse if the field is a structure.
576 Note the field offset is relative to the outermost struct. */
577 if (field
->stag
!= NULL
)
578 stag_add_field_symbols (field
->stag
, name
,
580 rootsym
, root_stag_name
);
587 /* Keep track of stag fields so that when structures are nested we can add the
588 complete dereferencing symbols to the symbol table. */
591 stag_add_field (struct stag
*parent
,
596 struct stag_field
*sfield
= XCNEW (struct stag_field
);
598 sfield
->name
= xstrdup (name
);
599 sfield
->offset
= offset
;
600 sfield
->bitfield_offset
= parent
->current_bitfield_offset
;
602 if (parent
->field
== NULL
)
603 parent
->field
= sfield
;
606 struct stag_field
*sf
= parent
->field
;
607 while (sf
->next
!= NULL
)
611 /* Only create a symbol for this field if the parent has no name. */
612 if (!strncmp (".fake", parent
->name
, 5))
614 symbolS
*sym
= symbol_new (name
, absolute_section
,
615 (valueT
) offset
, &zero_address_frag
);
617 symbol_table_insert (sym
);
621 /* [STAG] .struct [OFFSET]
622 Start defining structure offsets (symbols in absolute section). */
625 tic54x_struct (int arg
)
627 int start_offset
= 0;
632 /* Starting a new struct, switch to absolute section. */
633 stag_saved_seg
= now_seg
;
634 stag_saved_subseg
= now_subseg
;
635 subseg_set (absolute_section
, 0);
637 /* Align the current pointer. */
638 else if (current_stag
->current_bitfield_offset
!= 0)
640 ++abs_section_offset
;
641 current_stag
->current_bitfield_offset
= 0;
644 /* Offset expression is only meaningful for global .structs. */
647 /* Offset is ignored in inner structs. */
649 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
650 start_offset
= get_absolute_expression ();
657 /* Nesting, link to outer one. */
658 current_stag
->inner
= XCNEW (struct stag
);
659 current_stag
->inner
->outer
= current_stag
;
660 current_stag
= current_stag
->inner
;
662 as_warn (_("Offset on nested structures is ignored"));
663 start_offset
= abs_section_offset
;
667 current_stag
= XCNEW (struct stag
);
668 abs_section_offset
= start_offset
;
670 current_stag
->is_union
= is_union
;
672 if (line_label
== NULL
)
674 static int struct_count
= 0;
675 char fake
[] = ".fake_stagNNNNNNN";
676 sprintf (fake
, ".fake_stag%d", struct_count
++);
677 current_stag
->sym
= symbol_new (fake
, absolute_section
,
678 (valueT
) abs_section_offset
,
683 char * label
= xstrdup (S_GET_NAME (line_label
));
684 current_stag
->sym
= symbol_new (label
,
686 (valueT
) abs_section_offset
,
690 current_stag
->name
= S_GET_NAME (current_stag
->sym
);
691 SF_SET_LOCAL (current_stag
->sym
);
692 /* Nested .structs don't go into the symbol table. */
693 if (current_stag
->outer
== NULL
)
694 symbol_table_insert (current_stag
->sym
);
699 /* [LABEL] .endstruct
700 finish defining structure offsets; optional LABEL's value will be the size
704 tic54x_endstruct (int is_union
)
708 !strncmp (current_stag
->name
, ".fake", 5) ? "" : current_stag
->name
;
710 if (!current_stag
|| current_stag
->is_union
!= is_union
)
712 as_bad (_(".end%s without preceding .%s"),
713 is_union
? "union" : "struct",
714 is_union
? "union" : "struct");
715 ignore_rest_of_line ();
719 /* Align end of structures. */
720 if (current_stag
->current_bitfield_offset
)
722 ++abs_section_offset
;
723 current_stag
->current_bitfield_offset
= 0;
726 if (current_stag
->is_union
)
727 size
= current_stag
->size
;
729 size
= abs_section_offset
- S_GET_VALUE (current_stag
->sym
);
730 if (line_label
!= NULL
)
732 S_SET_VALUE (line_label
, size
);
733 symbol_table_insert (line_label
);
737 /* Union size has already been calculated. */
738 if (!current_stag
->is_union
)
739 current_stag
->size
= size
;
740 /* Nested .structs don't get put in the stag table. */
741 if (current_stag
->outer
== NULL
)
743 hash_insert (stag_hash
, current_stag
->name
, current_stag
);
744 stag_add_field_symbols (current_stag
, path
,
745 S_GET_VALUE (current_stag
->sym
),
748 current_stag
= current_stag
->outer
;
750 /* If this is a nested .struct/.union, add it as a field to the enclosing
751 one. otherwise, restore the section we were in. */
752 if (current_stag
!= NULL
)
754 stag_add_field (current_stag
, current_stag
->inner
->name
,
755 S_GET_VALUE (current_stag
->inner
->sym
),
756 current_stag
->inner
);
759 subseg_set (stag_saved_seg
, stag_saved_subseg
);
763 Reference a structure within a structure, as a sized field with an optional
765 If used outside of a .struct/.endstruct, overlays the given structure
766 format on the existing allocated space. */
769 tic54x_tag (int ignore ATTRIBUTE_UNUSED
)
772 int c
= get_symbol_name (&name
);
773 struct stag
*stag
= (struct stag
*) hash_find (stag_hash
, name
);
778 as_bad (_("Unrecognized struct/union tag '%s'"), name
);
780 as_bad (_(".tag requires a structure tag"));
781 ignore_rest_of_line ();
784 if (line_label
== NULL
)
786 as_bad (_("Label required for .tag"));
787 ignore_rest_of_line ();
794 label
= xstrdup (S_GET_NAME (line_label
));
795 if (current_stag
!= NULL
)
796 stag_add_field (current_stag
, label
,
797 abs_section_offset
- S_GET_VALUE (current_stag
->sym
),
801 symbolS
*sym
= symbol_find (label
);
805 as_bad (_(".tag target '%s' undefined"), label
);
806 ignore_rest_of_line ();
810 stag_add_field_symbols (stag
, S_GET_NAME (sym
),
811 S_GET_VALUE (stag
->sym
), sym
, stag
->name
);
816 /* Bump by the struct size, but only if we're within a .struct section. */
817 if (current_stag
!= NULL
&& !current_stag
->is_union
)
818 abs_section_offset
+= stag
->size
;
820 (void) restore_line_pointer (c
);
821 demand_empty_rest_of_line ();
825 /* Handle all .byte, .char, .double, .field, .float, .half, .int, .long,
826 .short, .string, .ubyte, .uchar, .uhalf, .uint, .ulong, .ushort, .uword,
830 tic54x_struct_field (int type
)
834 int new_bitfield_offset
= 0;
835 int field_align
= current_stag
->current_bitfield_offset
!= 0;
836 int longword_align
= 0;
839 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
840 count
= get_absolute_expression ();
856 case '*': /* String. */
865 case '.': /* Bitfield. */
867 if (count
< 1 || count
> 32)
869 as_bad (_(".field count '%d' out of range (1 <= X <= 32)"), count
);
870 ignore_rest_of_line ();
873 if (current_stag
->current_bitfield_offset
+ count
> 16)
875 /* Set the appropriate size and new field offset. */
885 new_bitfield_offset
= count
- 16;
888 new_bitfield_offset
= count
;
893 new_bitfield_offset
= current_stag
->current_bitfield_offset
+ count
;
897 as_bad (_("Unrecognized field type '%c'"), type
);
898 ignore_rest_of_line ();
904 /* Align to the actual starting position of the field. */
905 current_stag
->current_bitfield_offset
= 0;
906 ++abs_section_offset
;
908 /* Align to longword boundary. */
909 if (longword_align
&& (abs_section_offset
& 0x1))
910 ++abs_section_offset
;
912 if (line_label
== NULL
)
914 static int fieldno
= 0;
915 char fake
[] = ".fake_fieldNNNNN";
917 sprintf (fake
, ".fake_field%d", fieldno
++);
918 stag_add_field (current_stag
, fake
,
919 abs_section_offset
- S_GET_VALUE (current_stag
->sym
),
926 label
= xstrdup (S_GET_NAME (line_label
));
927 stag_add_field (current_stag
, label
,
928 abs_section_offset
- S_GET_VALUE (current_stag
->sym
),
933 if (current_stag
->is_union
)
935 /* Note we treat the element as if it were an array of COUNT. */
936 if (current_stag
->size
< (unsigned) size
* count
)
937 current_stag
->size
= size
* count
;
941 abs_section_offset
+= (unsigned) size
* count
;
942 current_stag
->current_bitfield_offset
= new_bitfield_offset
;
947 /* Handle .byte, .word. .int, .long and all variants. */
950 tic54x_cons (int type
)
955 /* If we're within a .struct construct, don't actually allocate space. */
956 if (current_stag
!= NULL
)
958 tic54x_struct_field (type
);
962 #ifdef md_flush_pending_output
963 md_flush_pending_output ();
966 generate_lineno_debug ();
968 /* Align long words to long word boundaries (4 octets). */
969 if (type
== 'l' || type
== 'L')
971 frag_align (2, 0, 2);
972 /* If there's a label, assign it to the first allocated word. */
973 if (line_label
!= NULL
)
975 symbol_set_frag (line_label
, frag_now
);
976 S_SET_VALUE (line_label
, frag_now_fix ());
1000 if (*input_line_pointer
== '"')
1002 input_line_pointer
++;
1003 while (is_a_char (c
= next_char_of_string ()))
1004 tic54x_emit_char (c
);
1005 know (input_line_pointer
[-1] == '\"');
1011 input_line_pointer
= parse_expression (input_line_pointer
, &expn
);
1012 if (expn
.X_op
== O_constant
)
1014 offsetT value
= expn
.X_add_number
;
1015 /* Truncate overflows. */
1019 if ((value
> 0 && value
> 0xFF)
1020 || (value
< 0 && value
< - 0x100))
1021 as_warn (_("Overflow in expression, truncated to 8 bits"));
1024 if ((value
> 0 && value
> 0xFFFF)
1025 || (value
< 0 && value
< - 0x10000))
1026 as_warn (_("Overflow in expression, truncated to 16 bits"));
1030 if (expn
.X_op
!= O_constant
&& octets
< 2)
1032 /* Disallow .byte with a non constant expression that will
1033 require relocation. */
1034 as_bad (_("Relocatable values require at least WORD storage"));
1035 ignore_rest_of_line ();
1039 if (expn
.X_op
!= O_constant
1043 /* FIXME -- at one point TI tools used to output REL16
1044 relocations, but I don't think the latest tools do at all
1045 The current tools output extended relocations regardless of
1046 the addressing mode (I actually think that ".c_mode" is
1047 totally ignored in the latest tools). */
1050 emit_expr (&expn
, 4);
1056 emitting_long
= octets
== 4;
1057 emit_expr (&expn
, (octets
== 1) ? 2 : octets
);
1062 while (*input_line_pointer
++ == ',');
1064 input_line_pointer
--; /* Put terminator back into stream. */
1065 demand_empty_rest_of_line ();
1068 /* .global <symbol>[,...,<symbolN>]
1069 .def <symbol>[,...,<symbolN>]
1070 .ref <symbol>[,...,<symbolN>]
1072 These all identify global symbols.
1074 .def means the symbol is defined in the current module and can be accessed
1075 by other files. The symbol should be placed in the symbol table.
1077 .ref means the symbol is used in the current module but defined in another
1078 module. The linker is to resolve this symbol's definition at link time.
1080 .global should act as a .ref or .def, as needed.
1082 global, def and ref all have symbol storage classes of C_EXT.
1084 I can't identify any difference in how the "other" c54x assembler treats
1085 these, so we ignore the type here. */
1088 tic54x_global (int type
)
1095 as_warn (_("Use of .def/.ref is deprecated. Use .global instead"));
1097 ILLEGAL_WITHIN_STRUCT ();
1101 c
= get_symbol_name (&name
);
1102 symbolP
= symbol_find_or_make (name
);
1103 c
= restore_line_pointer (c
);
1105 S_SET_STORAGE_CLASS (symbolP
, C_EXT
);
1108 input_line_pointer
++;
1109 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1110 c
= *input_line_pointer
;
1115 demand_empty_rest_of_line ();
1118 /* Remove the symbol from the local label hash lookup. */
1121 tic54x_remove_local_label (const char *key
, void *value ATTRIBUTE_UNUSED
)
1123 void *elem
= hash_delete (local_label_hash
[macro_level
], key
, FALSE
);
1127 /* Reset all local labels. */
1130 tic54x_clear_local_labels (int ignored ATTRIBUTE_UNUSED
)
1132 hash_traverse (local_label_hash
[macro_level
], tic54x_remove_local_label
);
1137 .sect "section name"
1140 make sure local labels get cleared when changing sections
1142 ARG is 't' for text, 'd' for data, or '*' for a named section
1144 For compatibility, '*' sections are SEC_CODE if instructions are
1145 encountered, or SEC_DATA if not.
1149 tic54x_sect (int arg
)
1151 ILLEGAL_WITHIN_STRUCT ();
1153 /* Local labels are cleared when changing sections. */
1154 tic54x_clear_local_labels (0);
1158 else if (arg
== 'd')
1164 /* Make sure all named initialized sections flagged properly. If we
1165 encounter instructions, we'll flag it with SEC_CODE as well. */
1166 const char *flags
= ",\"w\"\n";
1168 /* If there are quotes, remove them. */
1169 if (*input_line_pointer
== '"')
1171 name
= demand_copy_C_string (&len
);
1172 demand_empty_rest_of_line ();
1173 name
= concat (name
, flags
, (char *) NULL
);
1179 c
= get_symbol_name (&name
);
1180 name
= concat (name
, flags
, (char *) NULL
);
1181 (void) restore_line_pointer (c
);
1182 demand_empty_rest_of_line ();
1185 input_scrub_insert_line (name
);
1186 obj_coff_section (0);
1188 /* If there was a line label, make sure that it gets assigned the proper
1189 section. This is for compatibility, even though the actual behavior
1190 is not explicitly defined. For consistency, we make .sect behave
1191 like .usect, since that is probably what people expect. */
1192 if (line_label
!= NULL
)
1194 S_SET_SEGMENT (line_label
, now_seg
);
1195 symbol_set_frag (line_label
, frag_now
);
1196 S_SET_VALUE (line_label
, frag_now_fix ());
1197 if (S_GET_STORAGE_CLASS (line_label
) != C_EXT
)
1198 S_SET_STORAGE_CLASS (line_label
, C_LABEL
);
1203 /* [symbol] .space space_in_bits
1204 [symbol] .bes space_in_bits
1205 BES puts the symbol at the *last* word allocated
1207 cribbed from s_space. */
1210 tic54x_space (int arg
)
1216 int bits_per_byte
= (OCTETS_PER_BYTE
* 8);
1218 symbolS
*label
= line_label
;
1221 ILLEGAL_WITHIN_STRUCT ();
1223 #ifdef md_flush_pending_output
1224 md_flush_pending_output ();
1227 /* Read the bit count. */
1230 /* Some expressions are unresolvable until later in the assembly pass;
1231 postpone until relaxation/fixup. we also have to postpone if a previous
1232 partial allocation has not been completed yet. */
1233 if (expn
.X_op
!= O_constant
|| frag_bit_offset (frag_now
, now_seg
) == -1)
1235 struct bit_info
*bi
= XNEW (struct bit_info
);
1240 p
= frag_var (rs_machine_dependent
,
1241 65536 * 2, 1, (relax_substateT
) 0,
1242 make_expr_symbol (&expn
), (offsetT
) 0,
1250 /* Reduce the required size by any bit offsets currently left over
1251 from a previous .space/.bes/.field directive. */
1252 bit_offset
= frag_now
->tc_frag_data
;
1253 if (bit_offset
!= 0 && bit_offset
< 16)
1255 int spare_bits
= bits_per_byte
- bit_offset
;
1257 if (spare_bits
>= expn
.X_add_number
)
1259 /* Don't have to do anything; sufficient bits have already been
1260 allocated; just point the label to the right place. */
1263 symbol_set_frag (label
, frag_now
);
1264 S_SET_VALUE (label
, frag_now_fix () - 1);
1267 frag_now
->tc_frag_data
+= expn
.X_add_number
;
1270 expn
.X_add_number
-= spare_bits
;
1271 /* Set the label to point to the first word allocated, which in this
1272 case is the previous word, which was only partially filled. */
1273 if (!bes
&& label
!= NULL
)
1275 symbol_set_frag (label
, frag_now
);
1276 S_SET_VALUE (label
, frag_now_fix () - 1);
1280 /* Convert bits to bytes/words and octets, rounding up. */
1281 words
= ((expn
.X_add_number
+ bits_per_byte
- 1) / bits_per_byte
);
1282 /* How many do we have left over? */
1283 bit_offset
= expn
.X_add_number
% bits_per_byte
;
1284 octets
= words
* OCTETS_PER_BYTE
;
1287 as_warn (_(".space/.bes repeat count is negative, ignored"));
1290 else if (octets
== 0)
1292 as_warn (_(".space/.bes repeat count is zero, ignored"));
1296 /* If we are in the absolute section, just bump the offset. */
1297 if (now_seg
== absolute_section
)
1299 abs_section_offset
+= words
;
1300 if (bes
&& label
!= NULL
)
1301 S_SET_VALUE (label
, abs_section_offset
- 1);
1302 frag_now
->tc_frag_data
= bit_offset
;
1307 p
= frag_var (rs_fill
, 1, 1,
1308 (relax_substateT
) 0, (symbolS
*) 0,
1309 (offsetT
) octets
, (char *) 0);
1311 /* Make note of how many bits of this word we've allocated so far. */
1312 frag_now
->tc_frag_data
= bit_offset
;
1314 /* .bes puts label at *last* word allocated. */
1315 if (bes
&& label
!= NULL
)
1317 symbol_set_frag (label
, frag_now
);
1318 S_SET_VALUE (label
, frag_now_fix () - 1);
1326 demand_empty_rest_of_line ();
1329 /* [symbol] .usect "section-name", size-in-words
1330 [, [blocking-flag] [, alignment-flag]]
1332 Uninitialized section.
1333 Non-zero blocking means that if the section would cross a page (128-word)
1334 boundary, it will be page-aligned.
1335 Non-zero alignment aligns on a longword boundary.
1337 Has no effect on the current section. */
1340 tic54x_usect (int x ATTRIBUTE_UNUSED
)
1347 int size
, blocking_flag
, alignment_flag
;
1349 subsegT current_subseg
;
1352 ILLEGAL_WITHIN_STRUCT ();
1354 current_seg
= now_seg
; /* Save current seg. */
1355 current_subseg
= now_subseg
; /* Save current subseg. */
1357 c
= get_symbol_name (§ion_name
); /* Get terminator. */
1358 name
= xstrdup (section_name
);
1359 c
= restore_line_pointer (c
);
1362 ++input_line_pointer
;
1365 as_bad (_("Missing size argument"));
1366 ignore_rest_of_line ();
1370 size
= get_absolute_expression ();
1372 /* Read a possibly present third argument (blocking flag). */
1373 if (*input_line_pointer
== ',')
1375 ++input_line_pointer
;
1376 if (*input_line_pointer
!= ',')
1377 blocking_flag
= get_absolute_expression ();
1381 /* Read a possibly present fourth argument (alignment flag). */
1382 if (*input_line_pointer
== ',')
1384 ++input_line_pointer
;
1385 alignment_flag
= get_absolute_expression ();
1391 blocking_flag
= alignment_flag
= 0;
1393 seg
= subseg_new (name
, 0);
1394 flags
= bfd_get_section_flags (stdoutput
, seg
) | SEC_ALLOC
;
1398 /* s_align eats end of line; restore it. */
1400 --input_line_pointer
;
1403 if (line_label
!= NULL
)
1405 S_SET_SEGMENT (line_label
, seg
);
1406 symbol_set_frag (line_label
, frag_now
);
1407 S_SET_VALUE (line_label
, frag_now_fix ());
1408 /* Set scl to label, since that's what TI does. */
1409 if (S_GET_STORAGE_CLASS (line_label
) != C_EXT
)
1410 S_SET_STORAGE_CLASS (line_label
, C_LABEL
);
1413 seg_info (seg
)->bss
= 1; /* Uninitialized data. */
1415 p
= frag_var (rs_fill
, 1, 1,
1416 (relax_substateT
) 0, (symbolS
*) line_label
,
1417 size
* OCTETS_PER_BYTE
, (char *) 0);
1421 flags
|= SEC_TIC54X_BLOCK
;
1423 if (!bfd_set_section_flags (stdoutput
, seg
, flags
))
1424 as_warn (_("Error setting flags for \"%s\": %s"), name
,
1425 bfd_errmsg (bfd_get_error ()));
1427 subseg_set (current_seg
, current_subseg
); /* Restore current seg. */
1428 demand_empty_rest_of_line ();
1431 static enum cpu_version
1432 lookup_version (const char *ver
)
1434 enum cpu_version version
= VNONE
;
1436 if (ver
[0] == '5' && ver
[1] == '4')
1438 if (strlen (ver
) == 3
1439 && (ver
[2] == '1' || ver
[2] == '2' || ver
[2] == '3'
1440 || ver
[2] == '5' || ver
[2] == '8' || ver
[2] == '9'))
1441 version
= ver
[2] - '0';
1442 else if (strlen (ver
) == 5
1443 && TOUPPER (ver
[3]) == 'L'
1444 && TOUPPER (ver
[4]) == 'P'
1445 && (ver
[2] == '5' || ver
[2] == '6'))
1446 version
= ver
[2] - '0' + 10;
1453 set_cpu (enum cpu_version version
)
1456 if (version
== V545LP
|| version
== V546LP
)
1458 symbolS
*symbolP
= symbol_new ("__allow_lp", absolute_section
,
1459 (valueT
) 1, &zero_address_frag
);
1460 SF_SET_LOCAL (symbolP
);
1461 symbol_table_insert (symbolP
);
1465 /* .version cpu-version
1466 cpu-version may be one of the following:
1476 This is for compatibility only. It currently has no affect on assembly. */
1477 static int cpu_needs_set
= 1;
1480 tic54x_version (int x ATTRIBUTE_UNUSED
)
1482 enum cpu_version version
= VNONE
;
1483 enum cpu_version old_version
= cpu
;
1487 ILLEGAL_WITHIN_STRUCT ();
1490 ver
= input_line_pointer
;
1491 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1492 ++input_line_pointer
;
1493 c
= *input_line_pointer
;
1494 *input_line_pointer
= 0;
1496 version
= lookup_version (ver
);
1498 if (cpu
!= VNONE
&& cpu
!= version
)
1499 as_warn (_("CPU version has already been set"));
1501 if (version
== VNONE
)
1503 as_bad (_("Unrecognized version '%s'"), ver
);
1504 ignore_rest_of_line ();
1507 else if (assembly_begun
&& version
!= old_version
)
1509 as_bad (_("Changing of CPU version on the fly not supported"));
1510 ignore_rest_of_line ();
1516 *input_line_pointer
= c
;
1517 demand_empty_rest_of_line ();
1520 /* 'f' = float, 'x' = xfloat, 'd' = double, 'l' = ldouble. */
1523 tic54x_float_cons (int type
)
1525 if (current_stag
!= 0)
1526 tic54x_struct_field ('f');
1528 #ifdef md_flush_pending_output
1529 md_flush_pending_output ();
1532 /* Align to long word boundary (4 octets) unless it's ".xfloat". */
1535 frag_align (2, 0, 2);
1536 /* If there's a label, assign it to the first allocated word. */
1537 if (line_label
!= NULL
)
1539 symbol_set_frag (line_label
, frag_now
);
1540 S_SET_VALUE (line_label
, frag_now_fix ());
1547 /* The argument is capitalized if it should be zero-terminated
1548 's' is normal string with upper 8-bits zero-filled, 'p' is packed.
1549 Code copied from stringer, and slightly modified so that strings are packed
1550 and encoded into the correct octets. */
1553 tic54x_stringer (int type
)
1556 int append_zero
= type
== 'S' || type
== 'P';
1557 int packed
= type
== 'p' || type
== 'P';
1558 int last_char
= -1; /* Packed strings need two bytes at a time to encode. */
1560 if (current_stag
!= NULL
)
1562 tic54x_struct_field ('*');
1566 #ifdef md_flush_pending_output
1567 md_flush_pending_output ();
1570 c
= ','; /* Do loop. */
1574 switch (*input_line_pointer
)
1578 unsigned short value
= get_absolute_expression ();
1579 FRAG_APPEND_1_CHAR ( value
& 0xFF);
1580 FRAG_APPEND_1_CHAR ((value
>> 8) & 0xFF);
1584 ++input_line_pointer
; /* -> 1st char of string. */
1585 while (is_a_char (c
= next_char_of_string ()))
1589 FRAG_APPEND_1_CHAR (c
);
1590 FRAG_APPEND_1_CHAR (0);
1594 /* Packed strings are filled MS octet first. */
1595 if (last_char
== -1)
1599 FRAG_APPEND_1_CHAR (c
);
1600 FRAG_APPEND_1_CHAR (last_char
);
1607 if (packed
&& last_char
!= -1)
1609 FRAG_APPEND_1_CHAR (0);
1610 FRAG_APPEND_1_CHAR (last_char
);
1615 FRAG_APPEND_1_CHAR (0);
1616 FRAG_APPEND_1_CHAR (0);
1619 know (input_line_pointer
[-1] == '\"');
1623 c
= *input_line_pointer
;
1624 if (!is_end_of_line
[c
])
1625 ++input_line_pointer
;
1628 /* Finish up any leftover packed string. */
1629 if (packed
&& last_char
!= -1)
1631 FRAG_APPEND_1_CHAR (0);
1632 FRAG_APPEND_1_CHAR (last_char
);
1634 demand_empty_rest_of_line ();
1638 tic54x_p2align (int arg ATTRIBUTE_UNUSED
)
1640 as_bad (_("p2align not supported on this target"));
1644 tic54x_align_words (int arg
)
1646 /* Only ".align" with no argument is allowed within .struct/.union. */
1649 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1652 as_warn (_("Argument to .even ignored"));
1654 count
= get_absolute_expression ();
1657 if (current_stag
!= NULL
&& arg
== 128)
1659 if (current_stag
->current_bitfield_offset
!= 0)
1661 current_stag
->current_bitfield_offset
= 0;
1662 ++abs_section_offset
;
1664 demand_empty_rest_of_line ();
1668 ILLEGAL_WITHIN_STRUCT ();
1670 s_align_bytes (count
<< 1);
1673 /* Initialize multiple-bit fields within a single word of memory. */
1676 tic54x_field (int ignore ATTRIBUTE_UNUSED
)
1682 symbolS
*label
= line_label
;
1684 if (current_stag
!= NULL
)
1686 tic54x_struct_field ('.');
1690 input_line_pointer
= parse_expression (input_line_pointer
, &expn
);
1692 if (*input_line_pointer
== ',')
1694 ++input_line_pointer
;
1695 size
= get_absolute_expression ();
1696 if (size
< 1 || size
> 32)
1698 as_bad (_("Invalid field size, must be from 1 to 32"));
1699 ignore_rest_of_line ();
1704 /* Truncate values to the field width. */
1705 if (expn
.X_op
!= O_constant
)
1707 /* If the expression value is relocatable, the field size *must*
1711 as_bad (_("field size must be 16 when value is relocatable"));
1712 ignore_rest_of_line ();
1716 frag_now
->tc_frag_data
= 0;
1717 emit_expr (&expn
, 2);
1721 unsigned long fmask
= (size
== 32) ? 0xFFFFFFFF : (1ul << size
) - 1;
1723 value
= expn
.X_add_number
;
1724 expn
.X_add_number
&= fmask
;
1725 if (value
!= (valueT
) expn
.X_add_number
)
1726 as_warn (_("field value truncated"));
1727 value
= expn
.X_add_number
;
1728 /* Bits are stored MS first. */
1731 frag_now
->tc_frag_data
= 0;
1733 md_number_to_chars (p
, (value
>> (size
- 16)) & 0xFFFF, 2);
1738 int bit_offset
= frag_bit_offset (frag_now
, now_seg
);
1740 fragS
*alloc_frag
= bit_offset_frag (frag_now
, now_seg
);
1741 if (bit_offset
== -1)
1743 struct bit_info
*bi
= XNEW (struct bit_info
);
1744 /* We don't know the previous offset at this time, so store the
1745 info we need and figure it out later. */
1746 expressionS size_exp
;
1748 size_exp
.X_op
= O_constant
;
1749 size_exp
.X_add_number
= size
;
1751 bi
->type
= TYPE_FIELD
;
1753 p
= frag_var (rs_machine_dependent
,
1754 4, 1, (relax_substateT
) 0,
1755 make_expr_symbol (&size_exp
), (offsetT
) 0,
1759 else if (bit_offset
== 0 || bit_offset
+ size
> 16)
1761 /* Align a new field. */
1763 frag_now
->tc_frag_data
= 0;
1764 alloc_frag
= frag_now
;
1768 /* Put the new value entirely within the existing one. */
1769 p
= alloc_frag
== frag_now
?
1770 frag_now
->fr_literal
+ frag_now_fix_octets () - 2 :
1771 alloc_frag
->fr_literal
;
1774 symbol_set_frag (label
, alloc_frag
);
1775 if (alloc_frag
== frag_now
)
1776 S_SET_VALUE (label
, frag_now_fix () - 1);
1780 value
<<= 16 - alloc_frag
->tc_frag_data
- size
;
1782 /* OR in existing value. */
1783 if (alloc_frag
->tc_frag_data
)
1784 value
|= ((unsigned short) p
[1] << 8) | p
[0];
1785 md_number_to_chars (p
, value
, 2);
1786 alloc_frag
->tc_frag_data
+= size
;
1787 if (alloc_frag
->tc_frag_data
== 16)
1788 alloc_frag
->tc_frag_data
= 0;
1792 demand_empty_rest_of_line ();
1795 /* Ideally, we want to check SEC_LOAD and SEC_HAS_CONTENTS, but those aren't
1796 available yet. seg_info ()->bss is the next best thing. */
1799 tic54x_initialized_section (segT seg
)
1801 return !seg_info (seg
)->bss
;
1804 /* .clink ["section name"]
1806 Marks the section as conditionally linked (link only if contents are
1807 referenced elsewhere.
1808 Without a name, refers to the current initialized section.
1809 Name is required for uninitialized sections. */
1812 tic54x_clink (int ignored ATTRIBUTE_UNUSED
)
1816 ILLEGAL_WITHIN_STRUCT ();
1818 if (*input_line_pointer
== '\"')
1820 char *section_name
= ++input_line_pointer
;
1823 while (is_a_char (next_char_of_string ()))
1825 know (input_line_pointer
[-1] == '\"');
1826 input_line_pointer
[-1] = 0;
1827 name
= xstrdup (section_name
);
1829 seg
= bfd_get_section_by_name (stdoutput
, name
);
1832 as_bad (_("Unrecognized section '%s'"), section_name
);
1833 ignore_rest_of_line ();
1839 if (!tic54x_initialized_section (seg
))
1841 as_bad (_("Current section is uninitialized, "
1842 "section name required for .clink"));
1843 ignore_rest_of_line ();
1848 seg
->flags
|= SEC_TIC54X_CLINK
;
1850 demand_empty_rest_of_line ();
1853 /* Change the default include directory to be the current source file's
1854 directory, instead of the current working directory. If DOT is non-zero,
1855 set to "." instead. */
1858 tic54x_set_default_include (void)
1860 char *dir
, *tmp
= NULL
;
1861 const char *curfile
;
1864 curfile
= as_where (&lineno
);
1865 dir
= xstrdup (curfile
);
1866 tmp
= strrchr (dir
, '/');
1873 if (include_dir_count
== 0)
1875 include_dirs
= XNEWVEC (const char *, 1);
1876 include_dir_count
= 1;
1878 include_dirs
[0] = dir
;
1879 if (len
> include_dir_maxlen
)
1880 include_dir_maxlen
= len
;
1882 else if (include_dirs
!= NULL
)
1883 include_dirs
[0] = ".";
1886 /* .include "filename" | filename
1887 .copy "filename" | filename
1889 FIXME 'include' file should be omitted from any output listing,
1890 'copy' should be included in any output listing
1891 FIXME -- prevent any included files from changing listing (compat only)
1892 FIXME -- need to include source file directory in search path; what's a
1893 good way to do this?
1895 Entering/exiting included/copied file clears all local labels. */
1898 tic54x_include (int ignored ATTRIBUTE_UNUSED
)
1900 char newblock
[] = " .newblock\n";
1905 ILLEGAL_WITHIN_STRUCT ();
1909 if (*input_line_pointer
== '"')
1911 filename
= demand_copy_C_string (&len
);
1912 demand_empty_rest_of_line ();
1916 filename
= input_line_pointer
;
1917 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1918 ++input_line_pointer
;
1919 c
= *input_line_pointer
;
1920 *input_line_pointer
= '\0';
1921 filename
= xstrdup (filename
);
1922 *input_line_pointer
= c
;
1923 demand_empty_rest_of_line ();
1925 /* Insert a partial line with the filename (for the sake of s_include)
1927 The included file will be inserted before the newblock, so that the
1928 newblock is executed after the included file is processed. */
1929 input
= concat ("\"", filename
, "\"\n", newblock
, (char *) NULL
);
1930 input_scrub_insert_line (input
);
1932 tic54x_clear_local_labels (0);
1934 tic54x_set_default_include ();
1940 tic54x_message (int type
)
1946 ILLEGAL_WITHIN_STRUCT ();
1948 if (*input_line_pointer
== '"')
1949 msg
= demand_copy_C_string (&len
);
1952 msg
= input_line_pointer
;
1953 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1954 ++input_line_pointer
;
1955 c
= *input_line_pointer
;
1956 *input_line_pointer
= 0;
1957 msg
= xstrdup (msg
);
1958 *input_line_pointer
= c
;
1964 as_tsktsk ("%s", msg
);
1967 as_warn ("%s", msg
);
1974 demand_empty_rest_of_line ();
1978 Define a special symbol that refers to the loadtime address rather than the
1979 runtime address within the current section.
1981 This symbol gets a special storage class so that when it is resolved, it is
1982 resolved relative to the load address (lma) of the section rather than the
1983 run address (vma). */
1986 tic54x_label (int ignored ATTRIBUTE_UNUSED
)
1992 ILLEGAL_WITHIN_STRUCT ();
1994 c
= get_symbol_name (&name
);
1995 symbolP
= colon (name
);
1996 S_SET_STORAGE_CLASS (symbolP
, C_STATLAB
);
1998 (void) restore_line_pointer (c
);
1999 demand_empty_rest_of_line ();
2003 Install all memory-mapped register names into the symbol table as
2004 absolute local symbols. */
2007 tic54x_mmregs (int ignored ATTRIBUTE_UNUSED
)
2011 ILLEGAL_WITHIN_STRUCT ();
2013 for (sym
= (tic54x_symbol
*) mmregs
; sym
->name
; sym
++)
2015 symbolS
*symbolP
= symbol_new (sym
->name
, absolute_section
,
2016 (valueT
) sym
->value
, &zero_address_frag
);
2017 SF_SET_LOCAL (symbolP
);
2018 symbol_table_insert (symbolP
);
2023 Count defaults to 1024. */
2026 tic54x_loop (int count
)
2028 ILLEGAL_WITHIN_STRUCT ();
2031 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
2032 count
= get_absolute_expression ();
2034 do_repeat ((size_t) count
, "LOOP", "ENDLOOP");
2037 /* Normally, endloop gets eaten by the preceding loop. */
2040 tic54x_endloop (int ignore ATTRIBUTE_UNUSED
)
2042 as_bad (_("ENDLOOP without corresponding LOOP"));
2043 ignore_rest_of_line ();
2046 /* .break [condition]. */
2049 tic54x_break (int ignore ATTRIBUTE_UNUSED
)
2053 ILLEGAL_WITHIN_STRUCT ();
2056 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
2057 cond
= get_absolute_expression ();
2060 end_repeat (substitution_line
? 1 : 0);
2064 set_address_mode (int mode
)
2067 if (mode
== far_mode
)
2069 symbolS
*symbolP
= symbol_new ("__allow_far", absolute_section
,
2070 (valueT
) 1, &zero_address_frag
);
2071 SF_SET_LOCAL (symbolP
);
2072 symbol_table_insert (symbolP
);
2076 static int address_mode_needs_set
= 1;
2079 tic54x_address_mode (int mode
)
2081 if (assembly_begun
&& amode
!= (unsigned) mode
)
2083 as_bad (_("Mixing of normal and extended addressing not supported"));
2084 ignore_rest_of_line ();
2087 if (mode
== far_mode
&& cpu
!= VNONE
&& cpu
!= V548
&& cpu
!= V549
)
2089 as_bad (_("Extended addressing not supported on the specified CPU"));
2090 ignore_rest_of_line ();
2094 set_address_mode (mode
);
2095 demand_empty_rest_of_line ();
2098 /* .sblock "section"|section [,...,"section"|section]
2099 Designate initialized sections for blocking. */
2102 tic54x_sblock (int ignore ATTRIBUTE_UNUSED
)
2106 ILLEGAL_WITHIN_STRUCT ();
2113 if (*input_line_pointer
== '"')
2117 name
= demand_copy_C_string (&len
);
2123 c
= get_symbol_name (§ion_name
);
2124 name
= xstrdup (section_name
);
2125 (void) restore_line_pointer (c
);
2128 seg
= bfd_get_section_by_name (stdoutput
, name
);
2131 as_bad (_("Unrecognized section '%s'"), name
);
2132 ignore_rest_of_line ();
2135 else if (!tic54x_initialized_section (seg
))
2137 as_bad (_(".sblock may be used for initialized sections only"));
2138 ignore_rest_of_line ();
2141 seg
->flags
|= SEC_TIC54X_BLOCK
;
2143 c
= *input_line_pointer
;
2144 if (!is_end_of_line
[(unsigned char) c
])
2145 ++input_line_pointer
;
2148 demand_empty_rest_of_line ();
2151 /* symbol .set value
2154 value must be defined externals; no forward-referencing allowed
2155 symbols assigned with .set/.equ may not be redefined. */
2158 tic54x_set (int ignore ATTRIBUTE_UNUSED
)
2163 ILLEGAL_WITHIN_STRUCT ();
2167 as_bad (_("Symbol missing for .set/.equ"));
2168 ignore_rest_of_line ();
2171 name
= xstrdup (S_GET_NAME (line_label
));
2173 if ((symbolP
= symbol_find (name
)) == NULL
2174 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
2176 symbolP
= symbol_new (name
, absolute_section
, 0, &zero_address_frag
);
2177 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
2180 S_SET_DATA_TYPE (symbolP
, T_INT
);
2181 S_SET_SEGMENT (symbolP
, absolute_section
);
2182 symbol_table_insert (symbolP
);
2183 pseudo_set (symbolP
);
2184 demand_empty_rest_of_line ();
2189 List false conditional blocks. */
2192 tic54x_fclist (int show
)
2195 listing
&= ~LISTING_NOCOND
;
2197 listing
|= LISTING_NOCOND
;
2198 demand_empty_rest_of_line ();
2202 tic54x_sslist (int show
)
2204 ILLEGAL_WITHIN_STRUCT ();
2206 listing_sslist
= show
;
2209 /* .var SYM[,...,SYMN]
2210 Define a substitution string to be local to a macro. */
2213 tic54x_var (int ignore ATTRIBUTE_UNUSED
)
2215 static char empty
[] = "";
2219 ILLEGAL_WITHIN_STRUCT ();
2221 if (macro_level
== 0)
2223 as_bad (_(".var may only be used within a macro definition"));
2224 ignore_rest_of_line ();
2229 if (!ISALPHA (*input_line_pointer
))
2231 as_bad (_("Substitution symbols must begin with a letter"));
2232 ignore_rest_of_line ();
2235 c
= get_symbol_name (&name
);
2236 /* .var symbols start out with a null string. */
2237 name
= xstrdup (name
);
2238 hash_insert (subsym_hash
[macro_level
], name
, empty
);
2239 c
= restore_line_pointer (c
);
2242 ++input_line_pointer
;
2243 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
2244 c
= *input_line_pointer
;
2249 demand_empty_rest_of_line ();
2252 /* .mlib <macro library filename>
2254 Macro libraries are archived (standard AR-format) text macro definitions
2255 Expand the file and include it.
2257 FIXME need to try the source file directory as well. */
2260 tic54x_mlib (int ignore ATTRIBUTE_UNUSED
)
2267 ILLEGAL_WITHIN_STRUCT ();
2269 /* Parse the filename. */
2270 if (*input_line_pointer
== '"')
2272 if ((filename
= demand_copy_C_string (&len
)) == NULL
)
2279 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
2280 && !ISSPACE (*input_line_pointer
))
2282 obstack_1grow (¬es
, *input_line_pointer
);
2283 ++input_line_pointer
;
2286 obstack_1grow (¬es
, '\0');
2287 filename
= obstack_finish (¬es
);
2289 demand_empty_rest_of_line ();
2291 tic54x_set_default_include ();
2292 path
= XNEWVEC (char, (unsigned long) len
+ include_dir_maxlen
+ 5);
2294 for (i
= 0; i
< include_dir_count
; i
++)
2298 strcpy (path
, include_dirs
[i
]);
2300 strcat (path
, filename
);
2301 if ((try = fopen (path
, "r")) != NULL
)
2308 if (i
>= include_dir_count
)
2314 /* FIXME: if path is found, malloc'd storage is not freed. Of course, this
2315 happens all over the place, and since the assembler doesn't usually keep
2316 running for a very long time, it really doesn't matter. */
2317 register_dependency (path
);
2319 /* Expand all archive entries to temporary files and include them. */
2320 abfd
= bfd_openr (path
, NULL
);
2323 as_bad (_("can't open macro library file '%s' for reading: %s"),
2324 path
, bfd_errmsg (bfd_get_error ()));
2325 ignore_rest_of_line ();
2328 if (!bfd_check_format (abfd
, bfd_archive
))
2330 as_bad (_("File '%s' not in macro archive format"), path
);
2331 ignore_rest_of_line ();
2335 /* Open each BFD as binary (it should be straight ASCII text). */
2336 for (mbfd
= bfd_openr_next_archived_file (abfd
, NULL
);
2337 mbfd
!= NULL
; mbfd
= bfd_openr_next_archived_file (abfd
, mbfd
))
2339 /* Get a size at least as big as the archive member. */
2340 bfd_size_type size
= bfd_get_size (mbfd
);
2341 char *buf
= XNEWVEC (char, size
);
2342 char *fname
= tmpnam (NULL
);
2345 /* We're not sure how big it is, but it will be smaller than "size". */
2346 size
= bfd_bread (buf
, size
, mbfd
);
2348 /* Write to a temporary file, then use s_include to include it
2350 ftmp
= fopen (fname
, "w+b");
2351 fwrite ((void *) buf
, size
, 1, ftmp
);
2352 if (size
== 0 || buf
[size
- 1] != '\n')
2353 fwrite ("\n", 1, 1, ftmp
);
2356 input_scrub_insert_file (fname
);
2361 const pseudo_typeS md_pseudo_table
[] =
2363 { "algebraic", s_ignore
, 0 },
2364 { "align" , tic54x_align_words
, 128 },
2365 { "ascii" , tic54x_stringer
, 'p' },
2366 { "asciz" , tic54x_stringer
, 'P' },
2367 { "even" , tic54x_align_words
, 2 },
2368 { "asg" , tic54x_asg
, 0 },
2369 { "eval" , tic54x_eval
, 0 },
2370 { "bss" , tic54x_bss
, 0 },
2371 { "byte" , tic54x_cons
, 'b' },
2372 { "ubyte" , tic54x_cons
, 'B' },
2373 { "char" , tic54x_cons
, 'c' },
2374 { "uchar" , tic54x_cons
, 'C' },
2375 { "clink" , tic54x_clink
, 0 },
2376 { "c_mode" , tic54x_address_mode
, c_mode
},
2377 { "copy" , tic54x_include
, 'c' },
2378 { "include" , tic54x_include
, 'i' },
2379 { "data" , tic54x_sect
, 'd' },
2380 { "double" , tic54x_float_cons
, 'd' },
2381 { "ldouble" , tic54x_float_cons
, 'l' },
2382 { "drlist" , s_ignore
, 0 },
2383 { "drnolist" , s_ignore
, 0 },
2384 { "emsg" , tic54x_message
, 'e' },
2385 { "mmsg" , tic54x_message
, 'm' },
2386 { "wmsg" , tic54x_message
, 'w' },
2387 { "far_mode" , tic54x_address_mode
, far_mode
},
2388 { "fclist" , tic54x_fclist
, 1 },
2389 { "fcnolist" , tic54x_fclist
, 0 },
2390 { "field" , tic54x_field
, -1 },
2391 { "float" , tic54x_float_cons
, 'f' },
2392 { "xfloat" , tic54x_float_cons
, 'x' },
2393 { "global" , tic54x_global
, 'g' },
2394 { "def" , tic54x_global
, 'd' },
2395 { "ref" , tic54x_global
, 'r' },
2396 { "half" , tic54x_cons
, 'h' },
2397 { "uhalf" , tic54x_cons
, 'H' },
2398 { "short" , tic54x_cons
, 's' },
2399 { "ushort" , tic54x_cons
, 'S' },
2400 { "if" , s_if
, (int) O_ne
},
2401 { "elseif" , s_elseif
, (int) O_ne
},
2402 { "else" , s_else
, 0 },
2403 { "endif" , s_endif
, 0 },
2404 { "int" , tic54x_cons
, 'i' },
2405 { "uint" , tic54x_cons
, 'I' },
2406 { "word" , tic54x_cons
, 'w' },
2407 { "uword" , tic54x_cons
, 'W' },
2408 { "label" , tic54x_label
, 0 }, /* Loadtime
2410 { "length" , s_ignore
, 0 },
2411 { "width" , s_ignore
, 0 },
2412 { "long" , tic54x_cons
, 'l' },
2413 { "ulong" , tic54x_cons
, 'L' },
2414 { "xlong" , tic54x_cons
, 'x' },
2415 { "loop" , tic54x_loop
, 1024 },
2416 { "break" , tic54x_break
, 0 },
2417 { "endloop" , tic54x_endloop
, 0 },
2418 { "mlib" , tic54x_mlib
, 0 },
2419 { "mlist" , s_ignore
, 0 },
2420 { "mnolist" , s_ignore
, 0 },
2421 { "mmregs" , tic54x_mmregs
, 0 },
2422 { "newblock" , tic54x_clear_local_labels
, 0 },
2423 { "option" , s_ignore
, 0 },
2424 { "p2align" , tic54x_p2align
, 0 },
2425 { "sblock" , tic54x_sblock
, 0 },
2426 { "sect" , tic54x_sect
, '*' },
2427 { "set" , tic54x_set
, 0 },
2428 { "equ" , tic54x_set
, 0 },
2429 { "space" , tic54x_space
, 0 },
2430 { "bes" , tic54x_space
, 1 },
2431 { "sslist" , tic54x_sslist
, 1 },
2432 { "ssnolist" , tic54x_sslist
, 0 },
2433 { "string" , tic54x_stringer
, 's' },
2434 { "pstring" , tic54x_stringer
, 'p' },
2435 { "struct" , tic54x_struct
, 0 },
2436 { "tag" , tic54x_tag
, 0 },
2437 { "endstruct", tic54x_endstruct
, 0 },
2438 { "tab" , s_ignore
, 0 },
2439 { "text" , tic54x_sect
, 't' },
2440 { "union" , tic54x_struct
, 1 },
2441 { "endunion" , tic54x_endstruct
, 1 },
2442 { "usect" , tic54x_usect
, 0 },
2443 { "var" , tic54x_var
, 0 },
2444 { "version" , tic54x_version
, 0 },
2449 md_parse_option (int c
, const char *arg
)
2455 case OPTION_COFF_VERSION
:
2457 int version
= atoi (arg
);
2459 if (version
!= 0 && version
!= 1 && version
!= 2)
2460 as_fatal (_("Bad COFF version '%s'"), arg
);
2461 /* FIXME -- not yet implemented. */
2464 case OPTION_CPU_VERSION
:
2466 cpu
= lookup_version (arg
);
2469 as_fatal (_("Bad CPU version '%s'"), arg
);
2472 case OPTION_ADDRESS_MODE
:
2474 address_mode_needs_set
= 1;
2476 case OPTION_STDERR_TO_FILE
:
2478 const char *filename
= arg
;
2479 FILE *fp
= fopen (filename
, "w+");
2482 as_fatal (_("Can't redirect stderr to the file '%s'"), filename
);
2484 if ((fp
= freopen (filename
, "w+", stderr
)) == NULL
)
2485 as_fatal (_("Can't redirect stderr to the file '%s'"), filename
);
2493 /* Create a "local" substitution string hash table for a new macro level
2494 Some docs imply that macros have to use .newblock in order to be able
2495 to re-use a local label. We effectively do an automatic .newblock by
2496 deleting the local label hash between macro invocations. */
2499 tic54x_macro_start (void)
2501 if (++macro_level
>= MAX_SUBSYM_HASH
)
2503 as_fatal (_("Macro nesting is too deep"));
2506 subsym_hash
[macro_level
] = hash_new ();
2507 local_label_hash
[macro_level
] = hash_new ();
2511 tic54x_macro_info (const macro_entry
*macro
)
2513 const formal_entry
*entry
;
2515 /* Put the formal args into the substitution symbol table. */
2516 for (entry
= macro
->formals
; entry
; entry
= entry
->next
)
2518 char *name
= xstrndup (entry
->name
.ptr
, entry
->name
.len
);
2519 char *value
= xstrndup (entry
->actual
.ptr
, entry
->actual
.len
);
2521 name
[entry
->name
.len
] = '\0';
2522 value
[entry
->actual
.len
] = '\0';
2523 hash_insert (subsym_hash
[macro_level
], name
, value
);
2527 /* Get rid of this macro's .var's, arguments, and local labels. */
2530 tic54x_macro_end (void)
2532 hash_die (subsym_hash
[macro_level
]);
2533 subsym_hash
[macro_level
] = NULL
;
2534 hash_die (local_label_hash
[macro_level
]);
2535 local_label_hash
[macro_level
] = NULL
;
2540 subsym_symlen (char *a
, char *ignore ATTRIBUTE_UNUSED
)
2545 /* Compare symbol A to string B. */
2548 subsym_symcmp (char *a
, char *b
)
2550 return strcmp (a
, b
);
2553 /* Return the index of the first occurrence of B in A, or zero if none
2554 assumes b is an integer char value as a string. Index is one-based. */
2557 subsym_firstch (char *a
, char *b
)
2560 char *tmp
= strchr (a
, val
);
2562 return tmp
? tmp
- a
+ 1 : 0;
2565 /* Similar to firstch, but returns index of last occurrence of B in A. */
2568 subsym_lastch (char *a
, char *b
)
2571 char *tmp
= strrchr (a
, val
);
2573 return tmp
? tmp
- a
+ 1 : 0;
2576 /* Returns 1 if string A is defined in the symbol table (NOT the substitution
2580 subsym_isdefed (char *a
, char *ignore ATTRIBUTE_UNUSED
)
2582 symbolS
*symbolP
= symbol_find (a
);
2584 return symbolP
!= NULL
;
2587 /* Assign first member of comma-separated list B (e.g. "1,2,3") to the symbol
2588 A, or zero if B is a null string. Both arguments *must* be substitution
2589 symbols, unsubstituted. */
2592 subsym_ismember (char *sym
, char *list
)
2594 char *elem
, *ptr
, *listv
;
2599 listv
= subsym_lookup (list
, macro_level
);
2602 as_bad (_("Undefined substitution symbol '%s'"), list
);
2603 ignore_rest_of_line ();
2607 ptr
= elem
= xstrdup (listv
);
2608 while (*ptr
&& *ptr
!= ',')
2612 subsym_create_or_replace (sym
, elem
);
2614 /* Reassign the list. */
2615 subsym_create_or_replace (list
, ptr
);
2617 /* Assume this value, docs aren't clear. */
2621 /* Return zero if not a constant; otherwise:
2629 subsym_iscons (char *a
, char *ignore ATTRIBUTE_UNUSED
)
2633 parse_expression (a
, &expn
);
2635 if (expn
.X_op
== O_constant
)
2637 int len
= strlen (a
);
2639 switch (TOUPPER (a
[len
- 1]))
2652 /* No suffix; either octal, hex, or decimal. */
2653 if (*a
== '0' && len
> 1)
2655 if (TOUPPER (a
[1]) == 'X')
2665 /* Return 1 if A is a valid symbol name. Expects string input. */
2668 subsym_isname (char *a
, char *ignore ATTRIBUTE_UNUSED
)
2670 if (!is_name_beginner (*a
))
2674 if (!is_part_of_name (*a
))
2681 /* Return whether the string is a register; accepts ar0-7, unless .mmregs has
2682 been seen; if so, recognize any memory-mapped register.
2683 Note this does not recognize "A" or "B" accumulators. */
2686 subsym_isreg (char *a
, char *ignore ATTRIBUTE_UNUSED
)
2688 if (hash_find (reg_hash
, a
))
2690 if (hash_find (mmreg_hash
, a
))
2695 /* Return the structure size, given the stag. */
2698 subsym_structsz (char *name
, char *ignore ATTRIBUTE_UNUSED
)
2700 struct stag
*stag
= (struct stag
*) hash_find (stag_hash
, name
);
2708 /* If anybody actually uses this, they can fix it :)
2709 FIXME I'm not sure what the "reference point" of a structure is. It might
2710 be either the initial offset given .struct, or it may be the offset of the
2711 structure within another structure, or it might be something else
2712 altogether. since the TI assembler doesn't seem to ever do anything but
2713 return zero, we punt and return zero. */
2716 subsym_structacc (char *stag_name ATTRIBUTE_UNUSED
,
2717 char *ignore ATTRIBUTE_UNUSED
)
2723 math_ceil (float arg1
, float ignore ATTRIBUTE_UNUSED
)
2725 return (float) ceil (arg1
);
2729 math_cvi (float arg1
, float ignore ATTRIBUTE_UNUSED
)
2735 math_floor (float arg1
, float ignore ATTRIBUTE_UNUSED
)
2737 return (float) floor (arg1
);
2741 math_fmod (float arg1
, float arg2
)
2743 return (int) arg1
% (int) arg2
;
2747 math_int (float arg1
, float ignore ATTRIBUTE_UNUSED
)
2749 return ((float) ((int) arg1
)) == arg1
;
2753 math_round (float arg1
, float ignore ATTRIBUTE_UNUSED
)
2755 return arg1
> 0 ? (int) (arg1
+ 0.5) : (int) (arg1
- 0.5);
2759 math_sgn (float arg1
, float ignore ATTRIBUTE_UNUSED
)
2761 return (arg1
< 0) ? -1 : (arg1
? 1 : 0);
2765 math_trunc (float arg1
, float ignore ATTRIBUTE_UNUSED
)
2771 math_acos (float arg1
, float ignore ATTRIBUTE_UNUSED
)
2773 return (float) acos (arg1
);
2777 math_asin (float arg1
, float ignore ATTRIBUTE_UNUSED
)
2779 return (float) asin (arg1
);
2783 math_atan (float arg1
, float ignore ATTRIBUTE_UNUSED
)
2785 return (float) atan (arg1
);
2789 math_atan2 (float arg1
, float arg2
)
2791 return (float) atan2 (arg1
, arg2
);
2795 math_cosh (float arg1
, float ignore ATTRIBUTE_UNUSED
)
2797 return (float) cosh (arg1
);
2801 math_cos (float arg1
, float ignore ATTRIBUTE_UNUSED
)
2803 return (float) cos (arg1
);
2807 math_cvf (float arg1
, float ignore ATTRIBUTE_UNUSED
)
2809 return (float) arg1
;
2813 math_exp (float arg1
, float ignore ATTRIBUTE_UNUSED
)
2815 return (float) exp (arg1
);
2819 math_fabs (float arg1
, float ignore ATTRIBUTE_UNUSED
)
2821 return (float) fabs (arg1
);
2824 /* expr1 * 2^expr2. */
2827 math_ldexp (float arg1
, float arg2
)
2829 return arg1
* (float) pow (2.0, arg2
);
2833 math_log10 (float arg1
, float ignore ATTRIBUTE_UNUSED
)
2835 return (float) log10 (arg1
);
2839 math_log (float arg1
, float ignore ATTRIBUTE_UNUSED
)
2841 return (float) log (arg1
);
2845 math_max (float arg1
, float arg2
)
2847 return (arg1
> arg2
) ? arg1
: arg2
;
2851 math_min (float arg1
, float arg2
)
2853 return (arg1
< arg2
) ? arg1
: arg2
;
2857 math_pow (float arg1
, float arg2
)
2859 return (float) pow (arg1
, arg2
);
2863 math_sin (float arg1
, float ignore ATTRIBUTE_UNUSED
)
2865 return (float) sin (arg1
);
2869 math_sinh (float arg1
, float ignore ATTRIBUTE_UNUSED
)
2871 return (float) sinh (arg1
);
2875 math_sqrt (float arg1
, float ignore ATTRIBUTE_UNUSED
)
2877 return (float) sqrt (arg1
);
2881 math_tan (float arg1
, float ignore ATTRIBUTE_UNUSED
)
2883 return (float) tan (arg1
);
2887 math_tanh (float arg1
, float ignore ATTRIBUTE_UNUSED
)
2889 return (float) tanh (arg1
);
2892 /* Built-in substitution symbol functions and math functions. */
2896 int (*proc
) (char *, char *);
2898 } subsym_proc_entry
;
2900 static const subsym_proc_entry subsym_procs
[] =
2902 /* Assembler built-in string substitution functions. */
2903 { "$symlen", subsym_symlen
, 1, },
2904 { "$symcmp", subsym_symcmp
, 2, },
2905 { "$firstch", subsym_firstch
, 2, },
2906 { "$lastch", subsym_lastch
, 2, },
2907 { "$isdefed", subsym_isdefed
, 1, },
2908 { "$ismember", subsym_ismember
, 2, },
2909 { "$iscons", subsym_iscons
, 1, },
2910 { "$isname", subsym_isname
, 1, },
2911 { "$isreg", subsym_isreg
, 1, },
2912 { "$structsz", subsym_structsz
, 1, },
2913 { "$structacc", subsym_structacc
, 1, },
2920 float (*proc
) (float, float);
2925 static const math_proc_entry math_procs
[] =
2927 /* Integer-returning built-in math functions. */
2928 { "$cvi", math_cvi
, 1, 1 },
2929 { "$int", math_int
, 1, 1 },
2930 { "$sgn", math_sgn
, 1, 1 },
2932 /* Float-returning built-in math functions. */
2933 { "$acos", math_acos
, 1, 0 },
2934 { "$asin", math_asin
, 1, 0 },
2935 { "$atan", math_atan
, 1, 0 },
2936 { "$atan2", math_atan2
, 2, 0 },
2937 { "$ceil", math_ceil
, 1, 0 },
2938 { "$cosh", math_cosh
, 1, 0 },
2939 { "$cos", math_cos
, 1, 0 },
2940 { "$cvf", math_cvf
, 1, 0 },
2941 { "$exp", math_exp
, 1, 0 },
2942 { "$fabs", math_fabs
, 1, 0 },
2943 { "$floor", math_floor
, 1, 0 },
2944 { "$fmod", math_fmod
, 2, 0 },
2945 { "$ldexp", math_ldexp
, 2, 0 },
2946 { "$log10", math_log10
, 1, 0 },
2947 { "$log", math_log
, 1, 0 },
2948 { "$max", math_max
, 2, 0 },
2949 { "$min", math_min
, 2, 0 },
2950 { "$pow", math_pow
, 2, 0 },
2951 { "$round", math_round
, 1, 0 },
2952 { "$sin", math_sin
, 1, 0 },
2953 { "$sinh", math_sinh
, 1, 0 },
2954 { "$sqrt", math_sqrt
, 1, 0 },
2955 { "$tan", math_tan
, 1, 0 },
2956 { "$tanh", math_tanh
, 1, 0 },
2957 { "$trunc", math_trunc
, 1, 0 },
2958 { NULL
, NULL
, 0, 0 },
2966 const subsym_proc_entry
*subsym_proc
;
2967 const math_proc_entry
*math_proc
;
2968 const char *hash_err
;
2970 char *TIC54X_DIR
= getenv ("TIC54X_DIR");
2971 char *A_DIR
= TIC54X_DIR
? TIC54X_DIR
: getenv ("A_DIR");
2975 /* Look for A_DIR and add it to the include list. */
2978 char *tmp
= xstrdup (A_DIR
);
2982 char *next
= strchr (tmp
, ';');
2986 add_include_dir (tmp
);
2989 while (tmp
!= NULL
);
2992 op_hash
= hash_new ();
2993 for (tm
= (insn_template
*) tic54x_optab
; tm
->name
; tm
++)
2995 if (hash_find (op_hash
, tm
->name
))
2997 hash_err
= hash_insert (op_hash
, tm
->name
, (char *) tm
);
2999 as_fatal ("Internal Error: Can't hash %s: %s",
3000 tm
->name
, hash_err
);
3002 parop_hash
= hash_new ();
3003 for (tm
= (insn_template
*) tic54x_paroptab
; tm
->name
; tm
++)
3005 if (hash_find (parop_hash
, tm
->name
))
3007 hash_err
= hash_insert (parop_hash
, tm
->name
, (char *) tm
);
3009 as_fatal ("Internal Error: Can't hash %s: %s",
3010 tm
->name
, hash_err
);
3012 reg_hash
= hash_new ();
3013 for (sym
= (tic54x_symbol
*) regs
; sym
->name
; sym
++)
3015 /* Add basic registers to the symbol table. */
3016 symbolS
*symbolP
= symbol_new (sym
->name
, absolute_section
,
3017 (valueT
) sym
->value
, &zero_address_frag
);
3018 SF_SET_LOCAL (symbolP
);
3019 symbol_table_insert (symbolP
);
3020 hash_err
= hash_insert (reg_hash
, sym
->name
, (char *) sym
);
3022 for (sym
= (tic54x_symbol
*) mmregs
; sym
->name
; sym
++)
3023 hash_err
= hash_insert (reg_hash
, sym
->name
, (char *) sym
);
3024 mmreg_hash
= hash_new ();
3025 for (sym
= (tic54x_symbol
*) mmregs
; sym
->name
; sym
++)
3026 hash_err
= hash_insert (mmreg_hash
, sym
->name
, (char *) sym
);
3028 cc_hash
= hash_new ();
3029 for (sym
= (tic54x_symbol
*) condition_codes
; sym
->name
; sym
++)
3030 hash_err
= hash_insert (cc_hash
, sym
->name
, (char *) sym
);
3032 cc2_hash
= hash_new ();
3033 for (sym
= (tic54x_symbol
*) cc2_codes
; sym
->name
; sym
++)
3034 hash_err
= hash_insert (cc2_hash
, sym
->name
, (char *) sym
);
3036 cc3_hash
= hash_new ();
3037 for (sym
= (tic54x_symbol
*) cc3_codes
; sym
->name
; sym
++)
3038 hash_err
= hash_insert (cc3_hash
, sym
->name
, (char *) sym
);
3040 sbit_hash
= hash_new ();
3041 for (sym
= (tic54x_symbol
*) status_bits
; sym
->name
; sym
++)
3042 hash_err
= hash_insert (sbit_hash
, sym
->name
, (char *) sym
);
3044 misc_symbol_hash
= hash_new ();
3045 for (symname
= (char **) misc_symbols
; *symname
; symname
++)
3046 hash_err
= hash_insert (misc_symbol_hash
, *symname
, *symname
);
3048 /* Only the base substitution table and local label table are initialized;
3049 the others (for local macro substitution) get instantiated as needed. */
3050 local_label_hash
[0] = hash_new ();
3051 subsym_hash
[0] = hash_new ();
3052 for (subsym_proc
= subsym_procs
; subsym_proc
->name
; subsym_proc
++)
3053 hash_err
= hash_insert (subsym_hash
[0], subsym_proc
->name
,
3054 (char *) subsym_proc
);
3056 math_hash
= hash_new ();
3057 for (math_proc
= math_procs
; math_proc
->name
; math_proc
++)
3059 /* Insert into the main subsym hash for recognition; insert into
3060 the math hash to actually store information. */
3061 hash_err
= hash_insert (subsym_hash
[0], math_proc
->name
,
3062 (char *) math_proc
);
3063 hash_err
= hash_insert (math_hash
, math_proc
->name
,
3064 (char *) math_proc
);
3066 subsym_recurse_hash
= hash_new ();
3067 stag_hash
= hash_new ();
3071 is_accumulator (struct opstruct
*operand
)
3073 return strcasecmp (operand
->buf
, "a") == 0
3074 || strcasecmp (operand
->buf
, "b") == 0;
3077 /* Return the number of operands found, or -1 on error, copying the
3078 operands into the given array and the accompanying expressions into
3082 get_operands (struct opstruct operands
[], char *line
)
3086 int expecting_operand
= 0;
3089 while (numexp
< MAX_OPERANDS
&& !is_end_of_line
[(unsigned char) *lptr
])
3091 int paren_not_balanced
= 0;
3092 char *op_start
, *op_end
;
3094 while (*lptr
&& ISSPACE (*lptr
))
3097 while (paren_not_balanced
|| *lptr
!= ',')
3101 if (paren_not_balanced
)
3103 as_bad (_("Unbalanced parenthesis in operand %d"), numexp
);
3110 ++paren_not_balanced
;
3111 else if (*lptr
== ')')
3112 --paren_not_balanced
;
3116 if (op_end
!= op_start
)
3118 int len
= op_end
- op_start
;
3120 strncpy (operands
[numexp
].buf
, op_start
, len
);
3121 operands
[numexp
].buf
[len
] = 0;
3122 /* Trim trailing spaces; while the preprocessor gets rid of most,
3123 there are weird usage patterns that can introduce them
3124 (i.e. using strings for macro args). */
3125 while (len
> 0 && ISSPACE (operands
[numexp
].buf
[len
- 1]))
3126 operands
[numexp
].buf
[--len
] = 0;
3132 if (expecting_operand
|| *lptr
== ',')
3134 as_bad (_("Expecting operand after ','"));
3140 if (*++lptr
== '\0')
3142 as_bad (_("Expecting operand after ','"));
3145 expecting_operand
= 1;
3149 while (*lptr
&& ISSPACE (*lptr
++))
3151 if (!is_end_of_line
[(unsigned char) *lptr
])
3153 as_bad (_("Extra junk on line"));
3157 /* OK, now parse them into expressions. */
3158 for (i
= 0; i
< numexp
; i
++)
3160 memset (&operands
[i
].exp
, 0, sizeof (operands
[i
].exp
));
3161 if (operands
[i
].buf
[0] == '#')
3164 parse_expression (operands
[i
].buf
+ 1, &operands
[i
].exp
);
3166 else if (operands
[i
].buf
[0] == '@')
3168 /* Direct notation. */
3169 parse_expression (operands
[i
].buf
+ 1, &operands
[i
].exp
);
3171 else if (operands
[i
].buf
[0] == '*')
3174 char *paren
= strchr (operands
[i
].buf
, '(');
3176 /* Allow immediate syntax in the inner expression. */
3177 if (paren
&& paren
[1] == '#')
3180 /* Pull out the lk expression or SP offset, if present. */
3183 int len
= strlen (paren
);
3184 char *end
= paren
+ len
;
3187 while (end
[-1] != ')')
3190 as_bad (_("Badly formed address expression"));
3195 parse_expression (paren
, &operands
[i
].exp
);
3199 operands
[i
].exp
.X_op
= O_absent
;
3202 parse_expression (operands
[i
].buf
, &operands
[i
].exp
);
3208 /* Predicates for different operand types. */
3211 is_immediate (struct opstruct
*operand
)
3213 return *operand
->buf
== '#';
3216 /* This is distinguished from immediate because some numbers must be constants
3217 and must *not* have the '#' prefix. */
3220 is_absolute (struct opstruct
*operand
)
3222 return operand
->exp
.X_op
== O_constant
&& !is_immediate (operand
);
3225 /* Is this an indirect operand? */
3228 is_indirect (struct opstruct
*operand
)
3230 return operand
->buf
[0] == '*';
3233 /* Is this a valid dual-memory operand? */
3236 is_dual (struct opstruct
*operand
)
3238 if (is_indirect (operand
) && strncasecmp (operand
->buf
, "*ar", 3) == 0)
3240 char *tmp
= operand
->buf
+ 3;
3245 /* Only allow *ARx, *ARx-, *ARx+, or *ARx+0%. */
3246 valid_mod
= *tmp
== '\0' ||
3247 strcasecmp (tmp
, "-") == 0 ||
3248 strcasecmp (tmp
, "+") == 0 ||
3249 strcasecmp (tmp
, "+0%") == 0;
3250 return arf
>= 2 && arf
<= 5 && valid_mod
;
3256 is_mmreg (struct opstruct
*operand
)
3258 return (is_absolute (operand
)
3259 || is_immediate (operand
)
3260 || hash_find (mmreg_hash
, operand
->buf
) != 0);
3264 is_type (struct opstruct
*operand
, enum optype type
)
3269 return operand
->buf
[0] == 0;
3272 return is_dual (operand
);
3274 return is_indirect (operand
);
3276 /* This one *must* be immediate. */
3277 return is_immediate (operand
);
3286 /* Address may be a numeric, indirect, or an expression. */
3287 return !is_immediate (operand
);
3290 return is_mmreg (operand
);
3295 return is_accumulator (operand
);
3297 return is_accumulator (operand
) && TOUPPER (operand
->buf
[0]) == 'B';
3299 return is_accumulator (operand
) && TOUPPER (operand
->buf
[0]) == 'A';
3301 return strncasecmp ("ar", operand
->buf
, 2) == 0
3302 && ISDIGIT (operand
->buf
[2]);
3304 return hash_find (sbit_hash
, operand
->buf
) != 0 || is_absolute (operand
);
3306 return hash_find (cc_hash
, operand
->buf
) != 0;
3308 return hash_find (cc2_hash
, operand
->buf
) != 0;
3310 return hash_find (cc3_hash
, operand
->buf
) != 0
3311 || is_immediate (operand
) || is_absolute (operand
);
3313 return (is_immediate (operand
) || is_absolute (operand
))
3314 && operand
->exp
.X_add_number
== 16;
3316 /* Allow st0 or st1 instead of a numeric. */
3317 return is_absolute (operand
) || is_immediate (operand
) ||
3318 strcasecmp ("st0", operand
->buf
) == 0 ||
3319 strcasecmp ("st1", operand
->buf
) == 0;
3322 return is_absolute (operand
) || is_immediate (operand
);
3324 return (is_immediate (operand
) || is_absolute (operand
))
3325 && operand
->exp
.X_add_number
>= 0 && operand
->exp
.X_add_number
< 16;
3327 /* Let this one catch out-of-range values. */
3328 return (is_immediate (operand
) || is_absolute (operand
))
3329 && operand
->exp
.X_add_number
!= 16;
3333 return is_absolute (operand
) || is_immediate (operand
);
3335 return is_immediate (operand
)
3336 && operand
->exp
.X_op
== O_constant
3337 && operand
->exp
.X_add_number
>= 0
3338 && operand
->exp
.X_add_number
< 256;
3341 /* Allow anything; assumes opcodes are ordered with Smem operands
3347 /* Just make sure it's an integer; check range later. */
3348 return is_immediate (operand
);
3350 return strcasecmp ("t", operand
->buf
) == 0 ||
3351 strcasecmp ("treg", operand
->buf
) == 0;
3353 return strcasecmp ("ts", operand
->buf
) == 0;
3355 return strcasecmp ("asm", operand
->buf
) == 0;
3357 return strcasecmp ("trn", operand
->buf
) == 0;
3359 return strcasecmp ("dp", operand
->buf
) == 0;
3361 return strcasecmp ("arp", operand
->buf
) == 0;
3368 operands_match (tic54x_insn
*insn
,
3369 struct opstruct
*operands
,
3371 const enum optype
*refoptype
,
3375 int op
= 0, refop
= 0;
3377 if (opcount
== 0 && minops
== 0)
3380 while (op
<= maxops
&& refop
<= maxops
)
3382 while (!is_type (&operands
[op
], OPTYPE (refoptype
[refop
])))
3384 /* Skip an optional template operand if it doesn't agree
3385 with the current operand. */
3386 if (refoptype
[refop
] & OPT
)
3397 /* Save the actual operand type for later use. */
3398 operands
[op
].type
= OPTYPE (refoptype
[refop
]);
3401 /* Have we matched them all yet? */
3406 /* If a later operand is *not* optional, no match. */
3407 if ((refoptype
[refop
] & OPT
) == 0)
3409 /* Flag any implicit default OP_DST operands so we know to add
3410 them explicitly when encoding the operand later. */
3411 if (OPTYPE (refoptype
[refop
]) == OP_DST
)
3412 insn
->using_default_dst
= 1;
3424 /* 16-bit direct memory address
3425 Explicit dmad operands are always in last word of insn (usually second
3426 word, but bumped to third if lk addressing is used)
3428 We allow *(dmad) notation because the TI assembler allows it.
3431 0 for 16-bit addresses
3432 1 for full 23-bit addresses
3433 2 for the upper 7 bits of a 23-bit address (LDX). */
3436 encode_dmad (tic54x_insn
*insn
, struct opstruct
*operand
, int xpc_code
)
3438 int op
= 1 + insn
->is_lkaddr
;
3440 /* Only allow *(dmad) expressions; all others are invalid. */
3441 if (is_indirect (operand
) && operand
->buf
[strlen (operand
->buf
) - 1] != ')')
3443 as_bad (_("Invalid dmad syntax '%s'"), operand
->buf
);
3447 insn
->opcode
[op
].addr_expr
= operand
->exp
;
3449 if (insn
->opcode
[op
].addr_expr
.X_op
== O_constant
)
3451 valueT value
= insn
->opcode
[op
].addr_expr
.X_add_number
;
3455 insn
->opcode
[0].word
&= 0xFF80;
3456 insn
->opcode
[0].word
|= (value
>> 16) & 0x7F;
3457 insn
->opcode
[1].word
= value
& 0xFFFF;
3459 else if (xpc_code
== 2)
3460 insn
->opcode
[op
].word
= (value
>> 16) & 0xFFFF;
3462 insn
->opcode
[op
].word
= value
;
3466 /* Do the fixup later; just store the expression. */
3467 insn
->opcode
[op
].word
= 0;
3468 insn
->opcode
[op
].r_nchars
= 2;
3470 if (amode
== c_mode
)
3471 insn
->opcode
[op
].r_type
= BFD_RELOC_TIC54X_16_OF_23
;
3472 else if (xpc_code
== 1)
3474 /* This relocation spans two words, so adjust accordingly. */
3475 insn
->opcode
[0].addr_expr
= operand
->exp
;
3476 insn
->opcode
[0].r_type
= BFD_RELOC_TIC54X_23
;
3477 insn
->opcode
[0].r_nchars
= 4;
3478 insn
->opcode
[0].unresolved
= 1;
3479 /* It's really 2 words, but we want to stop encoding after the
3480 first, since we must encode both words at once. */
3483 else if (xpc_code
== 2)
3484 insn
->opcode
[op
].r_type
= BFD_RELOC_TIC54X_MS7_OF_23
;
3486 insn
->opcode
[op
].r_type
= BFD_RELOC_TIC54X_16_OF_23
;
3488 insn
->opcode
[op
].unresolved
= 1;
3494 /* 7-bit direct address encoding. */
3497 encode_address (tic54x_insn
*insn
, struct opstruct
*operand
)
3499 /* Assumes that dma addresses are *always* in word 0 of the opcode. */
3500 insn
->opcode
[0].addr_expr
= operand
->exp
;
3502 if (operand
->exp
.X_op
== O_constant
)
3503 insn
->opcode
[0].word
|= (operand
->exp
.X_add_number
& 0x7F);
3506 if (operand
->exp
.X_op
== O_register
)
3507 as_bad (_("Use the .mmregs directive to use memory-mapped register names such as '%s'"), operand
->buf
);
3508 /* Do the fixup later; just store the expression. */
3509 insn
->opcode
[0].r_nchars
= 1;
3510 insn
->opcode
[0].r_type
= BFD_RELOC_TIC54X_PARTLS7
;
3511 insn
->opcode
[0].unresolved
= 1;
3518 encode_indirect (tic54x_insn
*insn
, struct opstruct
*operand
)
3523 if (insn
->is_lkaddr
)
3525 /* lk addresses always go in the second insn word. */
3526 mod
= ((TOUPPER (operand
->buf
[1]) == 'A') ? 12 :
3527 (operand
->buf
[1] == '(') ? 15 :
3528 (strchr (operand
->buf
, '%') != NULL
) ? 14 : 13);
3529 arf
= ((mod
== 12) ? operand
->buf
[3] - '0' :
3530 (mod
== 15) ? 0 : operand
->buf
[4] - '0');
3532 insn
->opcode
[1].addr_expr
= operand
->exp
;
3534 if (operand
->exp
.X_op
== O_constant
)
3535 insn
->opcode
[1].word
= operand
->exp
.X_add_number
;
3538 insn
->opcode
[1].word
= 0;
3539 insn
->opcode
[1].r_nchars
= 2;
3540 insn
->opcode
[1].r_type
= BFD_RELOC_TIC54X_16_OF_23
;
3541 insn
->opcode
[1].unresolved
= 1;
3544 else if (strncasecmp (operand
->buf
, "*sp (", 4) == 0)
3546 /* Stack offsets look the same as 7-bit direct addressing. */
3547 return encode_address (insn
, operand
);
3551 arf
= (TOUPPER (operand
->buf
[1]) == 'A' ?
3552 operand
->buf
[3] : operand
->buf
[4]) - '0';
3554 if (operand
->buf
[1] == '+')
3556 mod
= 3; /* *+ARx */
3557 if (insn
->tm
->flags
& FL_SMR
)
3558 as_warn (_("Address mode *+ARx is write-only. "
3559 "Results of reading are undefined."));
3561 else if (operand
->buf
[4] == '\0')
3563 else if (operand
->buf
[5] == '\0')
3564 mod
= (operand
->buf
[4] == '-' ? 1 : 2); /* *ARx+ / *ARx- */
3565 else if (operand
->buf
[6] == '\0')
3567 if (operand
->buf
[5] == '0')
3568 mod
= (operand
->buf
[4] == '-' ? 5 : 6); /* *ARx+0 / *ARx-0 */
3570 mod
= (operand
->buf
[4] == '-' ? 8 : 10);/* *ARx+% / *ARx-% */
3572 else if (TOUPPER (operand
->buf
[6]) == 'B')
3573 mod
= (operand
->buf
[4] == '-' ? 4 : 7); /* ARx+0B / *ARx-0B */
3574 else if (TOUPPER (operand
->buf
[6]) == '%')
3575 mod
= (operand
->buf
[4] == '-' ? 9 : 11); /* ARx+0% / *ARx - 0% */
3578 as_bad (_("Unrecognized indirect address format \"%s\""),
3584 insn
->opcode
[0].word
|= 0x80 | (mod
<< 3) | arf
;
3590 encode_integer (tic54x_insn
*insn
,
3591 struct opstruct
*operand
,
3595 unsigned short mask
)
3597 long parse
, integer
;
3599 insn
->opcode
[which
].addr_expr
= operand
->exp
;
3601 if (operand
->exp
.X_op
== O_constant
)
3603 parse
= operand
->exp
.X_add_number
;
3604 /* Hack -- fixup for 16-bit hex quantities that get converted positive
3605 instead of negative. */
3606 if ((parse
& 0x8000) && min
== -32768 && max
== 32767)
3607 integer
= (short) parse
;
3611 if (integer
>= min
&& integer
<= max
)
3613 insn
->opcode
[which
].word
|= (integer
& mask
);
3616 as_bad (_("Operand '%s' out of range (%d <= x <= %d)"),
3617 operand
->buf
, min
, max
);
3621 if (insn
->opcode
[which
].addr_expr
.X_op
== O_constant
)
3623 insn
->opcode
[which
].word
|=
3624 insn
->opcode
[which
].addr_expr
.X_add_number
& mask
;
3628 /* Do the fixup later; just store the expression. */
3629 bfd_reloc_code_real_type rtype
=
3630 (mask
== 0x1FF ? BFD_RELOC_TIC54X_PARTMS9
:
3631 mask
== 0xFFFF ? BFD_RELOC_TIC54X_16_OF_23
:
3632 mask
== 0x7F ? BFD_RELOC_TIC54X_PARTLS7
: BFD_RELOC_8
);
3633 int size
= (mask
== 0x1FF || mask
== 0xFFFF) ? 2 : 1;
3635 if (rtype
== BFD_RELOC_8
)
3636 as_bad (_("Error in relocation handling"));
3638 insn
->opcode
[which
].r_nchars
= size
;
3639 insn
->opcode
[which
].r_type
= rtype
;
3640 insn
->opcode
[which
].unresolved
= 1;
3650 encode_condition (tic54x_insn
*insn
, struct opstruct
*operand
)
3652 tic54x_symbol
*cc
= (tic54x_symbol
*) hash_find (cc_hash
, operand
->buf
);
3655 as_bad (_("Unrecognized condition code \"%s\""), operand
->buf
);
3658 #define CC_GROUP 0x40
3660 #define CATG_A1 0x07
3661 #define CATG_B1 0x30
3662 #define CATG_A2 0x30
3663 #define CATG_B2 0x0C
3664 #define CATG_C2 0x03
3665 /* Disallow group 1 conditions mixed with group 2 conditions
3666 if group 1, allow only one category A and one category B
3667 if group 2, allow only one each of category A, B, and C. */
3668 if (((insn
->opcode
[0].word
& 0xFF) != 0))
3670 if ((insn
->opcode
[0].word
& CC_GROUP
) != (cc
->value
& CC_GROUP
))
3672 as_bad (_("Condition \"%s\" does not match preceding group"),
3676 if (insn
->opcode
[0].word
& CC_GROUP
)
3678 if ((insn
->opcode
[0].word
& CC_ACC
) != (cc
->value
& CC_ACC
))
3680 as_bad (_("Condition \"%s\" uses a different accumulator from "
3681 "a preceding condition"),
3685 if ((insn
->opcode
[0].word
& CATG_A1
) && (cc
->value
& CATG_A1
))
3687 as_bad (_("Only one comparison conditional allowed"));
3690 if ((insn
->opcode
[0].word
& CATG_B1
) && (cc
->value
& CATG_B1
))
3692 as_bad (_("Only one overflow conditional allowed"));
3696 else if ( ((insn
->opcode
[0].word
& CATG_A2
) && (cc
->value
& CATG_A2
))
3697 || ((insn
->opcode
[0].word
& CATG_B2
) && (cc
->value
& CATG_B2
))
3698 || ((insn
->opcode
[0].word
& CATG_C2
) && (cc
->value
& CATG_C2
)))
3700 as_bad (_("Duplicate %s conditional"), operand
->buf
);
3705 insn
->opcode
[0].word
|= cc
->value
;
3710 encode_cc3 (tic54x_insn
*insn
, struct opstruct
*operand
)
3712 tic54x_symbol
*cc3
= (tic54x_symbol
*) hash_find (cc3_hash
, operand
->buf
);
3713 int value
= cc3
? cc3
->value
: operand
->exp
.X_add_number
<< 8;
3715 if ((value
& 0x0300) != value
)
3717 as_bad (_("Unrecognized condition code \"%s\""), operand
->buf
);
3720 insn
->opcode
[0].word
|= value
;
3725 encode_arx (tic54x_insn
*insn
, struct opstruct
*operand
)
3727 int arf
= strlen (operand
->buf
) >= 3 ? operand
->buf
[2] - '0' : -1;
3729 if (strncasecmp ("ar", operand
->buf
, 2) || arf
< 0 || arf
> 7)
3731 as_bad (_("Invalid auxiliary register (use AR0-AR7)"));
3734 insn
->opcode
[0].word
|= arf
;
3739 encode_cc2 (tic54x_insn
*insn
, struct opstruct
*operand
)
3741 tic54x_symbol
*cc2
= (tic54x_symbol
*) hash_find (cc2_hash
, operand
->buf
);
3745 as_bad (_("Unrecognized condition code \"%s\""), operand
->buf
);
3748 insn
->opcode
[0].word
|= cc2
->value
;
3753 encode_operand (tic54x_insn
*insn
, enum optype type
, struct opstruct
*operand
)
3755 int ext
= (insn
->tm
->flags
& FL_EXT
) != 0;
3757 if (type
== OP_MMR
&& operand
->exp
.X_op
!= O_constant
)
3759 /* Disallow long-constant addressing for memory-mapped addressing. */
3760 if (insn
->is_lkaddr
)
3762 as_bad (_("lk addressing modes are invalid for memory-mapped "
3763 "register addressing"));
3767 /* Warn about *+ARx when used with MMR operands. */
3768 if (strncasecmp (operand
->buf
, "*+ar", 4) == 0)
3770 as_warn (_("Address mode *+ARx is not allowed in memory-mapped "
3771 "register addressing. Resulting behavior is "
3781 /* 16-bit immediate value. */
3782 return encode_dmad (insn
, operand
, 0);
3784 if (TOUPPER (*operand
->buf
) == 'B')
3786 insn
->opcode
[ext
? (1 + insn
->is_lkaddr
) : 0].word
|= (1 << 9);
3787 if (insn
->using_default_dst
)
3788 insn
->opcode
[ext
? (1 + insn
->is_lkaddr
) : 0].word
|= (1 << 8);
3792 /* Make sure this agrees with the OP_DST operand. */
3793 if (!((TOUPPER (operand
->buf
[0]) == 'B') ^
3794 ((insn
->opcode
[0].word
& (1 << 8)) != 0)))
3796 as_bad (_("Destination accumulator for each part of this parallel "
3797 "instruction must be different"));
3803 if (TOUPPER (operand
->buf
[0]) == 'B')
3804 insn
->opcode
[ext
? (1 + insn
->is_lkaddr
) : 0].word
|= (1 << 8);
3809 int mod
= (operand
->buf
[4] == '\0' ? 0 : /* *arx */
3810 operand
->buf
[4] == '-' ? 1 : /* *arx- */
3811 operand
->buf
[5] == '\0' ? 2 : 3); /* *arx+, *arx+0% */
3812 int arf
= operand
->buf
[3] - '0' - 2;
3813 int code
= (mod
<< 2) | arf
;
3814 insn
->opcode
[0].word
|= (code
<< (type
== OP_Xmem
? 4 : 0));
3819 if (!is_indirect (operand
))
3820 return encode_address (insn
, operand
);
3823 return encode_indirect (insn
, operand
);
3825 return encode_dmad (insn
, operand
, 2);
3827 return encode_dmad (insn
, operand
, 1);
3830 return encode_dmad (insn
, operand
, 0);
3832 return encode_arx (insn
, operand
);
3837 int value
= operand
->exp
.X_add_number
;
3840 insn
->opcode
[0].word
|= value
;
3843 if (value
< 16 || value
> 24)
3845 as_bad (_("Memory mapped register \"%s\" out of range"),
3849 if (type
== OP_MMRX
)
3850 insn
->opcode
[0].word
|= (value
- 16) << 4;
3852 insn
->opcode
[0].word
|= (value
- 16);
3860 return encode_integer (insn
, operand
, ext
+ insn
->is_lkaddr
,
3863 return encode_integer (insn
, operand
, ext
+ insn
->is_lkaddr
,
3866 return encode_integer (insn
, operand
, 1 + insn
->is_lkaddr
,
3867 -32768, 32767, 0xFFFF);
3869 return encode_condition (insn
, operand
);
3871 return encode_cc2 (insn
, operand
);
3873 return encode_cc3 (insn
, operand
);
3875 return encode_integer (insn
, operand
, 0, 0, 15, 0xF);
3877 return encode_integer (insn
, operand
, 0, -128, 127, 0xFF);
3880 int value
= operand
->exp
.X_add_number
;
3882 if (value
< 1 || value
> 3)
3884 as_bad (_("Invalid operand (use 1, 2, or 3)"));
3887 code
= value
== 1 ? 0 : value
== 2 ? 0x2 : 0x1;
3888 insn
->opcode
[0].word
|= (code
<< 8);
3892 return encode_integer (insn
, operand
, 0, 0, 31, 0x1F);
3894 return encode_integer (insn
, operand
, 0, 0, 255, 0xFF);
3896 return encode_integer (insn
, operand
, 1 + insn
->is_lkaddr
,
3900 tic54x_symbol
*sbit
= (tic54x_symbol
*)
3901 hash_find (sbit_hash
, operand
->buf
);
3902 int value
= is_absolute (operand
) ?
3903 operand
->exp
.X_add_number
: (sbit
? sbit
->value
: -1);
3906 if (insn
->opcount
== 1)
3910 as_bad (_("A status register or status bit name is required"));
3913 /* Guess the register based on the status bit; "ovb" is the last
3914 status bit defined for st0. */
3915 if (sbit
> (tic54x_symbol
*) hash_find (sbit_hash
, "ovb"))
3920 as_bad (_("Unrecognized status bit \"%s\""), operand
->buf
);
3923 insn
->opcode
[0].word
|= value
;
3924 insn
->opcode
[0].word
|= (reg
<< 9);
3928 if (strcasecmp (operand
->buf
, "st0") == 0
3929 || strcasecmp (operand
->buf
, "st1") == 0)
3931 insn
->opcode
[0].word
|=
3932 ((unsigned short) (operand
->buf
[2] - '0')) << 9;
3935 else if (operand
->exp
.X_op
== O_constant
3936 && (operand
->exp
.X_add_number
== 0
3937 || operand
->exp
.X_add_number
== 1))
3939 insn
->opcode
[0].word
|=
3940 ((unsigned short) (operand
->exp
.X_add_number
)) << 9;
3943 as_bad (_("Invalid status register \"%s\""), operand
->buf
);
3946 return encode_integer (insn
, operand
, 0, -16, 15, 0x1F);
3948 return encode_integer (insn
, operand
, 0, 0, 7, 0x7);
3950 return encode_integer (insn
, operand
, 0, 0, 0x1FF, 0x1FF);
3952 if (operand
->exp
.X_add_number
!= 1
3953 && operand
->exp
.X_add_number
!= 2)
3955 as_bad (_("Operand \"%s\" out of range (use 1 or 2)"), operand
->buf
);
3958 insn
->opcode
[0].word
|= (operand
->exp
.X_add_number
- 1) << 9;
3967 /* No encoding necessary. */
3977 emit_insn (tic54x_insn
*insn
)
3980 flagword oldflags
= bfd_get_section_flags (stdoutput
, now_seg
);
3981 flagword flags
= oldflags
| SEC_CODE
;
3983 if (! bfd_set_section_flags (stdoutput
, now_seg
, flags
))
3984 as_warn (_("error setting flags for \"%s\": %s"),
3985 bfd_section_name (stdoutput
, now_seg
),
3986 bfd_errmsg (bfd_get_error ()));
3988 for (i
= 0; i
< insn
->words
; i
++)
3990 int size
= (insn
->opcode
[i
].unresolved
3991 && insn
->opcode
[i
].r_type
== BFD_RELOC_TIC54X_23
) ? 4 : 2;
3992 char *p
= frag_more (size
);
3995 md_number_to_chars (p
, (valueT
) insn
->opcode
[i
].word
, 2);
3997 md_number_to_chars (p
, (valueT
) insn
->opcode
[i
].word
<< 16, 4);
3999 if (insn
->opcode
[i
].unresolved
)
4000 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
,
4001 insn
->opcode
[i
].r_nchars
, &insn
->opcode
[i
].addr_expr
,
4002 FALSE
, insn
->opcode
[i
].r_type
);
4006 /* Convert the operand strings into appropriate opcode values
4007 return the total number of words used by the instruction. */
4010 build_insn (tic54x_insn
*insn
)
4014 /* Only non-parallel instructions support lk addressing. */
4015 if (!(insn
->tm
->flags
& FL_PAR
))
4017 for (i
= 0; i
< insn
->opcount
; i
++)
4019 if ((OPTYPE (insn
->operands
[i
].type
) == OP_Smem
4020 || OPTYPE (insn
->operands
[i
].type
) == OP_Lmem
4021 || OPTYPE (insn
->operands
[i
].type
) == OP_Sind
)
4022 && strchr (insn
->operands
[i
].buf
, '(')
4023 /* Don't mistake stack-relative addressing for lk addressing. */
4024 && strncasecmp (insn
->operands
[i
].buf
, "*sp (", 4) != 0)
4026 insn
->is_lkaddr
= 1;
4027 insn
->lkoperand
= i
;
4032 insn
->words
= insn
->tm
->words
+ insn
->is_lkaddr
;
4034 insn
->opcode
[0].word
= insn
->tm
->opcode
;
4035 if (insn
->tm
->flags
& FL_EXT
)
4036 insn
->opcode
[1 + insn
->is_lkaddr
].word
= insn
->tm
->opcode2
;
4038 for (i
= 0; i
< insn
->opcount
; i
++)
4040 enum optype type
= insn
->operands
[i
].type
;
4042 if (!encode_operand (insn
, type
, &insn
->operands
[i
]))
4045 if (insn
->tm
->flags
& FL_PAR
)
4046 for (i
= 0; i
< insn
->paropcount
; i
++)
4048 enum optype partype
= insn
->paroperands
[i
].type
;
4050 if (!encode_operand (insn
, partype
, &insn
->paroperands
[i
]))
4060 optimize_insn (tic54x_insn
*insn
)
4062 /* Optimize some instructions, helping out the brain-dead programmer. */
4063 #define is_zero(op) ((op).exp.X_op == O_constant && (op).exp.X_add_number == 0)
4064 if (strcasecmp (insn
->tm
->name
, "add") == 0)
4066 if (insn
->opcount
> 1
4067 && is_accumulator (&insn
->operands
[insn
->opcount
- 2])
4068 && is_accumulator (&insn
->operands
[insn
->opcount
- 1])
4069 && strcasecmp (insn
->operands
[insn
->opcount
- 2].buf
,
4070 insn
->operands
[insn
->opcount
- 1].buf
) == 0)
4073 insn
->using_default_dst
= 1;
4077 /* Try to collapse if Xmem and shift count is zero. */
4078 if ((OPTYPE (insn
->tm
->operand_types
[0]) == OP_Xmem
4079 && OPTYPE (insn
->tm
->operand_types
[1]) == OP_SHFT
4080 && is_zero (insn
->operands
[1]))
4081 /* Or if Smem, shift is zero or absent, and SRC == DST. */
4082 || (OPTYPE (insn
->tm
->operand_types
[0]) == OP_Smem
4083 && OPTYPE (insn
->tm
->operand_types
[1]) == OP_SHIFT
4084 && is_type (&insn
->operands
[1], OP_SHIFT
)
4085 && is_zero (insn
->operands
[1]) && insn
->opcount
== 3))
4087 insn
->operands
[1] = insn
->operands
[2];
4092 else if (strcasecmp (insn
->tm
->name
, "ld") == 0)
4094 if (insn
->opcount
== 3 && insn
->operands
[0].type
!= OP_SRC
)
4096 if ((OPTYPE (insn
->tm
->operand_types
[1]) == OP_SHIFT
4097 || OPTYPE (insn
->tm
->operand_types
[1]) == OP_SHFT
)
4098 && is_zero (insn
->operands
[1])
4099 && (OPTYPE (insn
->tm
->operand_types
[0]) != OP_lk
4100 || (insn
->operands
[0].exp
.X_op
== O_constant
4101 && insn
->operands
[0].exp
.X_add_number
<= 255
4102 && insn
->operands
[0].exp
.X_add_number
>= 0)))
4104 insn
->operands
[1] = insn
->operands
[2];
4110 else if (strcasecmp (insn
->tm
->name
, "sth") == 0
4111 || strcasecmp (insn
->tm
->name
, "stl") == 0)
4113 if ((OPTYPE (insn
->tm
->operand_types
[1]) == OP_SHIFT
4114 || OPTYPE (insn
->tm
->operand_types
[1]) == OP_SHFT
)
4115 && is_zero (insn
->operands
[1]))
4117 insn
->operands
[1] = insn
->operands
[2];
4122 else if (strcasecmp (insn
->tm
->name
, "sub") == 0)
4124 if (insn
->opcount
> 1
4125 && is_accumulator (&insn
->operands
[insn
->opcount
- 2])
4126 && is_accumulator (&insn
->operands
[insn
->opcount
- 1])
4127 && strcasecmp (insn
->operands
[insn
->opcount
- 2].buf
,
4128 insn
->operands
[insn
->opcount
- 1].buf
) == 0)
4131 insn
->using_default_dst
= 1;
4135 if ( ((OPTYPE (insn
->tm
->operand_types
[0]) == OP_Smem
4136 && OPTYPE (insn
->tm
->operand_types
[1]) == OP_SHIFT
)
4137 || (OPTYPE (insn
->tm
->operand_types
[0]) == OP_Xmem
4138 && OPTYPE (insn
->tm
->operand_types
[1]) == OP_SHFT
))
4139 && is_zero (insn
->operands
[1])
4140 && insn
->opcount
== 3)
4142 insn
->operands
[1] = insn
->operands
[2];
4150 /* Find a matching template if possible, and get the operand strings. */
4153 tic54x_parse_insn (tic54x_insn
*insn
, char *line
)
4155 insn
->tm
= (insn_template
*) hash_find (op_hash
, insn
->mnemonic
);
4158 as_bad (_("Unrecognized instruction \"%s\""), insn
->mnemonic
);
4162 insn
->opcount
= get_operands (insn
->operands
, line
);
4163 if (insn
->opcount
< 0)
4166 /* Check each variation of operands for this mnemonic. */
4167 while (insn
->tm
->name
&& strcasecmp (insn
->tm
->name
, insn
->mnemonic
) == 0)
4169 if (insn
->opcount
>= insn
->tm
->minops
4170 && insn
->opcount
<= insn
->tm
->maxops
4171 && operands_match (insn
, &insn
->operands
[0], insn
->opcount
,
4172 insn
->tm
->operand_types
,
4173 insn
->tm
->minops
, insn
->tm
->maxops
))
4175 /* SUCCESS! now try some optimizations. */
4176 if (optimize_insn (insn
))
4178 insn
->tm
= (insn_template
*) hash_find (op_hash
,
4187 as_bad (_("Unrecognized operand list '%s' for instruction '%s'"),
4188 line
, insn
->mnemonic
);
4192 /* We set this in start_line_hook, 'cause if we do a line replacement, we
4193 won't be able to see the next line. */
4194 static int parallel_on_next_line_hint
= 0;
4196 /* See if this is part of a parallel instruction
4197 Look for a subsequent line starting with "||". */
4200 next_line_shows_parallel (char *next_line
)
4202 /* Look for the second half. */
4203 while (*next_line
!= 0 && ISSPACE (*next_line
))
4206 return (next_line
[0] == PARALLEL_SEPARATOR
4207 && next_line
[1] == PARALLEL_SEPARATOR
);
4211 tic54x_parse_parallel_insn_firstline (tic54x_insn
*insn
, char *line
)
4213 insn
->tm
= (insn_template
*) hash_find (parop_hash
, insn
->mnemonic
);
4216 as_bad (_("Unrecognized parallel instruction \"%s\""),
4221 while (insn
->tm
->name
&& strcasecmp (insn
->tm
->name
,
4222 insn
->mnemonic
) == 0)
4224 insn
->opcount
= get_operands (insn
->operands
, line
);
4225 if (insn
->opcount
< 0)
4227 if (insn
->opcount
== 2
4228 && operands_match (insn
, &insn
->operands
[0], insn
->opcount
,
4229 insn
->tm
->operand_types
, 2, 2))
4235 /* Didn't find a matching parallel; try for a normal insn. */
4239 /* Parse the second line of a two-line parallel instruction. */
4242 tic54x_parse_parallel_insn_lastline (tic54x_insn
*insn
, char *line
)
4244 int valid_mnemonic
= 0;
4246 insn
->paropcount
= get_operands (insn
->paroperands
, line
);
4247 while (insn
->tm
->name
&& strcasecmp (insn
->tm
->name
,
4248 insn
->mnemonic
) == 0)
4250 if (strcasecmp (insn
->tm
->parname
, insn
->parmnemonic
) == 0)
4254 if (insn
->paropcount
>= insn
->tm
->minops
4255 && insn
->paropcount
<= insn
->tm
->maxops
4256 && operands_match (insn
, insn
->paroperands
,
4258 insn
->tm
->paroperand_types
,
4259 insn
->tm
->minops
, insn
->tm
->maxops
))
4265 as_bad (_("Invalid operand (s) for parallel instruction \"%s\""),
4268 as_bad (_("Unrecognized parallel instruction combination \"%s || %s\""),
4269 insn
->mnemonic
, insn
->parmnemonic
);
4274 /* If quotes found, return copy of line up to closing quote;
4275 otherwise up until terminator.
4276 If it's a string, pass as-is; otherwise attempt substitution symbol
4277 replacement on the value. */
4280 subsym_get_arg (char *line
, const char *terminators
, char **str
, int nosub
)
4284 int is_string
= *line
== '"';
4285 int is_char
= ISDIGIT (*line
);
4289 while (ISDIGIT (*ptr
))
4292 *str
= xmemdup0 (line
, ptr
- line
);
4296 char *savedp
= input_line_pointer
;
4299 input_line_pointer
= ptr
;
4300 *str
= demand_copy_C_string (&len
);
4301 endp
= input_line_pointer
;
4302 input_line_pointer
= savedp
;
4304 /* Do forced substitutions if requested. */
4305 if (!nosub
&& **str
== ':')
4306 *str
= subsym_substitute (*str
, 1);
4310 const char *term
= terminators
;
4313 while (*ptr
&& *ptr
!= *term
)
4324 *str
= xmemdup0 (line
, ptr
- line
);
4325 /* Do simple substitution, if available. */
4326 if (!nosub
&& (value
= subsym_lookup (*str
, macro_level
)) != NULL
)
4333 /* Replace the given substitution string.
4334 We start at the innermost macro level, so that existing locals remain local
4335 Note: we're treating macro args identically to .var's; I don't know if
4336 that's compatible w/TI's assembler. */
4339 subsym_create_or_replace (char *name
, char *value
)
4343 for (i
= macro_level
; i
> 0; i
--)
4345 if (hash_find (subsym_hash
[i
], name
))
4347 hash_replace (subsym_hash
[i
], name
, value
);
4351 if (hash_find (subsym_hash
[0], name
))
4352 hash_replace (subsym_hash
[0], name
, value
);
4354 hash_insert (subsym_hash
[0], name
, value
);
4357 /* Look up the substitution string replacement for the given symbol.
4358 Start with the innermost macro substitution table given and work
4362 subsym_lookup (char *name
, int nest_level
)
4364 char *value
= hash_find (subsym_hash
[nest_level
], name
);
4366 if (value
|| nest_level
== 0)
4369 return subsym_lookup (name
, nest_level
- 1);
4372 /* Do substitution-symbol replacement on the given line (recursively).
4373 return the argument if no substitution was done
4375 Also look for built-in functions ($func (arg)) and local labels.
4377 If FORCED is set, look for forced substitutions of the form ':SYMBOL:'. */
4380 subsym_substitute (char *line
, int forced
)
4382 /* For each apparent symbol, see if it's a substitution symbol, and if so,
4383 replace it in the input. */
4384 char *replacement
; /* current replacement for LINE. */
4385 char *head
; /* Start of line. */
4386 char *ptr
; /* Current examination point. */
4387 int changed
= 0; /* Did we make a substitution? */
4388 int eval_line
= 0; /* Is this line a .eval/.asg statement? */
4389 int eval_symbol
= 0; /* Are we in the middle of the symbol for
4391 char *eval_end
= NULL
;
4393 int line_conditional
= 0;
4396 /* Work with a copy of the input line. */
4397 replacement
= xstrdup (line
);
4399 ptr
= head
= replacement
;
4401 /* Flag lines where we might need to replace a single '=' with two;
4402 GAS uses single '=' to assign macro args values, and possibly other
4403 places, so limit what we replace. */
4404 if (strstr (line
, ".if")
4405 || strstr (line
, ".elseif")
4406 || strstr (line
, ".break"))
4407 line_conditional
= 1;
4409 /* Watch out for .eval, so that we avoid doing substitution on the
4410 symbol being assigned a value. */
4411 if (strstr (line
, ".eval") || strstr (line
, ".asg"))
4414 /* If it's a macro definition, don't do substitution on the argument
4416 if (strstr (line
, ".macro"))
4419 unsigned char current_char
;
4420 while (!is_end_of_line
[(current_char
= * (unsigned char *) ptr
)])
4422 /* Need to update this since LINE may have been modified. */
4424 eval_end
= strrchr (ptr
, ',');
4426 /* Replace triple double quotes with bounding quote/escapes. */
4427 if (current_char
== '"' && ptr
[1] == '"' && ptr
[2] == '"')
4430 tmp
= strstr (ptr
+ 2, "\"\"\"");
4436 /* Replace a single '=' with a '==';
4437 for compatibility with older code only. */
4438 if (line_conditional
&& current_char
== '=')
4446 tmp
= concat (head
, "==", ptr
, (char *) NULL
);
4447 /* Continue examining after the '=='. */
4448 ptr
= tmp
+ strlen (head
) + 2;
4450 head
= replacement
= tmp
;
4454 /* Flag when we've reached the symbol part of .eval/.asg. */
4455 if (eval_line
&& ptr
>= eval_end
)
4458 /* For each apparent symbol, see if it's a substitution symbol, and if
4459 so, replace it in the input. */
4460 if ((forced
&& current_char
== ':')
4461 || (!forced
&& is_name_beginner (current_char
)))
4463 char *name
; /* Symbol to be replaced. */
4464 char *savedp
= input_line_pointer
;
4467 char *tail
; /* Rest of line after symbol. */
4469 /* Skip the colon. */
4473 input_line_pointer
= ptr
;
4474 c
= get_symbol_name (&name
);
4475 /* '?' is not normally part of a symbol, but it IS part of a local
4479 *input_line_pointer
++ = c
;
4480 c
= *input_line_pointer
;
4481 *input_line_pointer
= '\0';
4483 /* Avoid infinite recursion; if a symbol shows up a second time for
4484 substitution, leave it as is. */
4485 if (hash_find (subsym_recurse_hash
, name
) == NULL
)
4486 value
= subsym_lookup (name
, macro_level
);
4488 as_warn (_("%s symbol recursion stopped at "
4489 "second appearance of '%s'"),
4490 forced
? "Forced substitution" : "Substitution", name
);
4491 ptr
= tail
= input_line_pointer
;
4492 input_line_pointer
= savedp
;
4494 /* Check for local labels; replace them with the appropriate
4496 if ((*name
== '$' && ISDIGIT (name
[1]) && name
[2] == '\0')
4497 || name
[strlen (name
) - 1] == '?')
4499 /* Use an existing identifier for that label if, available, or
4500 create a new, unique identifier. */
4501 value
= hash_find (local_label_hash
[macro_level
], name
);
4505 char *namecopy
= xstrdup (name
);
4507 value
= strcpy (xmalloc (strlen (name
) + sizeof (digit
) + 1),
4510 value
[strlen (value
) - 1] = '\0';
4511 sprintf (digit
, ".%d", local_label_id
++);
4512 strcat (value
, digit
);
4513 hash_insert (local_label_hash
[macro_level
], namecopy
, value
);
4515 /* Indicate where to continue looking for substitutions. */
4518 /* Check for built-in subsym and math functions. */
4519 else if (value
!= NULL
&& *name
== '$')
4521 subsym_proc_entry
*entry
= (subsym_proc_entry
*) value
;
4522 math_proc_entry
*math_entry
= hash_find (math_hash
, name
);
4523 char *arg1
, *arg2
= NULL
;
4528 as_bad (_("Unrecognized substitution symbol function"));
4531 else if (*ptr
!= '(')
4533 as_bad (_("Missing '(' after substitution symbol function"));
4537 if (math_entry
!= NULL
)
4539 float farg1
, farg2
= 0;
4540 volatile float fresult
;
4542 farg1
= (float) strtod (ptr
, &ptr
);
4543 if (math_entry
->nargs
== 2)
4547 as_bad (_("Expecting second argument"));
4550 farg2
= (float) strtod (ptr
, &ptr
);
4552 fresult
= (*math_entry
->proc
) (farg1
, farg2
);
4553 value
= XNEWVEC (char, 128);
4554 if (math_entry
->int_return
)
4555 sprintf (value
, "%d", (int) fresult
);
4557 sprintf (value
, "%f", fresult
);
4560 as_bad (_("Extra junk in function call, expecting ')'"));
4563 /* Don't bother recursing; the replacement isn't a
4570 int arg_type
[2] = { *ptr
== '"' , 0 };
4571 int ismember
= !strcmp (entry
->name
, "$ismember");
4573 /* Parse one or two args, which must be a substitution
4574 symbol, string or a character-string constant. */
4575 /* For all functions, a string or substitution symbol may be
4576 used, with the following exceptions:
4577 firstch/lastch: 2nd arg must be character constant
4578 ismember: both args must be substitution symbols. */
4579 ptr
= subsym_get_arg (ptr
, ",)", &arg1
, ismember
);
4582 if (entry
->nargs
== 2)
4586 as_bad (_("Function expects two arguments"));
4589 /* Character constants are converted to numerics
4590 by the preprocessor. */
4591 arg_type
[1] = (ISDIGIT (*ptr
)) ? 2 : (*ptr
== '"');
4592 ptr
= subsym_get_arg (ptr
, ")", &arg2
, ismember
);
4594 /* Args checking. */
4595 if ((!strcmp (entry
->name
, "$firstch")
4596 || !strcmp (entry
->name
, "$lastch"))
4597 && arg_type
[1] != 2)
4599 as_bad (_("Expecting character constant argument"));
4603 && (arg_type
[0] != 0 || arg_type
[1] != 0))
4605 as_bad (_("Both arguments must be substitution symbols"));
4610 as_bad (_("Extra junk in function call, expecting ')'"));
4613 val
= (*entry
->proc
) (arg1
, arg2
);
4614 value
= XNEWVEC (char, 64);
4615 sprintf (value
, "%d", val
);
4617 /* Fix things up to replace the entire expression, not just the
4623 if (value
!= NULL
&& !eval_symbol
)
4625 /* Replace the symbol with its string replacement and
4626 continue. Recursively replace VALUE until either no
4627 substitutions are performed, or a substitution that has been
4628 previously made is encountered again.
4630 Put the symbol into the recursion hash table so we only
4631 try to replace a symbol once. */
4634 hash_insert (subsym_recurse_hash
, name
, name
);
4635 value
= subsym_substitute (value
, macro_level
> 0);
4636 hash_delete (subsym_recurse_hash
, name
, FALSE
);
4639 /* Temporarily zero-terminate where the symbol started. */
4645 /* Subscripted substitution symbol -- use just the
4646 indicated portion of the string; the description
4647 kinda indicates that forced substitution is not
4648 supposed to be recursive, but I'm not sure. */
4649 unsigned beg
, len
= 1; /* default to a single char */
4650 char *newval
= xstrdup (value
);
4652 savedp
= input_line_pointer
;
4653 input_line_pointer
= tail
+ 1;
4654 beg
= get_absolute_expression ();
4657 as_bad (_("Invalid subscript (use 1 to %d)"),
4658 (int) strlen (value
));
4661 if (*input_line_pointer
== ',')
4663 ++input_line_pointer
;
4664 len
= get_absolute_expression ();
4665 if (beg
+ len
> strlen (value
))
4667 as_bad (_("Invalid length (use 0 to %d)"),
4668 (int) strlen (value
) - beg
);
4674 tail
= input_line_pointer
;
4677 as_bad (_("Missing ')' in subscripted substitution "
4678 "symbol expression"));
4682 input_line_pointer
= savedp
;
4688 tmp
= xmalloc (strlen (head
) + strlen (value
) +
4689 strlen (tail
+ 1) + 2);
4691 strcat (tmp
, value
);
4692 /* Make sure forced substitutions are properly terminated. */
4697 as_bad (_("Missing forced substitution terminator ':'"));
4703 /* Restore the character after the symbol end. */
4706 /* Continue examining after the replacement value. */
4707 ptr
= tmp
+ strlen (head
) + strlen (value
);
4709 head
= replacement
= tmp
;
4727 /* We use this to handle substitution symbols
4728 hijack input_line_pointer, replacing it with our substituted string.
4730 .sslist should enable listing the line after replacements are made...
4732 returns the new buffer limit. */
4735 tic54x_start_line_hook (void)
4738 char *replacement
= NULL
;
4740 /* Work with a copy of the input line, including EOL char. */
4741 for (endp
= input_line_pointer
; *endp
!= 0; )
4742 if (is_end_of_line
[(unsigned char) *endp
++])
4745 line
= xmemdup0 (input_line_pointer
, endp
- input_line_pointer
);
4747 /* Scan ahead for parallel insns. */
4748 parallel_on_next_line_hint
= next_line_shows_parallel (endp
);
4750 /* If within a macro, first process forced replacements. */
4751 if (macro_level
> 0)
4752 replacement
= subsym_substitute (line
, 1);
4755 replacement
= subsym_substitute (replacement
, 0);
4757 if (replacement
!= line
)
4759 char *tmp
= replacement
;
4760 char *comment
= strchr (replacement
, ';');
4761 char endc
= replacement
[strlen (replacement
) - 1];
4763 /* Clean up the replacement; we'd prefer to have this done by the
4764 standard preprocessing equipment (maybe do_scrub_chars?)
4765 but for now, do a quick-and-dirty. */
4766 if (comment
!= NULL
)
4773 comment
= replacement
+ strlen (replacement
) - 1;
4775 /* Trim trailing whitespace. */
4776 while (ISSPACE (*comment
))
4783 /* Compact leading whitespace. */
4784 while (ISSPACE (tmp
[0]) && ISSPACE (tmp
[1]))
4787 input_line_pointer
= endp
;
4788 input_scrub_insert_line (tmp
);
4791 /* Keep track of whether we've done a substitution. */
4792 substitution_line
= 1;
4798 substitution_line
= 0;
4802 /* This is the guts of the machine-dependent assembler. STR points to a
4803 machine dependent instruction. This function is supposed to emit
4804 the frags/bytes it assembles to. */
4806 md_assemble (char *line
)
4808 static int repeat_slot
= 0;
4809 static int delay_slots
= 0; /* How many delay slots left to fill? */
4810 static int is_parallel
= 0;
4811 static tic54x_insn insn
;
4813 char *savedp
= input_line_pointer
;
4816 input_line_pointer
= line
;
4817 c
= get_symbol_name (&line
);
4821 if (address_mode_needs_set
)
4823 set_address_mode (amode
);
4824 address_mode_needs_set
= 0;
4837 strcpy (insn
.parmnemonic
, line
);
4838 lptr
= input_line_pointer
;
4840 input_line_pointer
= savedp
;
4842 if (tic54x_parse_parallel_insn_lastline (&insn
, lptr
))
4844 int words
= build_insn (&insn
);
4846 if (delay_slots
!= 0)
4848 if (words
> delay_slots
)
4850 as_bad (ngettext ("Instruction does not fit in available "
4851 "delay slots (%d-word insn, %d slot left)",
4852 "Instruction does not fit in available "
4853 "delay slots (%d-word insn, %d slots left)",
4855 words
, delay_slots
);
4859 delay_slots
-= words
;
4865 memset (&insn
, 0, sizeof (insn
));
4866 strcpy (insn
.mnemonic
, line
);
4867 lptr
= input_line_pointer
;
4869 input_line_pointer
= savedp
;
4871 /* See if this line is part of a parallel instruction; if so, either this
4872 line or the next line will have the "||" specifier preceding the
4873 mnemonic, and we look for it in the parallel insn hash table. */
4874 if (strstr (line
, "||") != NULL
|| parallel_on_next_line_hint
)
4876 char *tmp
= strstr (line
, "||");
4880 if (tic54x_parse_parallel_insn_firstline (&insn
, lptr
))
4883 /* If the parallel part is on the same line, process it now,
4884 otherwise let the assembler pick up the next line for us. */
4887 while (ISSPACE (tmp
[2]))
4889 md_assemble (tmp
+ 2);
4894 as_bad (_("Unrecognized parallel instruction '%s'"), line
);
4899 if (tic54x_parse_insn (&insn
, lptr
))
4903 if ((insn
.tm
->flags
& FL_LP
)
4904 && cpu
!= V545LP
&& cpu
!= V546LP
)
4906 as_bad (_("Instruction '%s' requires an LP cpu version"),
4910 if ((insn
.tm
->flags
& FL_FAR
)
4911 && amode
!= far_mode
)
4913 as_bad (_("Instruction '%s' requires far mode addressing"),
4918 words
= build_insn (&insn
);
4920 /* Is this instruction in a delay slot? */
4923 if (words
> delay_slots
)
4925 as_warn (ngettext ("Instruction does not fit in available "
4926 "delay slots (%d-word insn, %d slot left). "
4927 "Resulting behavior is undefined.",
4928 "Instruction does not fit in available "
4929 "delay slots (%d-word insn, %d slots left). "
4930 "Resulting behavior is undefined.",
4932 words
, delay_slots
);
4936 /* Branches in delay slots are not allowed. */
4937 if (insn
.tm
->flags
& FL_BMASK
)
4939 as_warn (_("Instructions which cause PC discontinuity are not "
4940 "allowed in a delay slot. "
4941 "Resulting behavior is undefined."));
4943 delay_slots
-= words
;
4946 /* Is this instruction the target of a repeat? */
4949 if (insn
.tm
->flags
& FL_NR
)
4950 as_warn (_("'%s' is not repeatable. "
4951 "Resulting behavior is undefined."),
4953 else if (insn
.is_lkaddr
)
4954 as_warn (_("Instructions using long offset modifiers or absolute "
4955 "addresses are not repeatable. "
4956 "Resulting behavior is undefined."));
4960 /* Make sure we check the target of a repeat instruction. */
4961 if (insn
.tm
->flags
& B_REPEAT
)
4964 /* FIXME -- warn if repeat_slot == 1 at EOF. */
4966 /* Make sure we check our delay slots for validity. */
4967 if (insn
.tm
->flags
& FL_DELAY
)
4970 /* FIXME -- warn if delay_slots != 0 at EOF. */
4975 /* Do a final adjustment on the symbol table; in this case, make sure we have
4976 a ".file" symbol. */
4979 tic54x_adjust_symtab (void)
4981 if (symbol_rootP
== NULL
4982 || S_GET_STORAGE_CLASS (symbol_rootP
) != C_FILE
)
4985 const char * filename
= as_where (&lineno
);
4986 c_dot_file_symbol (filename
, 0);
4990 /* In order to get gas to ignore any | chars at the start of a line,
4991 this function returns true if a | is found in a line.
4992 This lets us process parallel instructions, which span two lines. */
4995 tic54x_unrecognized_line (int c
)
4997 return c
== PARALLEL_SEPARATOR
;
5000 /* Watch for local labels of the form $[0-9] and [_a-zA-Z][_a-zA-Z0-9]*?
5001 Encode their names so that only we see them and can map them to the
5003 FIXME -- obviously this isn't done yet. These locals still show up in the
5006 tic54x_define_label (symbolS
*sym
)
5008 /* Just in case we need this later; note that this is not necessarily the
5009 same thing as line_label...
5010 When aligning or assigning labels to fields, sometimes the label is
5011 assigned other than the address at which the label appears.
5012 FIXME -- is this really needed? I think all the proper label assignment
5013 is done in tic54x_cons. */
5014 last_label_seen
= sym
;
5017 /* Try to parse something that normal parsing failed at. */
5020 tic54x_undefined_symbol (char *name
)
5024 /* Not sure how to handle predefined symbols. */
5025 if ((sym
= (tic54x_symbol
*) hash_find (cc_hash
, name
)) != NULL
||
5026 (sym
= (tic54x_symbol
*) hash_find (cc2_hash
, name
)) != NULL
||
5027 (sym
= (tic54x_symbol
*) hash_find (cc3_hash
, name
)) != NULL
||
5028 (sym
= (tic54x_symbol
*) hash_find (misc_symbol_hash
, name
)) != NULL
||
5029 (sym
= (tic54x_symbol
*) hash_find (sbit_hash
, name
)) != NULL
)
5031 return symbol_new (name
, reg_section
,
5032 (valueT
) sym
->value
,
5033 &zero_address_frag
);
5036 if ((sym
= (tic54x_symbol
*) hash_find (reg_hash
, name
)) != NULL
||
5037 (sym
= (tic54x_symbol
*) hash_find (mmreg_hash
, name
)) != NULL
||
5038 !strcasecmp (name
, "a") || !strcasecmp (name
, "b"))
5040 return symbol_new (name
, reg_section
,
5041 (valueT
) sym
? sym
->value
: 0,
5042 &zero_address_frag
);
5048 /* Parse a name in an expression before the expression parser takes a stab at
5052 tic54x_parse_name (char *name ATTRIBUTE_UNUSED
,
5053 expressionS
*expn ATTRIBUTE_UNUSED
)
5059 md_atof (int type
, char *literalP
, int *sizeP
)
5061 /* Target data is little-endian, but floats are stored
5062 big-"word"ian. ugh. */
5063 return ieee_md_atof (type
, literalP
, sizeP
, TRUE
);
5067 tc_gen_reloc (asection
*section
, fixS
*fixP
)
5070 bfd_reloc_code_real_type code
= fixP
->fx_r_type
;
5071 asymbol
*sym
= symbol_get_bfdsym (fixP
->fx_addsy
);
5073 rel
= XNEW (arelent
);
5074 rel
->sym_ptr_ptr
= XNEW (asymbol
*);
5075 *rel
->sym_ptr_ptr
= sym
;
5076 /* We assume that all rel->address are host byte offsets. */
5077 rel
->address
= fixP
->fx_frag
->fr_address
+ fixP
->fx_where
;
5078 rel
->address
/= OCTETS_PER_BYTE
;
5079 rel
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
5080 if (!strcmp (sym
->name
, section
->name
))
5081 rel
->howto
+= HOWTO_BANK
;
5085 const char *name
= S_GET_NAME (fixP
->fx_addsy
);
5088 as_fatal ("Cannot generate relocation type for symbol %s, code %s",
5089 name
, bfd_get_reloc_code_name (code
));
5095 /* Handle cons expressions. */
5098 tic54x_cons_fix_new (fragS
*frag
, int where
, int octets
, expressionS
*expn
,
5099 bfd_reloc_code_real_type r
)
5104 as_bad (_("Unsupported relocation size %d"), octets
);
5105 r
= BFD_RELOC_TIC54X_16_OF_23
;
5108 r
= BFD_RELOC_TIC54X_16_OF_23
;
5111 /* TI assembler always uses this, regardless of addressing mode. */
5113 r
= BFD_RELOC_TIC54X_23
;
5115 /* We never want to directly generate this; this is provided for
5116 stabs support only. */
5120 fix_new_exp (frag
, where
, octets
, expn
, 0, r
);
5123 /* Attempt to simplify or even eliminate a fixup.
5124 To indicate that a fixup has been eliminated, set fixP->fx_done.
5126 If fixp->fx_addsy is non-NULL, we'll have to generate a reloc entry. */
5129 md_apply_fix (fixS
*fixP
, valueT
*valP
, segT seg ATTRIBUTE_UNUSED
)
5131 char *buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
5132 valueT val
= * valP
;
5134 switch (fixP
->fx_r_type
)
5137 as_fatal ("Bad relocation type: 0x%02x", fixP
->fx_r_type
);
5139 case BFD_RELOC_TIC54X_MS7_OF_23
:
5140 val
= (val
>> 16) & 0x7F;
5142 case BFD_RELOC_TIC54X_16_OF_23
:
5144 bfd_put_16 (stdoutput
, val
, buf
);
5145 /* Indicate what we're actually writing, so that we don't get warnings
5146 about exceeding available space. */
5147 *valP
= val
& 0xFFFF;
5149 case BFD_RELOC_TIC54X_PARTLS7
:
5150 bfd_put_16 (stdoutput
,
5151 (bfd_get_16 (stdoutput
, buf
) & 0xFF80) | (val
& 0x7F),
5153 /* Indicate what we're actually writing, so that we don't get warnings
5154 about exceeding available space. */
5157 case BFD_RELOC_TIC54X_PARTMS9
:
5158 /* TI assembler doesn't shift its encoding for relocatable files, and is
5159 thus incompatible with this implementation's relocatable files. */
5160 bfd_put_16 (stdoutput
,
5161 (bfd_get_16 (stdoutput
, buf
) & 0xFE00) | (val
>> 7),
5165 case BFD_RELOC_TIC54X_23
:
5166 bfd_put_32 (stdoutput
,
5167 (bfd_get_32 (stdoutput
, buf
) & 0xFF800000) | val
,
5172 if (fixP
->fx_addsy
== NULL
&& fixP
->fx_pcrel
== 0)
5176 /* This is our chance to record section alignment
5177 don't need to do anything here, since BFD does the proper encoding. */
5180 md_section_align (segT segment ATTRIBUTE_UNUSED
, valueT section_size
)
5182 return section_size
;
5186 md_pcrel_from (fixS
*fixP ATTRIBUTE_UNUSED
)
5191 /* Mostly little-endian, but longwords (4 octets) get MS word stored
5195 tic54x_number_to_chars (char *buf
, valueT val
, int n
)
5198 number_to_chars_littleendian (buf
, val
, n
);
5201 number_to_chars_littleendian (buf
, val
>> 16 , 2);
5202 number_to_chars_littleendian (buf
+ 2, val
& 0xFFFF, 2);
5207 tic54x_estimate_size_before_relax (fragS
*frag ATTRIBUTE_UNUSED
,
5208 segT seg ATTRIBUTE_UNUSED
)
5213 /* We use this to handle bit allocations which we couldn't handle before due
5214 to symbols being in different frags. return number of octets added. */
5217 tic54x_relax_frag (fragS
*frag
, long stretch ATTRIBUTE_UNUSED
)
5219 symbolS
*sym
= frag
->fr_symbol
;
5225 struct bit_info
*bi
= (struct bit_info
*) frag
->fr_opcode
;
5226 int bit_offset
= frag_bit_offset (frag_prev (frag
, bi
->seg
), bi
->seg
);
5227 int size
= S_GET_VALUE (sym
);
5228 fragS
*prev_frag
= bit_offset_frag (frag_prev (frag
, bi
->seg
), bi
->seg
);
5229 int available
= 16 - bit_offset
;
5231 if (symbol_get_frag (sym
) != &zero_address_frag
5232 || S_IS_COMMON (sym
)
5233 || !S_IS_DEFINED (sym
))
5234 as_bad_where (frag
->fr_file
, frag
->fr_line
,
5235 _("non-absolute value used with .space/.bes"));
5239 as_warn (_("negative value ignored in %s"),
5240 bi
->type
== TYPE_SPACE
? ".space" :
5241 bi
->type
== TYPE_BES
? ".bes" : ".field");
5243 frag
->tc_frag_data
= frag
->fr_fix
= 0;
5247 if (bi
->type
== TYPE_FIELD
)
5249 /* Bit fields of 16 or larger will have already been handled. */
5250 if (bit_offset
!= 0 && available
>= size
)
5252 char *p
= prev_frag
->fr_literal
;
5254 valueT value
= bi
->value
;
5255 value
<<= available
- size
;
5256 value
|= ((unsigned short) p
[1] << 8) | p
[0];
5257 md_number_to_chars (p
, value
, 2);
5258 if ((prev_frag
->tc_frag_data
+= size
) == 16)
5259 prev_frag
->tc_frag_data
= 0;
5261 symbol_set_frag (bi
->sym
, prev_frag
);
5262 /* This frag is no longer used. */
5263 growth
= -frag
->fr_fix
;
5265 frag
->tc_frag_data
= 0;
5269 char *p
= frag
->fr_literal
;
5271 valueT value
= bi
->value
<< (16 - size
);
5272 md_number_to_chars (p
, value
, 2);
5273 if ((frag
->tc_frag_data
= size
) == 16)
5274 frag
->tc_frag_data
= 0;
5280 if (bit_offset
!= 0 && bit_offset
< 16)
5282 if (available
>= size
)
5284 if ((prev_frag
->tc_frag_data
+= size
) == 16)
5285 prev_frag
->tc_frag_data
= 0;
5287 symbol_set_frag (bi
->sym
, prev_frag
);
5288 /* This frag is no longer used. */
5289 growth
= -frag
->fr_fix
;
5291 frag
->tc_frag_data
= 0;
5294 if (bi
->type
== TYPE_SPACE
&& bi
->sym
)
5295 symbol_set_frag (bi
->sym
, prev_frag
);
5298 growth
= (size
+ 15) / 16 * OCTETS_PER_BYTE
- frag
->fr_fix
;
5299 for (i
= 0; i
< growth
; i
++)
5300 frag
->fr_literal
[i
] = 0;
5301 frag
->fr_fix
= growth
;
5302 frag
->tc_frag_data
= size
% 16;
5303 /* Make sure any BES label points to the LAST word allocated. */
5304 if (bi
->type
== TYPE_BES
&& bi
->sym
)
5305 S_SET_VALUE (bi
->sym
, frag
->fr_fix
/ OCTETS_PER_BYTE
- 1);
5308 frag
->fr_symbol
= 0;
5309 frag
->fr_opcode
= 0;
5316 tic54x_convert_frag (bfd
*abfd ATTRIBUTE_UNUSED
,
5317 segT seg ATTRIBUTE_UNUSED
,
5320 /* Offset is in bytes. */
5321 frag
->fr_offset
= (frag
->fr_next
->fr_address
5323 - frag
->fr_fix
) / frag
->fr_var
;
5324 if (frag
->fr_offset
< 0)
5326 as_bad_where (frag
->fr_file
, frag
->fr_line
,
5327 _("attempt to .space/.bes backwards? (%ld)"),
5328 (long) frag
->fr_offset
);
5330 frag
->fr_type
= rs_space
;
5333 /* We need to avoid having labels defined for certain directives/pseudo-ops
5334 since once the label is defined, it's in the symbol table for good. TI
5335 syntax puts the symbol *before* the pseudo (which is kinda like MRI syntax,
5336 I guess, except I've never seen a definition of MRI syntax).
5338 Don't allow labels to start with '.' */
5341 tic54x_start_label (char * label_start
, int nul_char
, int next_char
)
5345 /* If within .struct/.union, no auto line labels, please. */
5346 if (current_stag
!= NULL
)
5349 /* Disallow labels starting with "." */
5350 if (next_char
!= ':')
5352 if (*label_start
== '.')
5354 as_bad (_("Invalid label '%s'"), label_start
);
5359 if (is_end_of_line
[(unsigned char) next_char
])
5362 rest
= input_line_pointer
;
5363 if (nul_char
== '"')
5365 while (ISSPACE (next_char
))
5366 next_char
= *++rest
;
5367 if (next_char
!= '.')
5370 /* Don't let colon () define a label for any of these... */
5371 return ((strncasecmp (rest
, ".tag", 4) != 0 || !ISSPACE (rest
[4]))
5372 && (strncasecmp (rest
, ".struct", 7) != 0 || !ISSPACE (rest
[7]))
5373 && (strncasecmp (rest
, ".union", 6) != 0 || !ISSPACE (rest
[6]))
5374 && (strncasecmp (rest
, ".macro", 6) != 0 || !ISSPACE (rest
[6]))
5375 && (strncasecmp (rest
, ".set", 4) != 0 || !ISSPACE (rest
[4]))
5376 && (strncasecmp (rest
, ".equ", 4) != 0 || !ISSPACE (rest
[4])));