#define machine_it a29k_it
const relax_typeS md_relax_table[] =
-{0};
+{
+ { 0, 0, 0, 0 }
+};
#define IMMEDIATE_BIT 0x01000000 /* Turns RB into Immediate */
#define ABSOLUTE_BIT 0x01000000 /* Turns PC-relative to Absolute */
int reloc_offset; /* Offset of reloc within insn */
int reloc;
-
-
}
-
the_insn;
-#if __STDC__ == 1
-
-/* static int getExpression(char *str); */
-static void machine_ip (char *str);
-/* static void print_insn(struct machine_it *insn); */
-static void s_data1 (void);
-static void s_use (void);
-
-#else /* not __STDC__ */
-
-/* static int getExpression(); */
-static void machine_ip ();
-/* static void print_insn(); */
-static void s_data1 ();
-static void s_use ();
-
-#endif /* not __STDC__ */
+static void machine_ip PARAMS ((char *str));
+/* static void print_insn PARAMS ((struct machine_it *insn)); */
+#ifndef OBJ_COFF
+static void s_data1 PARAMS ((void));
+static void s_use PARAMS ((int));
+#endif
const pseudo_typeS
- md_pseudo_table[] =
+md_pseudo_table[] =
{
{"align", s_align_bytes, 4},
{"block", s_space, 0},
{"space", s_ignore, 0}, /* Listing control */
{"sect", s_ignore, 0}, /* Creation of coff sections */
#ifndef OBJ_COFF
-/* We can do this right with coff */
+ /* We can do this right with coff. */
{"use", s_use, 0},
#endif
{"word", cons, 4},
const char FLT_CHARS[] = "rRsSfFdDxXpP";
/* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
- changed in read.c . Ideally it shouldn't have to know about it at all,
- but nothing is ideal around here.
- */
+ changed in read.c. Ideally it shouldn't have to know about it at
+ all, but nothing is ideal around here. */
static unsigned char octal[256];
#define isoctal(c) octal[c]
*/
#define ANNUL (1 << 29)
+#ifndef OBJ_COFF
+
static void
-s_use ()
+s_use (ignore)
+ int ignore;
{
-
if (strncmp (input_line_pointer, ".text", 5) == 0)
{
input_line_pointer += 5;
- s_text ();
+ s_text (0);
return;
}
if (strncmp (input_line_pointer, ".data", 5) == 0)
{
input_line_pointer += 5;
- s_data ();
+ s_data (0);
return;
}
if (strncmp (input_line_pointer, ".data1", 6) == 0)
s_data1 ();
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. */
+ /* Literals can't go in the text segment because you can't read from
+ instruction memory on some 29k's. So, into initialized data. */
if (strncmp (input_line_pointer, ".lit", 4) == 0)
{
input_line_pointer += 4;
- subseg_new (SEG_DATA, 200);
+ subseg_set (SEG_DATA, 200);
demand_empty_rest_of_line ();
return;
}
as_bad ("Unknown segment type");
demand_empty_rest_of_line ();
- return;
}
static void
s_data1 ()
{
- subseg_new (SEG_DATA, 1);
+ subseg_set (SEG_DATA, 1);
demand_empty_rest_of_line ();
- return;
}
+#endif /* OBJ_COFF */
+
/* Install symbol definition that maps REGNAME to REGNO.
FIXME-SOON: These are not recognized in mixed case. */
char *regname;
int regnum;
{
- /* FIXME-SOON, put something in these syms so they won't be output to the symbol
- table of the resulting object file. */
+ /* FIXME-SOON, put something in these syms so they won't be output
+ to the symbol table of the resulting object file. */
/* Must be large enough to hold the names of the special registers. */
char buf[80];
int i;
- symbol_table_insert (symbol_new (regname, SEG_REGISTER, regnum, &zero_address_frag));
+ 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] = '\0';
- symbol_table_insert (symbol_new (buf, SEG_REGISTER, regnum, &zero_address_frag));
-} /* insert_sreg() */
+ symbol_table_insert (symbol_new (buf, SEG_REGISTER, (valueT) regnum,
+ &zero_address_frag));
+}
/* Install symbol definitions for assorted special registers.
See ASM29K Ref page 2-9. */
insert_sreg ("fps", SREG + 162);
/* "", SREG+163); Reserved */
insert_sreg ("exop", SREG + 164);
-} /* define_some_regs() */
+}
/* This function is called once, at assembler startup time. It should
- set up all the tables, etc. that the MD part of the assembler will need. */
+ set up all the tables, etc., that the MD part of the assembler will
+ need. */
void
md_begin ()
{
- register char *retval = NULL;
+ register const char *retval = NULL;
int lose = 0;
register int skipnext = 0;
register unsigned int i;
}
/* 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 ((machine_opcodes[i].opcode ^ machine_opcodes[i + 1].opcode)
- != 0x01000000)
+ if ((machine_opcodes[i].opcode & 0x01000000) != 0
+ || (machine_opcodes[i + 1].opcode & 0x01000000) == 0
+ || ((machine_opcodes[i].opcode | 0x01000000)
+ != machine_opcodes[i + 1].opcode))
goto bad_table;
strend = machine_opcodes[i].args + strlen (machine_opcodes[i].args) - 1;
strend2 = machine_opcodes[i + 1].args + strlen (machine_opcodes[i + 1].args) - 1;
if (*strend2 != 'i')
goto bad_table;
break;
- case 'i':
- if (*strend2 != 'b')
- goto bad_table;
- break;
case 'P':
if (*strend2 != 'A')
goto bad_table;
break;
- case 'A':
- if (*strend2 != 'P')
- goto bad_table;
- break;
default:
bad_table:
- fprintf (stderr, "internal error: can't handle opcode %s\n", name);
+ fprintf (stderr, "internal error: can't handle opcode %s\n",
+ name);
lose = 1;
}
- /* OK, this is an i/b or A/P pair. We skip the higher-valued one,
- and let the code for operand checking handle OR-ing in the bit. */
- if (machine_opcodes[i].opcode & 1)
- continue;
- else
- skipnext = 1;
+ /* OK, this is an i/b or A/P pair. We skip the
+ higher-valued one, and let the code for operand checking
+ handle OR-ing in the bit. */
+ skipnext = 1;
}
- retval = hash_insert (op_hash, name, &machine_opcodes[i]);
- if (retval != NULL && *retval != '\0')
+ retval = hash_insert (op_hash, name, (PTR) &machine_opcodes[i]);
+ if (retval != NULL)
{
fprintf (stderr, "internal error: can't hash `%s': %s\n",
machine_opcodes[i].name, retval);
define_some_regs ();
}
-void
-md_end ()
-{
- return;
-}
-
/* Assemble a single instruction. Its label has already been handled
by the generic front end. We just parse opcode and operands, and
produce the bytes of data and relocation. */
char *str;
{
char *toP;
- /* !!!! int rsd; */
know (str);
machine_ip (str);
{
char *s;
const char *args;
- /* !!!! char c; */
- /* !!!! unsigned long i; */
struct machine_opcode *insn;
char *argsStart;
unsigned long opcode;
- /* !!!! unsigned int mask; */
expressionS the_operand;
expressionS *operand = &the_operand;
unsigned int reg;
memset (&the_insn, '\0', sizeof (the_insn));
the_insn.reloc = NO_RELOC;
- /*
- * 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".
- */
+ /* 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". */
+
if (insn->args[0] != '\0')
s = parse_operand (s, operand); /* Prime the pump */
}
else
{
- as_bad ("Immediate value of %d is too large",
- operand->X_add_number);
+ as_bad ("Immediate value of %ld is too large",
+ (long) operand->X_add_number);
continue;
}
}
case 'b': /* A general register or 8-bit immediate */
case 'i':
/* We treat the two cases identically since we mashed
- them together in the opcode table. */
+ them together in the opcode table. */
if (operand->X_op == O_register)
goto general_reg;
+ /* Make sure the 'i' case really exists. */
+ if ((insn->opcode | IMMEDIATE_BIT) != (insn + 1)->opcode)
+ break;
+
opcode |= IMMEDIATE_BIT;
if (operand->X_op == O_constant)
{
}
else
{
- as_bad ("Immediate value of %d is too large",
- operand->X_add_number);
+ as_bad ("Immediate value of %ld is too large",
+ (long) operand->X_add_number);
continue;
}
}
if (reg >= SREG)
break; /* No special registers */
- /*
- * Got the register, now figure out where
- * it goes in the opcode.
- */
+ /* Got the register, now figure out where it goes in the
+ opcode. */
switch (*args)
{
case 'a':
opcode table entries together. */
if (operand->X_op == O_constant)
{
+ /* Make sure the 'A' case really exists. */
+ if ((insn->opcode | ABSOLUTE_BIT) != (insn + 1)->opcode)
+ break;
opcode |= ABSOLUTE_BIT |
(operand->X_add_number & 0x0003FC00) << 6 |
((operand->X_add_number & 0x000003FC) >> 2);
the_insn.reloc = RELOC_JUMPTARG;
the_insn.exp = *operand;
the_insn.pcrel = 1; /* Assume PC-relative jump */
- /* FIXME-SOON, Do we figure out whether abs later, after know sym val? */
+ /* FIXME-SOON, Do we figure out whether abs later, after
+ know sym val? */
continue;
case 'e': /* Coprocessor enable bit for LOAD/STORE insn */
}
}
-/*
- This is identical to the md_atof in m68k.c. I think this is right,
- but I'm not sure.
+/* This is identical to the md_atof in m68k.c. I think this is right,
+ 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 returned, or NULL on OK.
- */
+ 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
+ returned, or NULL on OK. */
/* Equal to MAX_PRECISION in atof-ieee.c */
#define MAX_LITTLENUMS 6
*sizeP = prec * sizeof (LITTLENUM_TYPE);
for (wordP = words; prec--;)
{
- md_number_to_chars (litP, (long) (*wordP++), sizeof (LITTLENUM_TYPE));
+ md_number_to_chars (litP, (valueT) (*wordP++), sizeof (LITTLENUM_TYPE));
litP += sizeof (LITTLENUM_TYPE);
}
- return ""; /* Someone should teach Dean about null pointers */
+ return 0;
}
/*
valueT val;
int n;
{
-
- switch (n)
- {
-
- case 4:
- *buf++ = val >> 24;
- *buf++ = val >> 16;
- case 2:
- *buf++ = val >> 8;
- case 1:
- *buf = val;
- break;
-
- default:
- as_fatal ("failed sanity check.");
- }
- return;
+ number_to_chars_bigendian (buf, val, n);
}
void
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.
- */
+ /* 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;
as_bad ("bad relocation type: 0x%02x", fixP->fx_r_type);
break;
}
- return;
}
#ifdef OBJ_COFF
} /* switch on type */
return (0);
-} /* tc_coff_fix2rtype() */
+}
#endif /* OBJ_COFF */
-/* should never be called for sparc */
+/* should never be called for 29k */
void
md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol)
char *ptr;
object_headers *headers;
register fragS *fragP;
{
- as_fatal ("sparc_convert_frag\n");
+ as_fatal ("a29k_convert_frag\n");
}
/* should never be called for 29k */
fragS *frag;
symbolS *to_symbol;
{
- as_fatal ("sparc_create_long_jump\n");
+ as_fatal ("a29k_create_long_jump\n");
}
/* should never be called for a29k */
register fragS *fragP;
segT segtype;
{
- as_fatal ("sparc_estimate_size_before_relax\n");
- return (0);
+ as_fatal ("a29k_estimate_size_before_relax\n");
+ return 0;
}
#if 0
fprintf (stderr, "\t\tX_add_number = %d\n",
insn->exp.X_add_number);
fprintf (stderr, "}\n");
- return;
}
#endif
where[7] = (((!S_IS_DEFINED (fixP->fx_addsy)) << 7) & 0x80) | (0 & 0x60) | (fixP->fx_r_type & 0x1F);
/* Also easy */
md_number_to_chars (&where[8], fixP->fx_addnumber, 4);
-
- return;
-} /* tc_aout_fix_to_chars() */
+}
#endif /* OBJ_AOUT */
int *cntP;
char ***vecP;
{
- return (0);
+ return 0;
}
/* We have a wiener! Define and return a new symbol for it. */
if (name[0] == 'l' || name[0] == 'L')
regnum += 128;
- return (symbol_new (name, SEG_REGISTER, regnum, &zero_address_frag));
+ return (symbol_new (name, SEG_REGISTER, (valueT) regnum,
+ &zero_address_frag));
}
}
return fixP->fx_where + fixP->fx_frag->fr_address;
}
-/*
- * Local Variables:
- * comment-column: 0
- * End:
- */
-
/* end of tc-a29k.c */