/* m88k.c -- Assembler for the Motorola 88000
Contributed by Devon Bowen of Buffalo University
and Torbjorn Granlund of the Swedish Institute of Computer Science.
- Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc.
+ Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999
+ Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
+the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
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, 675 Mass Ave, Cambridge, MA 02139, 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. */
#include <ctype.h>
#include "as.h"
+#include "subsegs.h"
#include "m88k-opcode.h"
-char *getval ();
-char *get_reg ();
-char *get_imm16 ();
-char *get_bf ();
-char *get_pcr ();
-char *get_cmp ();
-char *get_cnd ();
-char *get_cr ();
-char *get_fcr ();
-char *get_vec9 ();
-
struct field_val_assoc
{
char *name;
enum reloc_type reloc;
};
+static char *get_bf PARAMS ((char *param, unsigned *valp));
+static char *get_cmp PARAMS ((char *param, unsigned *valp));
+static char *get_cnd PARAMS ((char *param, unsigned *valp));
+static char *get_cr PARAMS ((char *param, unsigned *regnop));
+static char *get_fcr PARAMS ((char *param, unsigned *regnop));
+static char *get_imm16 PARAMS ((char *param, struct m88k_insn *insn));
+static char *get_o6 PARAMS ((char *param, unsigned *valp));
+static char *get_reg PARAMS ((char *param, unsigned *regnop, int reg_prefix));
+static char *get_vec9 PARAMS ((char *param, unsigned *valp));
+static char *getval PARAMS ((char *param, unsigned int *valp));
+
+static char *get_pcr PARAMS ((char *param, struct m88k_insn *insn,
+ enum reloc_type reloc));
+
+static int calcop PARAMS ((struct m88k_opcode *format,
+ char *param, struct m88k_insn *insn));
+
+
extern char *myname;
static struct hash_control *op_hash = NULL;
/* These bits should be turned off in the first address of every segment */
int md_seg_align = 7;
-/* This is the number to put at the beginning of the a.out file */
-long omagic = OMAGIC;
-
/* These chars start a comment anywhere in a source file (except inside
another comment */
const char comment_chars[] = ";";
extern void float_cons (), cons (), s_globl (), s_space (),
s_set (), s_lcomm ();
-static void s_file ();
const pseudo_typeS md_pseudo_table[] =
{
{"bss", s_lcomm, 1},
{"string", stringer, 0},
{"word", cons, 4},
- {"zero", s_space, 0},
+ /* Force set to be treated as an instruction. */
+ {"set", NULL, 0},
+ {".set", s_set, 0},
{0}
};
void
md_begin ()
{
- char *retval = NULL;
+ const char *retval = NULL;
unsigned int i = 0;
/* initialize hash table */
op_hash = hash_new ();
- if (op_hash == NULL)
- as_fatal ("Could not initialize hash table");
/* loop until you see the end of the list */
retval = hash_insert (op_hash, name, &m88k_opcodes[i]);
- if (retval != NULL && *retval != '\0')
- as_fatal ("Can't hash instruction '%s':%s",
+ if (retval != NULL)
+ as_fatal (_("Can't hash instruction '%s':%s"),
m88k_opcodes[i].name, retval);
/* skip to next unique mnemonic or end of list */
;
}
}
+\f
+CONST char *md_shortopts = "";
+struct option md_longopts[] = {
+ {NULL, no_argument, NULL, 0}
+};
+size_t md_longopts_size = sizeof(md_longopts);
int
-md_parse_option (argP, cntP, vecP)
- char **argP;
- int *cntP;
- char ***vecP;
+md_parse_option (c, arg)
+ int c;
+ char *arg;
{
return 0;
}
+void
+md_show_usage (stream)
+ FILE *stream;
+{
+}
+\f
void
md_assemble (op)
char *op;
if ((format = (struct m88k_opcode *) hash_find (op_hash, op)) == NULL)
{
- extern struct hash_control *po_hash;
- pseudo_typeS *pop;
- char *hold;
-
- /* The m88k assembler does not use `.' before pseudo-ops, for
- some reason. So if don't find an opcode, try for a
- pseudo-op. */
- pop = (pseudo_typeS *) hash_find (po_hash, op);
-
- if (pop == NULL)
- {
- as_bad ("Invalid mnemonic '%s'", op);
- return;
- }
-
- /* Restore the character after the opcode. */
- *--param = c;
-
- /* Now we have to hack. The pseudo-op code expects
- input_line_pointer to point to the first non-whitespace
- character after the pseudo-op itself. The calling code has
- already advanced input_line_pointer to the end of the line
- and inserted a null byte. We set things up for the pseudo-op
- code, and then prepare to return from this function. */
- hold = input_line_pointer;
- *hold = ';';
- input_line_pointer = param;
- SKIP_WHITESPACE ();
-
- (*pop->poc_handler) (pop->poc_val);
-
- input_line_pointer = hold;
-
+ as_bad (_("Invalid mnemonic '%s'"), op);
return;
}
/* try parsing this instruction into insn */
insn.exp.X_add_symbol = 0;
- insn.exp.X_subtract_symbol = 0;
+ insn.exp.X_op_symbol = 0;
insn.exp.X_add_number = 0;
- insn.exp.X_seg = 0;
+ insn.exp.X_op = O_illegal;
insn.reloc = NO_RELOC;
while (!calcop (format, param, &insn))
format++;
else
{
- as_fatal ("Parameter syntax error");
+ as_fatal (_("Parameter syntax error"));
return;
}
}
case RELOC_LO16:
case RELOC_HI16:
- fix_new (frag_now,
- thisfrag - frag_now->fr_literal + 2,
- 2,
- insn.exp.X_add_symbol,
- insn.exp.X_subtract_symbol,
- insn.exp.X_add_number,
- 0,
- insn.reloc);
+ fix_new_exp (frag_now,
+ thisfrag - frag_now->fr_literal + 2,
+ 2,
+ &insn.exp,
+ 0,
+ insn.reloc);
break;
case RELOC_IW16:
- fix_new (frag_now,
- thisfrag - frag_now->fr_literal,
- 4,
- insn.exp.X_add_symbol,
- insn.exp.X_subtract_symbol,
- insn.exp.X_add_number,
- 0,
- insn.reloc);
+ fix_new_exp (frag_now,
+ thisfrag - frag_now->fr_literal,
+ 4,
+ &insn.exp,
+ 0,
+ insn.reloc);
break;
case RELOC_PC16:
- fix_new (frag_now,
- thisfrag - frag_now->fr_literal + 2,
- 2,
- insn.exp.X_add_symbol,
- insn.exp.X_subtract_symbol,
- insn.exp.X_add_number,
- 1,
- insn.reloc);
+ fix_new_exp (frag_now,
+ thisfrag - frag_now->fr_literal + 2,
+ 2,
+ &insn.exp,
+ 1,
+ insn.reloc);
break;
case RELOC_PC26:
- fix_new (frag_now,
- thisfrag - frag_now->fr_literal,
- 4,
- insn.exp.X_add_symbol,
- insn.exp.X_subtract_symbol,
- insn.exp.X_add_number,
- 1,
- insn.reloc);
+ fix_new_exp (frag_now,
+ thisfrag - frag_now->fr_literal,
+ 4,
+ &insn.exp,
+ 1,
+ insn.reloc);
break;
default:
- as_fatal ("Unknown relocation type");
+ as_fatal (_("Unknown relocation type"));
break;
}
}
-int
+static int
calcop (format, param, insn)
struct m88k_opcode *format;
char *param;
{
case 0:
insn->opcode |= opcode;
- return *param == 0;
+ return (*param == 0 || *param == '\n');
default:
if (f != *param++)
opcode |= val << 21;
break;
+ case 'o':
+ param = get_o6 (param, &val);
+ opcode |= ((val >> 2) << 7);
+ break;
+
case 'x':
reg_prefix = 'x';
break;
case '?':
/* Having this here repeats the warning somtimes.
But can't we stand that? */
- as_warn ("Use of obsolete instruction");
+ as_warn (_("Use of obsolete instruction"));
break;
}
}
}
-char *
+static char *
match_name (param, assoc_tab, valp)
char *param;
struct field_val_assoc *assoc_tab;
}
}
-char *
+static char *
get_reg (param, regnop, reg_prefix)
char *param;
unsigned *regnop;
return 0;
}
-char *
+static char *
get_imm16 (param, insn)
char *param;
struct m88k_insn *insn;
{
enum reloc_type reloc = NO_RELOC;
unsigned int val;
- segT seg;
char *save_ptr;
if (!strncmp (param, "hi16", 4) && !isalnum (param[4]))
save_ptr = input_line_pointer;
input_line_pointer = param;
- seg = expression (&insn->exp);
+ expression (&insn->exp);
param = input_line_pointer;
input_line_pointer = save_ptr;
val = insn->exp.X_add_number;
- if (seg == SEG_ABSOLUTE)
+ if (insn->exp.X_op == O_constant)
{
/* Insert the value now, and reset reloc to NO_RELOC. */
if (reloc == NO_RELOC)
{
/* Warn about too big expressions if not surrounded by xx16. */
if (val > 0xffff)
- as_warn ("Expression truncated to 16 bits");
+ as_warn (_("Expression truncated to 16 bits"));
}
if (reloc == RELOC_HI16)
return param;
}
-char *
+static char *
get_pcr (param, insn, reloc)
char *param;
struct m88k_insn *insn;
enum reloc_type reloc;
{
char *saveptr, *saveparam;
- segT seg;
saveptr = input_line_pointer;
input_line_pointer = param;
- seg = expression (&insn->exp);
+ expression (&insn->exp);
saveparam = input_line_pointer;
input_line_pointer = saveptr;
- /* Botch: We should relocate now if SEG_ABSOLUTE. */
+ /* Botch: We should relocate now if O_constant. */
insn->reloc = reloc;
return saveparam;
}
-char *
+static char *
get_cmp (param, valp)
char *param;
unsigned *valp;
if (val >= 32)
{
- as_warn ("Expression truncated to 5 bits");
+ as_warn (_("Expression truncated to 5 bits"));
val %= 32;
}
}
return param;
}
-char *
+static char *
get_cnd (param, valp)
char *param;
unsigned *valp;
if (val >= 32)
{
- as_warn ("Expression truncated to 5 bits");
+ as_warn (_("Expression truncated to 5 bits"));
val %= 32;
}
}
return param;
}
-char *
+static char *
get_bf2 (param, bc)
char *param;
int bc;
}
}
-char *
+static char *
get_bf_offset_expression (param, offsetp)
char *param;
unsigned *offsetp;
return param;
}
-char *
+static char *
get_bf (param, valp)
char *param;
unsigned *valp;
return param;
}
-char *
+static char *
get_cr (param, regnop)
char *param;
unsigned *regnop;
{
unsigned regno;
unsigned c;
- int i;
- int name_len;
if (!strncmp (param, "cr", 2))
{
return param;
}
-char *
+static char *
get_fcr (param, regnop)
char *param;
unsigned *regnop;
{
unsigned regno;
unsigned c;
- int i;
- int name_len;
if (!strncmp (param, "fcr", 3))
{
return param;
}
-char *
+static char *
get_vec9 (param, valp)
char *param;
unsigned *valp;
input_line_pointer = save_ptr;
if (val >= 1 << 9)
- as_warn ("Expression truncated to 9 bits");
+ as_warn (_("Expression truncated to 9 bits"));
*valp = val % (1 << 9);
return param;
}
+static char *
+get_o6 (param, valp)
+ char *param;
+ unsigned *valp;
+{
+ unsigned val;
+ char *save_ptr;
+
+ save_ptr = input_line_pointer;
+ input_line_pointer = param;
+ val = get_absolute_expression ();
+ param = input_line_pointer;
+ input_line_pointer = save_ptr;
+
+ if (val & 0x3)
+ as_warn (_("Removed lower 2 bits of expression"));
+
+ *valp = val;
+
+ return(param);
+}
+
#define hexval(z) \
(isdigit (z) ? (z) - '0' : \
islower (z) ? (z) - 'a' + 10 : \
isupper (z) ? (z) - 'A' + 10 : -1)
-char *
+static char *
getval (param, valp)
char *param;
unsigned int *valp;
valueT val;
int nbytes;
{
- switch (nbytes)
- {
- case 4:
- *buf++ = val >> 24;
- *buf++ = val >> 16;
- case 2:
- *buf++ = val >> 8;
- case 1:
- *buf = val;
- break;
-
- default:
- abort ();
- }
+ number_to_chars_bigendian (buf, val, nbytes);
}
#if 0
break;
default:
- as_fatal ("Bad relocation type");
+ as_fatal (_("Bad relocation type"));
break;
}
}
int val;
int nbytes;
{
- as_fatal ("md_number_to_disp not defined");
+ as_fatal (_("md_number_to_disp not defined"));
md_number_to_chars (buf, val, nbytes);
}
int val;
int nbytes;
{
- as_fatal ("md_number_to_field not defined");
+ as_fatal (_("md_number_to_field not defined"));
md_number_to_chars (buf, val, nbytes);
}
LITTLENUM_TYPE words[MAX_LITTLENUMS];
LITTLENUM_TYPE *wordP;
char *t;
- char *atof_ieee ();
switch (type)
{
default:
*sizeP = 0;
- return "Bad call to MD_ATOF()";
+ return _("Bad call to MD_ATOF()");
}
t = atof_ieee (input_line_pointer, type, words);
if (t)
md_number_to_chars (litP, (long) (*wordP++), sizeof (LITTLENUM_TYPE));
litP += sizeof (LITTLENUM_TYPE);
}
- return ""; /* Someone should teach Dean about null pointers */
+ return 0;
}
int md_short_jump_size = 4;
ptr - frag->fr_literal,
4,
to_symbol,
- (symbolS *) 0,
- (long int) 0,
+ (offsetT) 0,
0,
RELOC_PC26); /* Botch: Shouldn't this be RELOC_PC16? */
}
ptr - frag->fr_literal,
4,
to_symbol,
- (symbolS *) 0,
- (long int) 0,
+ (offsetT) 0,
0,
RELOC_PC26);
}
fragS *fragP;
segT segment_type;
{
- as_fatal ("Relaxation should never occur");
-}
-
-const relax_typeS md_relax_table[] =
-{0};
-
-void
-md_end ()
-{
+ as_fatal (_("Relaxation should never occur"));
+ return (-1);
}
#if 0
ri.r_extern = 0;
ri.r_symbolnum = symbolP->sy_type & N_TYPE;
}
- if (symbolP && symbolP->sy_frag)
+ if (symbolP && symbol_get_frag (symbolP))
{
- ri.r_addend = symbolP->sy_frag->fr_address;
+ ri.r_addend = symbol_get_frag (symbolP)->fr_address;
}
ri.r_type = fixP->fx_r_type;
if (fixP->fx_pcrel)
append (&next_object_file_charP, (char *) &ri, sizeof (ri));
}
}
- return;
}
#endif /* 0 */
SKIP_WHITESPACE ();
if (*input_line_pointer != ',')
{
- as_warn ("Expected comma after name");
+ as_warn (_("Expected comma after name"));
ignore_rest_of_line ();
return;
}
input_line_pointer++;
if ((temp = get_absolute_expression ()) < 0)
{
- as_warn ("BSS length (%d.) <0! Ignored.", temp);
+ as_warn (_("BSS length (%d.) <0! Ignored."), temp);
ignore_rest_of_line ();
return;
}
segT current_seg = now_seg;
subsegT current_subseg = now_subseg;
- subseg_new (SEG_BSS, 1); /* switch to bss */
+ subseg_set (SEG_BSS, 1); /* switch to bss */
if (bss_align)
- frag_align (bss_align, 0);
+ frag_align (bss_align, 0, 0);
/* detach from old frag */
- if (symbolP->sy_type == N_BSS && symbolP->sy_frag != NULL)
- symbolP->sy_frag->fr_symbol = NULL;
+ if (symbolP->sy_type == N_BSS && symbol_get_frag (symbolP) != NULL)
+ symbol_get_frag (symbolP)->fr_symbol = NULL;
- symbolP->sy_frag = frag_now;
+ symbol_set_frag (symbolP, frag_now);
p = frag_var (rs_org, 1, 1, (relax_substateT)0, symbolP,
- temp, (char *)0);
+ (offsetT) temp, (char *)0);
*p = 0;
S_SET_SEGMENT (symbolP, SEG_BSS);
- subseg_new (current_seg, current_subseg);
+ subseg_set (current_seg, current_subseg);
}
}
else
{
- as_warn ("Ignoring attempt to re-define symbol %s.", name);
+ as_warn (_("Ignoring attempt to re-define symbol %s."), name);
}
- while (!is_end_of_line[*input_line_pointer])
+ while (!is_end_of_line[(unsigned char) *input_line_pointer])
{
input_line_pointer++;
}
-
- return;
}
#endif /* 0 */
char *buf;
buf = fixp->fx_frag->fr_literal + fixp->fx_where;
+ fixp->fx_offset = 0;
switch (fixp->fx_r_type)
{
case RELOC_IW16:
+ fixp->fx_offset = val >> 16;
buf[2] = val >> 8;
buf[3] = val;
break;
case RELOC_LO16:
+ fixp->fx_offset = val >> 16;
buf[0] = val >> 8;
buf[1] = val;
break;
case RELOC_HI16:
- buf[0] = val >> 24;
- buf[1] = val >> 16;
+ fixp->fx_offset = val >> 16;
+ buf[0] = val >> 8;
+ buf[1] = val;
break;
case RELOC_PC16:
md_pcrel_from (fixp)
fixS *fixp;
{
- return fixp->fx_frag->fr_address + fixp->fx_where + 4;
+ switch (fixp->fx_r_type)
+ {
+ case RELOC_PC16:
+ return fixp->fx_frag->fr_address + fixp->fx_where - 2;
+ case RELOC_PC26:
+ return fixp->fx_frag->fr_address + fixp->fx_where;
+ default:
+ abort ();
+ }
+ /*NOTREACHED*/
+}
+
+/* When we align the .init section, insert the correct NOP pattern. */
+
+int
+m88k_do_align (n, fill, max, len)
+ int n;
+ const char *fill;
+ int len;
+ int max;
+{
+ if (fill == NULL
+ && strcmp (obj_segment_name (now_seg), ".init") == 0)
+ {
+ static const unsigned char nop_pattern[] = { 0xf4, 0x00, 0x58, 0x00 };
+ frag_align_pattern (n, nop_pattern, sizeof (nop_pattern), max);
+ return 1;
+ }
+ return 0;
}
#endif /* M88KCOFF */