/* tc-a29k.c -- Assemble for the AMD 29000.
- Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
+ Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1998, 2000, 2001,
+ 2002, 2005
+ Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GNU General Public License for more details.
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. */
+ 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. */
/* John Gilmore has reorganized this module somewhat, to make it easier
to convert it to new machines' assemblers as desired. There was too
much bloody rewriting required before. There still probably is. */
-#include <ctype.h>
#include "as.h"
+#include "safe-ctype.h"
#include "opcode/a29k.h"
static void s_data1 PARAMS ((void));
static void s_use PARAMS ((int));
#endif
+static void insert_sreg PARAMS ((char *, int));
+static void define_some_regs PARAMS ((void));
+static char *parse_operand PARAMS ((char *, expressionS *, int));
const pseudo_typeS
md_pseudo_table[] =
{NULL, 0, 0},
};
-int md_short_jump_size = 4;
-int md_long_jump_size = 4;
#if defined(BFD_HEADERS)
#ifdef RELSZ
const int md_reloc_size = RELSZ; /* Coff headers */
.line and .file directives will appear in the pre-processed output */
/* Note that input_file.c hand checks for '#' at the beginning of the
first line of the input file. This is because the compiler outputs
- #NO_APP at the beginning of its output. */
+ #NO_APP at the beginning of its output. */
/* Also note that comments like this one will always work */
const char line_comment_chars[] = "#";
return;
}
/* Literals can't go in the text segment because you can't read from
- instruction memory on some 29k's. So, into initialized data. */
+ instruction memory on some 29k's. So, into initialized data. */
if (strncmp (input_line_pointer, ".lit", 4) == 0)
{
input_line_pointer += 4;
return;
}
- as_bad ("Unknown segment type");
+ as_bad (_("Unknown segment type"));
demand_empty_rest_of_line ();
}
symbol_table_insert (symbol_new (regname, SEG_REGISTER, (valueT) regnum,
&zero_address_frag));
for (i = 0; regname[i]; i++)
- buf[i] = islower (regname[i]) ? toupper (regname[i]) : regname[i];
+ buf[i] = TOUPPER (regname[i]);
buf[i] = '\0';
symbol_table_insert (symbol_new (buf, SEG_REGISTER, (valueT) regnum,
/* Install symbol definitions for assorted special registers.
See ASM29K Ref page 2-9. */
-void
+static void
define_some_regs ()
{
#define SREG 256
}
/* Hack to avoid multiple opcode entries. We pre-locate all the
- variations (b/i field and P/A field) and handle them. */
+ variations (b/i field and P/A field) and handle them. */
if (!strcmp (name, machine_opcodes[i + 1].name))
{
}
if (lose)
- as_fatal ("Broken assembler. No assembly attempted.");
+ as_fatal (_("Broken assembler. No assembly attempted."));
define_some_regs ();
}
}
}
-char *
+static char *
parse_operand (s, operandp, opt)
char *s;
expressionS *operandp;
input_line_pointer = s;
expression (operandp);
if (operandp->X_op == O_absent && ! opt)
- as_bad ("missing operand");
+ as_bad (_("missing operand"));
new = input_line_pointer;
input_line_pointer = save;
return new;
/* Must handle `div0' opcode. */
s = str;
- if (isalpha (*s))
- for (; isalnum (*s); ++s)
- if (isupper (*s))
- *s = tolower (*s);
+ if (ISALPHA (*s))
+ for (; ISALNUM (*s); ++s)
+ *s = TOLOWER (*s);
switch (*s)
{
break;
default:
- as_bad ("Unknown opcode: `%s'", str);
+ as_bad (_("Unknown opcode: `%s'"), str);
return;
}
if ((insn = (struct machine_opcode *) hash_find (op_hash, str)) == NULL)
{
- as_bad ("Unknown opcode `%s'.", str);
+ as_bad (_("Unknown opcode `%s'."), str);
return;
}
argsStart = s;
/* Build the opcode, checking as we go to make sure that the
operands match.
-
+
If an operand matches, we modify the_insn or opcode appropriately,
and do a "continue". If an operand fails to match, we "break". */
case '\0': /* end of args */
if (*s == '\0')
{
- /* We are truly done. */
+ /* We are truly done. */
the_insn.opcode = opcode;
return;
}
- as_bad ("Too many operands: %s", s);
+ as_bad (_("Too many operands: %s"), s);
break;
case ',': /* Must match a comma */
}
else
{
- as_bad ("Immediate value of %ld is too large",
+ as_bad (_("Immediate value of %ld is too large"),
(long) operand->X_add_number);
continue;
}
}
else
{
- as_bad ("Immediate value of %ld is too large",
+ as_bad (_("Immediate value of %ld is too large"),
(long) operand->X_add_number);
continue;
}
opcode |= reg << 16;
continue;
}
- as_fatal ("failed sanity check.");
+ as_fatal (_("failed sanity check."));
break;
case 'x': /* 16 bit constant, zero-extended */
}
break;
-
case 'f': /* FS bits of CONVERT */
if (operand->X_op == O_constant &&
operand->X_add_number < 4)
but I'm not sure.
Turn a string in input_line_pointer into a floating point constant
- of type type, and store the appropriate bytes in *litP. The number
- of LITTLENUMS emitted is stored in *sizeP . An error message is
+ of type TYPE, and store the appropriate bytes in *LITP. The number
+ of LITTLENUMS emitted is stored in *SIZEP. An error message is
returned, or NULL on OK. */
/* Equal to MAX_PRECISION in atof-ieee.c */
}
void
-md_apply_fix (fixP, val)
+md_apply_fix3 (fixP, valP, seg)
fixS *fixP;
- long val;
+ valueT *valP;
+ segT seg ATTRIBUTE_UNUSED;
{
+ valueT val = *valP;
char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
- fixP->fx_addnumber = val; /* Remember value for emit_reloc */
-
+ fixP->fx_addnumber = val; /* Remember value for emit_reloc. */
know (fixP->fx_size == 4);
know (fixP->fx_r_type < NO_RELOC);
/* This is a hack. There should be a better way to handle this. */
if (fixP->fx_r_type == RELOC_WDISP30 && fixP->fx_addsy)
- {
- val += fixP->fx_where + fixP->fx_frag->fr_address;
- }
+ val += fixP->fx_where + fixP->fx_frag->fr_address;
switch (fixP->fx_r_type)
{
-
case RELOC_32:
buf[0] = val >> 24;
buf[1] = val >> 16;
break;
case RELOC_WDISP30:
- val = (val >>= 2) + 1;
+ val = (val >> 2) + 1;
buf[0] |= (val >> 24) & 0x3f;
buf[1] = (val >> 16);
buf[2] = val >> 8;
break;
case RELOC_WDISP22:
- val = (val >>= 2) + 1;
+ val = (val >> 2) + 1;
/* FALLTHROUGH */
case RELOC_BASE22:
buf[1] |= (val >> 16) & 0x3f;
case RELOC_JUMPTARG: /* 00XX00XX pattern in a word */
if (!fixP->fx_done)
- /* let linker deal */
- ;
+ {
+ /* The linker tries to support both AMD and old GNU style
+ R_IREL relocs. That means that if the addend is exactly
+ the negative of the address within the section, the
+ linker will not handle it correctly. */
+ if (fixP->fx_pcrel
+ && val != 0
+ && val == - (fixP->fx_frag->fr_address + fixP->fx_where))
+ as_bad_where
+ (fixP->fx_file, fixP->fx_line,
+ "the linker will not handle this relocation correctly");
+ }
else if (fixP->fx_pcrel)
{
- long v = val >> 16;
- if (v != 0 && v != -1)
+ if (val + 0x20000 > 0x3ffff)
as_bad_where (fixP->fx_file, fixP->fx_line,
"call/jmp target out of range");
}
else
- /* this case was supposed to be handled in machine_ip */
+ /* This case was supposed to be handled in machine_ip. */
abort ();
buf[1] = val >> 10; /* Holds bits 0003FFFC of address */
buf[3] = val >> 2;
case NO_RELOC:
default:
- as_bad ("bad relocation type: 0x%02x", fixP->fx_r_type);
+ as_bad (_("bad relocation type: 0x%02x"), fixP->fx_r_type);
break;
}
+
+ if (fixP->fx_addsy == NULL && fixP->fx_pcrel == 0)
+ fixP->fx_done = 1;
}
#ifdef OBJ_COFF
case RELOC_JUMPTARG:
return (R_IREL);
default:
- printf ("need %o3\n", fixP->fx_r_type);
+ printf (_("need %o3\n"), fixP->fx_r_type);
abort ();
} /* switch on type */
#endif /* OBJ_COFF */
-/* should never be called for 29k */
-void
-md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol)
- char *ptr;
- addressT from_addr, to_addr;
- fragS *frag;
- symbolS *to_symbol;
-{
- as_fatal ("a29k_create_short_jmp\n");
-}
-
/* should never be called for 29k */
void
md_convert_frag (headers, seg, fragP)
- object_headers *headers;
- segT seg;
- register fragS *fragP;
-{
- as_fatal ("a29k_convert_frag\n");
-}
-
-/* should never be called for 29k */
-void
-md_create_long_jump (ptr, from_addr, to_addr, frag, to_symbol)
- char *ptr;
- addressT from_addr;
- addressT to_addr;
- fragS *frag;
- symbolS *to_symbol;
+ object_headers *headers ATTRIBUTE_UNUSED;
+ segT seg ATTRIBUTE_UNUSED;
+ register fragS *fragP ATTRIBUTE_UNUSED;
{
- as_fatal ("a29k_create_long_jump\n");
+ as_fatal (_("a29k_convert_frag\n"));
}
/* should never be called for a29k */
int
md_estimate_size_before_relax (fragP, segtype)
- register fragS *fragP;
- segT segtype;
+ register fragS *fragP ATTRIBUTE_UNUSED;
+ segT segtype ATTRIBUTE_UNUSED;
{
- as_fatal ("a29k_estimate_size_before_relax\n");
+ as_fatal (_("a29k_estimate_size_before_relax\n"));
return 0;
}
-#if 0
-/* for debugging only */
-static void
-print_insn (insn)
- struct machine_it *insn;
-{
- char *Reloc[] =
- {
- "RELOC_8",
- "RELOC_16",
- "RELOC_32",
- "RELOC_DISP8",
- "RELOC_DISP16",
- "RELOC_DISP32",
- "RELOC_WDISP30",
- "RELOC_WDISP22",
- "RELOC_HI22",
- "RELOC_22",
- "RELOC_13",
- "RELOC_LO10",
- "RELOC_SFA_BASE",
- "RELOC_SFA_OFF13",
- "RELOC_BASE10",
- "RELOC_BASE13",
- "RELOC_BASE22",
- "RELOC_PC10",
- "RELOC_PC22",
- "RELOC_JMP_TBL",
- "RELOC_SEGOFF16",
- "RELOC_GLOB_DAT",
- "RELOC_JMP_SLOT",
- "RELOC_RELATIVE",
- "NO_RELOC"
- };
-
- if (insn->error)
- {
- fprintf (stderr, "ERROR: %s\n");
- }
- fprintf (stderr, "opcode=0x%08x\n", insn->opcode);
- fprintf (stderr, "reloc = %s\n", Reloc[insn->reloc]);
- fprintf (stderr, "exp = {\n");
- fprintf (stderr, "\t\tX_add_symbol = %s\n",
- insn->exp.X_add_symbol ?
- (S_GET_NAME (insn->exp.X_add_symbol) ?
- S_GET_NAME (insn->exp.X_add_symbol) : "???") : "0");
- fprintf (stderr, "\t\tX_op_symbol = %s\n",
- insn->exp.X_op_symbol ?
- (S_GET_NAME (insn->exp.X_op_symbol) ?
- S_GET_NAME (insn->exp.X_op_symbol) : "???") : "0");
- fprintf (stderr, "\t\tX_add_number = %d\n",
- insn->exp.X_add_number);
- fprintf (stderr, "}\n");
-}
-
-#endif
-
/* Translate internal representation of relocation info to target format.
On sparc/29k: first 4 bytes are normal unsigned long address, next three
bytes are index, most sig. byte first. Byte 7 is broken up with
bit 7 as external, bits 6 & 5 unused, and the lower
- five bits as relocation type. Next 4 bytes are long addend. */
+ five bits as relocation type. Next 4 bytes are long addend. */
/* Thanx and a tip of the hat to Michael Bloom, mb@ttidca.tti.com */
#ifdef OBJ_AOUT
#endif /* OBJ_AOUT */
\f
-CONST char *md_shortopts = "";
+const char *md_shortopts = "";
struct option md_longopts[] = {
{NULL, no_argument, NULL, 0}
};
-size_t md_longopts_size = sizeof(md_longopts);
+size_t md_longopts_size = sizeof (md_longopts);
int
md_parse_option (c, arg)
- int c;
- char *arg;
+ int c ATTRIBUTE_UNUSED;
+ char *arg ATTRIBUTE_UNUSED;
{
return 0;
}
void
md_show_usage (stream)
- FILE *stream;
+ FILE *stream ATTRIBUTE_UNUSED;
{
}
\f
+/* This is called when a line is unrecognized. This is used to handle
+ definitions of a29k style local labels. */
+
+int
+a29k_unrecognized_line (c)
+ int c;
+{
+ int lab;
+ char *s;
+
+ if (c != '$'
+ || ! ISDIGIT (input_line_pointer[0]))
+ return 0;
+
+ s = input_line_pointer;
+
+ lab = 0;
+ while (ISDIGIT (*s))
+ {
+ lab = lab * 10 + *s - '0';
+ ++s;
+ }
+
+ if (*s != ':')
+ {
+ /* Not a label definition. */
+ return 0;
+ }
+
+ if (dollar_label_defined (lab))
+ {
+ as_bad (_("label \"$%d\" redefined"), lab);
+ return 0;
+ }
+
+ define_dollar_label (lab);
+ colon (dollar_label_name (lab, 0));
+ input_line_pointer = s + 1;
+
+ return 1;
+}
+
/* Default the values of symbols known that should be "predefined". We
don't bother to predefine them unless you actually use one, since there
are a lot of them. */
long maxreg;
/* Parse the number, make sure it has no extra zeroes or
- trailing chars. */
+ trailing chars. */
regnum = atol (&name[2]);
if (name[0] == 's' || name[0] == 'S')
(void) expression (expressionP);
if (expressionP->X_op != O_constant
|| expressionP->X_add_number > 255)
- as_bad ("Invalid expression after %%%%\n");
+ as_bad (_("Invalid expression after %%%%\n"));
expressionP->X_op = O_register;
}
else if (input_line_pointer[0] == '&')
input_line_pointer++; /* Skip & */
(void) expression (expressionP);
if (expressionP->X_op != O_register)
- as_bad ("Invalid register in & expression");
+ as_bad (_("Invalid register in & expression"));
else
expressionP->X_op = O_constant;
}
+ else if (input_line_pointer[0] == '$'
+ && ISDIGIT (input_line_pointer[1]))
+ {
+ long lab;
+ char *name;
+ symbolS *sym;
+
+ /* This is a local label. */
+ ++input_line_pointer;
+ lab = (long) get_absolute_expression ();
+ if (dollar_label_defined (lab))
+ {
+ name = dollar_label_name (lab, 0);
+ sym = symbol_find (name);
+ }
+ else
+ {
+ name = dollar_label_name (lab, 1);
+ sym = symbol_find_or_make (name);
+ }
+
+ expressionP->X_op = O_symbol;
+ expressionP->X_add_symbol = sym;
+ expressionP->X_add_number = 0;
+ }
+ else if (input_line_pointer[0] == '$')
+ {
+ char *s;
+ char type;
+ int fieldnum, fieldlimit;
+ LITTLENUM_TYPE floatbuf[8];
+
+ /* $float(), $doubleN(), or $extendN() convert floating values
+ to integers. */
+
+ s = input_line_pointer;
+
+ ++s;
+
+ fieldnum = 0;
+ if (strncmp (s, "double", sizeof "double" - 1) == 0)
+ {
+ s += sizeof "double" - 1;
+ type = 'd';
+ fieldlimit = 2;
+ }
+ else if (strncmp (s, "float", sizeof "float" - 1) == 0)
+ {
+ s += sizeof "float" - 1;
+ type = 'f';
+ fieldlimit = 1;
+ }
+ else if (strncmp (s, "extend", sizeof "extend" - 1) == 0)
+ {
+ s += sizeof "extend" - 1;
+ type = 'x';
+ fieldlimit = 4;
+ }
+ else
+ {
+ return;
+ }
+
+ if (ISDIGIT (*s))
+ {
+ fieldnum = *s - '0';
+ ++s;
+ }
+ if (fieldnum >= fieldlimit)
+ return;
+
+ SKIP_WHITESPACE ();
+ if (*s != '(')
+ return;
+ ++s;
+ SKIP_WHITESPACE ();
+
+ s = atof_ieee (s, type, floatbuf);
+ if (s == NULL)
+ return;
+ s = s;
+
+ SKIP_WHITESPACE ();
+ if (*s != ')')
+ return;
+ ++s;
+ SKIP_WHITESPACE ();
+
+ input_line_pointer = s;
+ expressionP->X_op = O_constant;
+ expressionP->X_unsigned = 1;
+ expressionP->X_add_number = ((floatbuf[fieldnum * 2]
+ << LITTLENUM_NUMBER_OF_BITS)
+ + floatbuf[fieldnum * 2 + 1]);
+ }
}
/* Round up a section size to the appropriate boundary. */
valueT
md_section_align (segment, size)
- segT segment;
+ segT segment ATTRIBUTE_UNUSED;
valueT size;
{
return size; /* Byte alignment is fine */
{
return fixP->fx_where + fixP->fx_frag->fr_address;
}
-
-/* end of tc-a29k.c */