/* Only word (et al.), align, or conditionals are allowed within
.struct/.union. */
-#define ILLEGAL_WITHIN_STRUCT() \
-do if (current_stag != NULL){ \
-as_bad (_("pseudo-op illegal within .struct/.union"));return; } while (0)
+#define ILLEGAL_WITHIN_STRUCT() \
+ do \
+ if (current_stag != NULL) \
+ { \
+ as_bad (_("pseudo-op illegal within .struct/.union")); \
+ return; \
+ } \
+ while (0)
void
md_show_usage (stream)
};
#define OPTION_ADDRESS_MODE (OPTION_MD_BASE)
-#define OPTION_CPU_VERSION (OPTION_ADDRESS_MODE+1)
-#define OPTION_COFF_VERSION (OPTION_CPU_VERSION+1)
-#define OPTION_STDERR_TO_FILE (OPTION_COFF_VERSION+1)
+#define OPTION_CPU_VERSION (OPTION_ADDRESS_MODE + 1)
+#define OPTION_COFF_VERSION (OPTION_CPU_VERSION + 1)
+#define OPTION_STDERR_TO_FILE (OPTION_COFF_VERSION + 1)
-struct option md_longopts[] =
+struct option md_longopts[] =
{
{ "mfar-mode", no_argument, NULL, OPTION_ADDRESS_MODE },
{ "mf", no_argument, NULL, OPTION_ADDRESS_MODE },
{ "mcpu", required_argument, NULL, OPTION_CPU_VERSION },
- /* { "mcoff-version", required_argument, NULL, OPTION_COFF_VERSION },*/
+#if 0
+ { "mcoff-version", required_argument, NULL, OPTION_COFF_VERSION },
+#endif
{ "merrors-to-file", required_argument, NULL, OPTION_STDERR_TO_FILE },
{ "me", required_argument, NULL, OPTION_STDERR_TO_FILE },
{ NULL, no_argument, NULL, 0},
/* Allow maximum levels of macro nesting; level 0 is the main substitution
symbol table. The other assembler only does 32 levels, so there! */
static struct hash_control *subsym_hash[100];
-/* Keep track of local labels so we can substitute them before GAS sees them
+/* Keep track of local labels so we can substitute them before GAS sees them
since macros use their own 'namespace' for local labels, use a separate hash
We do our own local label handling 'cuz it's subtly different from the
for (fragp = seginfo->frchainP->frch_root; fragp; fragp = fragp->fr_next)
if (fragp->fr_next == frag)
return fragp;
-
+
return NULL;
}
segT seg;
{
frag = bit_offset_frag (frag, seg);
-
+
if (frag)
return frag->fr_opcode != NULL ? -1 : frag->tc_frag_data;
return s; /* Return pointer to where parsing stopped. */
}
-/* .asg "character-string"|character-string, symbol
-
+/* .asg "character-string"|character-string, symbol
+
.eval is the only pseudo-op allowed to perform arithmetic on substitution
symbols. all other use of symbols defined with .asg are currently
unsupported. */
demand_empty_rest_of_line ();
}
-/* .eval expression, symbol
+/* .eval expression, symbol
There's something screwy about this. The other assembler sometimes does and
- sometimes doesn't substitute symbols defined with .eval.
+ sometimes doesn't substitute symbols defined with .eval.
We'll put the symbols into the subsym table as well as the normal symbol
table, since that's what works best. */
static void
demand_empty_rest_of_line ();
}
-/* .bss symbol, size [, [blocking flag] [, alignment flag]
+/* .bss symbol, size [, [blocking flag] [, alignment flag]
alignment is to a longword boundary; blocking is to 128-word boundary.
otherwise, check to see if the current SPC plus the space to be
allocated crosses the page boundary (128 words).
if there's not enough space, create a hole and align with the next page
- boundary.
+ boundary.
(not yet implemented). */
static void
tic54x_bss (x)
}
if (block)
- bss_section->flags |= SEC_BLOCK;
+ bss_section->flags |= SEC_BLOCK;
subseg_set (current_seg, current_subseg); /* restore current seg. */
demand_empty_rest_of_line ();
{
char prefix[strlen (path) + 2];
struct stag_field *field = stag->field;
-
- /* Construct a symbol for every field contained within this structure
+
+ /* Construct a symbol for every field contained within this structure
including fields within structure fields. */
strcpy (prefix, path);
if (*path)
if (rootsym == NULL)
{
symbolS *sym;
- sym = symbol_new (name, absolute_section,
+ sym = symbol_new (name, absolute_section,
(field->stag ? field->offset :
- (valueT)(base_offset + field->offset)),
+ (valueT) (base_offset + field->offset)),
&zero_address_frag);
SF_SET_LOCAL (sym);
symbol_table_insert (sym);
}
else
{
- char *replacement = xmalloc (strlen (name) + strlen (stag->name) + 2);
+ char *replacement = xmalloc (strlen (name)
+ + strlen (stag->name) + 2);
strcpy (replacement, S_GET_NAME (rootsym));
strcat (replacement, "+");
strcat (replacement, root_stag_name);
/* Recurse if the field is a structure.
Note the field offset is relative to the outermost struct. */
if (field->stag != NULL)
- stag_add_field_symbols (field->stag, name,
- field->offset,
+ stag_add_field_symbols (field->stag, name,
+ field->offset,
rootsym, root_stag_name);
field = field->next;
}
struct stag_field *sfield = xmalloc (sizeof (struct stag_field));
memset (sfield, 0, sizeof (*sfield));
- sfield->name = strcpy (xmalloc (strlen (name)+1), name);
+ sfield->name = strcpy (xmalloc (strlen (name) + 1), name);
sfield->offset = offset;
sfield->bitfield_offset = parent->current_bitfield_offset;
sfield->stag = stag;
if (parent->field == NULL)
parent->field = sfield;
- else {
- struct stag_field *sf = parent->field;
- while (sf->next != NULL)
- sf = sf->next;
- sf->next = sfield;
- }
+ else
+ {
+ struct stag_field *sf = parent->field;
+ while (sf->next != NULL)
+ sf = sf->next;
+ sf->next = sfield;
+ }
/* Only create a symbol for this field if the parent has no name. */
if (!strncmp (".fake", parent->name, 5))
{
- symbolS *sym = symbol_new (name, absolute_section,
- (valueT)offset, &zero_address_frag);
+ symbolS *sym = symbol_new (name, absolute_section,
+ (valueT) offset, &zero_address_frag);
SF_SET_LOCAL (sym);
symbol_table_insert (sym);
}
{
/* Offset is ignored in inner structs. */
SKIP_WHITESPACE ();
- if (!is_end_of_line[(int)*input_line_pointer])
+ if (!is_end_of_line[(int) *input_line_pointer])
start_offset = get_absolute_expression ();
else
start_offset = 0;
if (current_stag)
{
/* Nesting, link to outer one. */
- current_stag->inner = (struct stag *)xmalloc (sizeof (struct stag));
+ current_stag->inner = (struct stag *) xmalloc (sizeof (struct stag));
memset (current_stag->inner, 0, sizeof (struct stag));
current_stag->inner->outer = current_stag;
current_stag = current_stag->inner;
as_warn (_("Offset on nested structures is ignored"));
start_offset = abs_section_offset;
}
- else
+ else
{
- current_stag = (struct stag *)xmalloc (sizeof (struct stag));
+ current_stag = (struct stag *) xmalloc (sizeof (struct stag));
memset (current_stag, 0, sizeof (struct stag));
abs_section_offset = start_offset;
}
char fake[] = ".fake_stagNNNNNNN";
sprintf (fake, ".fake_stag%d", struct_count++);
current_stag->sym = symbol_new (fake, absolute_section,
- (valueT)abs_section_offset,
+ (valueT) abs_section_offset,
&zero_address_frag);
}
else
char label[strlen (S_GET_NAME (line_label)) + 1];
strcpy (label, S_GET_NAME (line_label));
current_stag->sym = symbol_new (label, absolute_section,
- (valueT)abs_section_offset,
+ (valueT) abs_section_offset,
&zero_address_frag);
}
current_stag->name = S_GET_NAME (current_stag->sym);
line_label = NULL;
}
-/* [LABEL] .endstruct
+/* [LABEL] .endstruct
finish defining structure offsets; optional LABEL's value will be the size
of the structure. */
static void
tic54x_endstruct (int is_union)
{
int size;
- const char *path =
+ const char *path =
!strncmp (current_stag->name, ".fake", 5) ? "" : current_stag->name;
-
+
if (!current_stag || current_stag->is_union != is_union)
{
- as_bad (_(".end%s without preceding .%s"),
+ as_bad (_(".end%s without preceding .%s"),
is_union ? "union" : "struct",
is_union ? "union" : "struct");
ignore_rest_of_line ();
if (current_stag->outer == NULL)
{
hash_insert (stag_hash, current_stag->name, current_stag);
- stag_add_field_symbols (current_stag, path,
+ stag_add_field_symbols (current_stag, path,
S_GET_VALUE (current_stag->sym),
NULL, NULL);
}
if (current_stag != NULL)
{
stag_add_field (current_stag, current_stag->inner->name,
- S_GET_VALUE (current_stag->inner->sym),
+ S_GET_VALUE (current_stag->inner->sym),
current_stag->inner);
}
else
/* [LABEL] .tag STAG
Reference a structure within a structure, as a sized field with an optional
- label.
+ label.
If used outside of a .struct/.endstruct, overlays the given structure
format on the existing allocated space. */
static void
tic54x_tag (ignore)
- int ignore ATTRIBUTE_UNUSED;
+ int ignore ATTRIBUTE_UNUSED;
{
char *name = input_line_pointer;
int c = get_symbol_end ();
- struct stag *stag = (struct stag *)hash_find (stag_hash, name);
+ struct stag *stag = (struct stag *) hash_find (stag_hash, name);
if (!stag)
{
}
else
{
- char label[strlen (S_GET_NAME (line_label))+1];
- strcpy (label, S_GET_NAME (line_label));
+ char label[strlen (S_GET_NAME (line_label)) + 1];
+
+ strcpy (label, S_GET_NAME (line_label));
if (current_stag != NULL)
- stag_add_field (current_stag, label,
- abs_section_offset - S_GET_VALUE (current_stag->sym),
+ stag_add_field (current_stag, label,
+ abs_section_offset - S_GET_VALUE (current_stag->sym),
stag);
else
{
ignore_rest_of_line ();
return;
}
- stag_add_field_symbols (stag, S_GET_NAME (sym),
+ stag_add_field_symbols (stag, S_GET_NAME (sym),
S_GET_VALUE (stag->sym), sym, stag->name);
}
}
-
+
/* Bump by the struct size, but only if we're within a .struct section. */
if (current_stag != NULL && !current_stag->is_union)
abs_section_offset += stag->size;
int longword_align = 0;
SKIP_WHITESPACE ();
- if (!is_end_of_line[(int)*input_line_pointer])
+ if (!is_end_of_line[(int) *input_line_pointer])
count = get_absolute_expression ();
switch (type)
/* Set the appropriate size and new field offset. */
if (count == 32)
{
- size = 2; count = 1;
+ size = 2;
+ count = 1;
}
else if (count > 16)
{
- size = 1; count = 1;
+ size = 1;
+ count = 1;
new_bitfield_offset = count - 16;
}
else
static int fieldno = 0;
char fake[] = ".fake_fieldNNNNN";
sprintf (fake, ".fake_field%d", fieldno++);
- stag_add_field (current_stag, fake,
- abs_section_offset - S_GET_VALUE (current_stag->sym),
+ stag_add_field (current_stag, fake,
+ abs_section_offset - S_GET_VALUE (current_stag->sym),
NULL);
}
else
{
char label[strlen (S_GET_NAME (line_label) + 1)];
strcpy (label, S_GET_NAME (line_label));
- stag_add_field (current_stag, label,
- abs_section_offset - S_GET_VALUE (current_stag->sym),
+ stag_add_field (current_stag, label,
+ abs_section_offset - S_GET_VALUE (current_stag->sym),
NULL);
}
if (current_stag->is_union)
{
/* Note we treat the element as if it were an array of COUNT. */
- if (current_stag->size < (unsigned)size * count)
+ if (current_stag->size < (unsigned) size * count)
current_stag->size = size * count;
}
else
{
- abs_section_offset += (unsigned)size * count;
+ abs_section_offset += (unsigned) size * count;
current_stag->current_bitfield_offset = new_bitfield_offset;
}
line_label = NULL;
/* Handle .byte, .word. .int, .long and all variants. */
int emitting_long = 0;
-static void
+static void
tic54x_cons (int type)
{
register unsigned int c;
if (exp.X_op != O_constant && octets < 2)
{
/* Disallow .byte with a non constant expression that will
- require relocation. */
+ require relocation. */
as_bad (_("Relocatable values require at least WORD storage"));
ignore_rest_of_line ();
return;
}
- if (exp.X_op != O_constant
+ if (exp.X_op != O_constant
&& amode == c_mode
&& octets == 4)
{
/* FIXME -- at one point TI tools used to output REL16
- relocations, but I don't think the latest tools do at all
+ relocations, but I don't think the latest tools do at all
The current tools output extended relocations regardless of
the addresing mode (I actually think that ".c_mode" is
totally ignored in the latest tools). */
.def <symbol>[,...,<symbolN>]
.ref <symbol>[,...,<symbolN>]
- These all identify global symbols.
+ These all identify global symbols.
.def means the symbol is defined in the current module and can be accessed
by other files. The symbol should be placed in the symbol table.
.global should act as a .ref or .def, as needed.
- global, def and ref all have symbol storage classes of C_EXT.
+ global, def and ref all have symbol storage classes of C_EXT.
I can't identify any difference in how the "other" c54x assembler treats
these, so we ignore the type here. */
if (c == ',')
{
input_line_pointer++;
- if (is_end_of_line[(int)*input_line_pointer])
+ if (is_end_of_line[(int) *input_line_pointer])
c = *input_line_pointer;
}
}
/* Remove the symbol from the local label hash lookup. */
static void
tic54x_remove_local_label (key, value)
- const char *key;
- PTR value ATTRIBUTE_UNUSED;
+ const char *key;
+ PTR value ATTRIBUTE_UNUSED;
{
PTR *elem = hash_delete (local_label_hash[macro_level], key);
free (elem);
}
/* Reset all local labels. */
-static void
+static void
tic54x_clear_local_labels (ignored)
- int ignored ATTRIBUTE_UNUSED;
+ int ignored ATTRIBUTE_UNUSED;
{
hash_traverse (local_label_hash[macro_level], tic54x_remove_local_label);
}
.sect "section name"
Initialized section
- make sure local labels get cleared when changing sections
+ make sure local labels get cleared when changing sections
ARG is 't' for text, 'd' for data, or '*' for a named section
{
name = demand_copy_C_string (&len);
demand_empty_rest_of_line ();
- name = strcpy (xmalloc (len+10), name);
+ name = strcpy (xmalloc (len + 10), name);
}
- else
+ else
{
int c;
name = input_line_pointer;
c = get_symbol_end ();
- name = strcpy (xmalloc (len+10), name);
+ name = strcpy (xmalloc (len + 10), name);
*input_line_pointer = c;
demand_empty_rest_of_line ();
}
}
}
-/* [symbol] .space space_in_bits
+/* [symbol] .space space_in_bits
[symbol] .bes space_in_bits
- BES puts the symbol at the *last* word allocated
+ BES puts the symbol at the *last* word allocated
cribbed from s_space. */
static void
bi->seg = now_seg;
bi->type = bes;
bi->sym = label;
- p = frag_var (rs_machine_dependent,
+ p = frag_var (rs_machine_dependent,
65536*2, 1, (relax_substateT) 0,
- make_expr_symbol (&exp), (offsetT) 0,
+ make_expr_symbol (&exp), (offsetT) 0,
(char *) bi);
if (p)
*p = 0;
if (spare_bits >= exp.X_add_number)
{
/* Don't have to do anything; sufficient bits have already been
- allocated; just point the label to the right place. */
+ allocated; just point the label to the right place. */
if (label != NULL)
{
symbol_set_frag (label, frag_now);
as_warn (_(".space/.bes repeat count is zero, ignored"));
goto getout;
}
-
+
/* If we are in the absolute section, just bump the offset. */
if (now_seg == absolute_section)
{
frag_now->tc_frag_data = bit_offset;
goto getout;
}
-
+
if (!need_pass_2)
- p = frag_var (rs_fill, 1, 1,
- (relax_substateT) 0, (symbolS *) 0,
+ p = frag_var (rs_fill, 1, 1,
+ (relax_substateT) 0, (symbolS *) 0,
(offsetT) octets, (char *) 0);
/* Make note of how many bits of this word we've allocated so far. */
if (bes && label != NULL)
{
symbol_set_frag (label, frag_now);
- S_SET_VALUE (label, frag_now_fix ()-1);
+ S_SET_VALUE (label, frag_now_fix () - 1);
}
-
+
if (p)
*p = 0;
demand_empty_rest_of_line ();
}
-/* [symbol] .usect "section-name", size-in-words
- [, [blocking-flag] [, alignment-flag]]
+/* [symbol] .usect "section-name", size-in-words
+ [, [blocking-flag] [, alignment-flag]]
Unitialized section.
Non-zero blocking means that if the section would cross a page (128-word)
Non-zero alignment aligns on a longword boundary.
Has no effect on the current section. */
-static void
+static void
tic54x_usect (x)
- int x ATTRIBUTE_UNUSED;
+ int x ATTRIBUTE_UNUSED;
{
char c;
char *name;
seg_info (seg)->bss = 1; /* Uninitialized data. */
- p = frag_var (rs_fill, 1, 1,
+ p = frag_var (rs_fill, 1, 1,
(relax_substateT) 0, (symbolS *) line_label,
size * OCTETS_PER_BYTE, (char *) 0);
*p = 0;
subseg_set (current_seg, current_subseg); /* Restore current seg. */
demand_empty_rest_of_line ();
-}
+}
static enum cpu_version
lookup_version (ver)
const char *ver;
{
enum cpu_version version = VNONE;
-
+
if (ver[0] == '5' && ver[1] == '4')
{
if (strlen (ver) == 3 &&
if (version == V545LP || version == V546LP)
{
symbolS *symbolP = symbol_new ("__allow_lp", absolute_section,
- (valueT)1, &zero_address_frag);
+ (valueT) 1, &zero_address_frag);
SF_SET_LOCAL (symbolP);
symbol_table_insert (symbolP);
}
}
-/* .version cpu-version
+/* .version cpu-version
cpu-version may be one of the following:
541
542
This is for compatibility only. It currently has no affect on assembly. */
static int cpu_needs_set = 1;
-static void
+static void
tic54x_version (x)
- int x ATTRIBUTE_UNUSED;
+ int x ATTRIBUTE_UNUSED;
{
enum cpu_version version = VNONE;
enum cpu_version old_version = cpu;
SKIP_WHITESPACE ();
ver = input_line_pointer;
- while (!is_end_of_line[(int)*input_line_pointer])
+ while (!is_end_of_line[(int) *input_line_pointer])
++input_line_pointer;
c = *input_line_pointer;
*input_line_pointer = 0;
-
+
version = lookup_version (ver);
if (cpu != VNONE && cpu != version)
#ifdef md_flush_pending_output
md_flush_pending_output ();
#endif
-
+
/* Align to long word boundary (4 octets) unless it's ".xfloat". */
if (type != 'x')
{
float_cons ('f');
}
-/* The argument is capitalized if it should be zero-terminated
+/* The argument is capitalized if it should be zero-terminated
's' is normal string with upper 8-bits zero-filled, 'p' is packed.
Code copied from read.c, and slightly modified so that strings are packed
and encoded into the correct octets. */
default:
{
unsigned short value = get_absolute_expression ();
- FRAG_APPEND_1_CHAR (value&0xFF);
- FRAG_APPEND_1_CHAR ((value>>8)&0xFF);
+ FRAG_APPEND_1_CHAR ( value & 0xFF);
+ FRAG_APPEND_1_CHAR ((value >> 8) & 0xFF);
break;
}
case '\"':
static void
tic54x_p2align (arg)
- int arg ATTRIBUTE_UNUSED;
+ int arg ATTRIBUTE_UNUSED;
{
as_bad (_("p2align not supported on this target"));
}
/* Only ".align" with no argument is allowed within .struct/.union. */
int count = arg;
- if (!is_end_of_line[(int)*input_line_pointer])
+ if (!is_end_of_line[(int) *input_line_pointer])
{
if (arg == 2)
as_warn (_("Argument to .even ignored"));
/* Initialize multiple-bit fields withing a single word of memory. */
static void
tic54x_field (ignore)
- int ignore ATTRIBUTE_UNUSED;
+ int ignore ATTRIBUTE_UNUSED;
{
expressionS exp;
int size = 16;
unsigned long fmask = (size == 32) ? 0xFFFFFFFF : (1ul << size) - 1;
value = exp.X_add_number;
exp.X_add_number &= fmask;
- if (value != (valueT)exp.X_add_number)
+ if (value != (valueT) exp.X_add_number)
as_warn (_("field value truncated"));
value = exp.X_add_number;
/* Bits are stored MS first. */
else
{
/* Put the new value entirely within the existing one. */
- p = alloc_frag == frag_now ?
+ p = alloc_frag == frag_now ?
frag_now->fr_literal + frag_now_fix_octets () - 2 :
alloc_frag->fr_literal;
if (label != NULL)
/* OR in existing value. */
if (alloc_frag->tc_frag_data)
- value |= ((unsigned short)p[1]<<8) | p[0];
+ value |= ((unsigned short) p[1] << 8) | p[0];
md_number_to_chars (p, value, 2);
alloc_frag->tc_frag_data += size;
if (alloc_frag->tc_frag_data == 16)
available yet. seg_info ()->bss is the next best thing. */
static int
tic54x_initialized_section (seg)
- segT seg;
+ segT seg;
{
return !seg_info (seg)->bss;
}
-/* .clink ["section name"]
+/* .clink ["section name"]
Marks the section as conditionally linked (link only if contents are
referenced elsewhere.
Name is required for uninitialized sections. */
static void
tic54x_clink (ignored)
- int ignored ATTRIBUTE_UNUSED;
+ int ignored ATTRIBUTE_UNUSED;
{
segT seg = now_seg;
set to "." instead. */
static void
tic54x_set_default_include (dot)
- int dot;
+ int dot;
{
char *dir = ".";
char *tmp = NULL;
-
+
if (!dot)
{
char *curfile;
unsigned lineno;
-
+
as_where (&curfile, &lineno);
- dir = strcpy (xmalloc (strlen (curfile)+1), curfile);
+ dir = strcpy (xmalloc (strlen (curfile) + 1), curfile);
tmp = strrchr (dir, '/');
}
if (tmp != NULL)
include_dirs[0] = ".";
}
-/* .include "filename" | filename
+/* .include "filename" | filename
.copy "filename" | filename
- FIXME 'include' file should be omitted from any output listing,
+ FIXME 'include' file should be omitted from any output listing,
'copy' should be included in any output listing
FIXME -- prevent any included files from changing listing (compat only)
FIXME -- need to include source file directory in search path; what's a
Entering/exiting included/copied file clears all local labels. */
static void
tic54x_include (ignored)
- int ignored ATTRIBUTE_UNUSED;
+ int ignored ATTRIBUTE_UNUSED;
{
char newblock[] = " .newblock\n";
char *filename;
int len, c = -1;
ILLEGAL_WITHIN_STRUCT ();
-
+
SKIP_WHITESPACE ();
if (*input_line_pointer == '"')
else
{
filename = input_line_pointer;
- while (!is_end_of_line[(int)*input_line_pointer])
+ while (!is_end_of_line[(int) *input_line_pointer])
++input_line_pointer;
c = *input_line_pointer;
*input_line_pointer = '\0';
- filename = strcpy (xmalloc (strlen (filename)+1), filename);
+ filename = strcpy (xmalloc (strlen (filename) + 1), filename);
*input_line_pointer = c;
demand_empty_rest_of_line ();
}
else
{
msg = input_line_pointer;
- while (! is_end_of_line[(int)*input_line_pointer])
+ while (!is_end_of_line[(int) *input_line_pointer])
++input_line_pointer;
c = *input_line_pointer;
*input_line_pointer = 0;
demand_empty_rest_of_line ();
}
-/* .label <symbol>
+/* .label <symbol>
define a special symbol that refers to the loadtime address rather than the
runtime address within the current section.
run address (vma). */
static void
tic54x_label (ignored)
- int ignored ATTRIBUTE_UNUSED;
+ int ignored ATTRIBUTE_UNUSED;
{
char *name = input_line_pointer;
symbolS *symbolP;
local symbols. */
static void
tic54x_mmregs (ignored)
- int ignored ATTRIBUTE_UNUSED;
+ int ignored ATTRIBUTE_UNUSED;
{
symbol *sym;
ILLEGAL_WITHIN_STRUCT ();
- for (sym = (symbol *)mmregs; sym->name; sym++)
+ for (sym = (symbol *) mmregs; sym->name; sym++)
{
symbolS *symbolP = symbol_new (sym->name, absolute_section,
(valueT) sym->value, &zero_address_frag);
ILLEGAL_WITHIN_STRUCT ();
SKIP_WHITESPACE ();
- if (!is_end_of_line[(int)*input_line_pointer])
+ if (!is_end_of_line[(int) *input_line_pointer])
count = get_absolute_expression ();
do_repeat (count, "LOOP", "ENDLOOP");
/* Normally, endloop gets eaten by the preceding loop. */
static void
tic54x_endloop (ignore)
- int ignore ATTRIBUTE_UNUSED;
+ int ignore ATTRIBUTE_UNUSED;
{
as_bad (_("ENDLOOP without corresponding LOOP"));
ignore_rest_of_line ();
/* .break [condition]. */
static void
tic54x_break (ignore)
- int ignore ATTRIBUTE_UNUSED;
+ int ignore ATTRIBUTE_UNUSED;
{
int cond = 1;
ILLEGAL_WITHIN_STRUCT ();
SKIP_WHITESPACE ();
- if (!is_end_of_line[(int)*input_line_pointer])
+ if (!is_end_of_line[(int) *input_line_pointer])
{
cond = get_absolute_expression ();
}
static void
set_address_mode (mode)
- int mode;
+ int mode;
{
amode = mode;
if (mode == far_mode)
{
- symbolS *symbolP = symbol_new ("__allow_far", absolute_section,
- (valueT)1, &zero_address_frag);
+ symbolS *symbolP = symbol_new ("__allow_far", absolute_section,
+ (valueT) 1, &zero_address_frag);
SF_SET_LOCAL (symbolP);
symbol_table_insert (symbolP);
}
static int address_mode_needs_set = 1;
static void
tic54x_address_mode (mode)
- int mode;
+ int mode;
{
- if (assembly_begun && amode != (unsigned)mode)
+ if (assembly_begun && amode != (unsigned) mode)
{
as_bad (_("Mixing of normal and extended addressing not supported"));
ignore_rest_of_line ();
designate initialized sections for blocking. */
static void
tic54x_sblock (ignore)
- int ignore ATTRIBUTE_UNUSED;
+ int ignore ATTRIBUTE_UNUSED;
{
int c = ',';
{
segT seg;
char *name;
-
+
if (*input_line_pointer == '"')
{
int len;
{
char *section_name = input_line_pointer;
c = get_symbol_end ();
- name = xmalloc (strlen (section_name)+1);
+ name = xmalloc (strlen (section_name) + 1);
strcpy (name, section_name);
*input_line_pointer = c;
}
seg->flags |= SEC_BLOCK;
c = *input_line_pointer;
- if (!is_end_of_line[(int)c])
+ if (!is_end_of_line[(int) c])
++input_line_pointer;
}
}
/* symbol .set value
- symbol .equ value
+ symbol .equ value
value must be defined externals; no forward-referencing allowed
symbols assigned with .set/.equ may not be redefined. */
static void
tic54x_set (ignore)
- int ignore ATTRIBUTE_UNUSED;
+ int ignore ATTRIBUTE_UNUSED;
{
symbolS *symbolP;
char *name;
listing_sslist = show;
}
-/* .var SYM[,...,SYMN]
+/* .var SYM[,...,SYMN]
define a substitution string to be local to a macro. */
static void
tic54x_var (ignore)
- int ignore ATTRIBUTE_UNUSED;
+ int ignore ATTRIBUTE_UNUSED;
{
static char empty[] = "";
char *name;
ignore_rest_of_line ();
return;
}
- do
+ do
{
if (!isalpha (*input_line_pointer))
{
name = input_line_pointer;
c = get_symbol_end ();
/* .var symbols start out with a null string */
- name = strcpy (xmalloc (strlen (name)+1), name);
+ name = strcpy (xmalloc (strlen (name) + 1), name);
hash_insert (subsym_hash[macro_level], name, empty);
*input_line_pointer = c;
if (c == ',')
{
++input_line_pointer;
- if (is_end_of_line[(int)*input_line_pointer])
+ if (is_end_of_line[(int) *input_line_pointer])
c = *input_line_pointer;
}
}
demand_empty_rest_of_line ();
}
-/* .mlib <macro library filename>
+/* .mlib <macro library filename>
Macro libraries are archived (standard AR-format) text macro definitions
Expand the file and include it.
FIXME need to try the source file directory as well. */
static void
tic54x_mlib (ignore)
- int ignore ATTRIBUTE_UNUSED;
+ int ignore ATTRIBUTE_UNUSED;
{
char *filename;
char *path;
{
SKIP_WHITESPACE ();
len = 0;
- while (! is_end_of_line[(int)*input_line_pointer]
+ while (!is_end_of_line[(int) *input_line_pointer]
&& !isspace (*input_line_pointer))
{
obstack_1grow (¬es, *input_line_pointer);
tic54x_set_default_include (0);
path = xmalloc ((unsigned long) len + include_dir_maxlen + 5);
- for (i=0;i < include_dir_count; i++)
+ for (i = 0; i < include_dir_count; i++)
{
FILE *try;
strcpy (path, include_dirs[i]);
fclose (try);
break;
}
- }
+ }
if (i >= include_dir_count)
{
free (path);
/* FIXME: if path is found, malloc'd storage is not freed. Of course, this
happens all over the place, and since the assembler doesn't usually keep
- running for a very long time, it really doesn't matter... */
+ running for a very long time, it really doesn't matter... */
register_dependency (path);
/* Expand all archive entries to temporary files and include them. */
/* We're not sure how big it is, but it will be smaller than "size". */
bfd_read (buf, size, 1, mbfd);
- /* Write to a temporary file, then use s_include to include it
+ /* Write to a temporary file, then use s_include to include it
a bit of a hack... */
ftmp = fopen (fname, "w+b");
- fwrite ((void *)buf, size, 1, ftmp);
- if (buf[size-1] != '\n')
+ fwrite ((void *) buf, size, 1, ftmp);
+ if (buf[size - 1] != '\n')
fwrite ("\n", 1, 1, ftmp);
fclose (ftmp);
free (buf);
}
}
-const pseudo_typeS md_pseudo_table[] =
+const pseudo_typeS md_pseudo_table[] =
{
{ "algebraic", s_ignore, 0 },
- { "align", tic54x_align_words, 128 },
- { "even", tic54x_align_words, 2 },
+ { "align", tic54x_align_words, 128 },
+ { "even", tic54x_align_words, 2 },
{ "asg", tic54x_asg, 0 },
{ "eval", tic54x_eval, 0 },
{ "bss", tic54x_bss, 0 },
{ "emsg", tic54x_message, 'e' },
{ "mmsg", tic54x_message, 'm' },
{ "wmsg", tic54x_message, 'w' },
- /*{ "end", s_end, 0 }, */
- { "far_mode", tic54x_address_mode, far_mode },
+#if 0
+ { "end", s_end, 0 },
+#endif
+ { "far_mode", tic54x_address_mode, far_mode },
{ "fclist", tic54x_fclist, 1 },
{ "fcnolist", tic54x_fclist, 0 },
{ "field", tic54x_field, -1 },
{ "uhalf", tic54x_cons, 'H' },
{ "short", tic54x_cons, 's' },
{ "ushort", tic54x_cons, 'S' },
- { "if", s_if, (int)O_ne },
- { "elseif", s_elseif, (int)O_ne },
+ { "if", s_if, (int) O_ne },
+ { "elseif", s_elseif, (int) O_ne },
{ "else", s_else, 0 },
{ "endif", s_endif, 0 },
{ "int", tic54x_cons, 'i' },
{ "word", tic54x_cons, 'w' },
{ "uword", tic54x_cons, 'W' },
{ "label", tic54x_label, 0 }, /* loadtime address */
- { "length", s_ignore, 0 },
- { "width", s_ignore, 0 },
- /*{ "list", listing_list, 1 }, */
- /*{ "nolist", listing_list, 0 }, */
- { "long", tic54x_cons, 'l' },
- { "ulong", tic54x_cons, 'L' },
- { "xlong", tic54x_cons, 'x' },
- { "loop", tic54x_loop, 1024 },
- { "break", tic54x_break, 0 },
- { "endloop", tic54x_endloop, 0 },
- { "mlib", tic54x_mlib, 0 },
- { "mlist", s_ignore, 0 },
- { "mnolist", s_ignore, 0 },
- { "mmregs", tic54x_mmregs, 0 },
- { "newblock", tic54x_clear_local_labels, 0 },
- { "option", s_ignore, 0 },
+ { "length", s_ignore, 0 },
+ { "width", s_ignore, 0 },
+#if 0
+ { "list", listing_list, 1 },
+ { "nolist", listing_list, 0 },
+#endif
+ { "long", tic54x_cons, 'l' },
+ { "ulong", tic54x_cons, 'L' },
+ { "xlong", tic54x_cons, 'x' },
+ { "loop", tic54x_loop, 1024 },
+ { "break", tic54x_break, 0 },
+ { "endloop", tic54x_endloop, 0 },
+ { "mlib", tic54x_mlib, 0 },
+ { "mlist", s_ignore, 0 },
+ { "mnolist", s_ignore, 0 },
+ { "mmregs", tic54x_mmregs, 0 },
+ { "newblock", tic54x_clear_local_labels, 0 },
+ { "option", s_ignore, 0 },
{ "p2align", tic54x_p2align, 0 },
- /*{ "page", listing_eject, 0 }, */
- { "sblock", tic54x_sblock, 0 },
- { "sect", tic54x_sect, '*' },
- { "set", tic54x_set, 0 },
- { "equ", tic54x_set, 0 },
- { "space", tic54x_space, 0 },
- { "bes", tic54x_space, 1 },
- { "sslist", tic54x_sslist, 1 },
- { "ssnolist", tic54x_sslist, 0 },
+#if 0
+ { "page", listing_eject, 0 },
+#endif
+ { "sblock", tic54x_sblock, 0 },
+ { "sect", tic54x_sect, '*' },
+ { "set", tic54x_set, 0 },
+ { "equ", tic54x_set, 0 },
+ { "space", tic54x_space, 0 },
+ { "bes", tic54x_space, 1 },
+ { "sslist", tic54x_sslist, 1 },
+ { "ssnolist", tic54x_sslist, 0 },
{ "string", tic54x_stringer, 's' },
{ "pstring", tic54x_stringer, 'p' },
- { "struct", tic54x_struct, 0 },
- { "tag", tic54x_tag, 0 },
- { "endstruct", tic54x_endstruct, 0 },
- { "tab", s_ignore, 0 },
- { "text", tic54x_sect, 't' },
- /*{ "title", listing_title, 0 }, */
- { "union", tic54x_struct, 1 },
- { "endunion", tic54x_endstruct, 1 },
- { "usect", tic54x_usect, 0 },
- { "var", tic54x_var, 0 },
- { "version", tic54x_version, 0 },
+ { "struct", tic54x_struct, 0 },
+ { "tag", tic54x_tag, 0 },
+ { "endstruct", tic54x_endstruct, 0 },
+ { "tab", s_ignore, 0 },
+ { "text", tic54x_sect, 't' },
+#if 0
+ { "title", listing_title, 0 },
+#endif
+ { "union", tic54x_struct, 1 },
+ { "endunion", tic54x_endstruct, 1 },
+ { "usect", tic54x_usect, 0 },
+ { "var", tic54x_var, 0 },
+ { "version", tic54x_version, 0 },
{0, 0, 0}
};
#if 0
/* For debugging, strings for each operand type. */
-static const char *optypes[] =
+static const char *optypes[] =
{
"none", "Xmem", "Ymem", "pmad", "dmad", "Smem", "Lmem", "MMR", "PA",
- "Sind", "xpmad", "xpmad+", "MMRX", "MMRY",
- "SRC1", "SRC", "RND", "DST",
- "ARX",
+ "Sind", "xpmad", "xpmad+", "MMRX", "MMRY",
+ "SRC1", "SRC", "RND", "DST",
+ "ARX",
"SHIFT", "SHFT",
- "B", "A", "lk", "TS", "k8", "16", "BITC", "CC", "CC2", "CC3", "123", "031",
+ "B", "A", "lk", "TS", "k8", "16", "BITC", "CC", "CC2", "CC3", "123", "031",
"k5", "k8u", "ASM", "T", "DP", "ARP", "k3", "lku", "N", "SBIT", "12",
"k9", "TRN",
};
int
md_parse_option (c, arg)
- int c;
- char *arg;
+ int c;
+ char *arg;
{
switch (c)
{
return 1;
}
-/* Create a "local" substitution string hash table for a new macro level
+/* Create a "local" substitution string hash table for a new macro level
Some docs imply that macros have to use .newblock in order to be able
to re-use a local label. We effectively do an automatic .newblock by
deleting the local label hash between macro invocations. */
-void
+void
tic54x_macro_start ()
{
++macro_level;
struct hash_control *formal_hash; /* hash table of formals. */
} *macro;
- macro = (struct macro_struct *)info;
+ macro = (struct macro_struct *) info;
/* Put the formal args into the substitution symbol table. */
for (entry = macro->formals; entry; entry = entry->next)
return strcmp (a, b);
}
-/* Return the index of the first occurence of B in A, or zero if none
+/* Return the index of the first occurence of B in A, or zero if none
assumes b is an integer char value as a string. Index is one-based. */
static int
subsym_firstch (a, b)
{
int val = atoi (b);
char *tmp = strchr (a, val);
-
+
return tmp ? tmp - a + 1 : 0;
}
return 0;
}
- ptr = elem = xmalloc (strlen (listv)+1);
+ ptr = elem = xmalloc (strlen (listv) + 1);
strcpy (elem, listv);
while (*ptr && *ptr != ',')
++ptr;
/* Reassign the list. */
subsym_create_or_replace (list, ptr);
-
+
/* Assume this value, docs aren't clear. */
return *list != 0;
}
5 if decimal. */
static int
subsym_iscons (a, ignore)
- char *a;
- char *ignore ATTRIBUTE_UNUSED;
+ char *a;
+ char *ignore ATTRIBUTE_UNUSED;
{
expressionS exp;
{
int len = strlen (a);
- switch (toupper (a[len-1]))
+ switch (toupper (a[len - 1]))
{
case 'B':
return 1;
/* Return 1 if A is a valid symbol name. Expects string input. */
static int
subsym_isname (a, ignore)
- char *a;
- char *ignore ATTRIBUTE_UNUSED;
+ char *a;
+ char *ignore ATTRIBUTE_UNUSED;
{
if (!is_name_beginner (*a))
return 0;
Note this does not recognize "A" or "B" accumulators. */
static int
subsym_isreg (a, ignore)
- char *a;
- char *ignore ATTRIBUTE_UNUSED;
+ char *a;
+ char *ignore ATTRIBUTE_UNUSED;
{
if (hash_find (reg_hash, a))
return 1;
/* Return the structrure size, given the stag. */
static int
subsym_structsz (name, ignore)
- char *name;
- char *ignore ATTRIBUTE_UNUSED;
+ char *name;
+ char *ignore ATTRIBUTE_UNUSED;
{
- struct stag *stag = (struct stag *)hash_find (stag_hash, name);
+ struct stag *stag = (struct stag *) hash_find (stag_hash, name);
if (stag)
return stag->size;
return zero, we punt and return zero. */
static int
subsym_structacc (stag_name, ignore)
- char *stag_name ATTRIBUTE_UNUSED;
- char *ignore ATTRIBUTE_UNUSED;
+ char *stag_name ATTRIBUTE_UNUSED;
+ char *ignore ATTRIBUTE_UNUSED;
{
return 0;
}
static float
math_ceil (arg1, ignore)
- float arg1;
- float ignore ATTRIBUTE_UNUSED;
+ float arg1;
+ float ignore ATTRIBUTE_UNUSED;
{
- return (float)ceil (arg1);
+ return (float) ceil (arg1);
}
static float
math_cvi (arg1, ignore)
- float arg1;
- float ignore ATTRIBUTE_UNUSED;
+ float arg1;
+ float ignore ATTRIBUTE_UNUSED;
{
- return (int)arg1;
+ return (int) arg1;
}
static float
math_floor (arg1, ignore)
- float arg1;
- float ignore ATTRIBUTE_UNUSED;
+ float arg1;
+ float ignore ATTRIBUTE_UNUSED;
{
- return (float)floor (arg1);
+ return (float) floor (arg1);
}
static float
math_fmod (float arg1, float arg2)
{
- return (int)arg1 % (int)arg2;
+ return (int) arg1 % (int) arg2;
}
static float
math_int (arg1, ignore)
- float arg1;
- float ignore ATTRIBUTE_UNUSED;
+ float arg1;
+ float ignore ATTRIBUTE_UNUSED;
{
- return ((float)((int)arg1)) == arg1;
+ return ((float) ((int) arg1)) == arg1;
}
static float
math_round (arg1, ignore)
- float arg1;
- float ignore ATTRIBUTE_UNUSED;
+ float arg1;
+ float ignore ATTRIBUTE_UNUSED;
{
- return arg1 > 0 ? (int)(arg1 + 0.5) : (int)(arg1 - 0.5);
+ return arg1 > 0 ? (int) (arg1 + 0.5) : (int) (arg1 - 0.5);
}
static float
math_sgn (arg1, ignore)
- float arg1;
- float ignore ATTRIBUTE_UNUSED;
+ float arg1;
+ float ignore ATTRIBUTE_UNUSED;
{
return (arg1 < 0) ? -1 : (arg1 ? 1 : 0);
}
static float
math_trunc (arg1, ignore)
- float arg1;
- float ignore ATTRIBUTE_UNUSED;
+ float arg1;
+ float ignore ATTRIBUTE_UNUSED;
{
- return (int)arg1;
+ return (int) arg1;
}
static float
math_acos (arg1, ignore)
- float arg1;
- float ignore ATTRIBUTE_UNUSED;
+ float arg1;
+ float ignore ATTRIBUTE_UNUSED;
{
- return (float)acos (arg1);
+ return (float) acos (arg1);
}
static float
math_asin (arg1, ignore)
- float arg1;
- float ignore ATTRIBUTE_UNUSED;
+ float arg1;
+ float ignore ATTRIBUTE_UNUSED;
{
- return (float)asin (arg1);
+ return (float) asin (arg1);
}
static float
math_atan (arg1, ignore)
- float arg1;
- float ignore ATTRIBUTE_UNUSED;
+ float arg1;
+ float ignore ATTRIBUTE_UNUSED;
{
- return (float)atan (arg1);
+ return (float) atan (arg1);
}
static float
-math_atan2(float arg1, float arg2)
+math_atan2 (float arg1, float arg2)
{
- return (float)atan2 (arg1, arg2);
+ return (float) atan2 (arg1, arg2);
}
static float
math_cosh (arg1, ignore)
- float arg1;
- float ignore ATTRIBUTE_UNUSED;
+ float arg1;
+ float ignore ATTRIBUTE_UNUSED;
{
- return (float)cosh (arg1);
+ return (float) cosh (arg1);
}
static float
math_cos (arg1, ignore)
- float arg1;
- float ignore ATTRIBUTE_UNUSED;
+ float arg1;
+ float ignore ATTRIBUTE_UNUSED;
{
- return (float)cos (arg1);
+ return (float) cos (arg1);
}
static float
math_cvf (arg1, ignore)
- float arg1;
- float ignore ATTRIBUTE_UNUSED;
+ float arg1;
+ float ignore ATTRIBUTE_UNUSED;
{
- return (float)arg1;
+ return (float) arg1;
}
static float
math_exp (arg1, ignore)
- float arg1;
- float ignore ATTRIBUTE_UNUSED;
+ float arg1;
+ float ignore ATTRIBUTE_UNUSED;
{
- return (float)exp (arg1);
+ return (float) exp (arg1);
}
static float
math_fabs (arg1, ignore)
- float arg1;
- float ignore ATTRIBUTE_UNUSED;
+ float arg1;
+ float ignore ATTRIBUTE_UNUSED;
{
- return (float)fabs (arg1);
+ return (float) fabs (arg1);
}
/* expr1 * 2^expr2. */
static float
math_ldexp (float arg1, float arg2)
{
- return arg1 * (float)pow (2.0, arg2);
+ return arg1 * (float) pow (2.0, arg2);
}
static float
math_log10 (arg1, ignore)
- float arg1;
- float ignore ATTRIBUTE_UNUSED;
+ float arg1;
+ float ignore ATTRIBUTE_UNUSED;
{
- return (float)log10 (arg1);
+ return (float) log10 (arg1);
}
static float
math_log (arg1, ignore)
- float arg1;
- float ignore ATTRIBUTE_UNUSED;
+ float arg1;
+ float ignore ATTRIBUTE_UNUSED;
{
- return (float)log (arg1);
+ return (float) log (arg1);
}
static float
static float
math_pow (float arg1, float arg2)
{
- return (float)pow (arg1, arg2);
+ return (float) pow (arg1, arg2);
}
static float
math_sin (arg1, ignore)
- float arg1;
- float ignore ATTRIBUTE_UNUSED;
+ float arg1;
+ float ignore ATTRIBUTE_UNUSED;
{
- return (float)sin (arg1);
+ return (float) sin (arg1);
}
static float
math_sinh (arg1, ignore)
- float arg1;
- float ignore ATTRIBUTE_UNUSED;
+ float arg1;
+ float ignore ATTRIBUTE_UNUSED;
{
- return (float)sinh (arg1);
+ return (float) sinh (arg1);
}
static float
math_sqrt (arg1, ignore)
- float arg1;
- float ignore ATTRIBUTE_UNUSED;
+ float arg1;
+ float ignore ATTRIBUTE_UNUSED;
{
- return (float)sqrt (arg1);
+ return (float) sqrt (arg1);
}
static float
math_tan (arg1, ignore)
- float arg1;
- float ignore ATTRIBUTE_UNUSED;
+ float arg1;
+ float ignore ATTRIBUTE_UNUSED;
{
- return (float)tan (arg1);
+ return (float) tan (arg1);
}
static float
math_tanh (arg1, ignore)
- float arg1;
- float ignore ATTRIBUTE_UNUSED;
+ float arg1;
+ float ignore ATTRIBUTE_UNUSED;
{
- return (float)tanh (arg1);
+ return (float) tanh (arg1);
}
/* Built-in substitution symbol functions and math functions. */
-typedef struct
+typedef struct
{
char *name;
- int (*proc)(char *, char *);
+ int (*proc) (char *, char *);
int nargs;
} subsym_proc_entry;
typedef struct
{
char *name;
- float (*proc)(float, float);
+ float (*proc) (float, float);
int nargs;
int int_return;
} math_proc_entry;
{ "$acos", math_acos, 1, 0 },
{ "$asin", math_asin, 1, 0 },
{ "$atan", math_atan, 1, 0 },
- { "$atan2", math_atan2, 2, 0 },
+ { "$atan2", math_atan2, 2, 0 },
{ "$ceil", math_ceil, 1, 0 },
{ "$cosh", math_cosh, 1, 0 },
{ "$cos", math_cos, 1, 0 },
if (A_DIR != NULL)
{
char *tmp = xstrdup (A_DIR);
- do {
- char *next = strchr (tmp, ';');
- if (next)
- *next++ = '\0';
- add_include_dir (tmp);
- tmp = next;
- } while (tmp != NULL);
+ do
+ {
+ char *next = strchr (tmp, ';');
+ if (next)
+ *next++ = '\0';
+ add_include_dir (tmp);
+ tmp = next;
+ }
+ while (tmp != NULL);
}
op_hash = hash_new ();
- for (opcode=(template *)tic54x_optab; opcode->name; opcode++)
+ for (opcode = (template *) tic54x_optab; opcode->name; opcode++)
{
if (hash_find (op_hash, opcode->name))
continue;
- hash_err = hash_insert (op_hash, opcode->name, (char *)opcode);
+ hash_err = hash_insert (op_hash, opcode->name, (char *) opcode);
if (hash_err)
- as_fatal ("Internal Error: Can't hash %s: %s",
+ as_fatal ("Internal Error: Can't hash %s: %s",
opcode->name, hash_err);
}
parop_hash = hash_new ();
- for (paropcode=(partemplate *)tic54x_paroptab; paropcode->name; paropcode++)
+ for (paropcode = (partemplate *) tic54x_paroptab;
+ paropcode->name;
+ paropcode++)
{
if (hash_find (parop_hash, paropcode->name))
continue;
- hash_err = hash_insert (parop_hash, paropcode->name, (char *)paropcode);
+ hash_err = hash_insert (parop_hash, paropcode->name, (char *) paropcode);
if (hash_err)
- as_fatal ("Internal Error: Can't hash %s: %s",
+ as_fatal ("Internal Error: Can't hash %s: %s",
paropcode->name, hash_err);
}
reg_hash = hash_new ();
- for (sym = (symbol *)regs; sym->name; sym++)
+ for (sym = (symbol *) regs; sym->name; sym++)
{
/* Add basic registers to the symbol table. */
symbolS *symbolP = symbol_new (sym->name, absolute_section,
- (valueT)sym->value, &zero_address_frag);
+ (valueT) sym->value, &zero_address_frag);
SF_SET_LOCAL (symbolP);
symbol_table_insert (symbolP);
- hash_err = hash_insert (reg_hash, sym->name, (char *)sym);
+ hash_err = hash_insert (reg_hash, sym->name, (char *) sym);
}
- for (sym = (symbol *)mmregs; sym->name; sym++)
- hash_err = hash_insert (reg_hash, sym->name, (char *)sym);
+ for (sym = (symbol *) mmregs; sym->name; sym++)
+ hash_err = hash_insert (reg_hash, sym->name, (char *) sym);
mmreg_hash = hash_new ();
- for (sym = (symbol *)mmregs; sym->name; sym++)
+ for (sym = (symbol *) mmregs; sym->name; sym++)
{
- hash_err = hash_insert (mmreg_hash, sym->name, (char *)sym);
+ hash_err = hash_insert (mmreg_hash, sym->name, (char *) sym);
}
cc_hash = hash_new ();
- for (sym = (symbol *)condition_codes; sym->name; sym++)
+ for (sym = (symbol *) condition_codes; sym->name; sym++)
{
- hash_err = hash_insert (cc_hash, sym->name, (char *)sym);
+ hash_err = hash_insert (cc_hash, sym->name, (char *) sym);
}
cc2_hash = hash_new ();
- for (sym = (symbol *)cc2_codes; sym->name; sym++)
+ for (sym = (symbol *) cc2_codes; sym->name; sym++)
{
- hash_err = hash_insert (cc2_hash, sym->name, (char *)sym);
+ hash_err = hash_insert (cc2_hash, sym->name, (char *) sym);
}
cc3_hash = hash_new ();
- for (sym = (symbol *)cc3_codes; sym->name; sym++)
+ for (sym = (symbol *) cc3_codes; sym->name; sym++)
{
- hash_err = hash_insert (cc3_hash, sym->name, (char *)sym);
+ hash_err = hash_insert (cc3_hash, sym->name, (char *) sym);
}
sbit_hash = hash_new ();
- for (sym = (symbol *)status_bits; sym->name; sym++)
+ for (sym = (symbol *) status_bits; sym->name; sym++)
{
- hash_err = hash_insert (sbit_hash, sym->name, (char *)sym);
+ hash_err = hash_insert (sbit_hash, sym->name, (char *) sym);
}
misc_symbol_hash = hash_new ();
- for (symname = (char **)misc_symbols; *symname; symname++)
+ for (symname = (char **) misc_symbols; *symname; symname++)
{
hash_err = hash_insert (misc_symbol_hash, *symname, *symname);
}
subsym_hash[0] = hash_new ();
for (subsym_proc = subsym_procs; subsym_proc->name; subsym_proc++)
{
- hash_err = hash_insert (subsym_hash[0], subsym_proc->name,
- (char *)subsym_proc);
+ hash_err = hash_insert (subsym_hash[0], subsym_proc->name,
+ (char *) subsym_proc);
}
math_hash = hash_new ();
for (math_proc = math_procs; math_proc->name; math_proc++)
/* Insert into the main subsym hash for recognition; insert into
the math hash to actually store information. */
hash_err = hash_insert (subsym_hash[0], math_proc->name,
- (char *)math_proc);
+ (char *) math_proc);
hash_err = hash_insert (math_hash, math_proc->name,
- (char *)math_proc);
+ (char *) math_proc);
}
subsym_recurse_hash = hash_new ();
stag_hash = hash_new ();
int is_lkaddr;
int lkoperand;
int words; /* size of insn in 16-bit words */
- int using_default_dst; /* do we need to explicitly set an
+ int using_default_dst; /* do we need to explicitly set an
omitted OP_DST operand? */
struct
{
static int encode_operand (tic54x_insn *, enum optype, struct opstruct *);
static int encode_dmad (tic54x_insn *, struct opstruct *, int);
-static int operands_match (tic54x_insn *, struct opstruct *, int,
+static int operands_match (tic54x_insn *, struct opstruct *, int,
const enum optype *, int, int);
static int encode_address (tic54x_insn *, struct opstruct *);
is_accumulator (operand)
struct opstruct *operand;
{
- return strcasecmp (operand->buf, "a") == 0
+ return strcasecmp (operand->buf, "a") == 0
|| strcasecmp (operand->buf, "b") == 0;
}
int expecting_operand = 0;
int i;
- while (numexp < MAX_OPERANDS && !is_end_of_line[(int)*lptr])
+ while (numexp < MAX_OPERANDS && !is_end_of_line[(int) *lptr])
{
int paren_not_balanced = 0;
char *op_start, *op_end;
/* Trim trailing spaces; while the preprocessor gets rid of most,
there are weird usage patterns that can introduce them
(i.e. using strings for macro args). */
- while (len > 0 && isspace (operands[numexp].buf[len-1]))
+ while (len > 0 && isspace (operands[numexp].buf[len - 1]))
operands[numexp].buf[--len] = 0;
lptr = op_end;
++numexp;
}
- else
+ else
{
if (expecting_operand || *lptr == ',')
{
while (*lptr && isspace (*lptr++))
;
- if (!is_end_of_line[(int)*lptr])
+ if (!is_end_of_line[(int) *lptr])
{
as_bad ("Extra junk on line");
return -1;
}
/* OK, now parse them into expressions. */
- for (i=0;i < numexp;i++)
+ for (i = 0; i < numexp; i++)
{
memset (&operands[i].exp, 0, sizeof (operands[i].exp));
if (operands[i].buf[0] == '#')
is_immediate (operand)
struct opstruct *operand;
{
- return *operand->buf == '#';
+ return *operand->buf == '#';
}
/* This is distinguished from immediate because some numbers must be constants
char *tmp = operand->buf + 3;
int arf;
int valid_mod;
-
+
arf = *tmp++ - '0';
/* Only allow *ARx, *ARx-, *ARx+, or *ARx+0%. */
valid_mod = *tmp == '\0' ||
strcasecmp (tmp, "-") == 0 ||
- strcasecmp (tmp, "+") == 0 ||
+ strcasecmp (tmp, "+") == 0 ||
strcasecmp (tmp, "+0%") == 0;
return arf >= 2 && arf <= 5 && valid_mod;
}
static int
is_type (operand, type)
- struct opstruct *operand;
- enum optype type;
+ struct opstruct *operand;
+ enum optype type;
{
switch (type)
{
case OP_A:
return is_accumulator (operand) && toupper (operand->buf[0]) == 'A';
case OP_ARX:
- return strncasecmp ("ar", operand->buf, 2) == 0
+ return strncasecmp ("ar", operand->buf, 2) == 0
&& isdigit (operand->buf[2]);
case OP_SBIT:
return hash_find (sbit_hash, operand->buf) != 0 || is_absolute (operand);
case OP_CC2:
return hash_find (cc2_hash, operand->buf) != 0;
case OP_CC3:
- return hash_find (cc3_hash, operand->buf) != 0
+ return hash_find (cc3_hash, operand->buf) != 0
|| is_immediate (operand) || is_absolute (operand);
case OP_16:
return (is_immediate (operand) || is_absolute (operand))
case OP_k8:
return is_absolute (operand) || is_immediate (operand);
case OP_k8u:
- return is_immediate (operand)
- && operand->exp.X_op == O_constant
+ return is_immediate (operand)
+ && operand->exp.X_op == O_constant
&& operand->exp.X_add_number >= 0
&& operand->exp.X_add_number < 256;
case OP_lk:
case OP_lku:
- /* Allow anything; assumes opcodes are ordered with Smem operands
+ /* Allow anything; assumes opcodes are ordered with Smem operands
versions first. */
return 1;
case OP_k5:
/* Just make sure it's an integer; check range later. */
return is_immediate (operand);
case OP_T:
- return strcasecmp ("t", operand->buf) == 0 ||
+ return strcasecmp ("t", operand->buf) == 0 ||
strcasecmp ("treg", operand->buf) == 0;
case OP_TS:
return strcasecmp ("ts", operand->buf) == 0;
static int
operands_match (insn, operands, opcount, refoptype, minops, maxops)
- tic54x_insn *insn;
- struct opstruct *operands;
- int opcount;
- const enum optype *refoptype;
- int minops, maxops;
+ tic54x_insn *insn;
+ struct opstruct *operands;
+ int opcount;
+ const enum optype *refoptype;
+ int minops, maxops;
{
int op = 0, refop = 0;
return 0;
}
-/* 16-bit direct memory address
+/* 16-bit direct memory address
Explicit dmad operands are always in last word of insn (usually second
word, but bumped to third if lk addressing is used)
We allow *(dmad) notation because the TI assembler allows it.
- XPC_CODE:
+ XPC_CODE:
0 for 16-bit addresses
1 for full 23-bit addresses
2 for the upper 7 bits of a 23-bit address (LDX). */
static int
encode_dmad (insn, operand, xpc_code)
- tic54x_insn *insn;
- struct opstruct *operand;
- int xpc_code;
+ tic54x_insn *insn;
+ struct opstruct *operand;
+ int xpc_code;
{
int op = 1 + insn->is_lkaddr;
/* Only allow *(dmad) expressions; all others are invalid. */
- if (is_indirect (operand) && operand->buf[strlen (operand->buf)-1] != ')')
+ if (is_indirect (operand) && operand->buf[strlen (operand->buf) - 1] != ')')
{
as_bad (_("Invalid dmad syntax '%s'"), operand->buf);
return 0;
/* 7-bit direct address encoding. */
static int
encode_address (insn, operand)
- tic54x_insn *insn;
- struct opstruct *operand;
+ tic54x_insn *insn;
+ struct opstruct *operand;
{
/* Assumes that dma addresses are *always* in word 0 of the opcode. */
insn->opcode[0].addr_expr = operand->exp;
static int
encode_indirect (insn, operand)
- tic54x_insn *insn;
- struct opstruct *operand;
+ tic54x_insn *insn;
+ struct opstruct *operand;
{
int arf;
int mod;
(strchr (operand->buf, '%') != NULL) ? 14 : 13);
arf = ((mod == 12) ? operand->buf[3] - '0' :
(mod == 15) ? 0 : operand->buf[4] - '0');
-
+
insn->opcode[1].addr_expr = operand->exp;
if (operand->exp.X_op == O_constant)
}
else
{
- arf = (toupper (operand->buf[1]) == 'A' ?
+ arf = (toupper (operand->buf[1]) == 'A' ?
operand->buf[3] : operand->buf[4]) - '0';
-
- if (operand->buf[1] == '+')
+
+ if (operand->buf[1] == '+')
{
mod = 3; /* *+ARx */
if (insn->tm->flags & FL_SMR)
as_warn (_("Address mode *+ARx is write-only. "
"Results of reading are undefined."));
}
- else if (operand->buf[4] == '\0')
+ else if (operand->buf[4] == '\0')
mod = 0; /* *ARx */
else if (operand->buf[5] == '\0')
mod = (operand->buf[4] == '-' ? 1 : 2); /* *ARx+ / *ARx- */
mod = (operand->buf[4] == '-' ? 9 : 11); /* ARx+0% / *ARx - 0% */
else
{
- as_bad (_("Unrecognized indirect address format \"%s\""),
+ as_bad (_("Unrecognized indirect address format \"%s\""),
operand->buf);
return 0;
}
- }
+ }
- insn->opcode[0].word |= 0x80 | (mod<<3) | arf;
+ insn->opcode[0].word |= 0x80 | (mod << 3) | arf;
return 1;
}
static int
encode_integer (insn, operand, which, min, max, mask)
- tic54x_insn *insn;
- struct opstruct *operand;
- int which, min, max;
- unsigned short mask;
+ tic54x_insn *insn;
+ struct opstruct *operand;
+ int which, min, max;
+ unsigned short mask;
{
long parse, integer;
/* Hack -- fixup for 16-bit hex quantities that get converted positive
instead of negative. */
if ((parse & 0x8000) && min == -32768 && max == 32767)
- integer = (short)parse;
+ integer = (short) parse;
else
integer = parse;
insn->opcode[which].word |= (integer & mask);
return 1;
}
- as_bad (_("Operand '%s' out of range (%d <= x <= %d)"),
+ as_bad (_("Operand '%s' out of range (%d <= x <= %d)"),
operand->buf, min, max);
}
else
{
if (insn->opcode[which].addr_expr.X_op == O_constant)
{
- insn->opcode[which].word |=
+ insn->opcode[which].word |=
insn->opcode[which].addr_expr.X_add_number & mask;
}
else
{
/* Do the fixup later; just store the expression. */
- bfd_reloc_code_real_type rtype =
- (mask == 0x1FF ? BFD_RELOC_TIC54X_PARTMS9 :
+ bfd_reloc_code_real_type rtype =
+ (mask == 0x1FF ? BFD_RELOC_TIC54X_PARTMS9 :
mask == 0xFFFF ? BFD_RELOC_TIC54X_16_OF_23 :
mask == 0x7F ? BFD_RELOC_TIC54X_PARTLS7 : BFD_RELOC_8);
int size = (mask == 0x1FF || mask == 0xFFFF) ? 2 : 1;
static int
encode_condition (insn, operand)
- tic54x_insn *insn;
- struct opstruct *operand;
+ tic54x_insn *insn;
+ struct opstruct *operand;
{
- symbol *cc = (symbol *)hash_find (cc_hash, operand->buf);
+ symbol *cc = (symbol *) hash_find (cc_hash, operand->buf);
if (!cc)
{
as_bad (_("Unrecognized condition code \"%s\""), operand->buf);
{
if ((insn->opcode[0].word & CC_GROUP) != (cc->value & CC_GROUP))
{
- as_bad (_("Condition \"%s\" does not match preceding group"),
+ as_bad (_("Condition \"%s\" does not match preceding group"),
operand->buf);
return 0;
}
if ((insn->opcode[0].word & CC_ACC) != (cc->value & CC_ACC))
{
as_bad (_("Condition \"%s\" uses a different accumulator from "
- "a preceding condition"),
+ "a preceding condition"),
operand->buf);
return 0;
}
static int
encode_cc3 (insn, operand)
- tic54x_insn *insn;
- struct opstruct *operand;
+ tic54x_insn *insn;
+ struct opstruct *operand;
{
- symbol *cc3 = (symbol *)hash_find (cc3_hash, operand->buf);
+ symbol *cc3 = (symbol *) hash_find (cc3_hash, operand->buf);
int value = cc3 ? cc3->value : operand->exp.X_add_number << 8;
if ((value & 0x0300) != value)
static int
encode_arx (insn, operand)
- tic54x_insn *insn;
- struct opstruct *operand;
+ tic54x_insn *insn;
+ struct opstruct *operand;
{
int arf = strlen (operand->buf) >= 3 ? operand->buf[2] - '0' : -1;
if (strncasecmp ("ar", operand->buf, 2) || arf < 0 || arf > 7)
static int
encode_cc2 (insn, operand)
- tic54x_insn *insn;
- struct opstruct *operand;
+ tic54x_insn *insn;
+ struct opstruct *operand;
{
- symbol *cc2 = (symbol *)hash_find (cc2_hash, operand->buf);
+ symbol *cc2 = (symbol *) hash_find (cc2_hash, operand->buf);
if (!cc2)
{
as_bad (_("Unrecognized condition code \"%s\""), operand->buf);
static int
encode_operand (insn, type, operand)
- tic54x_insn *insn;
- enum optype type;
- struct opstruct *operand;
+ tic54x_insn *insn;
+ enum optype type;
+ struct opstruct *operand;
{
int ext = insn->tm && ((insn->tm->flags & FL_EXT) != 0);
return 1;
case OP_Xmem:
case OP_Ymem:
- {
- int mod = (operand->buf[4] == '\0' ? 0 : /* *arx */
- operand->buf[4] == '-' ? 1 : /* *arx- */
- operand->buf[5] == '\0' ? 2 : 3); /* *arx+, *arx+0% */
- int arf = operand->buf[3] - '0' - 2;
- int code = (mod << 2)|arf;
- insn->opcode[0].word |= (code << (type == OP_Xmem ? 4 : 0));
- return 1;
- }
+ {
+ int mod = (operand->buf[4] == '\0' ? 0 : /* *arx */
+ operand->buf[4] == '-' ? 1 : /* *arx- */
+ operand->buf[5] == '\0' ? 2 : 3); /* *arx+, *arx+0% */
+ int arf = operand->buf[3] - '0' - 2;
+ int code = (mod << 2) | arf;
+ insn->opcode[0].word |= (code << (type == OP_Xmem ? 4 : 0));
+ return 1;
+ }
case OP_Lmem:
case OP_Smem:
if (!is_indirect (operand))
case OP_MMRX:
case OP_MMRY:
case OP_MMR:
- {
- int value = operand->exp.X_add_number;
- if (type == OP_MMR)
- insn->opcode[0].word |= value;
- else {
- if (value < 16 || value > 24)
- {
- as_bad (_("Memory mapped register \"%s\" out of range"),
- operand->buf);
- return 0;
- }
- if (type == OP_MMRX)
- insn->opcode[0].word |= (value - 16) << 4;
- else
- insn->opcode[0].word |= (value - 16);
+ {
+ int value = operand->exp.X_add_number;
+
+ if (type == OP_MMR)
+ insn->opcode[0].word |= value;
+ else
+ {
+ if (value < 16 || value > 24)
+ {
+ as_bad (_("Memory mapped register \"%s\" out of range"),
+ operand->buf);
+ return 0;
+ }
+ if (type == OP_MMRX)
+ insn->opcode[0].word |= (value - 16) << 4;
+ else
+ insn->opcode[0].word |= (value - 16);
+ }
+ return 1;
}
- return 1;
- }
case OP_B:
case OP_A:
return 1;
case OP_SHFT:
- return encode_integer (insn, operand, ext + insn->is_lkaddr,
+ return encode_integer (insn, operand, ext + insn->is_lkaddr,
0, 15, 0xF);
case OP_SHIFT:
- return encode_integer (insn, operand, ext + insn->is_lkaddr,
+ return encode_integer (insn, operand, ext + insn->is_lkaddr,
-16, 15, 0x1F);
case OP_lk:
return encode_integer (insn, operand, 1 + insn->is_lkaddr,
case OP_k8:
return encode_integer (insn, operand, 0, -128, 127, 0xFF);
case OP_123:
- {
- int value = operand->exp.X_add_number;
- int code;
- if (value < 1 || value > 3)
- {
- as_bad (_("Invalid operand (use 1, 2, or 3)"));
- return 0;
- }
- code = value == 1 ? 0 : value == 2 ? 0x2 : 0x1;
- insn->opcode[0].word |= (code << 8);
- return 1;
- }
+ {
+ int value = operand->exp.X_add_number;
+ int code;
+ if (value < 1 || value > 3)
+ {
+ as_bad (_("Invalid operand (use 1, 2, or 3)"));
+ return 0;
+ }
+ code = value == 1 ? 0 : value == 2 ? 0x2 : 0x1;
+ insn->opcode[0].word |= (code << 8);
+ return 1;
+ }
case OP_031:
return encode_integer (insn, operand, 0, 0, 31, 0x1F);
case OP_k8u:
return encode_integer (insn, operand, 0, 0, 255, 0xFF);
case OP_lku:
- return encode_integer (insn, operand, 1 + insn->is_lkaddr,
+ return encode_integer (insn, operand, 1 + insn->is_lkaddr,
0, 65535, 0xFFFF);
case OP_SBIT:
- {
- symbol *sbit = (symbol *)hash_find (sbit_hash, operand->buf);
- int value = is_absolute (operand) ?
- operand->exp.X_add_number : (sbit ? sbit->value : -1);
- int reg = 0;
-
- if (insn->opcount == 1)
- {
- if (!sbit)
- {
- as_bad (_("A status register or status bit name is required"));
- return 0;
- }
- /* Guess the register based on the status bit; "ovb" is the last
- status bit defined for st0. */
- if (sbit > (symbol *)hash_find (sbit_hash, "ovb"))
- reg = 1;
- }
- if (value == -1)
- {
- as_bad (_("Unrecognized status bit \"%s\""), operand->buf);
- return 0;
- }
- insn->opcode[0].word |= value;
- insn->opcode[0].word |= (reg << 9);
- return 1;
- }
+ {
+ symbol *sbit = (symbol *) hash_find (sbit_hash, operand->buf);
+ int value = is_absolute (operand) ?
+ operand->exp.X_add_number : (sbit ? sbit->value : -1);
+ int reg = 0;
+
+ if (insn->opcount == 1)
+ {
+ if (!sbit)
+ {
+ as_bad (_("A status register or status bit name is required"));
+ return 0;
+ }
+ /* Guess the register based on the status bit; "ovb" is the last
+ status bit defined for st0. */
+ if (sbit > (symbol *) hash_find (sbit_hash, "ovb"))
+ reg = 1;
+ }
+ if (value == -1)
+ {
+ as_bad (_("Unrecognized status bit \"%s\""), operand->buf);
+ return 0;
+ }
+ insn->opcode[0].word |= value;
+ insn->opcode[0].word |= (reg << 9);
+ return 1;
+ }
case OP_N:
if (strcasecmp (operand->buf, "st0") == 0
|| strcasecmp (operand->buf, "st1") == 0)
{
- insn->opcode[0].word |= ((unsigned short)(operand->buf[2] - '0'))<<9;
+ insn->opcode[0].word |= ((unsigned short) (operand->buf[2] - '0'))<<9;
return 1;
}
else if (operand->exp.X_op == O_constant
- && (operand->exp.X_add_number == 0
+ && (operand->exp.X_add_number == 0
|| operand->exp.X_add_number == 1))
{
insn->opcode[0].word |= ((unsigned short)
case OP_k9:
return encode_integer (insn, operand, 0, 0, 0x1FF, 0x1FF);
case OP_12:
- if (operand->exp.X_add_number != 1
+ if (operand->exp.X_add_number != 1
&& operand->exp.X_add_number != 2)
{
as_bad (_("Operand \"%s\" out of range (use 1 or 2)"), operand->buf);
static void
emit_insn (insn)
- tic54x_insn *insn;
+ tic54x_insn *insn;
{
int i;
- for (i=0;i < insn->words;i++)
+
+ for (i = 0; i < insn->words; i++)
{
- int size = (insn->opcode[i].unresolved
+ int size = (insn->opcode[i].unresolved
&& insn->opcode[i].r_type == BFD_RELOC_TIC54X_23) ? 4 : 2;
char *p = frag_more (size);
if (size == 2)
- md_number_to_chars (p, (valueT)insn->opcode[i].word, 2);
+ md_number_to_chars (p, (valueT) insn->opcode[i].word, 2);
else
- md_number_to_chars (p, (valueT)insn->opcode[i].word << 16, 4);
-
+ md_number_to_chars (p, (valueT) insn->opcode[i].word << 16, 4);
+
if (insn->opcode[i].unresolved)
fix_new_exp (frag_now, p - frag_now->fr_literal,
insn->opcode[i].r_nchars, &insn->opcode[i].addr_expr,
}
}
-/* Convert the operand strings into appropriate opcode values
+/* Convert the operand strings into appropriate opcode values
return the total number of words used by the instruction. */
static int
build_insn (insn)
- tic54x_insn *insn;
+ tic54x_insn *insn;
{
int i;
/* Only non-parallel instructions support lk addressing. */
if (insn->tm)
{
- for (i=0; i < insn->opcount; i++)
+ for (i = 0; i < insn->opcount; i++)
{
if ((OPTYPE (insn->operands[i].type) == OP_Smem ||
OPTYPE (insn->operands[i].type) == OP_Lmem ||
}
}
}
- insn->words =
+ insn->words =
(insn->tm ? insn->tm->words : insn->ptm->words) + insn->is_lkaddr;
insn->opcode[0].word = insn->tm ? insn->tm->opcode : insn->ptm->opcode;
if (insn->tm && (insn->tm->flags & FL_EXT))
- insn->opcode[1 + insn->is_lkaddr].word = insn->tm->opcode2;
+ insn->opcode[1 + insn->is_lkaddr].word = insn->tm->opcode2;
for (i=0; i < insn->opcount; i++)
{
static int
optimize_insn (insn)
- tic54x_insn *insn;
+ tic54x_insn *insn;
{
- /* Optimize some instructions, helping out the brain-dead programmer. */
+ /* Optimize some instructions, helping out the brain-dead programmer. */
#define is_zero(op) ((op).exp.X_op == O_constant && (op).exp.X_add_number == 0)
if (strcasecmp (insn->tm->name, "add") == 0)
{
is_accumulator (&insn->operands[insn->opcount-2]) &&
is_accumulator (&insn->operands[insn->opcount-1]) &&
strcasecmp (insn->operands[insn->opcount-2].buf,
- insn->operands[insn->opcount-1].buf) == 0)
+ insn->operands[insn->opcount-1].buf) == 0)
{
--insn->opcount;
insn->using_default_dst = 1;
return 1;
}
-
+
/* Try to collapse if Xmem and shift count is zero. */
if ((OPTYPE (insn->tm->operand_types[0]) == OP_Xmem &&
OPTYPE (insn->tm->operand_types[1]) == OP_SHFT &&
/* Or if Smem, shift is zero or absent, and SRC == DST. */
(OPTYPE (insn->tm->operand_types[0]) == OP_Smem &&
OPTYPE (insn->tm->operand_types[1]) == OP_SHIFT &&
- is_type (&insn->operands[1], OP_SHIFT) &&
+ is_type (&insn->operands[1], OP_SHIFT) &&
is_zero (insn->operands[1]) && insn->opcount == 3))
{
insn->operands[1] = insn->operands[2];
is_accumulator (&insn->operands[insn->opcount-2]) &&
is_accumulator (&insn->operands[insn->opcount-1]) &&
strcasecmp (insn->operands[insn->opcount-2].buf,
- insn->operands[insn->opcount-1].buf) == 0)
+ insn->operands[insn->opcount-1].buf) == 0)
{
--insn->opcount;
insn->using_default_dst = 1;
return 1;
}
-
+
if (((OPTYPE (insn->tm->operand_types[0]) == OP_Smem &&
OPTYPE (insn->tm->operand_types[1]) == OP_SHIFT) ||
(OPTYPE (insn->tm->operand_types[0]) == OP_Xmem &&
/* Find a matching template if possible, and get the operand strings. */
static int
tic54x_parse_insn (insn, line)
- tic54x_insn *insn;
- char *line;
+ tic54x_insn *insn;
+ char *line;
{
- insn->tm = (template *)hash_find (op_hash, insn->mnemonic);
+ insn->tm = (template *) hash_find (op_hash, insn->mnemonic);
if (!insn->tm)
{
as_bad (_("Unrecognized instruction \"%s\""), insn->mnemonic);
insn->opcount = get_operands (insn->operands, line);
if (insn->opcount < 0)
- return 0;
+ return 0;
/* Check each variation of operands for this mnemonic. */
while (insn->tm->name && strcasecmp (insn->tm->name, insn->mnemonic) == 0)
if (insn->opcount >= insn->tm->minops &&
insn->opcount <= insn->tm->maxops &&
operands_match (insn, &insn->operands[0], insn->opcount,
- insn->tm->operand_types,
+ insn->tm->operand_types,
insn->tm->minops, insn->tm->maxops))
{
/* SUCCESS! now try some optimizations. */
if (optimize_insn (insn))
{
- insn->tm = (template *)hash_find (op_hash,
- insn->mnemonic);
+ insn->tm = (template *) hash_find (op_hash,
+ insn->mnemonic);
continue;
}
}
++(insn->tm);
}
- as_bad (_("Unrecognized operand list '%s' for instruction '%s'"),
- line, insn->mnemonic);
+ as_bad (_("Unrecognized operand list '%s' for instruction '%s'"),
+ line, insn->mnemonic);
return 0;
}
Look for a subsequent line starting with "||". */
static int
next_line_shows_parallel (next_line)
- char *next_line;
+ char *next_line;
{
/* look for the second half */
while (isspace (*next_line))
static int
tic54x_parse_parallel_insn_firstline (insn, line)
- tic54x_insn *insn;
- char *line;
+ tic54x_insn *insn;
+ char *line;
{
- insn->ptm = (partemplate *)hash_find (parop_hash, insn->mnemonic);
+ insn->ptm = (partemplate *) hash_find (parop_hash, insn->mnemonic);
if (!insn->ptm)
{
- as_bad (_("Unrecognized parallel instruction \"%s\""),
+ as_bad (_("Unrecognized parallel instruction \"%s\""),
insn->mnemonic);
return 0;
}
while (insn->ptm->name && strcasecmp (insn->ptm->name,
- insn->mnemonic) == 0)
+ insn->mnemonic) == 0)
{
insn->opcount = get_operands (insn->operands, line);
if (insn->opcount < 0)
return 0;
- if (insn->opcount == 2 &&
+ if (insn->opcount == 2 &&
operands_match (insn, &insn->operands[0], insn->opcount,
insn->ptm->operand_types, 2, 2))
{
char *line;
{
int valid_mnemonic = 0;
-
+
insn->paropcount = get_operands (insn->paroperands, line);
while (insn->ptm->name && strcasecmp (insn->ptm->name,
insn->mnemonic) == 0)
valid_mnemonic = 1;
if (insn->paropcount >= insn->ptm->minops &&
insn->paropcount <= insn->ptm->maxops &&
- operands_match (insn, insn->paroperands,
+ operands_match (insn, insn->paroperands,
insn->paropcount,
insn->ptm->paroperand_types,
insn->ptm->minops, insn->ptm->maxops))
}
/* If quotes found, return copy of line up to closing quote;
- otherwise up until terminator
+ otherwise up until terminator
if it's a string, pass as-is; otherwise attempt substitution symbol
replacement on the value. */
static char *
(*str)[ptr - line] = 0;
/* Do simple substitution, if available. */
if (!nosub && (value = subsym_lookup (*str, macro_level)) != NULL)
- *str = value;
+ *str = value;
}
return endp;
{
int i;
- for (i=macro_level;i > 0;i--)
+ for (i = macro_level; i > 0; i--)
{
if (hash_find (subsym_hash[i], name))
{
hash_insert (subsym_hash[0], name, value);
}
-/* Look up the substitution string replacement for the given symbol
+/* Look up the substitution string replacement for the given symbol
start with the innermost macro substituion table given and work outwards. */
static char *
subsym_lookup (name, nest_level)
if (value || nest_level == 0)
return value;
- return subsym_lookup (name, nest_level-1);
+ return subsym_lookup (name, nest_level - 1);
}
/* Do substitution-symbol replacement on the given line (recursively).
- return the argument if no substitution was done
+ return the argument if no substitution was done
Also look for built-in functions ($func (arg)) and local labels.
/* Flag lines where we might need to replace a single '=' with two;
GAS uses single '=' to assign macro args values, and possibly other
places, so limit what we replace. */
- if (strstr (line, ".if")
- || strstr (line, ".elseif")
+ if (strstr (line, ".if")
+ || strstr (line, ".elseif")
|| strstr (line, ".break"))
{
line_conditional = 1;
/* Watch out for .eval, so that we avoid doing substitution on the
symbol being assigned a value. */
if (strstr (line, ".eval") || strstr (line, ".asg"))
- eval_line = 1;
+ eval_line = 1;
/* If it's a macro definition, don't do substitution on the argument names. */
if (strstr (line, ".macro"))
return line;
- while (!is_end_of_line[(int)*ptr])
+ while (!is_end_of_line[(int) *ptr])
{
int current_char = *ptr;
/* Need to update this since LINE may have been modified. */
if (eval_line)
- eval_end = strrchr (ptr, ',');
+ eval_end = strrchr (ptr, ',');
/* Replace triple double quotes with bounding quote/escapes. */
if (current_char == '"' && ptr[1] == '"' && ptr[2] == '"')
{
ptr[1] = '\\';
- tmp = strstr (ptr+2, "\"\"\"");
+ tmp = strstr (ptr + 2, "\"\"\"");
if (tmp)
tmp[0] = '\\';
changed = 1;
/* Replace a single '=' with a '==';
for compatibility with older code only. */
- if (line_conditional && current_char == '=')
+ if (line_conditional && current_char == '=')
{
if (ptr[1] == '=')
{
- ptr += 2;
+ ptr += 2;
continue;
}
*ptr++ = '\0';
int c;
char *value = NULL;
char *tail; /* rest of line after symbol */
-
+
/* Skip the colon. */
if (forced)
++ptr;
name = input_line_pointer = ptr;
c = get_symbol_end ();
/* '?' is not normally part of a symbol, but it IS part of a local
- label. */
+ label. */
if (c == '?')
{
*input_line_pointer++ = c;
value = subsym_lookup (name, macro_level);
else
as_warn (_("%s symbol recursion stopped at "
- "second appearance of '%s'"),
+ "second appearance of '%s'"),
forced ? "Forced substitution": "Substitution", name);
ptr = tail = input_line_pointer;
input_line_pointer = savedp;
/* Check for local labels; replace them with the appropriate
substitution. */
- if ((*name == '$' && isdigit (name[1]) && name[2] == '\0')
- || name[strlen (name)-1] == '?')
+ if ((*name == '$' && isdigit (name[1]) && name[2] == '\0')
+ || name[strlen (name) - 1] == '?')
{
/* Use an existing identifier for that label if, available, or
create a new, unique identifier. */
value = strcpy (xmalloc (strlen (name) + sizeof (digit) + 1),
name);
if (*value != '$')
- value[strlen (value)-1] = '\0';
+ value[strlen (value) - 1] = '\0';
sprintf (digit, ".%d", local_label_id++);
strcat (value, digit);
hash_insert (local_label_hash[macro_level], namecopy, value);
float arg1, arg2 = 0;
volatile float fresult;
- arg1 = (float)strtod (ptr, &ptr);
+ arg1 = (float) strtod (ptr, &ptr);
if (math_entry->nargs == 2)
{
if (*ptr++ != ',')
as_bad (_("Expecting second argument"));
break;
}
- arg2 = (float)strtod (ptr, &ptr);
+ arg2 = (float) strtod (ptr, &ptr);
}
- fresult = (*math_entry->proc)(arg1, arg2);
+ fresult = (*math_entry->proc) (arg1, arg2);
value = xmalloc (128);
if (math_entry->int_return)
- sprintf (value, "%d", (int)fresult);
+ sprintf (value, "%d", (int) fresult);
else
sprintf (value, "%f", fresult);
if (*ptr++ != ')')
}
/* Args checking. */
if ((!strcmp (entry->name, "$firstch")
- || !strcmp (entry->name, "$lastch"))
+ || !strcmp (entry->name, "$lastch"))
&& arg_type[1] != 2)
{
as_bad (_("Expecting character constant argument"));
as_bad (_("Extra junk in function call, expecting ')'"));
break;
}
- val = (*entry->proc)(arg1, arg2);
+ val = (*entry->proc) (arg1, arg2);
value = xmalloc (64);
sprintf (value, "%d", val);
}
}
/* Temporarily zero-terminate where the symbol started. */
- *name = 0;
+ *name = 0;
if (forced)
{
if (c == '(')
kinda indicates that forced substituion is not
supposed to be recursive, but I'm not sure. */
unsigned beg, len = 1; /* default to a single char */
- char *newval = strcpy (xmalloc (strlen (value)+1), value);
+ char *newval = strcpy (xmalloc (strlen (value) + 1), value);
savedp = input_line_pointer;
input_line_pointer = tail + 1;
beg = get_absolute_expression ();
if (beg < 1)
{
- as_bad (_("Invalid subscript (use 1 to %d)"),
+ as_bad (_("Invalid subscript (use 1 to %d)"),
strlen (value));
break;
}
if (beg + len > strlen (value))
{
as_bad (_("Invalid length (use 0 to %d"),
- strlen (value) - beg);
+ strlen (value) - beg);
break;
}
}
}
name[-1] = 0;
}
- tmp = xmalloc (strlen (head) + strlen (value) +
- strlen (tail+1) + 2);
+ tmp = xmalloc (strlen (head) + strlen (value) +
+ strlen (tail + 1) + 2);
strcpy (tmp, head);
strcat (tmp, value);
/* Make sure forced substitutions are properly terminated. */
}
++tail;
#if 0
- /* Try to replace required whitespace
+ /* Try to replace required whitespace
eliminated by the preprocessor; technically, a forced
substitution could come anywhere, even mid-symbol,
e.g. if x is "0", 'sym:x:end' should result in 'sym0end',
complete. */
if ((is_part_of_name (tail[1])
&& tail[1] != '.'
- && tail[1] != '$')
+ && tail[1] != '$')
|| tail[1] == '\0' || tail[1] == ',' || tail[1] == '"')
++tail;
else
return line;
}
-/* We use this to handle substitution symbols
+/* We use this to handle substitution symbols
hijack input_line_pointer, replacing it with our substituted string.
.sslist should enable listing the line after replacements are made...
/* Work with a copy of the input line, including EOL char. */
endp = input_line_pointer;
- while (!is_end_of_line[(int)*endp++])
+ while (!is_end_of_line[(int) *endp++])
;
line = xmalloc (endp - input_line_pointer + 1);
strncpy (line, input_line_pointer, endp - input_line_pointer + 1);
{
char *tmp = replacement;
char *comment = strchr (replacement,';');
- char endc = replacement[strlen (replacement)-1];
+ char endc = replacement[strlen (replacement) - 1];
/* Clean up the replacement; we'd prefer to have this done by the
standard preprocessing equipment (maybe do_scrub_chars?)
comment[1] = 0;
--comment;
}
- else
+ else
comment = replacement + strlen (replacement) - 1;
/* Trim trailing whitespace. */
the frags/bytes it assembles to. */
void
md_assemble (line)
- char *line;
+ char *line;
{
static int repeat_slot = 0;
static int delay_slots = 0; /* how many delay slots left to fill? */
if (words > delay_slots)
{
as_bad (_("Instruction does not fit in available delay "
- "slots (%d-word insn, %d slots left)"),
- words, delay_slots);
+ "slots (%d-word insn, %d slots left)"),
+ words, delay_slots);
delay_slots = 0;
return;
}
lptr = input_line_pointer;
*lptr = c;
input_line_pointer = savedp;
-
+
/* See if this line is part of a parallel instruction; if so, either this
line or the next line will have the "||" specifier preceding the
mnemonic, and we look for it in the parallel insn hash table. */
{
while (isspace (tmp[2]))
++tmp;
- md_assemble (tmp+2);
+ md_assemble (tmp + 2);
}
}
else
{
int words;
- if ((insn.tm->flags & FL_LP)
+ if ((insn.tm->flags & FL_LP)
&& cpu != V545LP && cpu != V546LP)
{
as_bad (_("Instruction '%s' requires an LP cpu version"),
insn.tm->name);
return;
}
- if ((insn.tm->flags & FL_FAR)
+ if ((insn.tm->flags & FL_FAR)
&& amode != far_mode)
{
as_bad (_("Instruction '%s' requires far mode addressing"),
{
as_warn (_("Instruction does not fit in available delay "
"slots (%d-word insn, %d slots left). "
- "Resulting behavior is undefined."),
+ "Resulting behavior is undefined."),
words, delay_slots);
delay_slots = 0;
return;
}
delay_slots -= words;
}
-
+
/* Is this instruction the target of a repeat? */
if (repeat_slot)
{
if (insn.tm->flags & FL_NR)
as_warn (_("'%s' is not repeatable. "
- "Resulting behavior is undefined."),
+ "Resulting behavior is undefined."),
insn.tm->name);
else if (insn.is_lkaddr)
as_warn (_("Instructions using long offset modifiers or absolute "
"Resulting behavior is undefined."));
repeat_slot = 0;
}
-
+
/* Make sure we check the target of a repeat instruction. */
if (insn.tm->flags & B_REPEAT)
{
}
/* In order to get gas to ignore any | chars at the start of a line,
- this function returns true if a | is found in a line.
+ this function returns true if a | is found in a line.
This lets us process parallel instructions, which span two lines. */
int
tic54x_unrecognized_line (int c)
tic54x_define_label (sym)
symbolS *sym;
{
- /*static int local_label_count = 0;*/
- /*const char *name = S_GET_NAME (sym);*/
+#if 0
+ static int local_label_count = 0;
+ const char *name = S_GET_NAME (sym);
+#endif
/* Just in case we need this later; note that this is not necessarily the
- same thing as line_label...
+ same thing as line_label...
When aligning or assigning labels to fields, sometimes the label is
assigned other than the address at which the label appears.
FIXME -- is this really needed? I think all the proper label assignment
symbol *sym;
/* Not sure how to handle predefined symbols. */
- if ((sym = (symbol *)hash_find (cc_hash, name)) != NULL ||
- (sym = (symbol *)hash_find (cc2_hash, name)) != NULL ||
- (sym = (symbol *)hash_find (cc3_hash, name)) != NULL ||
- (sym = (symbol *)hash_find (misc_symbol_hash, name)) != NULL ||
- (sym = (symbol *)hash_find (sbit_hash, name)) != NULL)
+ if ((sym = (symbol *) hash_find (cc_hash, name)) != NULL ||
+ (sym = (symbol *) hash_find (cc2_hash, name)) != NULL ||
+ (sym = (symbol *) hash_find (cc3_hash, name)) != NULL ||
+ (sym = (symbol *) hash_find (misc_symbol_hash, name)) != NULL ||
+ (sym = (symbol *) hash_find (sbit_hash, name)) != NULL)
{
- return symbol_new (name, reg_section,
+ return symbol_new (name, reg_section,
(valueT) sym->value,
&zero_address_frag);
}
- if ((sym = (symbol *)hash_find (reg_hash, name)) != NULL ||
- (sym = (symbol *)hash_find (mmreg_hash, name)) != NULL ||
+ if ((sym = (symbol *) hash_find (reg_hash, name)) != NULL ||
+ (sym = (symbol *) hash_find (mmreg_hash, name)) != NULL ||
!strcasecmp (name, "a") || !strcasecmp (name, "b"))
{
- return symbol_new (name, reg_section,
+ return symbol_new (name, reg_section,
(valueT) sym ? sym->value : 0,
&zero_address_frag);
}
expressionS *exp ATTRIBUTE_UNUSED;
{
#if 0
- symbol *sym = (symbol *)hash_find (mmreg_hash, name);
+ symbol *sym = (symbol *) hash_find (mmreg_hash, name);
+
/* If it's a MMREG, replace it with its constant value. */
if (sym)
{
input_line_pointer = t;
*sizeP = 4;
- /* Target data is little-endian, but floats are stored big-"word"ian. ugh. */
+ /* Target data is little-endian, but floats are stored
+ big-"word"ian. ugh. */
for (word = words; prec--;)
{
- md_number_to_chars (literalP, (long)(*word++), sizeof (LITTLENUM_TYPE));
+ md_number_to_chars (literalP, (long) (*word++), sizeof (LITTLENUM_TYPE));
literalP += sizeof (LITTLENUM_TYPE);
}
asymbol *sym = symbol_get_bfdsym (fixP->fx_addsy);
rel = (arelent *) xmalloc (sizeof (arelent));
- rel->sym_ptr_ptr = (asymbol **)xmalloc (sizeof (asymbol *));
+ rel->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
*rel->sym_ptr_ptr = sym;
/* We assume that all rel->address are host byte offsets */
rel->address = fixP->fx_frag->fr_address + fixP->fx_where;
const char *name = S_GET_NAME (fixP->fx_addsy);
if (name == NULL)
name = "<unknown>";
- as_fatal ("Cannot generate relocation type for symbol %s, code %s",
+ as_fatal ("Cannot generate relocation type for symbol %s, code %s",
name, bfd_get_reloc_code_name (code));
return NULL;
}
if (emitting_long)
r = BFD_RELOC_TIC54X_23;
else
- /* We never want to directly generate this; this is provided for
+ /* We never want to directly generate this; this is provided for
stabs support only. */
r = BFD_RELOC_32;
break;
fix_new_exp (frag, where, octets, exp, 0, r);
}
-/* Attempt to simplify or even eliminate a fixup.
+/* Attempt to simplify or even eliminate a fixup.
To indicate that a fixup has been eliminated, set fixP->fx_done.
If fixp->fx_addsy is non-NULL, we'll have to generate a reloc entry. */
break;
case BFD_RELOC_TIC54X_PARTMS9:
/* TI assembler doesn't shift its encoding for relocatable files, and is
- thus incompatible with this implementation's relocatable files. */
- bfd_put_16 (stdoutput,
- (bfd_get_16 (stdoutput, buf) & 0xFE00) | (val >> 7),
+ thus incompatible with this implementation's relocatable files. */
+ bfd_put_16 (stdoutput,
+ (bfd_get_16 (stdoutput, buf) & 0xFE00) | (val >> 7),
buf);
break;
case BFD_RELOC_32:
return 0; /* Return value is ignored. */
}
-/* This is our chance to record section alignment
+/* This is our chance to record section alignment
don't need to do anything here, since BFD does the proper encoding. */
valueT
md_section_align (segment, section_size)
number_to_chars_littleendian (buf, val, n);
else
{
- number_to_chars_littleendian (buf, val>>16, 2);
- number_to_chars_littleendian (buf+2, val&0xFFFF, 2);
+ number_to_chars_littleendian (buf , val >> 16 , 2);
+ number_to_chars_littleendian (buf + 2, val & 0xFFFF, 2);
}
}
-int
+int
tic54x_estimate_size_before_relax (frag, seg)
fragS *frag ATTRIBUTE_UNUSED;
segT seg ATTRIBUTE_UNUSED;
/* We use this to handle bit allocations which we couldn't handle before due
to symbols being in different frags. return number of octets added. */
-int
+int
tic54x_relax_frag (frag, stretch)
- fragS *frag;
- long stretch ATTRIBUTE_UNUSED;
+ fragS *frag;
+ long stretch ATTRIBUTE_UNUSED;
{
symbolS *sym = frag->fr_symbol;
int growth = 0;
if (sym != NULL)
{
- struct bit_info *bi = (struct bit_info *)frag->fr_opcode;
+ struct bit_info *bi = (struct bit_info *) frag->fr_opcode;
int bit_offset = frag_bit_offset (frag_prev (frag, bi->seg), bi->seg);
int size = S_GET_VALUE (sym);
fragS *prev_frag = bit_offset_frag (frag_prev (frag, bi->seg), bi->seg);
char *p = prev_frag->fr_literal;
valueT value = bi->value;
value <<= available - size;
- value |= ((unsigned short)p[1]<<8) | p[0];
+ value |= ((unsigned short) p[1]<<8) | p[0];
md_number_to_chars (p, value, 2);
if ((prev_frag->tc_frag_data += size) == 16)
prev_frag->tc_frag_data = 0;
getout:
frag->fr_symbol = 0;
frag->fr_opcode = 0;
- free ((void *)bi);
+ free ((void *) bi);
}
return growth;
}
void
tic54x_convert_frag (abfd, seg, frag)
- bfd *abfd ATTRIBUTE_UNUSED;
- segT seg ATTRIBUTE_UNUSED;
- fragS *frag;
+ bfd *abfd ATTRIBUTE_UNUSED;
+ segT seg ATTRIBUTE_UNUSED;
+ fragS *frag;
{
/* Offset is in bytes. */
- frag->fr_offset = (frag->fr_next->fr_address
+ frag->fr_offset = (frag->fr_next->fr_address
- frag->fr_address
- frag->fr_fix) / frag->fr_var;
if (frag->fr_offset < 0)
I guess, except I've never seen a definition of MRI syntax).
C is the character that used to be at *REST, which points to the end of the
- label.
+ label.
Don't allow labels to start with '.' */
int
tic54x_start_label (c, rest)
- int c;
- char *rest;
+ int c;
+ char *rest;
{
/* If within .struct/.union, no auto line labels, please. */
if (current_stag != NULL)
if (c != ':')
{
char *label = rest;
- while (!is_end_of_line[(int)label[-1]])
+ while (!is_end_of_line[(int) label[-1]])
--label;
if (*label == '.')
{
}
}
- if (is_end_of_line[(int)c])
+ if (is_end_of_line[(int) c])
return 1;
if (isspace (c))