/* tc-tic4x.c -- Assemble for the Texas Instruments TMS320C[34]x.
- Copyright (C) 1997,1998, 2002, 2003 Free Software Foundation.
+ Copyright (C) 1997,1998, 2002, 2003, 2005 Free Software Foundation.
Contributed by Michael P. Hayes (m.hayes@elec.canterbury.ac.nz)
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ the Free Software Foundation, 51 Franklin Street - Fifth Floor,
+ Boston, MA 02110-1301, USA. */
/*
TODOs:
------
should be possible to define a 32-bits pattern.
o .align fills all section with NOP's when used regardless if has
- been used in .text or .data. (However the .align is primarely
+ been used in .text or .data. (However the .align is primarily
intended used in .text sections. If you require something else,
use .align <size>,0x00)
- o .align: Implement a 'bu' insn if the number of nop's exeeds 4
+ o .align: Implement a 'bu' insn if the number of nop's exceeds 4
within the align frag. if(fragsize>4words) insert bu fragend+1
first.
*/
#include <stdio.h>
-#include <ctype.h>
-
+#include "safe-ctype.h"
#include "as.h"
#include "opcode/tic4x.h"
#include "subsegs.h"
static char *tic4x_expression
PARAMS ((char *, expressionS *));
static char *tic4x_expression_abs
- PARAMS ((char *, int *));
+ PARAMS ((char *, offsetT *));
static void tic4x_emit_char
PARAMS ((char, int));
static void tic4x_seg_alloc
PARAMS ((char *, unsigned long, char *));
static int tic4x_inst_add
PARAMS ((tic4x_inst_t *));
-void md_begin
- PARAMS ((void));
void tic4x_end
PARAMS ((void));
static int tic4x_indirect_parse
PARAMS ((tic4x_insn_t *));
static int tic4x_operands_parse
PARAMS ((char *, tic4x_operand_t *, int ));
-void md_assemble
- PARAMS ((char *));
void tic4x_cleanup
PARAMS ((void));
-char *md_atof
- PARAMS ((int, char *, int *));
-void md_apply_fix3
- PARAMS ((fixS *, valueT *, segT ));
-void md_convert_frag
- PARAMS ((bfd *, segT, fragS *));
-void md_create_short_jump
- PARAMS ((char *, addressT, addressT, fragS *, symbolS *));
-void md_create_long_jump
- PARAMS ((char *, addressT, addressT, fragS *, symbolS *));
-int md_estimate_size_before_relax
- PARAMS ((register fragS *, segT));
-int md_parse_option
- PARAMS ((int, char *));
-void md_show_usage
- PARAMS ((FILE *));
int tic4x_unrecognized_line
PARAMS ((int));
-symbolS *md_undefined_symbol
- PARAMS ((char *));
-void md_operand
- PARAMS ((expressionS *));
-valueT md_section_align
- PARAMS ((segT, valueT));
static int tic4x_pc_offset
PARAMS ((unsigned int));
-long md_pcrel_from
- PARAMS ((fixS *));
int tic4x_do_align
PARAMS ((int, const char *, int, int));
void tic4x_start_line
int md_short_jump_size = 4;
int md_long_jump_size = 4;
-const int md_reloc_size = RELSZ; /* Coff headers. */
/* This array holds the chars that always start a comment. If the
pre-processor is disabled, these aren't very useful. */
/* Precision in LittleNums. */
#define MAX_PRECISION (4) /* Its a bit overkill for us, but the code
- reqires it... */
+ requires it... */
#define S_PRECISION (1) /* Short float constants 16-bit. */
#define F_PRECISION (2) /* Float and double types 32-bit. */
#define E_PRECISION (4) /* Extended precision, 64-bit (real 40-bit). */
unsigned int rbit; /* Round bit. */
int shift; /* Shift count. */
- /* NOTE: Svein Seldal <Svein.Seldal@solidas.com>
+ /* NOTE: Svein Seldal <Svein@dev.seldal.com>
The code in this function is altered slightly to support floats
with 31-bits mantissas, thus the documentation below may be a
little bit inaccurate.
We now have to left shift the other littlenums by the same amount,
propagating the shifted bits into the more significant littlenums.
- To save a lot of unecessary shifting we only have to consider
+ To save a lot of unnecessary shifting we only have to consider
two or three littlenums, since the greatest number of mantissa
bits required is 24 + 1 rounding bit. While two littlenums
provide 32 bits of precision, the most significant littlenum
symbol_table_insert (symbol_new (regname, reg_section, (valueT) regnum,
&zero_address_frag));
for (i = 0; regname[i]; i++)
- buf[i] = islower (regname[i]) ? toupper (regname[i]) : regname[i];
+ buf[i] = ISLOWER (regname[i]) ? TOUPPER (regname[i]) : regname[i];
buf[i] = '\0';
symbol_table_insert (symbol_new (buf, reg_section, (valueT) regnum,
static char *
tic4x_expression_abs (str, value)
char *str;
- int *value;
+ offsetT *value;
{
char *s;
char *t;
char c;
char *name;
char *p;
- int size;
+ offsetT size;
segT current_seg;
subsegT current_subseg;
symbolS *symbolP;
tic4x_expression_abs (++input_line_pointer, &size);
if (size < 0)
{
- as_bad (".bss size %d < 0!", size);
+ as_bad (".bss size %ld < 0!", (long) size);
return;
}
subseg_set (bss_section, 0);
int x ATTRIBUTE_UNUSED;
{
char c;
- int value;
+ offsetT value;
char *name;
SKIP_WHITESPACE ();
char *subsection_name;
char *name;
segT seg;
- int num;
+ offsetT num;
SKIP_WHITESPACE ();
if (*input_line_pointer == '"')
ignore_rest_of_line ();
return;
}
+ ++input_line_pointer;
symbolP = symbol_find_or_make (name);
}
else
char *name;
char *section_name;
segT seg;
- int size, alignment_flag;
+ offsetT size, alignment_flag;
segT current_seg;
subsegT current_subseg;
tic4x_version (x)
int x ATTRIBUTE_UNUSED;
{
- unsigned int temp;
+ offsetT temp;
input_line_pointer =
tic4x_expression_abs (input_line_pointer, &temp);
if (!IS_CPU_TIC3X (temp) && !IS_CPU_TIC4X (temp))
- as_bad ("This assembler does not support processor generation %d",
- temp);
+ as_bad ("This assembler does not support processor generation %ld",
+ (long) temp);
- if (tic4x_cpu && temp != tic4x_cpu)
+ if (tic4x_cpu && temp != (offsetT) tic4x_cpu)
as_warn ("Changing processor generation on fly not supported...");
tic4x_cpu = temp;
demand_empty_rest_of_line ();
if (*s == '%')
s++;
#endif
- while (isalnum (*s))
+ while (ISALNUM (*s))
*b++ = *s++;
*b++ = '\0';
if (!(symbolP = symbol_find (name)))
break;
default:
- if (tolower (*s) != *n)
+ if (TOLOWER (*s) != *n)
return 0;
s++;
}
int ieee;
LITTLENUM_TYPE words[MAX_LITTLENUMS];
LITTLENUM_TYPE *wordP;
- unsigned char *t;
+ char *t;
switch (type)
{
if (t)
input_line_pointer = t;
*sizeP = prec * sizeof (LITTLENUM_TYPE);
- t = litP;
+
/* This loops outputs the LITTLENUMs in REVERSE order; in accord with
little endian byte order. */
/* SES: However it is required to put the words (32-bits) out in the
}
void
-md_apply_fix3 (fixP, value, seg)
+md_apply_fix (fixP, value, seg)
fixS *fixP;
valueT *value;
segT seg ATTRIBUTE_UNUSED;
switch (c)
{
case OPTION_CPU: /* cpu brand */
- if (tolower (*arg) == 'c')
+ if (TOLOWER (*arg) == 'c')
arg++;
tic4x_cpu = atoi (arg);
if (!IS_CPU_TIC3X (tic4x_cpu) && !IS_CPU_TIC4X (tic4x_cpu))
int lab;
char *s;
- if (c != '$' || !isdigit (input_line_pointer[0]))
+ if (c != '$' || ! ISDIGIT (input_line_pointer[0]))
return 0;
s = input_line_pointer;
/* Let's allow multiple digit local labels. */
lab = 0;
- while (isdigit (*s))
+ while (ISDIGIT (*s))
{
lab = lab * 10 + *s - '0';
s++;
char *name;
{
/* Look for local labels of the form $n. */
- if (name[0] == '$' && isdigit (name[1]))
+ if (name[0] == '$' && ISDIGIT (name[1]))
{
symbolS *symbolP;
char *s = name + 1;
int lab = 0;
- while (isdigit ((unsigned char) *s))
+ while (ISDIGIT ((unsigned char) *s))
{
lab = lab * 10 + *s - '0';
s++;
md_pcrel_from (fixP)
fixS *fixP;
{
- unsigned char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
+ unsigned char *buf;
unsigned int op;
+ buf = (unsigned char *) fixP->fx_frag->fr_literal + fixP->fx_where;
op = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
return ((fixP->fx_where + fixP->fx_frag->fr_address) >> 2) +
int len ATTRIBUTE_UNUSED;
int max ATTRIBUTE_UNUSED;
{
- unsigned long nop = NOP_OPCODE;
+ unsigned long nop = TIC_NOP_OPCODE;
- /* Because we are talking lwords, not bytes, adjust aligment to do words */
+ /* Because we are talking lwords, not bytes, adjust alignment to do words */
alignment += 2;
if (alignment != 0 && !need_pass_2)
{
if (fill == NULL)
{
- /*if (subseg_text_p (now_seg))*/ /* FIXME: doesnt work for .text for some reason */
+ /*if (subseg_text_p (now_seg))*/ /* FIXME: doesn't work for .text for some reason */
frag_align_pattern( alignment, (const char *)&nop, sizeof(nop), max);
return 1;
/*else
frag_align_pattern (alignment, fill, len, max);
}
- /* Return 1 to skip the default aligment function */
+ /* Return 1 to skip the default alignment function */
return 1;
}
/* So line counters get bumped. */
input_line_pointer[-1] = '\n';
}
- else
- {
- as_bad ("Parallel opcode cannot contain more than two instructions");
- }
}
else
{