We don't convert '' to '\0'
We don't allow strings with .byte/.half/.short/.long
Probably details of the subsym stuff are different
- TI sets labels to be data type 4 (T_INT); GAS uses T_NULL. */
+ TI sets labels to be data type 4 (T_INT); GAS uses T_NULL.
+
+ COFF1 limits section names to 8 characters.
+ Some of the default behavior changed from COFF1 to COFF2.
+*/
#include <stdlib.h>
#include <limits.h>
#include <errno.h>
#include "as.h"
+#include "safe-ctype.h"
#include "sb.h"
#include "macro.h"
#include "subsegs.h"
/* Output a single character (upper octect is zero). */
static void
-tic54x_emit_char (c)
- char c;
+tic54x_emit_char (char c)
{
expressionS exp;
/* Walk backwards in the frag chain. */
static fragS *
-frag_prev (frag, seg)
- fragS *frag;
- segT seg;
+frag_prev (fragS *frag, segT seg)
{
segment_info_type *seginfo = seg_info (seg);
fragS *fragp;
}
static fragS *
-bit_offset_frag (frag, seg)
- fragS *frag;
- segT seg;
+bit_offset_frag (fragS *frag, segT seg)
{
while (frag != NULL)
{
none. .field/.space/.bes may leave words partially allocated. */
static int
-frag_bit_offset (frag, seg)
- fragS *frag;
- segT seg;
+frag_bit_offset (fragS *frag, segT seg)
{
frag = bit_offset_frag (frag, seg);
unsupported. */
static void
-tic54x_asg (x)
- int x ATTRIBUTE_UNUSED;
+tic54x_asg (int x ATTRIBUTE_UNUSED)
{
int c;
char *name;
name = ++input_line_pointer;
c = get_symbol_end (); /* Get terminator. */
- if (!isalpha (*name))
+ if (!ISALPHA (*name))
{
as_bad ("symbols assigned with .asg must begin with a letter");
ignore_rest_of_line ();
table, since that's what works best. */
static void
-tic54x_eval (x)
- int x ATTRIBUTE_UNUSED;
+tic54x_eval (int x ATTRIBUTE_UNUSED)
{
char c;
int value;
name = strcpy (tmp, name);
*input_line_pointer = c;
- if (!isalpha (*name))
+ if (!ISALPHA (*name))
{
as_bad (_("symbols assigned with .eval must begin with a letter"));
ignore_rest_of_line ();
(not yet implemented). */
static void
-tic54x_bss (x)
- int x ATTRIBUTE_UNUSED;
+tic54x_bss (int x ATTRIBUTE_UNUSED)
{
char c;
char *name;
symbol_set_frag (symbolP, frag_now);
p = frag_var (rs_org, 1, 1, (relax_substateT) 0, symbolP,
- (offsetT) (words << 1), (char *) 0);
+ (offsetT) (words * OCTETS_PER_BYTE), (char *) 0);
*p = 0; /* Fill char. */
S_SET_SEGMENT (symbolP, bss_section);
}
static void
-stag_add_field_symbols (stag, path, base_offset, rootsym, root_stag_name)
- struct stag *stag;
- const char *path;
- bfd_vma base_offset;
- symbolS *rootsym;
- const char *root_stag_name;
+stag_add_field_symbols (struct stag *stag,
+ const char *path,
+ bfd_vma base_offset,
+ symbolS *rootsym,
+ const char *root_stag_name)
{
char prefix[strlen (path) + 2];
struct stag_field *field = stag->field;
complete dereferencing symbols to the symbol table. */
static void
-stag_add_field (parent, name, offset, stag)
- struct stag *parent;
- const char *name;
- bfd_vma offset;
- struct stag *stag;
+stag_add_field (struct stag *parent,
+ const char *name,
+ bfd_vma offset,
+ struct stag *stag)
{
struct stag_field *sfield = xmalloc (sizeof (struct stag_field));
format on the existing allocated space. */
static void
-tic54x_tag (ignore)
- int ignore ATTRIBUTE_UNUSED;
+tic54x_tag (int ignore ATTRIBUTE_UNUSED)
{
char *name = input_line_pointer;
int c = get_symbol_end ();
these, so we ignore the type here. */
void
-tic54x_global (type)
- int type;
+tic54x_global (int type)
{
char *name;
int c;
/* Remove the symbol from the local label hash lookup. */
static void
-tic54x_remove_local_label (key, value)
- const char *key;
- PTR value ATTRIBUTE_UNUSED;
+tic54x_remove_local_label (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
-tic54x_clear_local_labels (ignored)
- int ignored ATTRIBUTE_UNUSED;
+tic54x_clear_local_labels (int ignored ATTRIBUTE_UNUSED)
{
hash_traverse (local_label_hash[macro_level], tic54x_remove_local_label);
}
ARG is 't' for text, 'd' for data, or '*' for a named section
- For compatibility, '*' sections have SEC_DATA set instead of SEC_CODE. */
+ For compatibility, '*' sections are SEC_CODE if instructions are
+ encountered, or SEC_DATA if not.
+*/
static void
tic54x_sect (int arg)
int c;
name = input_line_pointer;
c = get_symbol_end ();
+ len = strlen(name);
name = strcpy (xmalloc (len + 10), name);
*input_line_pointer = c;
demand_empty_rest_of_line ();
}
- /* Make sure all named initialized sections are SEC_DATA. */
+ /* Make sure all named initialized sections flagged properly. If we
+ encounter instructions, we'll flag it with SEC_CODE as well. */
strcat (name, ",\"w\"\n");
input_scrub_insert_line (name);
obj_coff_section (0);
Has no effect on the current section. */
static void
-tic54x_usect (x)
- int x ATTRIBUTE_UNUSED;
+tic54x_usect (int x ATTRIBUTE_UNUSED)
{
char c;
char *name;
}
static enum cpu_version
-lookup_version (ver)
- const char *ver;
+lookup_version (const char *ver)
{
enum cpu_version version = VNONE;
|| ver[2] == '5' || ver[2] == '8' || ver[2] == '9'))
version = ver[2] - '0';
else if (strlen (ver) == 5
- && toupper (ver[3]) == 'L'
- && toupper (ver[4]) == 'P'
+ && TOUPPER (ver[3]) == 'L'
+ && TOUPPER (ver[4]) == 'P'
&& (ver[2] == '5' || ver[2] == '6'))
version = ver[2] - '0' + 10;
}
}
static void
-set_cpu (version)
- enum cpu_version version;
+set_cpu (enum cpu_version version)
{
cpu = version;
if (version == V545LP || version == V546LP)
static int cpu_needs_set = 1;
static void
-tic54x_version (x)
- int x ATTRIBUTE_UNUSED;
+tic54x_version (int x ATTRIBUTE_UNUSED)
{
enum cpu_version version = VNONE;
enum cpu_version old_version = cpu;
/* 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
+ Code copied from stringer, and slightly modified so that strings are packed
and encoded into the correct octets. */
static void
-tic54x_stringer (type)
- int type;
+tic54x_stringer (int type)
{
register unsigned int c;
char *start;
}
static void
-tic54x_p2align (arg)
- int arg ATTRIBUTE_UNUSED;
+tic54x_p2align (int arg ATTRIBUTE_UNUSED)
{
as_bad (_("p2align not supported on this target"));
}
static void
-tic54x_align_words (arg)
- int arg;
+tic54x_align_words (int arg)
{
/* Only ".align" with no argument is allowed within .struct/.union. */
int count = arg;
/* Initialize multiple-bit fields withing a single word of memory. */
static void
-tic54x_field (ignore)
- int ignore ATTRIBUTE_UNUSED;
+tic54x_field (int ignore ATTRIBUTE_UNUSED)
{
expressionS exp;
int size = 16;
available yet. seg_info ()->bss is the next best thing. */
static int
-tic54x_initialized_section (seg)
- segT seg;
+tic54x_initialized_section (segT seg)
{
return !seg_info (seg)->bss;
}
Name is required for uninitialized sections. */
static void
-tic54x_clink (ignored)
- int ignored ATTRIBUTE_UNUSED;
+tic54x_clink (int ignored ATTRIBUTE_UNUSED)
{
segT seg = now_seg;
set to "." instead. */
static void
-tic54x_set_default_include (dot)
- int dot;
+tic54x_set_default_include (int dot)
{
char *dir = ".";
char *tmp = NULL;
Entering/exiting included/copied file clears all local labels. */
static void
-tic54x_include (ignored)
- int ignored ATTRIBUTE_UNUSED;
+tic54x_include (int ignored ATTRIBUTE_UNUSED)
{
char newblock[] = " .newblock\n";
char *filename;
}
static void
-tic54x_message (type)
- int type;
+tic54x_message (int type)
{
char *msg;
char c;
run address (vma). */
static void
-tic54x_label (ignored)
- int ignored ATTRIBUTE_UNUSED;
+tic54x_label (int ignored ATTRIBUTE_UNUSED)
{
char *name = input_line_pointer;
symbolS *symbolP;
absolute local symbols. */
static void
-tic54x_mmregs (ignored)
- int ignored ATTRIBUTE_UNUSED;
+tic54x_mmregs (int ignored ATTRIBUTE_UNUSED)
{
symbol *sym;
/* Normally, endloop gets eaten by the preceding loop. */
static void
-tic54x_endloop (ignore)
- int ignore ATTRIBUTE_UNUSED;
+tic54x_endloop (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;
+tic54x_break (int ignore ATTRIBUTE_UNUSED)
{
int cond = 1;
}
static void
-set_address_mode (mode)
- int mode;
+set_address_mode (int mode)
{
amode = mode;
if (mode == far_mode)
static int address_mode_needs_set = 1;
static void
-tic54x_address_mode (mode)
- int mode;
+tic54x_address_mode (int mode)
{
if (assembly_begun && amode != (unsigned) mode)
{
Designate initialized sections for blocking. */
static void
-tic54x_sblock (ignore)
- int ignore ATTRIBUTE_UNUSED;
+tic54x_sblock (int ignore ATTRIBUTE_UNUSED)
{
int c = ',';
symbols assigned with .set/.equ may not be redefined. */
static void
-tic54x_set (ignore)
- int ignore ATTRIBUTE_UNUSED;
+tic54x_set (int ignore ATTRIBUTE_UNUSED)
{
symbolS *symbolP;
char *name;
Define a substitution string to be local to a macro. */
static void
-tic54x_var (ignore)
- int ignore ATTRIBUTE_UNUSED;
+tic54x_var (int ignore ATTRIBUTE_UNUSED)
{
static char empty[] = "";
char *name;
}
do
{
- if (!isalpha (*input_line_pointer))
+ if (!ISALPHA (*input_line_pointer))
{
as_bad (_("Substitution symbols must begin with a letter"));
ignore_rest_of_line ();
FIXME need to try the source file directory as well. */
static void
-tic54x_mlib (ignore)
- int ignore ATTRIBUTE_UNUSED;
+tic54x_mlib (int ignore ATTRIBUTE_UNUSED)
{
char *filename;
char *path;
SKIP_WHITESPACE ();
len = 0;
while (!is_end_of_line[(int) *input_line_pointer]
- && !isspace (*input_line_pointer))
+ && !ISSPACE (*input_line_pointer))
{
obstack_1grow (¬es, *input_line_pointer);
++input_line_pointer;
{
{ "algebraic", s_ignore , 0 },
{ "align" , tic54x_align_words , 128 },
+ { "ascii" , tic54x_stringer , 'p' },
+ { "asciz" , tic54x_stringer , 'P' },
{ "even" , tic54x_align_words , 2 },
{ "asg" , tic54x_asg , 0 },
{ "eval" , tic54x_eval , 0 },
}
static int
-subsym_symlen (a, ignore)
- char *a;
- char *ignore ATTRIBUTE_UNUSED;
+subsym_symlen (char *a, char *ignore ATTRIBUTE_UNUSED)
{
return strlen (a);
}
/* Compare symbol A to string B. */
static int
-subsym_symcmp (a, b)
- char *a;
- char *b;
+subsym_symcmp (char *a, char *b)
{
return strcmp (a, b);
}
assumes b is an integer char value as a string. Index is one-based. */
static int
-subsym_firstch (a, b)
- char *a;
- char *b;
+subsym_firstch (char *a, char *b)
{
int val = atoi (b);
char *tmp = strchr (a, val);
/* Similar to firstch, but returns index of last occurrence of B in A. */
static int
-subsym_lastch (a, b)
- char *a;
- char *b;
+subsym_lastch (char *a, char *b)
{
int val = atoi (b);
char *tmp = strrchr (a, val);
symbol table). */
static int
-subsym_isdefed (a, ignore)
- char *a;
- char *ignore ATTRIBUTE_UNUSED;
+subsym_isdefed (char *a, char *ignore ATTRIBUTE_UNUSED)
{
symbolS *symbolP = symbol_find (a);
symbols, unsubstituted. */
static int
-subsym_ismember (sym, list)
- char *sym;
- char *list;
+subsym_ismember (char *sym, char *list)
{
char *elem, *ptr, *listv;
5 if decimal. */
static int
-subsym_iscons (a, ignore)
- char *a;
- char *ignore ATTRIBUTE_UNUSED;
+subsym_iscons (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;
/* No suffix; either octal, hex, or decimal. */
if (*a == '0' && len > 1)
{
- if (toupper (a[1]) == 'X')
+ if (TOUPPER (a[1]) == 'X')
return 3;
return 2;
}
/* Return 1 if A is a valid symbol name. Expects string input. */
static int
-subsym_isname (a, ignore)
- char *a;
- char *ignore ATTRIBUTE_UNUSED;
+subsym_isname (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;
+subsym_isreg (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;
+subsym_structsz (char *name, char *ignore ATTRIBUTE_UNUSED)
{
struct stag *stag = (struct stag *) hash_find (stag_hash, name);
if (stag)
return zero, we punt and return zero. */
static int
-subsym_structacc (stag_name, ignore)
- char *stag_name ATTRIBUTE_UNUSED;
- char *ignore ATTRIBUTE_UNUSED;
+subsym_structacc (char *stag_name ATTRIBUTE_UNUSED,
+ char *ignore ATTRIBUTE_UNUSED)
{
return 0;
}
void
md_begin ()
{
- template *opcode;
- partemplate *paropcode;
+ template *tm;
symbol *sym;
const subsym_proc_entry *subsym_proc;
const math_proc_entry *math_proc;
}
op_hash = hash_new ();
- for (opcode = (template *) tic54x_optab; opcode->name; opcode++)
+ for (tm = (template *) tic54x_optab; tm->name; tm++)
{
- if (hash_find (op_hash, opcode->name))
+ if (hash_find (op_hash, tm->name))
continue;
- hash_err = hash_insert (op_hash, opcode->name, (char *) opcode);
+ hash_err = hash_insert (op_hash, tm->name, (char *) tm);
if (hash_err)
as_fatal ("Internal Error: Can't hash %s: %s",
- opcode->name, hash_err);
+ tm->name, hash_err);
}
parop_hash = hash_new ();
- for (paropcode = (partemplate *) tic54x_paroptab;
- paropcode->name;
- paropcode++)
+ for (tm = (template *) tic54x_paroptab; tm->name; tm++)
{
- if (hash_find (parop_hash, paropcode->name))
+ if (hash_find (parop_hash, tm->name))
continue;
- hash_err = hash_insert (parop_hash, paropcode->name, (char *) paropcode);
+ hash_err = hash_insert (parop_hash, tm->name, (char *) tm);
if (hash_err)
as_fatal ("Internal Error: Can't hash %s: %s",
- paropcode->name, hash_err);
+ tm->name, hash_err);
}
reg_hash = hash_new ();
for (sym = (symbol *) regs; sym->name; sym++)
typedef struct _tic54x_insn
{
const template *tm; /* Opcode template. */
- const partemplate *ptm; /* Parallel opcode template. */
char mnemonic[MAX_LINE]; /* Opcode name/mnemonic. */
char parmnemonic[MAX_LINE]; /* 2nd mnemonic of parallel insn. */
static int operands_match (tic54x_insn *, struct opstruct *, int,
const enum optype *, int, int);
static int encode_address (tic54x_insn *, struct opstruct *);
+static int is_accumulator (struct opstruct *);
static int
-is_accumulator (operand)
- struct opstruct *operand;
+is_accumulator (struct opstruct *operand)
{
return strcasecmp (operand->buf, "a") == 0
|| strcasecmp (operand->buf, "b") == 0;
the next array. */
static int
-get_operands (operands, line)
- struct opstruct operands[];
- char *line;
+get_operands (struct opstruct operands[], char *line)
{
char *lptr = line;
int numexp = 0;
{
int paren_not_balanced = 0;
char *op_start, *op_end;
- while (*lptr && isspace (*lptr))
+ while (*lptr && ISSPACE (*lptr))
++lptr;
op_start = lptr;
while (paren_not_balanced || *lptr != ',')
/* 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;
}
}
- while (*lptr && isspace (*lptr++))
+ while (*lptr && ISSPACE (*lptr++))
;
if (!is_end_of_line[(int) *lptr])
{
/* Predicates for different operand types. */
static int
-is_immediate (operand)
- struct opstruct *operand;
+is_immediate (struct opstruct *operand)
{
return *operand->buf == '#';
}
and must *not* have the '#' prefix. */
static int
-is_absolute (operand)
- struct opstruct *operand;
+is_absolute (struct opstruct *operand)
{
return operand->exp.X_op == O_constant && !is_immediate (operand);
}
/* Is this an indirect operand? */
static int
-is_indirect (operand)
- struct opstruct *operand;
+is_indirect (struct opstruct *operand)
{
return operand->buf[0] == '*';
}
/* Is this a valid dual-memory operand? */
static int
-is_dual (operand)
- struct opstruct *operand;
+is_dual (struct opstruct *operand)
{
if (is_indirect (operand) && strncasecmp (operand->buf, "*ar", 3) == 0)
{
}
static int
-is_mmreg (operand)
- struct opstruct *operand;
+is_mmreg (struct opstruct *operand)
{
return (is_absolute (operand)
|| is_immediate (operand)
}
static int
-is_type (operand, type)
- struct opstruct *operand;
- enum optype type;
+is_type (struct opstruct *operand, enum optype type)
{
switch (type)
{
case OP_DST:
return is_accumulator (operand);
case OP_B:
- return is_accumulator (operand) && toupper (operand->buf[0]) == 'B';
+ return is_accumulator (operand) && TOUPPER (operand->buf[0]) == 'B';
case OP_A:
- return is_accumulator (operand) && toupper (operand->buf[0]) == 'A';
+ return is_accumulator (operand) && TOUPPER (operand->buf[0]) == 'A';
case OP_ARX:
return strncasecmp ("ar", operand->buf, 2) == 0
- && isdigit (operand->buf[2]);
+ && ISDIGIT (operand->buf[2]);
case OP_SBIT:
return hash_find (sbit_hash, operand->buf) != 0 || is_absolute (operand);
case OP_CC:
}
static int
-encode_indirect (insn, operand)
- tic54x_insn *insn;
- struct opstruct *operand;
+encode_indirect (tic54x_insn *insn, struct opstruct *operand)
{
int arf;
int mod;
if (insn->is_lkaddr)
{
/* lk addresses always go in the second insn word. */
- mod = ((toupper (operand->buf[1]) == 'A') ? 12 :
+ mod = ((TOUPPER (operand->buf[1]) == 'A') ? 12 :
(operand->buf[1] == '(') ? 15 :
(strchr (operand->buf, '%') != NULL) ? 14 : 13);
arf = ((mod == 12) ? operand->buf[3] - '0' :
}
else
{
- arf = (toupper (operand->buf[1]) == 'A' ?
+ arf = (TOUPPER (operand->buf[1]) == 'A' ?
operand->buf[3] : operand->buf[4]) - '0';
if (operand->buf[1] == '+')
else
mod = (operand->buf[4] == '-' ? 8 : 10);/* *ARx+% / *ARx-% */
}
- else if (toupper (operand->buf[6]) == 'B')
+ else if (TOUPPER (operand->buf[6]) == 'B')
mod = (operand->buf[4] == '-' ? 4 : 7); /* ARx+0B / *ARx-0B */
- else if (toupper (operand->buf[6]) == '%')
+ else if (TOUPPER (operand->buf[6]) == '%')
mod = (operand->buf[4] == '-' ? 9 : 11); /* ARx+0% / *ARx - 0% */
else
{
}
static int
-encode_integer (insn, operand, which, min, max, mask)
- tic54x_insn *insn;
- struct opstruct *operand;
- int which, min, max;
- unsigned short mask;
+encode_integer (tic54x_insn *insn,
+ struct opstruct *operand,
+ int which, int min, int max, unsigned short mask)
{
long parse, integer;
}
static int
-encode_condition (insn, operand)
- tic54x_insn *insn;
- struct opstruct *operand;
+encode_condition (tic54x_insn *insn, struct opstruct *operand)
{
symbol *cc = (symbol *) hash_find (cc_hash, operand->buf);
if (!cc)
}
static int
-encode_cc3 (insn, operand)
- tic54x_insn *insn;
- struct opstruct *operand;
+encode_cc3 (tic54x_insn *insn, struct opstruct *operand)
{
symbol *cc3 = (symbol *) hash_find (cc3_hash, operand->buf);
int value = cc3 ? cc3->value : operand->exp.X_add_number << 8;
}
static int
-encode_arx (insn, operand)
- tic54x_insn *insn;
- struct opstruct *operand;
+encode_arx (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;
+encode_cc2 (tic54x_insn *insn, struct opstruct *operand)
{
symbol *cc2 = (symbol *) hash_find (cc2_hash, operand->buf);
if (!cc2)
enum optype type;
struct opstruct *operand;
{
- int ext = insn->tm && ((insn->tm->flags & FL_EXT) != 0);
+ int ext = (insn->tm->flags & FL_EXT) != 0;
if (type == OP_MMR && operand->exp.X_op != O_constant)
{
/* 16-bit immediate value. */
return encode_dmad (insn, operand, 0);
case OP_SRC:
- if (toupper (*operand->buf) == 'B')
+ if (TOUPPER (*operand->buf) == 'B')
{
insn->opcode[ext ? (1 + insn->is_lkaddr) : 0].word |= (1 << 9);
if (insn->using_default_dst)
return 1;
case OP_RND:
/* Make sure this agrees with with the OP_DST operand. */
- if (!((toupper (operand->buf[0]) == 'B') ^
+ if (!((TOUPPER (operand->buf[0]) == 'B') ^
((insn->opcode[0].word & (1 << 8)) != 0)))
{
as_bad (_("Destination accumulator for each part of this parallel "
return 1;
case OP_SRC1:
case OP_DST:
- if (toupper (operand->buf[0]) == 'B')
+ if (TOUPPER (operand->buf[0]) == 'B')
insn->opcode[ext ? (1 + insn->is_lkaddr) : 0].word |= (1 << 8);
return 1;
case OP_Xmem:
}
static void
-emit_insn (insn)
- tic54x_insn *insn;
+emit_insn (tic54x_insn *insn)
{
int i;
+ flagword oldflags = bfd_get_section_flags (stdoutput, now_seg);
+ flagword flags = oldflags | SEC_CODE;
+
+ if (! bfd_set_section_flags (stdoutput, now_seg, flags))
+ as_warn (_("error setting flags for \"%s\": %s"),
+ bfd_section_name (stdoutput, now_seg),
+ bfd_errmsg (bfd_get_error ()));
for (i = 0; i < insn->words; i++)
{
return the total number of words used by the instruction. */
static int
-build_insn (insn)
- tic54x_insn *insn;
+build_insn (tic54x_insn *insn)
{
int i;
/* Only non-parallel instructions support lk addressing. */
- if (insn->tm)
+ if (!(insn->tm->flags & FL_PAR))
{
for (i = 0; i < insn->opcount; i++)
{
}
}
}
- insn->words =
- (insn->tm ? insn->tm->words : insn->ptm->words) + insn->is_lkaddr;
+ insn->words = insn->tm->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[0].word = insn->tm->opcode;
+ if (insn->tm->flags & FL_EXT)
insn->opcode[1 + insn->is_lkaddr].word = insn->tm->opcode2;
for (i = 0; i < insn->opcount; i++)
if (!encode_operand (insn, type, &insn->operands[i]))
return 0;
}
- if (insn->ptm)
+ if (insn->tm->flags & FL_PAR)
for (i = 0; i < insn->paropcount; i++)
{
enum optype partype = insn->paroperands[i].type;
}
static int
-optimize_insn (insn)
- tic54x_insn *insn;
+optimize_insn (tic54x_insn *insn)
{
/* 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)
/* Find a matching template if possible, and get the operand strings. */
static int
-tic54x_parse_insn (insn, line)
- tic54x_insn *insn;
- char *line;
+tic54x_parse_insn (tic54x_insn *insn, char *line)
{
insn->tm = (template *) hash_find (op_hash, insn->mnemonic);
if (!insn->tm)
Look for a subsequent line starting with "||". */
static int
-next_line_shows_parallel (next_line)
- char *next_line;
+next_line_shows_parallel (char *next_line)
{
/* Look for the second half. */
- while (isspace (*next_line))
+ while (ISSPACE (*next_line))
++next_line;
return (next_line[0] == PARALLEL_SEPARATOR
}
static int
-tic54x_parse_parallel_insn_firstline (insn, line)
- tic54x_insn *insn;
- char *line;
+tic54x_parse_parallel_insn_firstline (tic54x_insn *insn, char *line)
{
- insn->ptm = (partemplate *) hash_find (parop_hash, insn->mnemonic);
- if (!insn->ptm)
+ insn->tm = (template *) hash_find (parop_hash, insn->mnemonic);
+ if (!insn->tm)
{
as_bad (_("Unrecognized parallel instruction \"%s\""),
insn->mnemonic);
return 0;
}
- while (insn->ptm->name && strcasecmp (insn->ptm->name,
- insn->mnemonic) == 0)
+ while (insn->tm->name && strcasecmp (insn->tm->name,
+ insn->mnemonic) == 0)
{
insn->opcount = get_operands (insn->operands, line);
if (insn->opcount < 0)
return 0;
if (insn->opcount == 2
&& operands_match (insn, &insn->operands[0], insn->opcount,
- insn->ptm->operand_types, 2, 2))
+ insn->tm->operand_types, 2, 2))
{
return 1;
}
- ++(insn->ptm);
+ ++(insn->tm);
}
/* Didn't find a matching parallel; try for a normal insn. */
return 0;
/* Parse the second line of a two-line parallel instruction. */
static int
-tic54x_parse_parallel_insn_lastline (insn, line)
- tic54x_insn *insn;
- char *line;
+tic54x_parse_parallel_insn_lastline (tic54x_insn *insn, char *line)
{
int valid_mnemonic = 0;
insn->paropcount = get_operands (insn->paroperands, line);
- while (insn->ptm->name && strcasecmp (insn->ptm->name,
+ while (insn->tm->name && strcasecmp (insn->tm->name,
insn->mnemonic) == 0)
{
- if (strcasecmp (insn->ptm->parname, insn->parmnemonic) == 0)
+ if (strcasecmp (insn->tm->parname, insn->parmnemonic) == 0)
{
valid_mnemonic = 1;
- if (insn->paropcount >= insn->ptm->minops
- && insn->paropcount <= insn->ptm->maxops
+ if (insn->paropcount >= insn->tm->minops
+ && insn->paropcount <= insn->tm->maxops
&& operands_match (insn, insn->paroperands,
insn->paropcount,
- insn->ptm->paroperand_types,
- insn->ptm->minops, insn->ptm->maxops))
+ insn->tm->paroperand_types,
+ insn->tm->minops, insn->tm->maxops))
{
return 1;
}
}
- ++(insn->ptm);
+ ++(insn->tm);
}
if (valid_mnemonic)
as_bad (_("Invalid operand (s) for parallel instruction \"%s\""),
char *ptr = line;
char *endp;
int is_string = *line == '"';
- int is_char = isdigit (*line);
+ int is_char = ISDIGIT (*line);
if (is_char)
{
- while (isdigit (*ptr))
+ while (ISDIGIT (*ptr))
++ptr;
endp = ptr;
*str = xmalloc (ptr - line + 1);
/* Check for local labels; replace them with the appropriate
substitution. */
- if ((*name == '$' && isdigit (name[1]) && name[2] == '\0')
+ if ((*name == '$' && ISDIGIT (name[1]) && name[2] == '\0')
|| name[strlen (name) - 1] == '?')
{
/* Use an existing identifier for that label if, available, or
}
/* Character constants are converted to numerics
by the preprocessor. */
- arg_type[1] = (isdigit (*ptr)) ? 2 : (*ptr == '"');
+ arg_type[1] = (ISDIGIT (*ptr)) ? 2 : (*ptr == '"');
ptr = subsym_get_arg (ptr, ")", &arg2, ismember);
}
/* Args checking. */
comment = replacement + strlen (replacement) - 1;
/* Trim trailing whitespace. */
- while (isspace (*comment))
+ while (ISSPACE (*comment))
{
comment[0] = endc;
comment[1] = 0;
}
/* Compact leading whitespace. */
- while (isspace (tmp[0]) && isspace (tmp[1]))
+ while (ISSPACE (tmp[0]) && ISSPACE (tmp[1]))
++tmp;
input_line_pointer = endp;
otherwise let the assembler pick up the next line for us. */
if (tmp != NULL)
{
- while (isspace (tmp[2]))
+ while (ISSPACE (tmp[2]))
++tmp;
md_assemble (tmp + 2);
}
If fixp->fx_addsy is non-NULL, we'll have to generate a reloc entry. */
-int
-md_apply_fix (fixP, valP)
+void
+md_apply_fix3 (fixP, valP, seg)
fixS *fixP;
- valueT *valP;
+ valueT * valP;
+ segT seg ATTRIBUTE_UNUSED;
{
char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
- valueT val = *valP;
+ valueT val = * valP;
switch (fixP->fx_r_type)
{
default:
as_fatal ("Bad relocation type: 0x%02x", fixP->fx_r_type);
- return 0;
+ return;
case BFD_RELOC_TIC54X_MS7_OF_23:
val = (val >> 16) & 0x7F;
/* Fall through. */
break;
}
- return 0; /* Return value is ignored. */
+ if (fixP->fx_addsy == NULL && fixP->fx_pcrel == 0)
+ fixP->fx_done = 1;
}
/* This is our chance to record section alignment
if (is_end_of_line[(int) c])
return 1;
- if (isspace (c))
- while (isspace (c = *++rest))
+ if (ISSPACE (c))
+ while (ISSPACE (c = *++rest))
;
if (c == '.')
{
/* Don't let colon () define a label for any of these... */
- return (strncasecmp (rest, ".tag", 4) != 0 || !isspace (rest[4]))
- && (strncasecmp (rest, ".struct", 7) != 0 || !isspace (rest[7]))
- && (strncasecmp (rest, ".union", 6) != 0 || !isspace (rest[6]))
- && (strncasecmp (rest, ".macro", 6) != 0 || !isspace (rest[6]))
- && (strncasecmp (rest, ".set", 4) != 0 || !isspace (rest[4]))
- && (strncasecmp (rest, ".equ", 4) != 0 || !isspace (rest[4]));
+ return (strncasecmp (rest, ".tag", 4) != 0 || !ISSPACE (rest[4]))
+ && (strncasecmp (rest, ".struct", 7) != 0 || !ISSPACE (rest[7]))
+ && (strncasecmp (rest, ".union", 6) != 0 || !ISSPACE (rest[6]))
+ && (strncasecmp (rest, ".macro", 6) != 0 || !ISSPACE (rest[6]))
+ && (strncasecmp (rest, ".set", 4) != 0 || !ISSPACE (rest[4]))
+ && (strncasecmp (rest, ".equ", 4) != 0 || !ISSPACE (rest[4]));
}
return 1;