/* tc-c30.c -- Assembly code for the Texas Instruments TMS320C30
- Copyright (C) 1998-2015 Free Software Foundation, Inc.
+ Copyright (C) 1998-2019 Free Software Foundation, Inc.
Contributed by Steven Haworth (steve@pm.cse.rmit.edu.au)
This file is part of GAS, the GNU Assembler.
/* Put here all non-digit non-letter characters that may occur in an
operand. */
static char operand_special_chars[] = "%$-+(,)*._~/<>&^!:[@]";
-static char *ordinal_names[] =
+static const char *ordinal_names[] =
{
N_("first"), N_("second"), N_("third"), N_("fourth"), N_("fifth")
};
}
}
}
- parallel_insn = malloc (strlen (first_opcode) + strlen (first_operands)
- + strlen (second_opcode) + strlen (second_operands) + 8);
- sprintf (parallel_insn, "q_%s_%s %s | %s",
- first_opcode, second_opcode,
- first_operands, second_operands);
+
+ parallel_insn = concat ("q_", first_opcode, "_", second_opcode, " ",
+ first_operands, " | ", second_operands,
+ (char *) NULL);
debug ("parallel insn = %s\n", parallel_insn);
return parallel_insn;
}
tic30_operand (char *token)
{
unsigned int count;
- char ind_buffer[strlen (token)];
operand *current_op;
debug ("In tic30_operand with %s\n", token);
- current_op = malloc (sizeof (* current_op));
- memset (current_op, '\0', sizeof (operand));
+ current_op = XCNEW (operand);
if (*token == DIRECT_REFERENCE)
{
int disp_number = 0;
int buffer_posn = 1;
ind_addr_type *ind_addr_op;
+ char * ind_buffer;
+
+ ind_buffer = XNEWVEC (char, strlen (token));
debug ("Found indirect reference\n");
ind_buffer[0] = *token;
if (found_ar)
{
as_bad (_("More than one AR register found in indirect reference"));
+ free (ind_buffer);
return NULL;
}
if (*(token + count + 1) < '0' || *(token + count + 1) > '7')
{
as_bad (_("Illegal AR register in indirect reference"));
+ free (ind_buffer);
return NULL;
}
ar_number = *(token + count + 1) - '0';
if (found_disp)
{
as_bad (_("More than one displacement found in indirect reference"));
+ free (ind_buffer);
return NULL;
}
count++;
if (!is_digit_char (*(token + count)))
{
as_bad (_("Invalid displacement in indirect reference"));
+ free (ind_buffer);
return NULL;
}
disp[disp_posn++] = *(token + (count++));
if (!found_ar)
{
as_bad (_("AR register not found in indirect reference"));
+ free (ind_buffer);
return NULL;
}
{
/* Maybe an implied displacement of 1 again. */
as_bad (_("required displacement wasn't given in indirect reference"));
- return 0;
+ free (ind_buffer);
+ return NULL;
}
}
else
{
as_bad (_("illegal indirect reference"));
+ free (ind_buffer);
return NULL;
}
if (found_disp && (disp_number < 0 || disp_number > 255))
{
as_bad (_("displacement must be an unsigned 8-bit number"));
+ free (ind_buffer);
return NULL;
}
current_op->indirect.disp = disp_number;
current_op->indirect.ARnum = ar_number;
current_op->op_type = Indirect;
+ free (ind_buffer);
}
else
{
segT retval;
debug ("Probably a label: %s\n", token);
- current_op->immediate.label = malloc (strlen (token) + 1);
- strcpy (current_op->immediate.label, token);
- current_op->immediate.label[strlen (token)] = '\0';
+ current_op->immediate.label = xstrdup (token);
save_input_line_pointer = input_line_pointer;
input_line_pointer = token;
for (count = 0; count < strlen (token); count++)
if (*(token + count) == '.')
current_op->immediate.decimal_found = 1;
- current_op->immediate.label = malloc (strlen (token) + 1);
- strcpy (current_op->immediate.label, token);
- current_op->immediate.label[strlen (token)] = '\0';
+ current_op->immediate.label = xstrdup (token);
current_op->immediate.f_number = (float) atof (token);
current_op->immediate.s_number = (int) atoi (token);
current_op->immediate.u_number = (unsigned int) atoi (token);
int
md_parse_option (int c ATTRIBUTE_UNUSED,
- char *arg ATTRIBUTE_UNUSED)
+ const char *arg ATTRIBUTE_UNUSED)
{
debug ("In md_parse_option()\n");
return 0;
return fixP->fx_where - fixP->fx_size + (INSN_SIZE * offset);
}
-char *
+const char *
md_atof (int what_statement_type,
char *literalP,
int *sizeP)
#undef MAP
#undef F
- rel = xmalloc (sizeof (* rel));
+ rel = XNEW (arelent);
gas_assert (rel != 0);
- rel->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ rel->sym_ptr_ptr = XNEW (asymbol *);
*rel->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
rel->address = fixP->fx_frag->fr_address + fixP->fx_where;
rel->addend = 0;