/* tc-crx.c -- Assembler code for the CRX CPU core.
- Copyright (C) 2004-2016 Free Software Foundation, Inc.
+ Copyright (C) 2004-2020 Free Software Foundation, Inc.
Contributed by Tomer Levi, NSC, Israel.
Originally written for GAS 2.12 by Tomer Levi, NSC, Israel.
/* CRX coprocessor registers hash table. */
static struct hash_control *copreg_hash;
/* Current instruction we're assembling. */
-const inst *instruction;
+static const inst *instruction;
/* Global variables. */
/* Array to hold an instruction encoding. */
-long output_opcode[2];
+static long output_opcode[2];
/* Nonzero means a relocatable symbol. */
-int relocatable;
+static int relocatable;
/* A copy of the original instruction (used in error messages). */
-char ins_parse[MAX_INST_LEN];
+static char ins_parse[MAX_INST_LEN];
/* The current processed argument number. */
-int cur_arg_num;
+static int cur_arg_num;
/* Generic assembler global variables which must be defined by all targets. */
static int get_cinv_parameters (const char *);
static long getconstant (long, int);
static op_err check_range (long *, int, unsigned int, int);
-static int getreg_image (reg);
+static int getreg_image (int);
static void parse_operands (ins *, char *);
static void parse_insn (ins *, char *);
static void print_operand (int, int, argument *);
{
/* 'opcode' points to the start of the instruction, whether
we need to change the instruction's fixed encoding. */
- char *opcode = fragP->fr_literal + fragP->fr_fix;
+ char *opcode = &fragP->fr_literal[0] + fragP->fr_fix;
bfd_reloc_code_real_type reloc;
subseg_change (sec, 0);
{
hashret = hash_insert (reg_hash, regtab->name, (void *) regtab);
if (hashret)
- as_fatal (_("Internal Error: Can't hash %s: %s"),
+ as_fatal (_("Internal error: Can't hash %s: %s"),
regtab->name,
hashret);
}
hashret = hash_insert (copreg_hash, copregtab->name,
(void *) copregtab);
if (hashret)
- as_fatal (_("Internal Error: Can't hash %s: %s"),
+ as_fatal (_("Internal error: Can't hash %s: %s"),
copregtab->name,
hashret);
}
static void
set_operand (char *operand, ins * crx_ins)
{
- char *operandS; /* Pointer to start of sub-opearand. */
- char *operandE; /* Pointer to end of sub-opearand. */
+ char *operandS; /* Pointer to start of sub-operand. */
+ char *operandE; /* Pointer to end of sub-operand. */
expressionS scale;
int scale_val;
char *input_save, c;
operandE++;
*operandE = '\0';
if ((cur_arg->r = get_register (operandS)) == nullregister)
- as_bad (_("Illegal register `%s' in Instruction `%s'"),
+ as_bad (_("Illegal register `%s' in instruction `%s'"),
operandS, ins_parse);
if (cur_arg->type != arg_rbase)
operandE++;
*operandE++ = '\0';
if ((cur_arg->r = get_register (operandS)) == nullregister)
- as_bad (_("Illegal register `%s' in Instruction `%s'"),
+ as_bad (_("Illegal register `%s' in instruction `%s'"),
operandS, ins_parse);
/* Skip leading white space. */
*operandE++ = '\0';
if ((cur_arg->i_r = get_register (operandS)) == nullregister)
- as_bad (_("Illegal register `%s' in Instruction `%s'"),
+ as_bad (_("Illegal register `%s' in instruction `%s'"),
operandS, ins_parse);
/* Skip leading white space. */
cur_arg->type = arg_c;
goto set_params;
-/* Parse an operand according to its type. */
-set_params:
+ /* Parse an operand according to its type. */
+ set_params:
cur_arg->constant = 0;
set_operand (operand, crx_ins);
}
int i;
/* Handle instructions with no operands. */
- for (i = 0; no_op_insn[i] != NULL; i++)
+ for (i = 0; crx_no_op_insn[i] != NULL; i++)
{
- if (streq (no_op_insn[i], instruction->mnemonic))
+ if (streq (crx_no_op_insn[i], instruction->mnemonic))
{
insn->nargs = 0;
return;
issue an error. */
static int
-getreg_image (reg r)
+getreg_image (int r)
{
const reg_entry *rreg;
char *reg_name;
/* Issue a error message when register is illegal. */
#define IMAGE_ERR \
- as_bad (_("Illegal register (`%s') in Instruction: `%s'"), \
- reg_name, ins_parse); \
- break;
+ as_bad (_("Illegal register (`%s') in instruction: `%s'"), \
+ reg_name, ins_parse);
switch (rreg->type)
{
return rreg->image;
else
IMAGE_ERR;
+ break;
case CRX_CFG_REGTYPE:
if (is_procreg)
return rreg->image;
else
IMAGE_ERR;
+ break;
case CRX_R_REGTYPE:
if (! is_procreg)
return rreg->image;
else
IMAGE_ERR;
+ break;
case CRX_C_REGTYPE:
case CRX_CS_REGTYPE:
default:
IMAGE_ERR;
+ break;
}
return 0;
case arg_copr:
if (arg->cr < c0 || arg->cr > c15)
- as_bad (_("Illegal Co-processor register in Instruction `%s' "),
+ as_bad (_("Illegal co-processor register in instruction `%s'"),
ins_parse);
CRX_PRINT (0, getreg_image (arg->cr), shift);
break;
case arg_copsr:
if (arg->cr < cs0 || arg->cr > cs15)
- as_bad (_("Illegal Co-processor special register in Instruction `%s' "),
+ as_bad (_("Illegal co-processor special register in instruction `%s'"),
ins_parse);
CRX_PRINT (0, getreg_image (arg->cr), shift);
break;
: instruction->flags & DISPUD4 ? 4
: 0);
- for (bin = 0; bin < cst4_maps; bin++)
+ for (bin = 0; bin < crx_cst4_maps; bin++)
{
if (value == mul * bin)
{
{
int is_cst4 = 0;
- for (bin = 0; bin < cst4_maps; bin++)
+ for (bin = 0; bin < crx_cst4_maps; bin++)
{
- if (value == (uint32_t) cst4_map[bin])
+ if (value == (uint32_t) crx_cst4_map[bin])
{
is_cst4 = 1;
if (update)
match = 1;
break;
-/* Try again with next instruction. */
-next_insn:
+ /* Try again with next instruction. */
+ next_insn:
instruction++;
}
else
/* Full match - print the encoding to output file. */
{
- /* Make further checkings (such that couldn't be made earlier).
+ /* Make further checking (such that couldn't be made earlier).
Warn the user if necessary. */
warn_if_needed (insn);
return 1;
}
-/* Bunch of error checkings.
+/* Bunch of error checking.
The checks are made after a matching instruction was found. */
void
{
if ((reg)r > (reg)sp)
{
- as_bad (_("Invalid Register in Register List"));
+ as_bad (_("Invalid register in register list"));
return;
}
int reg_counter = 0; /* Count number of parsed registers. */
unsigned short int mask = 0; /* Mask for 16 general purpose registers. */
char *new_param; /* New created operands string. */
- char *paramP = param; /* Pointer to original opearands string. */
+ char *paramP = param; /* Pointer to original operands string. */
char maskstring[10]; /* Array to print the mask as a string. */
int hi_found = 0, lo_found = 0; /* Boolean flags for hi/lo registers. */
reg r;
as_bad (_("Maximum %d bits may be set in `mask16' operand"),
MAX_REGS_IN_MASK16);
-next_inst:
+ next_inst:
while (!ISALNUM (*paramP) && *paramP != '}')
paramP++;
}
words[j++] = output_opcode[i] & 0xFFFF;
}
- /* Handle relaxtion. */
+ /* Handle relaxation. */
if ((instruction->flags & RELAXABLE) && relocatable)
{
int relax_subtype;