aboutsummaryrefslogtreecommitdiff
path: root/gas/config
diff options
context:
space:
mode:
authorK. Richard Pixley <rich@cygnus>1992-02-17 15:54:49 +0000
committerK. Richard Pixley <rich@cygnus>1992-02-17 15:54:49 +0000
commit542e1629fdd4df8920511c4eb2df15bb83feb13b (patch)
treef1b70b61ce3707e08b2f43081adfd3b4850654f3 /gas/config
parentaf2136245013fad2f72249258452d5f7154d5719 (diff)
downloadgdb-542e1629fdd4df8920511c4eb2df15bb83feb13b.zip
gdb-542e1629fdd4df8920511c4eb2df15bb83feb13b.tar.gz
gdb-542e1629fdd4df8920511c4eb2df15bb83feb13b.tar.bz2
fighting bitrot in a major way
Diffstat (limited to 'gas/config')
-rw-r--r--gas/config/.Sanitize9
-rw-r--r--gas/config/ho-ansi.h1
-rw-r--r--gas/config/ho-generic.h2
-rw-r--r--gas/config/ho-sunos.h3
-rw-r--r--gas/config/ho-sysv.h2
-rw-r--r--gas/config/obj-coffbfd.c10
-rw-r--r--gas/config/tc-a29k.c27
-rw-r--r--gas/config/tc-a29k.h12
-rw-r--r--gas/config/tc-i386.c219
-rw-r--r--gas/config/tc-i386.h78
-rw-r--r--gas/config/tc-i860.c10
-rw-r--r--gas/config/tc-i960.c10
-rw-r--r--gas/config/tc-m68kmote.c6885
-rw-r--r--gas/config/tc-m68kmote.h2
-rw-r--r--gas/config/tc-ns32k.c2488
-rw-r--r--gas/config/tc-sparc.c4
16 files changed, 4901 insertions, 4861 deletions
diff --git a/gas/config/.Sanitize b/gas/config/.Sanitize
index d831b5d..b3f5e27 100644
--- a/gas/config/.Sanitize
+++ b/gas/config/.Sanitize
@@ -32,9 +32,7 @@ atof-ieee.c
atof-vax.c
coff.gnu.h
cplus-dem.c
-ho-a29k.h
ho-ansi.h
-ho-cygnus.h
ho-decstation.h
ho-generic.h
ho-hpux.h
@@ -46,8 +44,6 @@ ho-sun4.h
ho-sunos.h
ho-sysv.h
ho-vax.h
-mh-a29k
-mh-cygnus
mh-i386
mt-ebmon29k
mt-h8300
@@ -128,7 +124,10 @@ echo Done in `pwd`.
#
#
# $Log$
-# Revision 1.14 1992/02/13 10:13:24 rich
+# Revision 1.15 1992/02/17 15:53:46 rich
+# fighting bitrot in a major way
+#
+# Revision 1.14 1992/02/13 10:13:24 rich
# clean up Sanitize for gas
#
# Revision 1.13 1992/02/11 00:51:52 sac
diff --git a/gas/config/ho-ansi.h b/gas/config/ho-ansi.h
index 095c24b..2af0341 100644
--- a/gas/config/ho-ansi.h
+++ b/gas/config/ho-ansi.h
@@ -25,6 +25,5 @@
#define sys_nerr _sys_nerr
#define sys_errlist _sys_errlist
-#define bzero(b,l) (memset((b),0,(l)))
/* end of ho-ansi.h */
diff --git a/gas/config/ho-generic.h b/gas/config/ho-generic.h
index 04db63e..493cfc6 100644
--- a/gas/config/ho-generic.h
+++ b/gas/config/ho-generic.h
@@ -23,6 +23,8 @@
#define M_GENERIC 1
+#define HAVE_STRERROR
+
extern int free();
/* end of ho-generic.h */
diff --git a/gas/config/ho-sunos.h b/gas/config/ho-sunos.h
index 52951a6..1193b1b 100644
--- a/gas/config/ho-sunos.h
+++ b/gas/config/ho-sunos.h
@@ -43,9 +43,6 @@ extern char *strchr();
extern char *strrchr();
extern int _filbuf();
extern int _flsbuf();
-extern int bcopy();
-extern int bzero();
-extern int bzero();
extern int fclose();
extern int fgetc();
extern int fprintf();
diff --git a/gas/config/ho-sysv.h b/gas/config/ho-sysv.h
index bc9b267..443fe3b 100644
--- a/gas/config/ho-sysv.h
+++ b/gas/config/ho-sysv.h
@@ -19,8 +19,6 @@
#define HO_USG
-#define bcopy(from,to,n) memcpy((to),(from),(n))
-#define bzero(s,n) memset((s),0,(n))
#define setbuffer(stream, buf, size) setvbuf((stream), (buf), _IOLBF, (size))
extern int free();
diff --git a/gas/config/obj-coffbfd.c b/gas/config/obj-coffbfd.c
index dd4c527..4d10635 100644
--- a/gas/config/obj-coffbfd.c
+++ b/gas/config/obj-coffbfd.c
@@ -597,7 +597,7 @@ symbolS *symbolP;
/* Additional information */
symbolP->sy_symbol.ost_flags = 0;
/* Auxiliary entries */
- bzero((char*)&symbolP->sy_symbol.ost_auxent[0], AUXESZ);
+ memset((char*) &symbolP->sy_symbol.ost_auxent[0], '\0', AUXESZ);
#ifdef STRIP_UNDERSCORE
/* Remove leading underscore at the beginning of the symbol.
@@ -749,7 +749,7 @@ static void
SKIP_WHITESPACES();
def_symbol_in_progress = (symbolS *) obstack_alloc(&notes, sizeof(*def_symbol_in_progress));
- bzero(def_symbol_in_progress, sizeof(*def_symbol_in_progress));
+ memset(def_symbol_in_progress, '\0', sizeof(*def_symbol_in_progress));
symbol_name = input_line_pointer;
name_end = get_symbol_end();
@@ -1269,8 +1269,8 @@ static unsigned int DEFUN_VOID(yank_symbols)
} /* make it at least 1 */
/* Clobber possible stale .dim information. */
- bzero(symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen,
- sizeof(symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen));
+ memset(symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen,
+ '\0', sizeof(symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen));
}
/* The C_FCN doesn't need any additional information.
I don't even know if this is needed for sdb. But the
@@ -1947,7 +1947,7 @@ static void
S_SET_OFFSET(symbolP, symbolP->sy_name_offset);
S_SET_ZEROES(symbolP, 0);
} else {
- bzero(symbolP->sy_symbol.ost_entry.n_name, SYMNMLEN);
+ memset(symbolP->sy_symbol.ost_entry.n_name, '\0', SYMNMLEN);
strncpy(symbolP->sy_symbol.ost_entry.n_name, temp, SYMNMLEN);
}
where = symbol_to_chars(abfd, where, symbolP);
diff --git a/gas/config/tc-a29k.c b/gas/config/tc-a29k.c
index 5fe4909..fbdadb5 100644
--- a/gas/config/tc-a29k.c
+++ b/gas/config/tc-a29k.c
@@ -437,7 +437,7 @@ char *str;
}
argsStart = s;
opcode = insn->opcode;
- bzero(&the_insn, sizeof(the_insn));
+ memset(&the_insn, '\0', sizeof(the_insn));
the_insn.reloc = NO_RELOC;
/*
@@ -900,20 +900,21 @@ register fragS *fragP;
/* should never be called for 29k */
void md_create_long_jump(ptr, from_addr, to_addr, frag, to_symbol)
char *ptr;
-long from_addr,
- to_addr;
+long from_addr;
+long to_addr;
fragS *frag;
symbolS *to_symbol;
{
as_fatal("sparc_create_long_jump\n");
}
-/* should never be called for sparc */
+/* should never be called for a29k */
int md_estimate_size_before_relax(fragP, segtype)
register fragS *fragP;
segT segtype;
{
as_fatal("sparc_estimate_size_before_relax\n");
+ return(0);
}
#if 0
@@ -986,24 +987,22 @@ char *where;
fixS *fixP;
relax_addressT segment_address_in_file;
{
- long r_index;
+ long r_symbolnum;
know(fixP->fx_r_type < NO_RELOC);
know(fixP->fx_addsy != NULL);
- r_index = (S_IS_DEFINED(fixP->fx_addsy)
- ? S_GET_TYPE(fixP->fx_addsy)
- : fixP->fx_addsy->sy_number);
-
- /* this is easy */
md_number_to_chars(where,
fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file,
4);
- /* now the fun stuff */
- where[4] = (r_index >> 16) & 0x0ff;
- where[5] = (r_index >> 8) & 0x0ff;
- where[6] = r_index & 0x0ff;
+ r_symbolnum = (S_IS_DEFINED(fixP->fx_addsy)
+ ? S_GET_TYPE(fixP->fx_addsy)
+ : fixP->fx_addsy->sy_number);
+
+ where[4] = (r_symbolnum >> 16) & 0x0ff;
+ where[5] = (r_symbolnum >> 8) & 0x0ff;
+ where[6] = r_symbolnum & 0x0ff;
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);
diff --git a/gas/config/tc-a29k.h b/gas/config/tc-a29k.h
index 254ebe1..d176262 100644
--- a/gas/config/tc-a29k.h
+++ b/gas/config/tc-a29k.h
@@ -19,15 +19,17 @@
#define TC_A29K
-#define tc_headers_hook(a) ; /* not used */
-#define tc_headers_hook(a) ; /* not used */
-#define tc_crawl_symbol_chain(a) ; /* not used */
-#define tc_coff_symbol_emit_hook(a) ; /* not used */
-
+#define tc_aout_pre_write_hook(x) {;} /* not used */
+#define tc_coff_symbol_emit_hook(a) {;} /* not used */
+#define tc_crawl_symbol_chain(a) {;} /* not used */
+#define tc_headers_hook(a) {;} /* not used */
+#define tc_headers_hook(a) {;} /* not used */
+
#define AOUT_MACHTYPE 101
#define TC_COFF_FIX2RTYPE(fix_ptr) tc_coff_fix2rtype(fix_ptr)
#define BFD_ARCH bfd_arch_a29k
#define COFF_MAGIC SIPFBOMAGIC
+
/* Should the reloc be output ?
on the 29k, this is true only if there is a symbol attatched.
on the h8, this is allways true, since no fixup is done
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 42398ae..92b4b4a 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -34,46 +34,47 @@
typedef struct {
/* TM holds the template for the insn were currently assembling. */
- template tm;
+ template tm;
/* SUFFIX holds the opcode suffix (e.g. 'l' for 'movl') if given. */
- char suffix;
+ char suffix;
/* Operands are coded with OPERANDS, TYPES, DISPS, IMMS, and REGS. */
/* OPERANDS gives the number of given operands. */
- unsigned int operands;
+ unsigned int operands;
/* REG_OPERANDS, DISP_OPERANDS, MEM_OPERANDS, IMM_OPERANDS give the number of
given register, displacement, memory operands and immediate operands. */
- unsigned int reg_operands, disp_operands, mem_operands, imm_operands;
+ unsigned int reg_operands, disp_operands, mem_operands, imm_operands;
/* TYPES [i] is the type (see above #defines) which tells us how to
search through DISPS [i] & IMMS [i] & REGS [i] for the required
operand. */
- unsigned int types [MAX_OPERANDS];
+ unsigned int types[MAX_OPERANDS];
/* Displacements (if given) for each operand. */
- expressionS * disps [MAX_OPERANDS];
+ expressionS *disps[MAX_OPERANDS];
/* Immediate operands (if given) for each operand. */
- expressionS * imms [MAX_OPERANDS];
+ expressionS *imms[MAX_OPERANDS];
/* Register operands (if given) for each operand. */
- reg_entry * regs [MAX_OPERANDS];
+ reg_entry *regs[MAX_OPERANDS];
/* BASE_REG, INDEX_REG, and LOG2_SCALE_FACTOR are used to encode
the base index byte below. */
- reg_entry * base_reg;
- reg_entry * index_reg;
- unsigned int log2_scale_factor;
+ reg_entry *base_reg;
+ reg_entry *index_reg;
+ unsigned int log2_scale_factor;
/* SEG gives the seg_entry of this insn. It is equal to zero unless
an explicit segment override is given. */
- seg_entry * seg; /* segment for memory operands (if given) */
+ const seg_entry *seg; /* segment for memory operands (if given) */
/* PREFIX holds all the given prefix opcodes (usually null).
PREFIXES is the size of PREFIX. */
- char prefix [MAX_PREFIXES];
- unsigned int prefixes;
+ /* richfix: really unsigned? */
+ unsigned char prefix[MAX_PREFIXES];
+ unsigned int prefixes;
/* RM and IB are the modrm byte and the base index byte where the addressing
modes of this insn are encoded. */
@@ -203,14 +204,28 @@ const relax_typeS md_relax_table[] = {
#if __STDC__ == 1
static char *output_invalid(int c);
+static int fits_in_signed_byte(long num);
+static int fits_in_signed_word(long num);
+static int fits_in_unsigned_byte(long num);
+static int fits_in_unsigned_word(long num);
static int i386_operand(char *operand_string);
+static int smallest_imm_type(long num);
static reg_entry *parse_register(char *reg_string);
+static unsigned long mode_from_disp_size(unsigned long t);
+static unsigned long opcode_suffix_to_type(unsigned long s);
#else /* not __STDC__ */
static char *output_invalid();
+static int fits_in_signed_byte();
+static int fits_in_signed_word();
+static int fits_in_unsigned_byte();
+static int fits_in_unsigned_word();
static int i386_operand();
+static int smallest_imm_type();
static reg_entry *parse_register();
+static unsigned long mode_from_disp_size();
+static unsigned long opcode_suffix_to_type();
#endif /* not __STDC__ */
@@ -317,11 +332,11 @@ void md_begin ()
{
register unsigned int c;
- bzero (opcode_chars, sizeof(opcode_chars));
- bzero (operand_chars, sizeof(operand_chars));
- bzero (space_chars, sizeof(space_chars));
- bzero (identifier_chars, sizeof(identifier_chars));
- bzero (digit_chars, sizeof(digit_chars));
+ memset(opcode_chars, '\0', sizeof(opcode_chars));
+ memset(operand_chars, '\0', sizeof(operand_chars));
+ memset(space_chars, '\0', sizeof(space_chars));
+ memset(identifier_chars, '\0', sizeof(identifier_chars));
+ memset(digit_chars, '\0', sizeof(digit_chars));
for (c = 0; c < 256; c++) {
if (islower(c) || isdigit(c)) {
@@ -473,15 +488,15 @@ void md_assemble (line)
char *line;
{
/* Holds temlate once we've found it. */
- register template * t;
+ register template *t;
/* Possible templates for current insn */
templates *current_templates = (templates *) 0;
/* Initialize globals. */
- bzero (&i, sizeof(i));
- bzero (disp_expressions, sizeof(disp_expressions));
- bzero (im_expressions, sizeof(im_expressions));
+ memset(&i, '\0', sizeof(i));
+ memset(disp_expressions, '\0', sizeof(disp_expressions));
+ memset(im_expressions, '\0', sizeof(im_expressions));
save_stack_p = save_stack; /* reset stack pointer */
/* Fist parse an opcode & call i386_operand for the operands.
@@ -638,12 +653,12 @@ char *line;
/* now *l must be either ',' or END_OF_INSN */
if (*l == ',') {
- if (*++l == END_OF_INSN) { /* just skip it, if it's \n complain */
+ if (*++l == END_OF_INSN) { /* just skip it, if it's \n complain */
goto expecting_operand_after_comma;
}
expecting_operand = 1;
}
- } while (*l != END_OF_INSN); /* until we get end of insn */
+ } while (*l != END_OF_INSN); /* until we get end of insn */
}
}
@@ -676,7 +691,7 @@ char *line;
( ((t0 & t1 & (Reg)) == 0 && (m0 & m1 & (Reg)) == 0) || \
((t0 & t1) & (m0 & m1) & (Reg)) \
) : 1)
- {
+ {
register unsigned int overlap0, overlap1;
expressionS * exp;
unsigned int overlap2;
@@ -746,7 +761,7 @@ char *line;
}
/* Copy the template we found (we may change it!). */
- bcopy (t, &i.tm, sizeof (template));
+ memcpy(&i.tm, t, sizeof(template));
t = &i.tm; /* alter new copy of template */
/* If there's no opcode suffix we try to invent one based on register
@@ -917,7 +932,7 @@ char *line;
if (i.base_reg == esp && ! i.index_reg) {
/* <disp>(%esp) becomes two byte modrm with no index register. */
i.rm.regmem = ESCAPE_TO_TWO_BYTE_ADDRESSING;
- i.rm.mode = MODE_FROM_DISP_SIZE (i.types[o]);
+ i.rm.mode = mode_from_disp_size(i.types[o]);
i.bi.base = ESP_REG_NUM;
i.bi.index = NO_INDEX_REGISTER;
i.bi.scale = 0; /* Must be zero! */
@@ -929,7 +944,7 @@ char *line;
/* fake_zero_displacement code does not set this. */
i.types[o] |= Disp8;
}
- i.rm.mode = MODE_FROM_DISP_SIZE (i.types[o]);
+ i.rm.mode = mode_from_disp_size(i.types[o]);
i.rm.regmem = EBP_REG_NUM;
} else if (! i.base_reg && (i.types[o] & BaseIndex)) {
/* There are three cases here.
@@ -961,7 +976,7 @@ char *line;
} else {
/* It's not a special case; rev'em up. */
i.rm.regmem = i.base_reg->reg_num;
- i.rm.mode = MODE_FROM_DISP_SIZE (i.types[o]);
+ i.rm.mode = mode_from_disp_size(i.types[o]);
if (i.index_reg) {
i.rm.regmem = ESCAPE_TO_TWO_BYTE_ADDRESSING;
i.bi.base = i.base_reg->reg_num;
@@ -970,7 +985,7 @@ char *line;
if (i.base_reg == ebp && i.disp_operands == 0) { /* pace */
fake_zero_displacement = 1;
i.types[o] |= Disp8;
- i.rm.mode = MODE_FROM_DISP_SIZE (i.types[o]);
+ i.rm.mode = mode_from_disp_size(i.types[o]);
}
}
}
@@ -987,15 +1002,15 @@ char *line;
/* Select the correct segment for the memory operand. */
if (i.seg) {
- const unsigned int seg_index;
- const seg_entry * default_seg;
+ unsigned int seg_index;
+ const seg_entry *default_seg;
if (i.rm.regmem == ESCAPE_TO_TWO_BYTE_ADDRESSING) {
seg_index = (i.rm.mode<<3) | i.bi.base;
- default_seg = two_byte_segment_defaults [seg_index];
+ default_seg = two_byte_segment_defaults[seg_index];
} else {
seg_index = (i.rm.mode<<3) | i.rm.regmem;
- default_seg = one_byte_segment_defaults [seg_index];
+ default_seg = one_byte_segment_defaults[seg_index];
}
/* If the specified segment is not the default, use an
opcode prefix to select it */
@@ -1054,12 +1069,12 @@ char *line;
switch (i.disps[0]->X_seg) {
case SEG_ABSOLUTE:
- if (FITS_IN_SIGNED_BYTE (n)) {
+ if (fits_in_signed_byte(n)) {
p = frag_more (2);
p[0] = t->base_opcode;
p[1] = n;
#if 0 /* leave out 16 bit jumps - pace */
- } else if (FITS_IN_SIGNED_WORD (n)) {
+ } else if (fits_in_signed_word(n)) {
p = frag_more (4);
p[0] = WORD_PREFIX_OPCODE;
p[1] = t->base_opcode;
@@ -1106,7 +1121,7 @@ char *line;
int size = (t->opcode_modifier & JumpByte) ? 1 : 4;
int n = i.disps[0]->X_add_number;
- if (FITS_IN_UNSIGNED_BYTE(t->base_opcode)) {
+ if (fits_in_unsigned_byte(t->base_opcode)) {
FRAG_APPEND_1_CHAR (t->base_opcode);
} else {
p = frag_more (2); /* opcode can be at most two bytes */
@@ -1119,7 +1134,7 @@ char *line;
switch (i.disps[0]->X_seg) {
case SEG_ABSOLUTE:
md_number_to_chars (p, n, size);
- if (size == 1 && ! FITS_IN_SIGNED_BYTE (n)) {
+ if (size == 1 && ! fits_in_signed_byte(n)) {
as_bad("loop/jecx only takes byte displacement; %d shortened to %d",
n, *p);
}
@@ -1145,7 +1160,7 @@ char *line;
md_number_to_chars (p + 5, i.imms[0]->X_add_number, 2);
} else {
/* Output normal instructions here. */
- register char *q;
+ unsigned char *q;
/* First the prefix bytes. */
for (q = i.prefix; q < i.prefix + i.prefixes; q++) {
@@ -1154,9 +1169,9 @@ char *line;
}
/* Now the opcode; be careful about word order here! */
- if (FITS_IN_UNSIGNED_BYTE(t->base_opcode)) {
+ if (fits_in_unsigned_byte(t->base_opcode)) {
FRAG_APPEND_1_CHAR (t->base_opcode);
- } else if (FITS_IN_UNSIGNED_WORD(t->base_opcode)) {
+ } else if (fits_in_unsigned_word(t->base_opcode)) {
p = frag_more (2);
/* put out high byte first: can't use md_number_to_chars! */
*p++ = (t->base_opcode >> 8) & 0xff;
@@ -1271,8 +1286,8 @@ char *operand_string;
char * end_of_operand_string = operand_string + strlen(operand_string);
/* Start and end of displacement string expression (if found). */
- char * displacement_string_start = 0;
- char * displacement_string_end;
+ char *displacement_string_start = NULL;
+ char *displacement_string_end = NULL;
/* We check for an absolute prefix (differentiating,
for example, 'jmp pc_relative_label' from 'jmp *absolute_label'. */
@@ -1283,8 +1298,8 @@ char *operand_string;
/* Check if operand is a register. */
if (*op_string == REGISTER_PREFIX) {
- register reg_entry * r;
- if (! (r = parse_register (op_string))) {
+ register reg_entry *r;
+ if (!(r = parse_register (op_string))) {
as_bad("bad register name ('%s')", op_string);
return 0;
}
@@ -1323,19 +1338,22 @@ char *operand_string;
i.regs[this_operand] = r;
i.reg_operands++;
} else if (*op_string == IMMEDIATE_PREFIX) { /* ... or an immediate */
- char * save_input_line_pointer;
- register expressionS *exp;
- segT exp_seg;
+ char *save_input_line_pointer;
+ segT exp_seg = SEG_GOOF;
+ expressionS *exp;
+
if (i.imm_operands == MAX_IMMEDIATE_OPERANDS) {
as_bad("only 1 or 2 immediate operands are allowed");
return 0;
}
+
exp = &im_expressions[i.imm_operands++];
- i.imms [this_operand] = exp;
+ i.imms[this_operand] = exp;
save_input_line_pointer = input_line_pointer;
input_line_pointer = ++op_string; /* must advance op_string! */
- exp_seg = expression (exp);
+ exp_seg = expression(exp);
input_line_pointer = save_input_line_pointer;
+
switch (exp_seg) {
case SEG_ABSENT: /* missing or bad expr becomes absolute 0 */
as_bad("missing or invalid immediate expression '%s' taken as 0",
@@ -1347,7 +1365,7 @@ char *operand_string;
i.types[this_operand] |= Imm;
break;
case SEG_ABSOLUTE:
- i.types[this_operand] |= SMALLEST_IMM_TYPE (exp->X_add_number);
+ i.types[this_operand] |= smallest_imm_type(exp->X_add_number);
break;
case SEG_TEXT: case SEG_DATA: case SEG_BSS: case SEG_UNKNOWN:
i.types[this_operand] |= Imm32; /* this is an address ==> 32bit */
@@ -1511,16 +1529,16 @@ char *operand_string;
assuming displacement_string_start and displacement_string_end
are meaningful. */
if (displacement_string_start) {
- register expressionS * exp;
- segT exp_seg;
- char * save_input_line_pointer;
+ register expressionS *exp;
+ segT exp_seg = SEG_GOOF;
+ char *save_input_line_pointer;
exp = &disp_expressions[i.disp_operands];
i.disps [this_operand] = exp;
i.disp_operands++;
save_input_line_pointer = input_line_pointer;
input_line_pointer = displacement_string_start;
END_STRING_AND_SAVE (displacement_string_end);
- exp_seg = expression (exp);
+ exp_seg = expression(exp);
if(*input_line_pointer)
as_bad("Ignoring junk '%s' after expression",input_line_pointer);
RESTORE_END_STRING (displacement_string_end);
@@ -1641,10 +1659,11 @@ void
object_headers *headers;
register fragS * fragP;
{
- register unsigned char * opcode;
- unsigned char * where_to_put_displacement;
- unsigned int target_address, opcode_address;
- unsigned int extension;
+ register unsigned char *opcode;
+ unsigned char *where_to_put_displacement = NULL;
+ unsigned int target_address;
+ unsigned int opcode_address;
+ unsigned int extension = 0;
int displacement_from_opcode_start;
opcode = (unsigned char *) fragP -> fr_opcode;
@@ -1860,26 +1879,24 @@ relax_addressT segment_address_in_file;
*/
static unsigned char nbytes_r_length [] = { 42, 0, 1, 42, 2 };
- long r_index;
+ long r_symbolnum;
know(fixP->fx_addsy != NULL);
- r_index = (S_IS_DEFINED(fixP->fx_addsy)
- ? S_GET_TYPE(fixP->fx_addsy)
- : fixP->fx_addsy->sy_number);
-
- /* this is easy */
md_number_to_chars(where,
fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file,
4);
- /* now the fun stuff */
- where[4] = r_index & 0x0ff;
- where[5] = (r_index >> 8) & 0x0ff;
- where[6] = (r_index >> 16) & 0x0ff;
+ r_symbolnum = (S_IS_DEFINED(fixP->fx_addsy)
+ ? S_GET_TYPE(fixP->fx_addsy)
+ : fixP->fx_addsy->sy_number);
+
+ where[6] = (r_symbolnum >> 16) & 0x0ff;
+ where[5] = (r_symbolnum >> 8) & 0x0ff;
+ where[4] = r_symbolnum & 0x0ff;
where[7] = ((((!S_IS_DEFINED(fixP->fx_addsy)) << 3) & 0x08)
| ((nbytes_r_length[fixP->fx_size] << 1) & 0x06)
- | ((fixP->fx_pcrel << 0) & 0x01) & 0x0f);
+ | (((fixP->fx_pcrel << 0) & 0x01) & 0x0f));
return;
} /* tc_aout_fix_to_chars() */
@@ -2006,6 +2023,66 @@ fixS *fixP;
return fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address;
}
+ /* these were macros, but I don't trust macros that eval their
+ arguments more than once. Besides, gcc can static inline them.
+ xoxorich. */
+
+static unsigned long mode_from_disp_size(t)
+unsigned long t;
+{
+ return((t & (Disp8))
+ ? 1
+ : ((t & (Disp32)) ? 2 : 0));
+} /* mode_from_disp_size() */
+
+/* convert opcode suffix ('b' 'w' 'l' typically) into type specifyer */
+
+static unsigned long opcode_suffix_to_type(s)
+unsigned long s;
+{
+ return(s == BYTE_OPCODE_SUFFIX
+ ? Byte : (s == WORD_OPCODE_SUFFIX
+ ? Word : DWord));
+} /* opcode_suffix_to_type() */
+
+static int fits_in_signed_byte(num)
+long num;
+{
+ return((num >= -128) && (num <= 127));
+} /* fits_in_signed_byte() */
+
+static int fits_in_unsigned_byte(num)
+long num;
+{
+ return((num & 0xff) == num);
+} /* fits_in_unsigned_byte() */
+
+static int fits_in_unsigned_word(num)
+long num;
+{
+ return((num & 0xffff) == num);
+} /* fits_in_unsigned_word() */
+
+static int fits_in_signed_word(num)
+long num;
+{
+ return((-32768 <= num) && (num <= 32767));
+} /* fits_in_signed_word() */
+
+static int smallest_imm_type(num)
+long num;
+{
+ return((num == 1)
+ ? (Imm1|Imm8|Imm8S|Imm16|Imm32)
+ : (fits_in_signed_byte(num)
+ ? (Imm8S|Imm8|Imm16|Imm32)
+ : (fits_in_unsigned_byte(num)
+ ? (Imm8|Imm16|Imm32)
+ : ((fits_in_signed_word(num) || fits_in_unsigned_word(num))
+ ? (Imm16|Imm32)
+ : (Imm32)))));
+} /* smallest_imm_type() */
+
/*
* Local Variables:
* comment-column: 0
diff --git a/gas/config/tc-i386.h b/gas/config/tc-i386.h
index b68f956..6e89dfc 100644
--- a/gas/config/tc-i386.h
+++ b/gas/config/tc-i386.h
@@ -1,5 +1,5 @@
-/* i386.h -- Header file for i386.c
- Copyright (C) 1989, Free Software Foundation.
+/* tc-i386.h -- Header file for tc-i386.c
+ Copyright (C) 1989, 1992 Free Software Foundation.
This file is part of GAS, the GNU Assembler.
@@ -22,16 +22,19 @@
#define AOUT_MACHTYPE 100
#define REVERSE_SORT_RELOCS
-#define tc_crawl_symbol_chain(a) ; /* not used */
-#define tc_headers_hook(a) ; /* not used */
-
+#define NO_LISTING
+
+#define tc_aout_pre_write_hook(x) {;} /* not used */
+#define tc_crawl_symbol_chain(a) {;} /* not used */
+#define tc_headers_hook(a) {;} /* not used */
+
#define MAX_OPERANDS 3 /* max operands per insn */
#define MAX_PREFIXES 4 /* max prefixes per opcode */
#define MAX_IMMEDIATE_OPERANDS 2 /* max immediates per insn */
#define MAX_MEMORY_OPERANDS 2 /* max memory ref per insn
* lcall uses 2
*/
- /* we define the syntax here (modulo base,index,scale syntax) */
+/* we define the syntax here (modulo base,index,scale syntax) */
#define REGISTER_PREFIX '%'
#define IMMEDIATE_PREFIX '$'
#define ABSOLUTE_PREFIX '*'
@@ -39,18 +42,18 @@
#define TWO_BYTE_OPCODE_ESCAPE 0x0f
- /* register numbers */
+/* register numbers */
#define EBP_REG_NUM 5
#define ESP_REG_NUM 4
- /* modrm_byte.regmem for twobyte escape */
+/* modrm_byte.regmem for twobyte escape */
#define ESCAPE_TO_TWO_BYTE_ADDRESSING ESP_REG_NUM
- /* index_base_byte.index for no index register addressing */
+/* index_base_byte.index for no index register addressing */
#define NO_INDEX_REGISTER ESP_REG_NUM
- /* index_base_byte.base for no base register addressing */
+/* index_base_byte.base for no base register addressing */
#define NO_BASE_REGISTER EBP_REG_NUM
- /* these are the att as opcode suffixes, making movl --> mov, for example */
+ /* these are the att as opcode suffixes, making movl --> mov, for example */
#define DWORD_OPCODE_SUFFIX 'l'
#define WORD_OPCODE_SUFFIX 'w'
#define BYTE_OPCODE_SUFFIX 'b'
@@ -115,53 +118,32 @@
#define Abs32 0x20000000
#define Abs (Abs8|Abs16|Abs32)
-#define MODE_FROM_DISP_SIZE(t) \
- ((t&(Disp8)) ? 1 : \
- ((t&(Disp32)) ? 2 : 0))
-
#define Byte (Reg8|Imm8|Imm8S)
#define Word (Reg16|Imm16)
#define DWord (Reg32|Imm32)
-/* convert opcode suffix ('b' 'w' 'l' typically) into type specifyer */
-#define OPCODE_SUFFIX_TO_TYPE(s) \
- (s == BYTE_OPCODE_SUFFIX ? Byte : \
- (s == WORD_OPCODE_SUFFIX ? Word : DWord))
-
-#define FITS_IN_SIGNED_BYTE(num) ((num) >= -128 && (num) <= 127)
-#define FITS_IN_UNSIGNED_BYTE(num) ((num) >= 0 && (num) <= 255)
-#define FITS_IN_UNSIGNED_WORD(num) ((num) >= 0 && (num) <= 65535)
-#define FITS_IN_SIGNED_WORD(num) ((num) >= -32768 && (num) <= 32767)
-
#define SMALLEST_DISP_TYPE(num) \
- FITS_IN_SIGNED_BYTE(num) ? (Disp8|Disp32|Abs8|Abs32) : (Disp32|Abs32)
-
-#define SMALLEST_IMM_TYPE(num) \
- (num == 1) ? (Imm1|Imm8|Imm8S|Imm16|Imm32): \
- FITS_IN_SIGNED_BYTE(num) ? (Imm8S|Imm8|Imm16|Imm32) : \
- FITS_IN_UNSIGNED_BYTE(num) ? (Imm8|Imm16|Imm32): \
- (FITS_IN_SIGNED_WORD(num)||FITS_IN_UNSIGNED_WORD(num)) ? (Imm16|Imm32) : \
- (Imm32)
+ fits_in_signed_byte(num) ? (Disp8|Disp32|Abs8|Abs32) : (Disp32|Abs32)
typedef struct {
/* instruction name sans width suffix ("mov" for movl insns) */
- char *name;
+ char *name;
/* how many operands */
- unsigned int operands;
+ unsigned int operands;
/* base_opcode is the fundamental opcode byte with a optional prefix(es). */
- unsigned int base_opcode;
+ unsigned int base_opcode;
/* extension_opcode is the 3 bit extension for group <n> insns.
If this template has no extension opcode (the usual case) use None */
- unsigned char extension_opcode;
-#define None 0xff /* If no extension_opcode is possible. */
+ unsigned char extension_opcode;
+#define None 0xff /* If no extension_opcode is possible. */
/* the bits in opcode_modifier are used to generate the final opcode from
the base_opcode. These bits also are used to detect alternate forms of
the same instruction */
- unsigned int opcode_modifier;
+ unsigned int opcode_modifier;
/* opcode_modifier bits: */
#define W 0x1 /* set if operands are words or dwords */
@@ -211,26 +193,26 @@ typedef struct {
END.
*/
typedef struct {
- template *start;
- template *end;
+ template *start;
+ template *end;
} templates;
/* these are for register name --> number & type hash lookup */
typedef struct {
- char * reg_name;
- unsigned int reg_type;
- unsigned int reg_num;
+ char *reg_name;
+ unsigned int reg_type;
+ unsigned int reg_num;
} reg_entry;
typedef struct {
- char * seg_name;
- unsigned int seg_prefix;
+ char *seg_name;
+ unsigned int seg_prefix;
} seg_entry;
/* these are for prefix name --> prefix code hash lookup */
typedef struct {
- char * prefix_name;
- unsigned char prefix_code;
+ char *prefix_name;
+ unsigned char prefix_code;
} prefix_entry;
/* 386 operand encoding bytes: see 386 book for details of this. */
diff --git a/gas/config/tc-i860.c b/gas/config/tc-i860.c
index ced89f2..abd53c8 100644
--- a/gas/config/tc-i860.c
+++ b/gas/config/tc-i860.c
@@ -464,7 +464,7 @@ char *str;
argsStart = s;
for (;;) {
opcode = insn->match;
- bzero(&the_insn, sizeof(the_insn));
+ memset(&the_insn, '\0', sizeof(the_insn));
the_insn.reloc = NO_RELOC;
/*
@@ -630,13 +630,13 @@ char *str;
break;
case '5': /* 5 bit immediate in src1 */
- bzero(&the_insn, sizeof(the_insn));
+ memset(&the_insn, '\0', sizeof(the_insn));
if ( !getExpression(s)) {
s = expr_end;
if (the_insn.exp.X_add_number & ~0x1f)
as_bad("5-bit immediate too large");
opcode |= (the_insn.exp.X_add_number & 0x1f) << 11;
- bzero(&the_insn, sizeof(the_insn));
+ memset(&the_insn, '\0', sizeof(the_insn));
the_insn.reloc = NO_RELOC;
continue;
}
@@ -1019,7 +1019,7 @@ struct relocation_info *ri_p, ri;
/* Also easy */
md_number_to_chars(&the_bytes[8], ri.r_addend, sizeof(ri.r_addend));
/* now put it back where you found it, Junior... */
- bcopy (the_bytes, (char *)ri_p, sizeof(*ri_p));
+ memcpy((char *) ri_p, the_bytes, sizeof(*ri_p));
#endif
}
@@ -1122,7 +1122,7 @@ relax_addressT segment_address_in_file;
extern char *next_object_file_charP;
long add_number;
- bzero((char *) &ri, sizeof(ri));
+ memset((char *) &ri, '\0', sizeof(ri));
for (; fixP; fixP = fixP->fx_next) {
if (fixP->fx_r_type & ~0x3f) {
diff --git a/gas/config/tc-i960.c b/gas/config/tc-i960.c
index c2baa08..262ed8b 100644
--- a/gas/config/tc-i960.c
+++ b/gas/config/tc-i960.c
@@ -1,5 +1,5 @@
-/* i960.c - All the i80960-specific stuff
- Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc.
+/* tc-i960.c - All the i80960-specific stuff
+ Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
This file is part of GAS.
@@ -496,7 +496,7 @@ char *textP; /* Source text of instruction */
/* Parse instruction into opcode and operands */
- bzero(args, sizeof(args));
+ memset(args, '\0', sizeof(args));
n_ops = i_scan(textP, args);
if (n_ops == -1){
return; /* Error message already issued */
@@ -1471,7 +1471,7 @@ struct i960_opcode *oP; /* Pointer to description of instruction */
expressionS expr; /* Parsed expression */
fixS *fixP; /*->description of deferred address fixup */
- bzero(&instr, sizeof(memS));
+ memset(&instr, '\0', sizeof(memS));
instr.opcode = oP->opcode;
/* Process operands. */
@@ -2551,7 +2551,7 @@ relax_addressT segment_address_in_file;
symbolS *symbolP;
/* JF this is for paranoia */
- bzero((char *)&ri, sizeof(ri));
+ memset((char *)&ri, '\0', sizeof(ri));
know((symbolP = fixP->fx_addsy) != 0);
diff --git a/gas/config/tc-m68kmote.c b/gas/config/tc-m68kmote.c
index 8bf73ef..206312a 100644
--- a/gas/config/tc-m68kmote.c
+++ b/gas/config/tc-m68kmote.c
@@ -141,182 +141,182 @@ static struct obstack robyn;
*/
enum operand_type {
- IMMED = 1,
- DREG,
- AREG,
- AINDR,
- ADEC,
- AINC,
- AOFF,
- AINDX,
- APODX,
- AMIND,
- APRDX,
- ABSL,
- MSCR,
- REGLST,
+ IMMED = 1,
+ DREG,
+ AREG,
+ AINDR,
+ ADEC,
+ AINC,
+ AOFF,
+ AINDX,
+ APODX,
+ AMIND,
+ APRDX,
+ ABSL,
+ MSCR,
+ REGLST,
};
struct m68k_exp {
- char *e_beg;
- char *e_end;
- expressionS e_exp;
- short e_siz; /* 0== default 1==short/byte 2==word 3==long */
+ char *e_beg;
+ char *e_end;
+ expressionS e_exp;
+ short e_siz; /* 0== default 1==short/byte 2==word 3==long */
};
/* DATA and ADDR have to be contiguous, so that reg-DATA gives 0-7==data reg,
8-15==addr reg for operands that take both types */
enum _register {
- DATA = 1, /* 1- 8 == data registers 0-7 */
- DATA0 = DATA,
- DATA1,
- DATA2,
- DATA3,
- DATA4,
- DATA5,
- DATA6,
- DATA7,
-
- ADDR,
- ADDR0 = ADDR,
- ADDR1,
- ADDR2,
- ADDR3,
- ADDR4,
- ADDR5,
- ADDR6,
- ADDR7,
-
- /* Note that COPNUM==processor #1 -- COPNUM+7==#8, which stores as 000 */
- /* I think. . . */
-
- SP = ADDR7,
-
- FPREG, /* Eight FP registers */
- FP0 = FPREG,
- FP1,
- FP2,
- FP3,
- FP4,
- FP5,
- FP6,
- FP7,
- COPNUM = (FPREG+8), /* Co-processor #1-#8 */
- COP0 = COPNUM,
- COP1,
- COP2,
- COP3,
- COP4,
- COP5,
- COP6,
- COP7,
- PC, /* Program counter */
- ZPC, /* Hack for Program space, but 0 addressing */
- SR, /* Status Reg */
- CCR, /* Condition code Reg */
-
- /* These have to be in order for the movec instruction to work. */
- USP, /* User Stack Pointer */
- ISP, /* Interrupt stack pointer */
- SFC,
- DFC,
- CACR,
- VBR,
- CAAR,
- MSP,
- ITT0,
- ITT1,
- DTT0,
- DTT1,
- MMUSR,
- TC,
- SRP,
- URP,
- /* end of movec ordering constraints */
-
- FPI,
- FPS,
- FPC,
-
- DRP,
- CRP,
- CAL,
- VAL,
- SCC,
- AC,
- BAD,
- BAD0 = BAD,
- BAD1,
- BAD2,
- BAD3,
- BAD4,
- BAD5,
- BAD6,
- BAD7,
- BAC,
- BAC0 = BAC,
- BAC1,
- BAC2,
- BAC3,
- BAC4,
- BAC5,
- BAC6,
- BAC7,
- PSR,
- PCSR,
-
- IC, /* instruction cache token */
- DC, /* data cache token */
- NC, /* no cache token */
- BC, /* both caches token */
-
+ DATA = 1, /* 1- 8 == data registers 0-7 */
+ DATA0 = DATA,
+ DATA1,
+ DATA2,
+ DATA3,
+ DATA4,
+ DATA5,
+ DATA6,
+ DATA7,
+
+ ADDR,
+ ADDR0 = ADDR,
+ ADDR1,
+ ADDR2,
+ ADDR3,
+ ADDR4,
+ ADDR5,
+ ADDR6,
+ ADDR7,
+
+ /* Note that COPNUM==processor #1 -- COPNUM+7==#8, which stores as 000 */
+ /* I think. . . */
+
+ SP = ADDR7,
+
+ FPREG, /* Eight FP registers */
+ FP0 = FPREG,
+ FP1,
+ FP2,
+ FP3,
+ FP4,
+ FP5,
+ FP6,
+ FP7,
+ COPNUM = (FPREG+8), /* Co-processor #1-#8 */
+ COP0 = COPNUM,
+ COP1,
+ COP2,
+ COP3,
+ COP4,
+ COP5,
+ COP6,
+ COP7,
+ PC, /* Program counter */
+ ZPC, /* Hack for Program space, but 0 addressing */
+ SR, /* Status Reg */
+ CCR, /* Condition code Reg */
+
+ /* These have to be in order for the movec instruction to work. */
+ USP, /* User Stack Pointer */
+ ISP, /* Interrupt stack pointer */
+ SFC,
+ DFC,
+ CACR,
+ VBR,
+ CAAR,
+ MSP,
+ ITT0,
+ ITT1,
+ DTT0,
+ DTT1,
+ MMUSR,
+ TC,
+ SRP,
+ URP,
+ /* end of movec ordering constraints */
+
+ FPI,
+ FPS,
+ FPC,
+
+ DRP,
+ CRP,
+ CAL,
+ VAL,
+ SCC,
+ AC,
+ BAD,
+ BAD0 = BAD,
+ BAD1,
+ BAD2,
+ BAD3,
+ BAD4,
+ BAD5,
+ BAD6,
+ BAD7,
+ BAC,
+ BAC0 = BAC,
+ BAC1,
+ BAC2,
+ BAC3,
+ BAC4,
+ BAC5,
+ BAC6,
+ BAC7,
+ PSR,
+ PCSR,
+
+ IC, /* instruction cache token */
+ DC, /* data cache token */
+ NC, /* no cache token */
+ BC, /* both caches token */
+
};
/* Internal form of an operand. */
struct m68k_op {
- char *error; /* Couldn't parse it */
- enum operand_type mode; /* What mode this instruction is in. */
- enum _register reg; /* Base register */
- struct m68k_exp *con1;
- int ireg; /* Index register */
- int isiz; /* 0==unspec 1==byte(?) 2==short 3==long */
- int imul; /* Multipy ireg by this (1,2,4,or 8) */
- struct m68k_exp *con2;
+ char *error; /* Couldn't parse it */
+ enum operand_type mode; /* What mode this instruction is in. */
+ enum _register reg; /* Base register */
+ struct m68k_exp *con1;
+ int ireg; /* Index register */
+ int isiz; /* 0==unspec 1==byte(?) 2==short 3==long */
+ int imul; /* Multipy ireg by this (1,2,4,or 8) */
+ struct m68k_exp *con2;
};
/* internal form of a 68020 instruction */
struct m68k_it {
- char *error;
- char *args; /* list of opcode info */
- int numargs;
-
- int numo; /* Number of shorts in opcode */
- short opcode[11];
-
- struct m68k_op operands[6];
-
- int nexp; /* number of exprs in use */
- struct m68k_exp exprs[4];
-
- int nfrag; /* Number of frags we have to produce */
- struct {
- int fragoff; /* Where in the current opcode[] the frag ends */
- symbolS *fadd;
- long foff;
- int fragty;
- } fragb[4];
-
- int nrel; /* Num of reloc strucs in use */
- struct {
- int n;
- symbolS *add,
- *sub;
- long off;
- char wid;
- char pcrel;
- } reloc[5]; /* Five is enough??? */
+ char *error;
+ char *args; /* list of opcode info */
+ int numargs;
+
+ int numo; /* Number of shorts in opcode */
+ short opcode[11];
+
+ struct m68k_op operands[6];
+
+ int nexp; /* number of exprs in use */
+ struct m68k_exp exprs[4];
+
+ int nfrag; /* Number of frags we have to produce */
+ struct {
+ int fragoff; /* Where in the current opcode[] the frag ends */
+ symbolS *fadd;
+ long foff;
+ int fragty;
+ } fragb[4];
+
+ int nrel; /* Num of reloc strucs in use */
+ struct {
+ int n;
+ symbolS *add,
+ *sub;
+ long off;
+ char wid;
+ char pcrel;
+ } reloc[5]; /* Five is enough??? */
};
#define cpu_of_arch(x) ((x) & m68000up)
@@ -337,7 +337,7 @@ static struct m68k_it the_ins; /* the instruction being assembled */
the_ins.reloc[z].n+=2;\
the_ins.opcode[opcode->m_codenum]=w;\
the_ins.numo++;\
- }
+ }
#define add_exp(beg,end) (\
@@ -356,14 +356,14 @@ static struct m68k_it the_ins; /* the instruction being assembled */
the_ins.reloc[the_ins.nrel].off=offs((exp));\
the_ins.reloc[the_ins.nrel].wid=width;\
the_ins.reloc[the_ins.nrel++].pcrel=pc_rel;\
- }
+ }
#define add_frag(add,off,type) {\
the_ins.fragb[the_ins.nfrag].fragoff=the_ins.numo;\
the_ins.fragb[the_ins.nfrag].fadd=add;\
the_ins.fragb[the_ins.nfrag].foff=off;\
the_ins.fragb[the_ins.nfrag++].fragty=type;\
- }
+ }
#define isvar(exp) ((exp) && (adds(exp) || subs(exp)))
@@ -374,12 +374,12 @@ static struct m68k_it the_ins; /* the instruction being assembled */
struct m68k_incant {
- char *m_operands;
- unsigned long m_opcode;
- short m_opnum;
- short m_codenum;
- enum m68k_architecture m_arch;
- struct m68k_incant *m_next;
+ char *m_operands;
+ unsigned long m_opcode;
+ short m_opnum;
+ short m_codenum;
+ enum m68k_architecture m_arch;
+ struct m68k_incant *m_next;
};
#define getone(x) ((((x)->m_opcode)>>16)&0xffff)
@@ -439,42 +439,42 @@ static enum m68k_architecture current_architecture = 0;
*/
const relax_typeS
md_relax_table[] = {
- { 1, 1, 0, 0 }, /* First entries aren't used */
-{ 1, 1, 0, 0 }, /* For no good reason except */
-{ 1, 1, 0, 0 }, /* that the VAX doesn't either */
-{ 1, 1, 0, 0 },
-
-{ (127), (-128), 0, TAB(BRANCH,SHORT)},
-{ (32767), (-32768), 2, TAB(BRANCH,LONG) },
-{ 0, 0, 4, 0 },
-{ 1, 1, 0, 0 },
-
-{ 1, 1, 0, 0 }, /* FBRANCH doesn't come BYTE */
-{ (32767), (-32768), 2, TAB(FBRANCH,LONG)},
-{ 0, 0, 4, 0 },
-{ 1, 1, 0, 0 },
-
-{ 1, 1, 0, 0 }, /* PCREL doesn't come BYTE */
-{ (32767), (-32768), 2, TAB(PCREL,LONG)},
-{ 0, 0, 4, 0 },
-{ 1, 1, 0, 0 },
-
-{ (127), (-128), 0, TAB(BCC68000,SHORT)},
-{ (32767), (-32768), 2, TAB(BCC68000,LONG) },
-{ 0, 0, 6, 0 }, /* jmp long space */
-{ 1, 1, 0, 0 },
-
-{ 1, 1, 0, 0 }, /* DBCC doesn't come BYTE */
-{ (32767), (-32768), 2, TAB(DBCC,LONG) },
-{ 0, 0, 10, 0 }, /* bra/jmp long space */
-{ 1, 1, 0, 0 },
-
-{ 1, 1, 0, 0 }, /* PCLEA doesn't come BYTE */
-{ 32767, -32768, 2, TAB(PCLEA,LONG) },
-{ 0, 0, 6, 0 },
-{ 1, 1, 0, 0 },
-
-};
+ { 1, 1, 0, 0 }, /* First entries aren't used */
+ { 1, 1, 0, 0 }, /* For no good reason except */
+ { 1, 1, 0, 0 }, /* that the VAX doesn't either */
+ { 1, 1, 0, 0 },
+
+ { (127), (-128), 0, TAB(BRANCH,SHORT)},
+ { (32767), (-32768), 2, TAB(BRANCH,LONG) },
+ { 0, 0, 4, 0 },
+ { 1, 1, 0, 0 },
+
+ { 1, 1, 0, 0 }, /* FBRANCH doesn't come BYTE */
+ { (32767), (-32768), 2, TAB(FBRANCH,LONG)},
+ { 0, 0, 4, 0 },
+ { 1, 1, 0, 0 },
+
+ { 1, 1, 0, 0 }, /* PCREL doesn't come BYTE */
+ { (32767), (-32768), 2, TAB(PCREL,LONG)},
+ { 0, 0, 4, 0 },
+ { 1, 1, 0, 0 },
+
+ { (127), (-128), 0, TAB(BCC68000,SHORT)},
+ { (32767), (-32768), 2, TAB(BCC68000,LONG) },
+ { 0, 0, 6, 0 }, /* jmp long space */
+ { 1, 1, 0, 0 },
+
+ { 1, 1, 0, 0 }, /* DBCC doesn't come BYTE */
+ { (32767), (-32768), 2, TAB(DBCC,LONG) },
+ { 0, 0, 10, 0 }, /* bra/jmp long space */
+ { 1, 1, 0, 0 },
+
+ { 1, 1, 0, 0 }, /* PCLEA doesn't come BYTE */
+ { 32767, -32768, 2, TAB(PCLEA,LONG) },
+ { 0, 0, 6, 0 },
+ { 1, 1, 0, 0 },
+
+ };
/* These are the machine dependent pseudo-ops. These are included so
the assembler can work on the output from the SUN C compiler, which
@@ -498,40 +498,40 @@ void s_ds();
void s_dcb();
void s_dc();
const pseudo_typeS md_pseudo_table[] = {
-{ "xdef", s_globl, 0 },
-{ "sect", s_sect, 0 },
-{ "dc", s_dc, 2 },
-{ "dc.d", float_cons, 'd' },
-{ "dc.s", float_cons, 'f' },
-{ "dc.l", s_dc, 4 },
-{ "dc.w", s_dc, 2 },
-{ "dc.b", s_dc, 1 },
-{ "comline", s_ds, 1 },
-{ "ds.b", s_ds, 1 },
-{ "ds.w", s_ds, 2 },
-{ "ds", s_ds, 2 },
-{ "ds.l", s_ds, 4 },
-{ "ds.d", s_ds, 8 },
-{ "ds.s", s_ds, 4 },
-{ "dcb", s_dcb, 2 },
-{ "dcb.b", s_dcb, 1 },
-{ "dcb.w", s_dcb, 2 },
-{ "dcb.l", s_dcb, 4 },
-{ "xcom", s_comm, 0 },
-{ "align", s_align_bytes, 0 },
-{ "chip", s_chip, 0 },
-{ 0, 0, 0 }
+ { "xdef", s_globl, 0 },
+ { "sect", s_sect, 0 },
+ { "dc", s_dc, 2 },
+ { "dc.d", float_cons, 'd' },
+ { "dc.s", float_cons, 'f' },
+ { "dc.l", s_dc, 4 },
+ { "dc.w", s_dc, 2 },
+ { "dc.b", s_dc, 1 },
+ { "comline", s_ds, 1 },
+ { "ds.b", s_ds, 1 },
+ { "ds.w", s_ds, 2 },
+ { "ds", s_ds, 2 },
+ { "ds.l", s_ds, 4 },
+ { "ds.d", s_ds, 8 },
+ { "ds.s", s_ds, 4 },
+ { "dcb", s_dcb, 2 },
+ { "dcb.b", s_dcb, 1 },
+ { "dcb.w", s_dcb, 2 },
+ { "dcb.l", s_dcb, 4 },
+ { "xcom", s_comm, 0 },
+ { "align", s_align_bytes, 0 },
+ { "chip", s_chip, 0 },
+ { 0, 0, 0 }
};
#else
const pseudo_typeS md_pseudo_table[] = {
-{ "data1", s_data1, 0 },
-{ "data2", s_data2, 0 },
-{ "bss", s_bss, 0 },
-{ "even", s_even, 0 },
-{ "skip", s_space, 0 },
-{ "proc", s_proc, 0 },
-{ 0, 0, 0 }
+ { "data1", s_data1, 0 },
+ { "data2", s_data2, 0 },
+ { "bss", s_bss, 0 },
+ { "even", s_even, 0 },
+ { "skip", s_space, 0 },
+ { "proc", s_proc, 0 },
+ { 0, 0, 0 }
}
@@ -546,16 +546,16 @@ const pseudo_typeS md_pseudo_table[] = {
#define isubyte(x) ((x)>=0 && (x)<=255)
#define issword(x) ((x)>=-32768 && (x)<=32767)
#define isuword(x) ((x)>=0 && (x)<=65535)
-
+
#define isbyte(x) ((x)>=-128 && (x)<=255)
#define isword(x) ((x)>=-32768 && (x)<=65535)
#define islong(x) (1)
-
- extern char *input_line_pointer;
+
+extern char *input_line_pointer;
enum {
- FAIL = 0,
- OK = 1,
+ FAIL = 0,
+ OK = 1,
};
/* JF these tables here are for speed at the expense of size */
@@ -564,7 +564,7 @@ enum {
static char mklower_table[256];
#define mklower(c) (mklower_table[(unsigned char)(c)])
- static char notend_table[256];
+static char notend_table[256];
static char alt_notend_table[256];
#define notend(s) ( !(notend_table[(unsigned char)(*s)] || (*s==':' &&\
alt_notend_table[(unsigned char)(s[1])])))
@@ -572,7 +572,7 @@ static char alt_notend_table[256];
#if 0
#define mklower(c) (isupper(c) ? tolower(c) : c)
#endif
-
+
#define ISSPACE(x) ((x) == ' ' || (x) == '\t')
#ifdef MRI
#define MULTIPLIER '*'
@@ -581,270 +581,270 @@ static char alt_notend_table[256];
#define MULTIPLIER ':'
#define SIZER ':'
#endif
-
-
- /* JF modified this to handle cases where the first part of a symbol name
- looks like a register */
-
- /*
- * m68k_reg_parse() := if it looks like a register, return it's token &
- * advance the pointer.
- */
-
- enum _register m68k_reg_parse(ccp)
+
+
+/* JF modified this to handle cases where the first part of a symbol name
+ looks like a register */
+
+/*
+ * m68k_reg_parse() := if it looks like a register, return it's token &
+ * advance the pointer.
+ */
+
+enum _register m68k_reg_parse(ccp)
register char **ccp;
{
#ifndef MAX_REG_NAME_LEN
#define MAX_REG_NAME_LEN (6)
#endif /* MAX_REG_NAME_LEN */
- register char c[MAX_REG_NAME_LEN];
- char *p, *q;
- register int n = 0,
- ret = FAIL;
-
- c[0] = mklower(ccp[0][0]);
+ register char c[MAX_REG_NAME_LEN];
+ char *p, *q;
+ register int n = 0,
+ ret = FAIL;
+
+ c[0] = mklower(ccp[0][0]);
#ifdef REGISTER_PREFIX
- if (c[0] != REGISTER_PREFIX) {
- return(FAIL);
- } /* need prefix */
+ if (c[0] != REGISTER_PREFIX) {
+ return(FAIL);
+ } /* need prefix */
#endif
-
- for (p = c, q = ccp[0]; p < c + MAX_REG_NAME_LEN; ++p, ++q)
- {
- if (*q == 0)
- {
- *p = 0;
- break;
- }
- else
- *p = mklower(*q);
- } /* downcase */
-
- switch(c[0]) {
- case 'a':
- if(c[1]>='0' && c[1]<='7') {
- n=2;
- ret=ADDR+c[1]-'0';
- }
+
+ for (p = c, q = ccp[0]; p < c + MAX_REG_NAME_LEN; ++p, ++q)
+ {
+ if (*q == 0)
+ {
+ *p = 0;
+ break;
+ }
+ else
+ *p = mklower(*q);
+ } /* downcase */
+
+ switch(c[0]) {
+ case 'a':
+ if(c[1]>='0' && c[1]<='7') {
+ n=2;
+ ret=ADDR+c[1]-'0';
+ }
#ifndef NO_68851
- else if (c[1] == 'c') {
- n = 2;
- ret = AC;
- }
+ else if (c[1] == 'c') {
+ n = 2;
+ ret = AC;
+ }
#endif
- break;
+ break;
#ifndef NO_68851
- case 'b':
- if (c[1] == 'a') {
- if (c[2] == 'd') {
- if (c[3] >= '0' && c[3] <= '7') {
- n = 4;
- ret = BAD + c[3] - '0';
- }
- } /* BAD */
- if (c[2] == 'c') {
- if (c[3] >= '0' && c[3] <= '7') {
- n = 4;
- ret = BAC + c[3] - '0';
- }
- } /* BAC */
- } else if (c[1] == 'c') {
- n = 2;
- ret = BC;
- } /* BC */
- break;
+ case 'b':
+ if (c[1] == 'a') {
+ if (c[2] == 'd') {
+ if (c[3] >= '0' && c[3] <= '7') {
+ n = 4;
+ ret = BAD + c[3] - '0';
+ }
+ } /* BAD */
+ if (c[2] == 'c') {
+ if (c[3] >= '0' && c[3] <= '7') {
+ n = 4;
+ ret = BAC + c[3] - '0';
+ }
+ } /* BAC */
+ } else if (c[1] == 'c') {
+ n = 2;
+ ret = BC;
+ } /* BC */
+ break;
#endif
- case 'c':
+ case 'c':
#ifndef NO_68851
- if (c[1] == 'a' && c[2] == 'l') {
- n = 3;
- ret = CAL;
- } else
+ if (c[1] == 'a' && c[2] == 'l') {
+ n = 3;
+ ret = CAL;
+ } else
#endif
- /* This supports both CCR and CC as the ccr reg. */
- if(c[1]=='c' && c[2]=='r') {
- n=3;
- ret = CCR;
- } else if(c[1]=='c') {
- n=2;
- ret = CCR;
- } else if(c[1]=='a' && (c[2]=='a' || c[2]=='c') && c[3]=='r') {
- n=4;
- ret = c[2]=='a' ? CAAR : CACR;
- }
+ /* This supports both CCR and CC as the ccr reg. */
+ if(c[1]=='c' && c[2]=='r') {
+ n=3;
+ ret = CCR;
+ } else if(c[1]=='c') {
+ n=2;
+ ret = CCR;
+ } else if(c[1]=='a' && (c[2]=='a' || c[2]=='c') && c[3]=='r') {
+ n=4;
+ ret = c[2]=='a' ? CAAR : CACR;
+ }
#ifndef NO_68851
- else if (c[1] == 'r' && c[2] == 'p') {
- n = 3;
- ret = (CRP);
- }
+ else if (c[1] == 'r' && c[2] == 'p') {
+ n = 3;
+ ret = (CRP);
+ }
#endif
- break;
- case 'd':
- if (c[1] >= '0' && c[1] <= '7') {
- n = 2;
- ret = DATA + c[1] - '0';
- } else if (c[1] == 'f' && c[2] == 'c') {
- n = 3;
- ret = DFC;
- } else if (c[1] == 'c') {
- n = 2;
- ret = DC;
- } else if (c[1] == 't' && c[2] == 't') {
- if ('0' <= c[3] && c[3] <= '1') {
- n = 4;
- ret = DTT0 + (c[3] - '0');
- } /* DTT[01] */
- }
+ break;
+ case 'd':
+ if (c[1] >= '0' && c[1] <= '7') {
+ n = 2;
+ ret = DATA + c[1] - '0';
+ } else if (c[1] == 'f' && c[2] == 'c') {
+ n = 3;
+ ret = DFC;
+ } else if (c[1] == 'c') {
+ n = 2;
+ ret = DC;
+ } else if (c[1] == 't' && c[2] == 't') {
+ if ('0' <= c[3] && c[3] <= '1') {
+ n = 4;
+ ret = DTT0 + (c[3] - '0');
+ } /* DTT[01] */
+ }
#ifndef NO_68851
- else if (c[1] == 'r' && c[2] == 'p') {
- n = 3;
- ret = (DRP);
- }
+ else if (c[1] == 'r' && c[2] == 'p') {
+ n = 3;
+ ret = (DRP);
+ }
#endif
- break;
- case 'f':
- if(c[1]=='p') {
- if(c[2]>='0' && c[2]<='7') {
- n=3;
- ret = FPREG+c[2]-'0';
- if(c[3]==':')
- ccp[0][3]=',';
- } else if(c[2]=='i') {
- n=3;
- ret = FPI;
- } else if(c[2]=='s') {
- n= (c[3] == 'r' ? 4 : 3);
- ret = FPS;
- } else if(c[2]=='c') {
- n= (c[3] == 'r' ? 4 : 3);
- ret = FPC;
- } else if (!isalpha(c[2]) && !isdigit(c[2])) {
- n = 2;
- ret = ADDR + 6;
- }
-
-
- }
- break;
- case 'i':
- if (c[1] == 's' && c[2] == 'p') {
- n = 3;
- ret = ISP;
- } else if (c[1] == 'c') {
- n = 2;
- ret = IC;
- } else if (c[1] == 't' && c[2] == 't') {
- if ('0' <= c[3] && c[3] <= '1') {
- n = 4;
- ret = ITT0 + (c[3] - '0');
- } /* ITT[01] */
- }
- break;
- case 'm':
- if (c[1] == 's' && c[2] == 'p') {
- n = 3;
- ret = MSP;
- } else if (c[1] == 'm' && c[2] == 'u' && c[3] == 's' && c[4] == 'r') {
- n = 5;
- ret = MMUSR;
- }
- break;
- case 'n':
- if (c[1] == 'c') {
- n = 2;
- ret = NC;
- }
- break;
- case 'p':
- if(c[1]=='c') {
+ break;
+ case 'f':
+ if(c[1]=='p') {
+ if(c[2]>='0' && c[2]<='7') {
+ n=3;
+ ret = FPREG+c[2]-'0';
+ if(c[3]==':')
+ ccp[0][3]=',';
+ } else if(c[2]=='i') {
+ n=3;
+ ret = FPI;
+ } else if(c[2]=='s') {
+ n= (c[3] == 'r' ? 4 : 3);
+ ret = FPS;
+ } else if(c[2]=='c') {
+ n= (c[3] == 'r' ? 4 : 3);
+ ret = FPC;
+ } else if (!isalpha(c[2]) && !isdigit(c[2])) {
+ n = 2;
+ ret = ADDR + 6;
+ }
+
+
+ }
+ break;
+ case 'i':
+ if (c[1] == 's' && c[2] == 'p') {
+ n = 3;
+ ret = ISP;
+ } else if (c[1] == 'c') {
+ n = 2;
+ ret = IC;
+ } else if (c[1] == 't' && c[2] == 't') {
+ if ('0' <= c[3] && c[3] <= '1') {
+ n = 4;
+ ret = ITT0 + (c[3] - '0');
+ } /* ITT[01] */
+ }
+ break;
+ case 'm':
+ if (c[1] == 's' && c[2] == 'p') {
+ n = 3;
+ ret = MSP;
+ } else if (c[1] == 'm' && c[2] == 'u' && c[3] == 's' && c[4] == 'r') {
+ n = 5;
+ ret = MMUSR;
+ }
+ break;
+ case 'n':
+ if (c[1] == 'c') {
+ n = 2;
+ ret = NC;
+ }
+ break;
+ case 'p':
+ if(c[1]=='c') {
#ifndef NO_68851
- if(c[2] == 's' && c[3]=='r') {
- n=4;
- ret = (PCSR);
- } else
+ if(c[2] == 's' && c[3]=='r') {
+ n=4;
+ ret = (PCSR);
+ } else
#endif
- {
- n=2;
- ret = PC;
- }
- }
+ {
+ n=2;
+ ret = PC;
+ }
+ }
#ifndef NO_68851
- else if (c[1] == 's' && c[2] == 'r') {
- n = 3;
- ret = (PSR);
- }
+ else if (c[1] == 's' && c[2] == 'r') {
+ n = 3;
+ ret = (PSR);
+ }
#endif
- break;
- case 's':
+ break;
+ case 's':
#ifndef NO_68851
- if (c[1] == 'c' && c[2] == 'c') {
- n = 3;
- ret = (SCC);
- } else
+ if (c[1] == 'c' && c[2] == 'c') {
+ n = 3;
+ ret = (SCC);
+ } else
#endif
- if (c[1] == 'r') {
- if (c[2] == 'p') {
- n = 3;
- ret = SRP;
- } else {
- n = 2;
- ret = SR;
- } /* srp else sr */
- } else if (c[1] == 'p') {
- n = 2;
- ret = SP;
- } else if (c[1] == 'f' && c[2] == 'c') {
- n = 3;
- ret = SFC;
- }
- break;
- case 't':
- if (c[1] == 'c') {
- n = 2;
- ret = TC;
- }
- break;
- case 'u':
- if (c[1] == 's' && c[2] == 'p') {
- n=3;
- ret = USP;
- } else if (c[1] == 'r' && c[2] == 'p') {
- n = 3;
- ret = URP;
- }
- break;
- case 'v':
+ if (c[1] == 'r') {
+ if (c[2] == 'p') {
+ n = 3;
+ ret = SRP;
+ } else {
+ n = 2;
+ ret = SR;
+ } /* srp else sr */
+ } else if (c[1] == 'p') {
+ n = 2;
+ ret = SP;
+ } else if (c[1] == 'f' && c[2] == 'c') {
+ n = 3;
+ ret = SFC;
+ }
+ break;
+ case 't':
+ if (c[1] == 'c') {
+ n = 2;
+ ret = TC;
+ }
+ break;
+ case 'u':
+ if (c[1] == 's' && c[2] == 'p') {
+ n=3;
+ ret = USP;
+ } else if (c[1] == 'r' && c[2] == 'p') {
+ n = 3;
+ ret = URP;
+ }
+ break;
+ case 'v':
#ifndef NO_68851
- if (c[1] == 'a' && c[2] == 'l') {
- n = 3;
- ret = (VAL);
- } else
+ if (c[1] == 'a' && c[2] == 'l') {
+ n = 3;
+ ret = (VAL);
+ } else
#endif
- if(c[1]=='b' && c[2]=='r') {
- n=3;
- ret = VBR;
- }
- break;
- case 'z':
- if(c[1]=='p' && c[2]=='c') {
- n=3;
- ret = ZPC;
+ if(c[1]=='b' && c[2]=='r') {
+ n=3;
+ ret = VBR;
+ }
+ break;
+ case 'z':
+ if(c[1]=='p' && c[2]=='c') {
+ n=3;
+ ret = ZPC;
+ }
+ break;
+ default:
+ break;
}
- break;
- default:
- break;
- }
- if(n) {
+ if(n) {
#ifdef REGISTER_PREFIX
- n++;
+ n++;
#endif
- if(isalnum(ccp[0][n]) || ccp[0][n]=='_')
- ret=FAIL;
- else
- ccp[0]+=n;
- } else
- ret = FAIL;
- return ret;
+ if(isalnum(ccp[0][n]) || ccp[0][n]=='_')
+ ret=FAIL;
+ else
+ ccp[0]+=n;
+ } else
+ ret = FAIL;
+ return ret;
}
#define SKIP_WHITE() { str++; if(ISSPACE(*str)) str++;}
@@ -858,258 +858,258 @@ int
char *str;
register struct m68k_op *opP;
{
- char *strend;
- long i;
- char *parse_index();
-
- /* Skip leading blank */
- if(ISSPACE(*str))
- str++;
- if(!*str) {
- opP->error="Missing operand";
- return FAIL;
- }
- /* *strend = last character of string */
- for(strend=str;*strend;strend++)
- ;
- --strend;
-
- /* Logic of the parsing switch(*str):
- case opP->mode =
- ---- -----------
- #anything IMMED 1
- REG AREG or DREG or MSCR 3 or 2 or 13
- REG- or REG/ REGLST 14
- (REG) AINDR 4
- (REG)+ AINC 6
- (REG,INDX) AINDX 8
- (EXPR,REG) AOFF 7
- (EXPR,REG,INDX) AINDX 8
- -(REG) ADEC 5
- EXP2(REG) AOFF 7
- EXP2(REG,INDX) AINDX 8
- EXP2 ABSL 12
-
- REG means truth(m68k_reg_parse(&str))
- INDX means truth(try_index(&str,opP))
- EXPR means not REG
- EXP2 means not REG and not '(' and not '-('
- */
-
- if(*str=='#') {
- /* "#<expression>" Immediate mode */
- str++;
- opP->con1=add_exp(str,strend);
- opP->mode=IMMED;
- return OK;
- }
-
- i=m68k_reg_parse(&str);
- if (i!=FAIL) {
- if(*str=='\0') {
- /* "Rn" Register Direct mode */
- opP->reg=i;
- if(i>=DATA+0 && i<=DATA+7)
- opP->mode=DREG;
- else if(i>=ADDR+0 && i<=ADDR+7)
- opP->mode=AREG;
- else
- opP->mode=MSCR;
- return OK;
- }
- else if(*str=='/' || *str=='-') {
- /* "Rm-Rn/Ro-Rp" Register list for MOVEM instruction */
- opP->mode=REGLST;
- return get_regs(i,str,opP);
+ char *strend;
+ long i;
+ char *parse_index();
+
+ /* Skip leading blank */
+ if(ISSPACE(*str))
+ str++;
+ if(!*str) {
+ opP->error="Missing operand";
+ return FAIL;
}
- else {
- opP->error="Junk after register name";
- return FAIL;
+ /* *strend = last character of string */
+ for(strend=str;*strend;strend++)
+ ;
+ --strend;
+
+ /* Logic of the parsing switch(*str):
+ case opP->mode =
+ ---- -----------
+ #anything IMMED 1
+ REG AREG or DREG or MSCR 3 or 2 or 13
+ REG- or REG/ REGLST 14
+ (REG) AINDR 4
+ (REG)+ AINC 6
+ (REG,INDX) AINDX 8
+ (EXPR,REG) AOFF 7
+ (EXPR,REG,INDX) AINDX 8
+ -(REG) ADEC 5
+ EXP2(REG) AOFF 7
+ EXP2(REG,INDX) AINDX 8
+ EXP2 ABSL 12
+
+ REG means truth(m68k_reg_parse(&str))
+ INDX means truth(try_index(&str,opP))
+ EXPR means not REG
+ EXP2 means not REG and not '(' and not '-('
+ */
+
+ if(*str=='#') {
+ /* "#<expression>" Immediate mode */
+ str++;
+ opP->con1=add_exp(str,strend);
+ opP->mode=IMMED;
+ return OK;
}
- }
-
- if(*str=='(') {
- str++;
+
i=m68k_reg_parse(&str);
- if((i<ADDR+0 || i>ADDR+7) && i!=PC && i!=ZPC && i!=FAIL) {
- /* Can't indirect off non address regs */
- opP->error="Invalid indirect register";
- return FAIL;
- }
- if(i!=FAIL) {
- opP->reg=i;
- if(*str==')') {
- str++;
+ if (i!=FAIL) {
if(*str=='\0') {
- /* "(An)" Address Register Indirect mode */
- opP->mode=AINDR;
- return OK;
- }
- if(*str=='+') {
- if(str[1]=='\0') {
- /* "(An)+" Register Indirect w Postincrement */
- opP->mode=AINC;
+ /* "Rn" Register Direct mode */
+ opP->reg=i;
+ if(i>=DATA+0 && i<=DATA+7)
+ opP->mode=DREG;
+ else if(i>=ADDR+0 && i<=ADDR+7)
+ opP->mode=AREG;
+ else
+ opP->mode=MSCR;
return OK;
- }
}
- opP->error="Junk after indirect";
- return FAIL;
- }
- if(*str==',') {
- str++;
- i=try_index(&str,opP);
- if(i==FAIL) return FAIL;
- /* "(An,Rn)" Register Indirect with Index mode*/
- opP->mode=AINDX;
- return OK;
- }
- else {
- opP->error="Bad indirect syntax";
- return FAIL;
- }
+ else if(*str=='/' || *str=='-') {
+ /* "Rm-Rn/Ro-Rp" Register list for MOVEM instruction */
+ opP->mode=REGLST;
+ return get_regs(i,str,opP);
+ }
+ else {
+ opP->error="Junk after register name";
+ return FAIL;
+ }
}
- else {
- /* "(EXPR,..." , a displacement */
- char *stmp;
- char *index();
-
- if(stmp=index(str,',')) {
- opP->con1=add_exp(str,stmp-1);
- str=stmp;
- SKIP_WHITE();
+
+ if(*str=='(') {
+ str++;
i=m68k_reg_parse(&str);
- if((i<ADDR+0 || i>ADDR+7) && i!=PC && i!=ZPC) {
- /* Can't indirect off non address regs */
- opP->error="Invalid indirect register";
- return FAIL;
+ if((i<ADDR+0 || i>ADDR+7) && i!=PC && i!=ZPC && i!=FAIL) {
+ /* Can't indirect off non address regs */
+ opP->error="Invalid indirect register";
+ return FAIL;
}
if(i!=FAIL) {
- opP->reg=i;
- if(*str==')') {
- /* "(d,An)" Register Indirect w Displacement */
- opP->mode=AOFF;
- return OK;
- }
- if(*str==',') {
- str++;
- i=try_index(&str,opP);
- if(i==FAIL) return FAIL;
- /* "(d,An,Rn)" Register Indirect with Index */
- opP->mode=AINDX;
- return OK;
- }
- else {
- opP->error="Bad indirect syntax";
- return FAIL;
- }
+ opP->reg=i;
+ if(*str==')') {
+ str++;
+ if(*str=='\0') {
+ /* "(An)" Address Register Indirect mode */
+ opP->mode=AINDR;
+ return OK;
+ }
+ if(*str=='+') {
+ if(str[1]=='\0') {
+ /* "(An)+" Register Indirect w Postincrement */
+ opP->mode=AINC;
+ return OK;
+ }
+ }
+ opP->error="Junk after indirect";
+ return FAIL;
+ }
+ if(*str==',') {
+ str++;
+ i=try_index(&str,opP);
+ if(i==FAIL) return FAIL;
+ /* "(An,Rn)" Register Indirect with Index mode*/
+ opP->mode=AINDX;
+ return OK;
+ }
+ else {
+ opP->error="Bad indirect syntax";
+ return FAIL;
+ }
}
else {
- opP->error="Invalid register";
- return FAIL;
+ /* "(EXPR,..." , a displacement */
+ char *stmp;
+ char *index();
+
+ if(stmp=index(str,',')) {
+ opP->con1=add_exp(str,stmp-1);
+ str=stmp;
+ SKIP_WHITE();
+ i=m68k_reg_parse(&str);
+ if((i<ADDR+0 || i>ADDR+7) && i!=PC && i!=ZPC) {
+ /* Can't indirect off non address regs */
+ opP->error="Invalid indirect register";
+ return FAIL;
+ }
+ if(i!=FAIL) {
+ opP->reg=i;
+ if(*str==')') {
+ /* "(d,An)" Register Indirect w Displacement */
+ opP->mode=AOFF;
+ return OK;
+ }
+ if(*str==',') {
+ str++;
+ i=try_index(&str,opP);
+ if(i==FAIL) return FAIL;
+ /* "(d,An,Rn)" Register Indirect with Index */
+ opP->mode=AINDX;
+ return OK;
+ }
+ else {
+ opP->error="Bad indirect syntax";
+ return FAIL;
+ }
+ }
+ else {
+ opP->error="Invalid register";
+ return FAIL;
+ }
+ }
+ else {
+ opP->error="Missing register for indirect";
+ return FAIL;
+ }
}
- }
- else {
- opP->error="Missing register for indirect";
- return FAIL;
- }
}
- }
-
- if(*str=='-') {
- if(str[1]=='(') {
- str = str+2;
- i=m68k_reg_parse(&str);
- if((i<ADDR+0 || i>ADDR+7) && i!=PC && i!=ZPC && i!=FAIL) {
- /* Can't indirect off non address regs */
- opP->error="Invalid indirect register";
- return FAIL;
- }
- if(i!=FAIL) {
- opP->reg=i;
- if(*str==')') {
- str++;
- if(*str=='\0') {
- /* "-(An)" Register Indirect with Predecrement */
- opP->mode=ADEC;
- return OK;
- }
- opP->error="Junk after indirect";
- return FAIL;
+
+ if(*str=='-') {
+ if(str[1]=='(') {
+ str = str+2;
+ i=m68k_reg_parse(&str);
+ if((i<ADDR+0 || i>ADDR+7) && i!=PC && i!=ZPC && i!=FAIL) {
+ /* Can't indirect off non address regs */
+ opP->error="Invalid indirect register";
+ return FAIL;
+ }
+ if(i!=FAIL) {
+ opP->reg=i;
+ if(*str==')') {
+ str++;
+ if(*str=='\0') {
+ /* "-(An)" Register Indirect with Predecrement */
+ opP->mode=ADEC;
+ return OK;
+ }
+ opP->error="Junk after indirect";
+ return FAIL;
+ }
+ opP->error="Bad indirect syntax";
+ return FAIL;
+ }
+ opP->error="Invalid register";
+ return FAIL;
}
- opP->error="Bad indirect syntax";
- return FAIL;
- }
- opP->error="Invalid register";
- return FAIL;
+ /* if '-' but not "-(', do nothing */
}
- /* if '-' but not "-(', do nothing */
- }
-
- /* whether *str=='-' or not */
-{
- /* "EXP2" or "EXP2(REG..." */
- char *stmp;
- char *index();
- if(stmp=index(str,'(')) {
- opP->con1=add_exp(str,stmp-1);
- str=stmp+1;
- i=m68k_reg_parse(&str);
- if((i<ADDR+0 || i>ADDR+7) && i!=PC && i!=ZPC) {
- /* Can't indirect off non address regs */
- opP->error="Invalid indirect register";
- return FAIL;
- }
- if(i!=FAIL) {
- opP->reg=i;
- if(*str==')') {
- /* "d(An)" Register Indirect w Displacement */
- opP->mode=AOFF;
- return OK;
- }
- if(*str==',') {
- str++;
- i=try_index(&str,opP);
- if(i==FAIL) return FAIL;
- /* "d(An,Rn)" Register Indirect with Index */
- opP->mode=AINDX;
- return OK;
- }
- else {
- opP->error="Bad indirect syntax";
- return FAIL;
- }
- }
- else {
- opP->error="Invalid register";
- return FAIL;
- }
- }
- else {
- /* "EXP2" Absolute */
- opP->mode=ABSL;
- if(strend[-1]=='.') { /* mode ==foo.[wl] */
- switch(*strend) {
- case 'w':
- case 'W':
- opP->isiz=2;
- break;
- case 'l':
- case 'L':
- opP->isiz=3;
- break;
- default:
- opP->error="Size spec not .W or .L";
- return FAIL;
- }
- strend-=2;
- }
- else opP->isiz=0;
-
- opP->con1=add_exp(str,strend);
- return OK;
- }
-}
+ /* whether *str=='-' or not */
+ {
+ /* "EXP2" or "EXP2(REG..." */
+ char *stmp;
+ char *index();
+ if(stmp=index(str,'(')) {
+ opP->con1=add_exp(str,stmp-1);
+ str=stmp+1;
+ i=m68k_reg_parse(&str);
+ if((i<ADDR+0 || i>ADDR+7) && i!=PC && i!=ZPC) {
+ /* Can't indirect off non address regs */
+ opP->error="Invalid indirect register";
+ return FAIL;
+ }
+ if(i!=FAIL) {
+ opP->reg=i;
+ if(*str==')') {
+ /* "d(An)" Register Indirect w Displacement */
+ opP->mode=AOFF;
+ return OK;
+ }
+ if(*str==',') {
+ str++;
+ i=try_index(&str,opP);
+ if(i==FAIL) return FAIL;
+ /* "d(An,Rn)" Register Indirect with Index */
+ opP->mode=AINDX;
+ return OK;
+ }
+ else {
+ opP->error="Bad indirect syntax";
+ return FAIL;
+ }
+ }
+ else {
+ opP->error="Invalid register";
+ return FAIL;
+ }
+ }
+ else {
+ /* "EXP2" Absolute */
+ opP->mode=ABSL;
+ if(strend[-1]=='.') { /* mode ==foo.[wl] */
+ switch(*strend) {
+ case 'w':
+ case 'W':
+ opP->isiz=2;
+ break;
+ case 'l':
+ case 'L':
+ opP->isiz=3;
+ break;
+ default:
+ opP->error="Size spec not .W or .L";
+ return FAIL;
+ }
+ strend-=2;
+ }
+ else opP->isiz=0;
+
+
+ opP->con1=add_exp(str,strend);
+ return OK;
+ }
+ }
}
/* end of m68k_ip_op () */
#else
@@ -1129,237 +1129,237 @@ int
char *str;
register struct m68k_op *opP;
{
- char *strend;
- long i;
- char *parse_index();
-
- if (ISSPACE(*str)) {
- str++;
- } /* Find the beginning of the string */
-
- if(!*str) {
- opP->error="Missing operand";
- return FAIL;
- } /* Out of gas */
-
- for(strend = str; *strend; strend++) ;;
-
- --strend;
-
- if(*str=='#') {
- str++;
- opP->con1=add_exp(str,strend);
- opP->mode=IMMED;
- return OK;
- } /* Guess what: A constant. Shar and enjoy */
-
- i = m68k_reg_parse(&str);
-
- /* is a register, is exactly a register, and is followed by '@' */
-
- if((i==FAIL || *str!='\0') && *str!='@') {
- char *stmp;
-
- if(i!=FAIL && (*str=='/' || *str=='-')) {
- opP->mode=REGLST;
- return(get_regs(i,str,opP));
- }
- if ((stmp=strchr(str,'@')) != '\0') {
- opP->con1=add_exp(str,stmp-1);
- if(stmp==strend) {
- opP->mode=AINDX;
+ char *strend;
+ long i;
+ char *parse_index();
+
+ if (ISSPACE(*str)) {
+ str++;
+ } /* Find the beginning of the string */
+
+ if(!*str) {
+ opP->error="Missing operand";
+ return FAIL;
+ } /* Out of gas */
+
+ for(strend = str; *strend; strend++) ;;
+
+ --strend;
+
+ if(*str=='#') {
+ str++;
+ opP->con1=add_exp(str,strend);
+ opP->mode=IMMED;
+ return OK;
+ } /* Guess what: A constant. Shar and enjoy */
+
+ i = m68k_reg_parse(&str);
+
+ /* is a register, is exactly a register, and is followed by '@' */
+
+ if((i==FAIL || *str!='\0') && *str!='@') {
+ char *stmp;
+
+ if(i!=FAIL && (*str=='/' || *str=='-')) {
+ opP->mode=REGLST;
+ return(get_regs(i,str,opP));
+ }
+ if ((stmp=strchr(str,'@')) != '\0') {
+ opP->con1=add_exp(str,stmp-1);
+ if(stmp==strend) {
+ opP->mode=AINDX;
+ return(OK);
+ }
+
+ if ((current_architecture & m68020up) == 0) {
+ return(FAIL);
+ } /* if target is not a '20 or better */
+
+ stmp++;
+ if(*stmp++!='(' || *strend--!=')') {
+ opP->error="Malformed operand";
+ return(FAIL);
+ }
+ i=try_index(&stmp,opP);
+ opP->con2=add_exp(stmp,strend);
+
+ if (i == FAIL) {
+ opP->mode=AMIND;
+ } else {
+ opP->mode=APODX;
+ }
+ return(OK);
+ } /* if there's an '@' */
+ opP->mode = ABSL;
+ opP->con1 = add_exp(str,strend);
return(OK);
- }
-
- if ((current_architecture & m68020up) == 0) {
- return(FAIL);
- } /* if target is not a '20 or better */
-
- stmp++;
- if(*stmp++!='(' || *strend--!=')') {
- opP->error="Malformed operand";
- return(FAIL);
- }
- i=try_index(&stmp,opP);
- opP->con2=add_exp(stmp,strend);
-
- if (i == FAIL) {
- opP->mode=AMIND;
- } else {
- opP->mode=APODX;
- }
- return(OK);
- } /* if there's an '@' */
- opP->mode = ABSL;
- opP->con1 = add_exp(str,strend);
- return(OK);
- } /* not a register, not exactly a register, or no '@' */
-
- opP->reg=i;
-
- if (*str=='\0') {
- if(i>=DATA+0 && i<=DATA+7)
- opP->mode=DREG;
- else if(i>=ADDR+0 && i<=ADDR+7)
- opP->mode=AREG;
- else
- opP->mode=MSCR;
- return OK;
- }
-
- if((i<ADDR+0 || i>ADDR+7) && i!=PC && i!=ZPC && i!=FAIL) { /* Can't indirect off non address regs */
- opP->error="Invalid indirect register";
- return FAIL;
- }
- know(*str == '@');
-
- str++;
- switch(*str) {
- case '\0':
- opP->mode=AINDR;
- return OK;
- case '-':
- opP->mode=ADEC;
- return OK;
- case '+':
- opP->mode=AINC;
- return OK;
- case '(':
- str++;
- break;
- default:
- opP->error="Junk after indirect";
- return FAIL;
- }
- /* Some kind of indexing involved. Lets find out how bad it is */
- i=try_index(&str,opP);
- /* Didn't start with an index reg, maybe its offset or offset,reg */
- if(i==FAIL) {
- char *beg_str;
+ } /* not a register, not exactly a register, or no '@' */
- beg_str=str;
- for(i=1;i;) {
- switch(*str++) {
- case '\0':
- opP->error="Missing )";
+ opP->reg=i;
+
+ if (*str=='\0') {
+ if(i>=DATA+0 && i<=DATA+7)
+ opP->mode=DREG;
+ else if(i>=ADDR+0 && i<=ADDR+7)
+ opP->mode=AREG;
+ else
+ opP->mode=MSCR;
+ return OK;
+ }
+
+ if((i<ADDR+0 || i>ADDR+7) && i!=PC && i!=ZPC && i!=FAIL) { /* Can't indirect off non address regs */
+ opP->error="Invalid indirect register";
return FAIL;
- case ',': i=0; break;
- case '(': i++; break;
- case ')': --i; break;
- }
}
- /* if(str[-3]==':') {
- int siz;
-
- switch(str[-2]) {
- case 'b':
- case 'B':
- siz=1;
- break;
- case 'w':
- case 'W':
- siz=2;
- break;
- case 'l':
- case 'L':
- siz=3;
- break;
- default:
- opP->error="Specified size isn't :w or :l";
- return FAIL;
- }
- opP->con1=add_exp(beg_str,str-4);
- opP->con1->e_siz=siz;
- } else */
- opP->con1=add_exp(beg_str,str-2);
- /* Should be offset,reg */
- if(str[-1]==',') {
- i=try_index(&str,opP);
- if(i==FAIL) {
- opP->error="Malformed index reg";
+ know(*str == '@');
+
+ str++;
+ switch(*str) {
+ case '\0':
+ opP->mode=AINDR;
+ return OK;
+ case '-':
+ opP->mode=ADEC;
+ return OK;
+ case '+':
+ opP->mode=AINC;
+ return OK;
+ case '(':
+ str++;
+ break;
+ default:
+ opP->error="Junk after indirect";
return FAIL;
- }
}
- }
- /* We've now got offset) offset,reg) or reg) */
-
- if (*str == '\0') {
- /* Th-the-thats all folks */
- if (opP->reg == FAIL) opP->mode = AINDX; /* Other form of indirect */
- else if(opP->ireg == FAIL) opP->mode = AOFF;
- else opP->mode = AINDX;
- return(OK);
- }
- /* Next thing had better be another @ */
- if(*str!='@' || str[1]!='(') {
- opP->error = "junk after indirect";
- return(FAIL);
- }
-
- if ((current_architecture & m68020up) == 0) {
- return(FAIL);
- } /* if target is not a '20 or better */
-
- str+=2;
-
- if(opP->ireg != FAIL) {
- opP->mode = APRDX;
-
- i = try_index(&str, opP);
- if (i != FAIL) {
- opP->error = "Two index registers! not allowed!";
- return(FAIL);
+ /* Some kind of indexing involved. Lets find out how bad it is */
+ i=try_index(&str,opP);
+ /* Didn't start with an index reg, maybe its offset or offset,reg */
+ if(i==FAIL) {
+ char *beg_str;
+
+ beg_str=str;
+ for(i=1;i;) {
+ switch(*str++) {
+ case '\0':
+ opP->error="Missing )";
+ return FAIL;
+ case ',': i=0; break;
+ case '(': i++; break;
+ case ')': --i; break;
+ }
+ }
+ /* if(str[-3]==':') {
+ int siz;
+
+ switch(str[-2]) {
+ case 'b':
+ case 'B':
+ siz=1;
+ break;
+ case 'w':
+ case 'W':
+ siz=2;
+ break;
+ case 'l':
+ case 'L':
+ siz=3;
+ break;
+ default:
+ opP->error="Specified size isn't :w or :l";
+ return FAIL;
+ }
+ opP->con1=add_exp(beg_str,str-4);
+ opP->con1->e_siz=siz;
+ } else */
+ opP->con1=add_exp(beg_str,str-2);
+ /* Should be offset,reg */
+ if(str[-1]==',') {
+ i=try_index(&str,opP);
+ if(i==FAIL) {
+ opP->error="Malformed index reg";
+ return FAIL;
+ }
+ }
}
- } else {
- i = try_index(&str, opP);
- }
-
- if (i == FAIL) {
- char *beg_str;
-
- beg_str = str;
-
- for (i = 1; i; ) {
- switch(*str++) {
- case '\0':
- opP->error="Missing )";
+ /* We've now got offset) offset,reg) or reg) */
+
+ if (*str == '\0') {
+ /* Th-the-thats all folks */
+ if (opP->reg == FAIL) opP->mode = AINDX; /* Other form of indirect */
+ else if(opP->ireg == FAIL) opP->mode = AOFF;
+ else opP->mode = AINDX;
+ return(OK);
+ }
+ /* Next thing had better be another @ */
+ if(*str!='@' || str[1]!='(') {
+ opP->error = "junk after indirect";
return(FAIL);
- case ',': i=0; break;
- case '(': i++; break;
- case ')': --i; break;
- }
}
- opP->con2=add_exp(beg_str,str-2);
-
- if (str[-1] == ',') {
- if (opP->ireg != FAIL) {
- opP->error = "Can't have two index regs";
+ if ((current_architecture & m68020up) == 0) {
return(FAIL);
- }
-
- i = try_index(&str, opP);
-
- if (i == FAIL) {
- opP->error = "malformed index reg";
- return(FAIL);
- }
-
- opP->mode = APODX;
- } else if (opP->ireg != FAIL) {
- opP->mode = APRDX;
+ } /* if target is not a '20 or better */
+
+ str+=2;
+
+ if(opP->ireg != FAIL) {
+ opP->mode = APRDX;
+
+ i = try_index(&str, opP);
+ if (i != FAIL) {
+ opP->error = "Two index registers! not allowed!";
+ return(FAIL);
+ }
+ } else {
+ i = try_index(&str, opP);
+ }
+
+ if (i == FAIL) {
+ char *beg_str;
+
+ beg_str = str;
+
+ for (i = 1; i; ) {
+ switch(*str++) {
+ case '\0':
+ opP->error="Missing )";
+ return(FAIL);
+ case ',': i=0; break;
+ case '(': i++; break;
+ case ')': --i; break;
+ }
+ }
+
+ opP->con2=add_exp(beg_str,str-2);
+
+ if (str[-1] == ',') {
+ if (opP->ireg != FAIL) {
+ opP->error = "Can't have two index regs";
+ return(FAIL);
+ }
+
+ i = try_index(&str, opP);
+
+ if (i == FAIL) {
+ opP->error = "malformed index reg";
+ return(FAIL);
+ }
+
+ opP->mode = APODX;
+ } else if (opP->ireg != FAIL) {
+ opP->mode = APRDX;
+ } else {
+ opP->mode = AMIND;
+ }
} else {
- opP->mode = AMIND;
+ opP->mode = APODX;
+ }
+
+ if(*str!='\0') {
+ opP->error="Junk after indirect";
+ return FAIL;
}
- } else {
- opP->mode = APODX;
- }
-
- if(*str!='\0') {
- opP->error="Junk after indirect";
- return FAIL;
- }
- return(OK);
+ return(OK);
} /* m68k_ip_op() */
#endif
/*
@@ -1380,100 +1380,100 @@ register struct m68k_op *opP;
*/
static int try_index(s,opP)
- char **s;
- struct m68k_op *opP;
+char **s;
+struct m68k_op *opP;
{
- register int i;
- char *ss;
+ register int i;
+ char *ss;
#define SKIP_W() { ss++; if (ISSPACE(*ss)) ss++;}
-
- ss= *s;
- /* SKIP_W(); */
- i=m68k_reg_parse(&ss);
- if(!(i>=DATA+0 && i<=ADDR+7)) { /* if i is not DATA or ADDR reg */
- *s=ss;
- return FAIL;
- }
- opP->ireg=i;
- /* SKIP_W(); */
- if(*ss==')') {
- opP->isiz=0;
- opP->imul=1;
- SKIP_W();
- *s=ss;
- return OK;
- }
- if(*ss!=SIZER)
- {
- opP->error="Missing : in index register";
- *s=ss;
- return FAIL;
- }
- SKIP_W();
- switch(*ss) {
- case 'w':
- case 'W':
- opP->isiz=2;
- break;
- case 'l':
- case 'L':
- opP->isiz=3;
- break;
- default:
- opP->error="Index register size spec not :w or :l";
- *s=ss;
- return FAIL;
- }
- SKIP_W();
- if(*ss==MULTIPLIER)
- {
+
+ ss= *s;
+ /* SKIP_W(); */
+ i=m68k_reg_parse(&ss);
+ if(!(i>=DATA+0 && i<=ADDR+7)) { /* if i is not DATA or ADDR reg */
+ *s=ss;
+ return FAIL;
+ }
+ opP->ireg=i;
+ /* SKIP_W(); */
+ if(*ss==')') {
+ opP->isiz=0;
+ opP->imul=1;
+ SKIP_W();
+ *s=ss;
+ return OK;
+ }
+ if(*ss!=SIZER)
+ {
+ opP->error="Missing : in index register";
+ *s=ss;
+ return FAIL;
+ }
SKIP_W();
switch(*ss) {
- case '1':
- case '2':
- case '4':
- case '8':
- opP->imul= *ss-'0';
- break;
+ case 'w':
+ case 'W':
+ opP->isiz=2;
+ break;
+ case 'l':
+ case 'L':
+ opP->isiz=3;
+ break;
default:
- opP->error="index multiplier not 1, 2, 4 or 8";
- *s=ss;
- return FAIL;
+ opP->error="Index register size spec not :w or :l";
+ *s=ss;
+ return FAIL;
+ }
+ SKIP_W();
+ if(*ss==MULTIPLIER)
+ {
+ SKIP_W();
+ switch(*ss) {
+ case '1':
+ case '2':
+ case '4':
+ case '8':
+ opP->imul= *ss-'0';
+ break;
+ default:
+ opP->error="index multiplier not 1, 2, 4 or 8";
+ *s=ss;
+ return FAIL;
+ }
+ SKIP_W();
+ } else opP->imul=1;
+ if(*ss!=')') {
+ opP->error="Missing )";
+ *s=ss;
+ return FAIL;
}
SKIP_W();
- } else opP->imul=1;
- if(*ss!=')') {
- opP->error="Missing )";
*s=ss;
- return FAIL;
- }
- SKIP_W();
- *s=ss;
- return OK;
+ return OK;
} /* try_index() */
#ifdef TEST1 /* TEST1 tests m68k_ip_op(), which parses operands */
main()
{
- char buf[128];
- struct m68k_op thark;
-
- for(;;) {
- if(!gets(buf))
- break;
- bzero(&thark,sizeof(thark));
- if(!m68k_ip_op(buf,&thark)) printf("FAIL:");
- if(thark.error)
- printf("op1 error %s in %s\n",thark.error,buf);
- printf("mode %d, reg %d, ",thark.mode,thark.reg);
- if(thark.b_const)
- printf("Constant: '%.*s',",1+thark.e_const-thark.b_const,thark.b_const);
- printf("ireg %d, isiz %d, imul %d ",thark.ireg,thark.isiz,thark.imul);
- if(thark.b_iadd)
- printf("Iadd: '%.*s'",1+thark.e_iadd-thark.b_iadd,thark.b_iadd);
- printf("\n");
- }
- exit(0);
+ char buf[128];
+ struct m68k_op thark;
+
+ for(;;) {
+ if(!gets(buf))
+ break;
+ memset(&thark, '\0', sizeof(thark));
+ if(!m68k_ip_op(buf,&thark)) printf("FAIL:");
+ if(thark.error)
+ printf("op1 error %s in %s\n",thark.error,buf);
+ printf("mode %d, reg %d, ",thark.mode,thark.reg);
+ if(thark.b_const)
+ printf("Constant: '%.*s',",1+thark.e_const-thark.b_const,thark.b_const);
+ printf("ireg %d, isiz %d, imul %d ",thark.ireg,thark.isiz,thark.imul);
+ if(thark.b_iadd)
+ printf("Iadd: '%.*s'",1+thark.e_iadd-thark.b_iadd,thark.b_iadd);
+ printf("\n");
+ }
+ exit(0);
}
#endif
@@ -1510,1233 +1510,1233 @@ static struct hash_control* op_hash = NULL; /* handle of the OPCODE hash table
/* JF this function no longer returns a useful value. Sorry */
void m68k_ip (instring)
- char *instring;
+char *instring;
{
- register char *p;
- register struct m68k_op *opP;
- register struct m68k_incant *opcode, prev_opcode;
- register char *s;
- register int tmpreg = 0,
- baseo = 0,
- outro = 0,
- nextword;
- int siz1,
- siz2;
- char c;
- int losing;
- int opsfound;
- char *crack_operand();
-
- LITTLENUM_TYPE words[6];
- LITTLENUM_TYPE *wordp;
-
- if (ISSPACE(*instring))
- instring++; /* skip leading whitespace */
-
- /* Scan up to end of operation-code, which MUST end in end-of-string
- or exactly 1 space. */
- for (p = instring; *p != '\0'; p++)
- if (ISSPACE(*p))
- break;
-
-
- if (p == instring) {
- the_ins.error = "No operator";
- the_ins.opcode[0] = NULL;
- /* the_ins.numo=1; */
- return;
- }
-
- /* p now points to the end of the opcode name, probably whitespace.
- make sure the name is null terminated by clobbering the whitespace,
- look it up in the hash table, then fix it back. */
- c = *p;
- *p = '\0';
+ register char *p;
+ register struct m68k_op *opP;
+ register struct m68k_incant *opcode, prev_opcode;
+ register char *s;
+ register int tmpreg = 0,
+ baseo = 0,
+ outro = 0,
+ nextword;
+ int siz1,
+ siz2;
+ char c;
+ int losing;
+ int opsfound;
+ char *crack_operand();
+
+ LITTLENUM_TYPE words[6];
+ LITTLENUM_TYPE *wordp;
+
+ if (ISSPACE(*instring))
+ instring++; /* skip leading whitespace */
+
+ /* Scan up to end of operation-code, which MUST end in end-of-string
+ or exactly 1 space. */
+ for (p = instring; *p != '\0'; p++)
+ if (ISSPACE(*p))
+ break;
+
+
+ if (p == instring) {
+ the_ins.error = "No operator";
+ the_ins.opcode[0] = NULL;
+ /* the_ins.numo=1; */
+ return;
+ }
+
+ /* p now points to the end of the opcode name, probably whitespace.
+ make sure the name is null terminated by clobbering the whitespace,
+ look it up in the hash table, then fix it back. */
+ c = *p;
+ *p = '\0';
#ifdef MRI
- /* Copy from input line to our private buffer, and drop any dots */
-{
- char our_copy[100];
- char *dst = our_copy;
- char *src = instring;
- while (*src)
- {
- if (*src != '.')
- *dst++ = *src;
- src++;
- }
- *dst = 0;
-
-
- opcode = (struct m68k_incant *)hash_find (op_hash, our_copy);
-
- /* If no match, try again with a w suffix */
- if (!opcode)
- {
- *dst++ = 'w';
- *dst = 0;
- opcode = (struct m68k_incant *)hash_find (op_hash, our_copy);
- }
-
-
-
-}
-
+ /* Copy from input line to our private buffer, and drop any dots */
+ {
+ char our_copy[100];
+ char *dst = our_copy;
+ char *src = instring;
+ while (*src)
+ {
+ if (*src != '.')
+ *dst++ = *src;
+ src++;
+ }
+ *dst = 0;
+
+
+ opcode = (struct m68k_incant *)hash_find (op_hash, our_copy);
+
+ /* If no match, try again with a w suffix */
+ if (!opcode)
+ {
+ *dst++ = 'w';
+ *dst = 0;
+ opcode = (struct m68k_incant *)hash_find (op_hash, our_copy);
+ }
+
+
+
+ }
+
#else
-opcode = (struct m68k_incant *)hash_find (op_hash, instring);
+ opcode = (struct m68k_incant *)hash_find (op_hash, instring);
#endif
-*p = c;
-
-if (opcode == NULL) {
- the_ins.error = "Unknown opcode";
- the_ins.opcode[0] = NULL;
- /* the_ins.numo=1; */
- return;
-}
-
-/* found a legitimate opcode, start matching operands */
-while (ISSPACE(*p)) ++p;
-
- for(opP = &the_ins.operands[0]; *p; opP++) {
+ *p = c;
+
+ if (opcode == NULL) {
+ the_ins.error = "Unknown opcode";
+ the_ins.opcode[0] = NULL;
+ /* the_ins.numo=1; */
+ return;
+ }
- p = crack_operand(p, opP);
+ /* found a legitimate opcode, start matching operands */
+ while (ISSPACE(*p)) ++p;
- if (opP->error) {
- the_ins.error=opP->error;
- return;
+ for(opP = &the_ins.operands[0]; *p; opP++) {
+
+ p = crack_operand(p, opP);
+
+ if (opP->error) {
+ the_ins.error=opP->error;
+ return;
+ }
}
- }
-
- opsfound = opP - &the_ins.operands[0];
-
- /* This ugly hack is to support the floating pt opcodes in their standard form */
- /* Essentially, we fake a first enty of type COP#1 */
- if (opcode->m_operands[0]=='I') {
- int n;
- for(n=opsfound;n>0;--n)
- the_ins.operands[n]=the_ins.operands[n-1];
-
- /* bcopy((char *)(&the_ins.operands[0]),(char *)(&the_ins.operands[1]),opsfound*sizeof(the_ins.operands[0])); */
- bzero((char *)(&the_ins.operands[0]),sizeof(the_ins.operands[0]));
- the_ins.operands[0].mode=MSCR;
- the_ins.operands[0].reg=COPNUM; /* COP #1 */
- opsfound++;
- }
-
- /* We've got the operands. Find an opcode that'll accept them */
- for (losing = 0; ; ) {
- /* if we didn't get the right number of ops,
- or we have no common model with this pattern
- then reject this pattern. */
-
- if (opsfound != opcode->m_opnum
- || ((opcode->m_arch & current_architecture) == 0)) {
-
- ++losing;
-
- } else {
- for (s=opcode->m_operands, opP = &the_ins.operands[0]; *s && !losing; s += 2, opP++) {
- /* Warning: this switch is huge! */
- /* I've tried to organize the cases into this order:
- non-alpha first, then alpha by letter. lower-case goes directly
- before uppercase counterpart. */
- /* Code with multiple case ...: gets sorted by the lowest case ...
- it belongs to. I hope this makes sense. */
- switch(*s) {
- case '!':
- if (opP->mode == MSCR || opP->mode == IMMED
- || opP->mode == DREG || opP->mode == AREG
- || opP->mode == AINC || opP->mode == ADEC
- || opP->mode == REGLST)
- losing++;
- break;
-
- case '#':
- if(opP->mode!=IMMED)
- losing++;
- else {
- long t;
+ opsfound = opP - &the_ins.operands[0];
+
+ /* This ugly hack is to support the floating pt opcodes in their standard form */
+ /* Essentially, we fake a first enty of type COP#1 */
+ if (opcode->m_operands[0]=='I') {
+ int n;
+
+ for(n=opsfound;n>0;--n)
+ the_ins.operands[n]=the_ins.operands[n-1];
+
+ /* memcpy((char *)(&the_ins.operands[1]), (char *)(&the_ins.operands[0]), opsfound*sizeof(the_ins.operands[0])); */
+ memset((char *)(&the_ins.operands[0]), '\0', sizeof(the_ins.operands[0]));
+ the_ins.operands[0].mode=MSCR;
+ the_ins.operands[0].reg=COPNUM; /* COP #1 */
+ opsfound++;
+ }
+
+ /* We've got the operands. Find an opcode that'll accept them */
+ for (losing = 0; ; ) {
+ /* if we didn't get the right number of ops,
+ or we have no common model with this pattern
+ then reject this pattern. */
+
+ if (opsfound != opcode->m_opnum
+ || ((opcode->m_arch & current_architecture) == 0)) {
- t=get_num(opP->con1,80);
- if(s[1]=='b' && !isbyte(t))
- losing++;
- else if(s[1]=='w' && !isword(t))
- losing++;
- }
- break;
-
- case '^':
- case 'T':
- if(opP->mode!=IMMED)
- losing++;
- break;
-
- case '$':
- if(opP->mode==MSCR || opP->mode==AREG ||
- opP->mode==IMMED || opP->reg==PC || opP->reg==ZPC || opP->mode==REGLST)
- losing++;
- break;
-
+ ++losing;
+
+ } else {
+ for (s=opcode->m_operands, opP = &the_ins.operands[0]; *s && !losing; s += 2, opP++) {
+ /* Warning: this switch is huge! */
+ /* I've tried to organize the cases into this order:
+ non-alpha first, then alpha by letter. lower-case goes directly
+ before uppercase counterpart. */
+ /* Code with multiple case ...: gets sorted by the lowest case ...
+ it belongs to. I hope this makes sense. */
+ switch(*s) {
+ case '!':
+ if (opP->mode == MSCR || opP->mode == IMMED
+ || opP->mode == DREG || opP->mode == AREG
+ || opP->mode == AINC || opP->mode == ADEC
+ || opP->mode == REGLST)
+ losing++;
+ break;
+
+ case '#':
+ if(opP->mode!=IMMED)
+ losing++;
+ else {
+ long t;
+
+ t=get_num(opP->con1,80);
+ if(s[1]=='b' && !isbyte(t))
+ losing++;
+ else if(s[1]=='w' && !isword(t))
+ losing++;
+ }
+ break;
+
+ case '^':
+ case 'T':
+ if(opP->mode!=IMMED)
+ losing++;
+ break;
+
+ case '$':
+ if(opP->mode==MSCR || opP->mode==AREG ||
+ opP->mode==IMMED || opP->reg==PC || opP->reg==ZPC || opP->mode==REGLST)
+ losing++;
+ break;
+
+ case '%':
+ if(opP->mode==MSCR || opP->reg==PC ||
+ opP->reg==ZPC || opP->mode==REGLST)
+ losing++;
+ break;
+
+
+ case '&':
+ if(opP->mode==MSCR || opP->mode==DREG ||
+ opP->mode==AREG || opP->mode==IMMED || opP->reg==PC || opP->reg==ZPC ||
+ opP->mode==AINC || opP->mode==ADEC || opP->mode==REGLST)
+ losing++;
+ break;
+
+ case '*':
+ if(opP->mode==MSCR || opP->mode==REGLST)
+ losing++;
+ break;
+
+ case '+':
+ if(opP->mode!=AINC)
+ losing++;
+ break;
+
+ case '-':
+ if(opP->mode!=ADEC)
+ losing++;
+ break;
+
+ case '/':
+ if(opP->mode==MSCR || opP->mode==AREG ||
+ opP->mode==AINC || opP->mode==ADEC || opP->mode==IMMED || opP->mode==REGLST)
+ losing++;
+ break;
+
+ case ';':
+ if(opP->mode==MSCR || opP->mode==AREG || opP->mode==REGLST)
+ losing++;
+ break;
+
+ case '?':
+ if(opP->mode==MSCR || opP->mode==AREG ||
+ opP->mode==AINC || opP->mode==ADEC || opP->mode==IMMED || opP->reg==PC ||
+ opP->reg==ZPC || opP->mode==REGLST)
+ losing++;
+ break;
+
+ case '@':
+ if(opP->mode==MSCR || opP->mode==AREG ||
+ opP->mode==IMMED || opP->mode==REGLST)
+ losing++;
+ break;
+
+ case '~': /* For now! (JF FOO is this right?) */
+ if(opP->mode==MSCR || opP->mode==DREG ||
+ opP->mode==AREG || opP->mode==IMMED || opP->reg==PC || opP->reg==ZPC || opP->mode==REGLST)
+ losing++;
+ break;
+
+ case 'A':
+ if(opP->mode!=AREG)
+ losing++;
+ break;
+ case 'a':
+ if (opP->mode != AINDR) {
+ ++losing;
+ } /* if not address register indirect */
+ break;
+ case 'B': /* FOO */
+ if(opP->mode!=ABSL || (flagseen['S'] && instring[0] == 'j'
+ && instring[1] == 'b'
+ && instring[2] == 's'
+ && instring[3] == 'r'))
+ losing++;
+ break;
+
+ case 'C':
+ if(opP->mode!=MSCR || opP->reg!=CCR)
+ losing++;
+ break;
+
+ case 'd': /* FOO This mode is a KLUDGE!! */
+ if(opP->mode!=AOFF && (opP->mode!=ABSL ||
+ opP->con1->e_beg[0]!='(' || opP->con1->e_end[0]!=')'))
+ losing++;
+ break;
+
+ case 'D':
+ if(opP->mode!=DREG)
+ losing++;
+ break;
+
+ case 'F':
+ if(opP->mode!=MSCR || opP->reg<(FPREG+0) || opP->reg>(FPREG+7))
+ losing++;
+ break;
+
+ case 'I':
+ if(opP->mode!=MSCR || opP->reg<COPNUM ||
+ opP->reg>=COPNUM+7)
+ losing++;
+ break;
+
+ case 'J':
+ if (opP->mode != MSCR
+ || opP->reg < USP
+ || opP->reg > URP
+ || cpu_of_arch(current_architecture) < m68010 /* before 68010 had none */
+ || (cpu_of_arch(current_architecture) < m68020
+ && opP->reg != SFC
+ && opP->reg != DFC
+ && opP->reg != USP
+ && opP->reg != VBR) /* 68010's had only these */
+ || (cpu_of_arch(current_architecture) < m68040
+ && opP->reg != SFC
+ && opP->reg != DFC
+ && opP->reg != USP
+ && opP->reg != VBR
+ && opP->reg != CACR
+ && opP->reg != CAAR
+ && opP->reg != MSP
+ && opP->reg != ISP) /* 680[23]0's have only these */
+ || (cpu_of_arch(current_architecture) == m68040 /* 68040 has all but this */
+ && opP->reg == CAAR)) {
+ losing++;
+ } /* doesn't cut it */
+ break;
+
+ case 'k':
+ if(opP->mode!=IMMED)
+ losing++;
+ break;
+
+ case 'l':
+ case 'L':
+ if(opP->mode==DREG || opP->mode==AREG || opP->mode==FPREG) {
+ if(s[1]=='8')
+ losing++;
+ else {
+ opP->mode=REGLST;
+ opP->reg=1<<(opP->reg-DATA);
+ }
+ } else if(opP->mode!=REGLST) {
+ losing++;
+ } else if(s[1]=='8' && opP->reg&0x0FFffFF)
+ losing++;
+ else if(s[1]=='3' && opP->reg&0x7000000)
+ losing++;
+ break;
+
+ case 'M':
+ if(opP->mode!=IMMED)
+ losing++;
+ else {
+ long t;
+
+ t=get_num(opP->con1,80);
+ if(!issbyte(t) || isvar(opP->con1))
+ losing++;
+ }
+ break;
+
+ case 'O':
+ if(opP->mode!=DREG && opP->mode!=IMMED)
+ losing++;
+ break;
+
+ case 'Q':
+ if(opP->mode!=IMMED)
+ losing++;
+ else {
+ long t;
+
+ t=get_num(opP->con1,80);
+ if(t<1 || t>8 || isvar(opP->con1))
+ losing++;
+ }
+ break;
+
+ case 'R':
+ if(opP->mode!=DREG && opP->mode!=AREG)
+ losing++;
+ break;
+
+ case 's':
+ if(opP->mode!=MSCR || !(opP->reg==FPI || opP->reg==FPS || opP->reg==FPC))
+ losing++;
+ break;
+
+ case 'S':
+ if(opP->mode!=MSCR || opP->reg!=SR)
+ losing++;
+ break;
+
+ case 'U':
+ if(opP->mode!=MSCR || opP->reg!=USP)
+ losing++;
+ break;
+
+ /* JF these are out of order. We could put them
+ in order if we were willing to put up with
+ bunches of #ifdef m68851s in the code */
+#ifndef NO_68851
+ /* Memory addressing mode used by pflushr */
+ case '|':
+ if(opP->mode==MSCR || opP->mode==DREG ||
+ opP->mode==AREG || opP->mode==REGLST)
+ losing++;
+ break;
+
+ case 'f':
+ if (opP->mode != MSCR || (opP->reg != SFC && opP->reg != DFC))
+ losing++;
+ break;
+
+ case 'P':
+ if (opP->mode != MSCR || (opP->reg != TC && opP->reg != CAL &&
+ opP->reg != VAL && opP->reg != SCC && opP->reg != AC))
+ losing++;
+ break;
+
+ case 'V':
+ if (opP->reg != VAL)
+ losing++;
+ break;
+
+ case 'W':
+ if (opP->mode != MSCR || (opP->reg != DRP && opP->reg != SRP &&
+ opP->reg != CRP))
+ losing++;
+ break;
+
+ case 'X':
+ if (opP->mode != MSCR ||
+ (!(opP->reg >= BAD && opP->reg <= BAD+7) &&
+ !(opP->reg >= BAC && opP->reg <= BAC+7)))
+ losing++;
+ break;
+
+ case 'Y':
+ if (opP->reg != PSR)
+ losing++;
+ break;
+
+ case 'Z':
+ if (opP->reg != PCSR)
+ losing++;
+ break;
+#endif
+ case 'c':
+ if (opP->reg != NC
+ && opP->reg != IC
+ && opP->reg != DC
+ && opP->reg != BC) {
+ losing++;
+ } /* not a cache specifier. */
+ break;
+
+ case '_':
+ if (opP->mode != ABSL) {
+ ++losing;
+ } /* not absolute */
+ break;
+
+ default:
+ as_fatal("Internal error: Operand mode %c unknown in line %s of file \"%s\"",
+ *s, __LINE__, __FILE__);
+ } /* switch on type of operand */
+
+ if (losing) break;
+ } /* for each operand */
+ } /* if immediately wrong */
+
+ if (!losing) {
+ break;
+ } /* got it. */
+
+
+ if (!opcode->m_next)
+ {
+ if ((opcode->m_arch & current_architecture) == 0)
+ {
+ the_ins.error = "Opcode not available on architecture specified";
+ addword(0);
+
+ }
+ else
+ {
+ the_ins.error = "instruction/operands mismatch";
+ }
+
+ return;
+ } /* Fell off the end */
+ opcode = opcode->m_next;
+ losing = 0;
+ }
+
+ /* now assemble it */
+
+ the_ins.args=opcode->m_operands;
+ the_ins.numargs=opcode->m_opnum;
+ the_ins.numo=opcode->m_codenum;
+ the_ins.opcode[0]=getone(opcode);
+ the_ins.opcode[1]=gettwo(opcode);
+
+ for (s = the_ins.args, opP = &the_ins.operands[0]; *s; s += 2, opP++) {
+ /* This switch is a doozy.
+ Watch the first step; its a big one! */
+ switch(s[0]) {
+
+ case '*':
+ case '~':
case '%':
- if(opP->mode==MSCR || opP->reg==PC ||
- opP->reg==ZPC || opP->mode==REGLST)
- losing++;
- break;
-
-
+ case ';':
+ case '@':
+ case '!':
case '&':
- if(opP->mode==MSCR || opP->mode==DREG ||
- opP->mode==AREG || opP->mode==IMMED || opP->reg==PC || opP->reg==ZPC ||
- opP->mode==AINC || opP->mode==ADEC || opP->mode==REGLST)
- losing++;
- break;
-
- case '*':
- if(opP->mode==MSCR || opP->mode==REGLST)
- losing++;
- break;
-
+ case '$':
+ case '?':
+ case '/':
+#ifndef NO_68851
+ case '|':
+#endif
+ switch(opP->mode) {
+ case IMMED:
+ tmpreg=0x3c; /* 7.4 */
+ if (strchr("bwl",s[1])) nextword=get_num(opP->con1,80);
+ else nextword=nextword=get_num(opP->con1,0);
+ if(isvar(opP->con1))
+ add_fix(s[1],opP->con1,0);
+ switch(s[1]) {
+ case 'b':
+ if(!isbyte(nextword))
+ opP->error="operand out of range";
+ addword(nextword);
+ baseo=0;
+ break;
+ case 'w':
+ if(!isword(nextword))
+ opP->error="operand out of range";
+ addword(nextword);
+ baseo=0;
+ break;
+ case 'l':
+ addword(nextword>>16);
+ addword(nextword);
+ baseo=0;
+ break;
+
+ case 'f':
+ baseo=2;
+ outro=8;
+ break;
+ case 'F':
+ baseo=4;
+ outro=11;
+ break;
+ case 'x':
+ baseo=6;
+ outro=15;
+ break;
+ case 'p':
+ baseo=6;
+ outro= -1;
+ break;
+ default:
+ as_fatal("Internal error: Can't decode %c%c in line %s of file \"%s\"",
+ *s, s[1], __LINE__, __FILE__);
+ }
+ if(!baseo)
+ break;
+
+ /* We gotta put out some float */
+ if(seg(opP->con1)!=SEG_BIG) {
+ int_to_gen(nextword);
+ gen_to_words(words,baseo,(long int)outro);
+ for(wordp=words;baseo--;wordp++)
+ addword(*wordp);
+ break;
+ } /* Its BIG */
+ if(offs(opP->con1)>0) {
+ as_warn("Bignum assumed to be binary bit-pattern");
+ if(offs(opP->con1)>baseo) {
+ as_warn("Bignum too big for %c format; truncated",s[1]);
+ offs(opP->con1)=baseo;
+ }
+ baseo-=offs(opP->con1);
+ for(wordp=generic_bignum+offs(opP->con1)-1;offs(opP->con1)--;--wordp)
+ addword(*wordp);
+ while(baseo--)
+ addword(0);
+ break;
+ }
+ gen_to_words(words,baseo,(long)outro);
+ for (wordp=words;baseo--;wordp++)
+ addword(*wordp);
+ break;
+ case DREG:
+ tmpreg=opP->reg-DATA; /* 0.dreg */
+ break;
+ case AREG:
+ tmpreg=0x08+opP->reg-ADDR; /* 1.areg */
+ break;
+ case AINDR:
+ tmpreg=0x10+opP->reg-ADDR; /* 2.areg */
+ break;
+ case ADEC:
+ tmpreg=0x20+opP->reg-ADDR; /* 4.areg */
+ break;
+ case AINC:
+ tmpreg=0x18+opP->reg-ADDR; /* 3.areg */
+ break;
+ case AOFF:
+
+ nextword=get_num(opP->con1,80);
+ /* Force into index mode. Hope this works */
+
+ /* We do the first bit for 32-bit displacements,
+ and the second bit for 16 bit ones. It is
+ possible that we should make the default be
+ WORD instead of LONG, but I think that'd
+ break GCC, so we put up with a little
+ inefficiency for the sake of working output.
+ */
+
+ if( !issword(nextword)
+ || ( isvar(opP->con1)
+ && ( ( opP->con1->e_siz==0
+ && flagseen['l']==0)
+ || opP->con1->e_siz==3))) {
+
+ if(opP->reg==PC)
+ tmpreg=0x3B; /* 7.3 */
+ else
+ tmpreg=0x30+opP->reg-ADDR; /* 6.areg */
+ if(isvar(opP->con1)) {
+ if(opP->reg==PC) {
+ add_frag(adds(opP->con1),
+ offs(opP->con1),
+ TAB(PCLEA,SZ_UNDEF));
+ break;
+ } else {
+ addword(0x0170);
+ add_fix('l',opP->con1,1);
+ }
+ } else
+ addword(0x0170);
+ addword(nextword>>16);
+ } else {
+ if(opP->reg==PC)
+ tmpreg=0x3A; /* 7.2 */
+ else
+ tmpreg=0x28+opP->reg-ADDR; /* 5.areg */
+
+ if(isvar(opP->con1)) {
+ if(opP->reg==PC) {
+ add_fix('w',opP->con1,1);
+ } else
+ add_fix('w',opP->con1,0);
+ }
+ }
+ addword(nextword);
+ break;
+
+ case APODX:
+ case AMIND:
+ case APRDX:
+ know(current_architecture & m68020up);
+ /* intentional fall-through */
+ case AINDX:
+ nextword=0;
+ baseo=get_num(opP->con1,80);
+ outro=get_num(opP->con2,80);
+ /* Figure out the 'addressing mode' */
+ /* Also turn on the BASE_DISABLE bit, if needed */
+ if(opP->reg==PC || opP->reg==ZPC) {
+ tmpreg=0x3b; /* 7.3 */
+ if(opP->reg==ZPC)
+ nextword|=0x80;
+ } else if(opP->reg==FAIL) {
+ nextword|=0x80;
+ tmpreg=0x30; /* 6.garbage */
+ } else tmpreg=0x30+opP->reg-ADDR; /* 6.areg */
+
+ siz1= (opP->con1) ? opP->con1->e_siz : 0;
+ siz2= (opP->con2) ? opP->con2->e_siz : 0;
+
+ /* Index register stuff */
+ if(opP->ireg>=DATA+0 && opP->ireg<=ADDR+7) {
+ nextword|=(opP->ireg-DATA)<<12;
+
+ if(opP->isiz==0 || opP->isiz==3)
+ nextword|=0x800;
+ switch(opP->imul) {
+ case 1: break;
+ case 2: nextword|=0x200; break;
+ case 4: nextword|=0x400; break;
+ case 8: nextword|=0x600; break;
+ default: as_fatal("failed sanity check.");
+ }
+ /* IF its simple,
+ GET US OUT OF HERE! */
+
+ /* Must be INDEX, with an index
+ register. Address register
+ cannot be ZERO-PC, and either
+ :b was forced, or we know
+ it will fit */
+ if( opP->mode==AINDX
+ && opP->reg!=FAIL
+ && opP->reg!=ZPC
+ && ( siz1==1
+ || ( issbyte(baseo)
+ && !isvar(opP->con1)))) {
+ nextword +=baseo&0xff;
+ addword(nextword);
+ if(isvar(opP->con1))
+ add_fix('B',opP->con1,0);
+ break;
+ }
+ } else
+ nextword|=0x40; /* No index reg */
+
+ /* It aint simple */
+ nextword|=0x100;
+ /* If the guy specified a width, we assume that
+ it is wide enough. Maybe it isn't. If so, we lose
+ */
+ switch(siz1) {
+ case 0:
+ if(isvar(opP->con1) || !issword(baseo)) {
+ siz1=3;
+ nextword|=0x30;
+ } else if(baseo==0)
+ nextword|=0x10;
+ else {
+ nextword|=0x20;
+ siz1=2;
+ }
+ break;
+ case 1:
+ as_warn("Byte dispacement won't work. Defaulting to :w");
+ case 2:
+ nextword|=0x20;
+ break;
+ case 3:
+ nextword|=0x30;
+ break;
+ }
+
+ /* Figure out innner displacement stuff */
+ if(opP->mode!=AINDX) {
+ switch(siz2) {
+ case 0:
+ if(isvar(opP->con2) || !issword(outro)) {
+ siz2=3;
+ nextword|=0x3;
+ } else if(outro==0)
+ nextword|=0x1;
+ else {
+ nextword|=0x2;
+ siz2=2;
+ }
+ break;
+ case 1:
+ as_warn("Byte dispacement won't work. Defaulting to :w");
+ case 2:
+ nextword|=0x2;
+ break;
+ case 3:
+ nextword|=0x3;
+ break;
+ }
+ if(opP->mode==APODX) nextword|=0x04;
+ else if(opP->mode==AMIND) nextword|=0x40;
+ }
+ addword(nextword);
+
+ if(isvar(opP->con1)) {
+ if(opP->reg==PC || opP->reg==ZPC) {
+ add_fix(siz1==3 ? 'l' : 'w',opP->con1,1);
+ opP->con1->e_exp.X_add_number+=6;
+ } else
+ add_fix(siz1==3 ? 'l' : 'w',opP->con1,0);
+ }
+ if(siz1==3)
+ addword(baseo>>16);
+ if(siz1)
+ addword(baseo);
+
+ if(isvar(opP->con2)) {
+ if(opP->reg==PC || opP->reg==ZPC) {
+ add_fix(siz2==3 ? 'l' : 'w',opP->con2,1);
+ opP->con1->e_exp.X_add_number+=6;
+ } else
+ add_fix(siz2==3 ? 'l' : 'w',opP->con2,0);
+ }
+ if(siz2==3)
+ addword(outro>>16);
+ if(siz2)
+ addword(outro);
+
+ break;
+
+ case ABSL:
+ nextword=get_num(opP->con1,80);
+ switch(opP->con1->e_siz) {
+ default:
+ as_warn("Unknown size for absolute reference");
+ case 0:
+ if(!isvar(opP->con1) && issword(offs(opP->con1))) {
+ tmpreg=0x38; /* 7.0 */
+ addword(nextword);
+ break;
+ }
+ /* Don't generate pc relative code
+ on 68010 and 68000 */
+ if(isvar(opP->con1)
+ && !subs(opP->con1)
+ && seg(opP->con1) == SEG_TEXT
+ && now_seg == SEG_TEXT
+ && cpu_of_arch(current_architecture) < m68020
+ && !flagseen['S']
+ && !strchr("~%&$?", s[0])) {
+ tmpreg=0x3A; /* 7.2 */
+ add_frag(adds(opP->con1),
+ offs(opP->con1),
+ TAB(PCREL,SZ_UNDEF));
+ break;
+ }
+ case 3: /* Fall through into long */
+ if(isvar(opP->con1))
+ add_fix('l',opP->con1,0);
+
+ tmpreg=0x39; /* 7.1 mode */
+ addword(nextword>>16);
+ addword(nextword);
+ break;
+
+ case 2: /* Word */
+ if(isvar(opP->con1))
+ add_fix('w',opP->con1,0);
+
+ tmpreg=0x38; /* 7.0 mode */
+ addword(nextword);
+ break;
+ }
+ break;
+ case MSCR:
+ default:
+ as_bad("unknown/incorrect operand");
+ /* abort(); */
+ }
+ install_gen_operand(s[1],tmpreg);
+ break;
+
+ case '#':
+ case '^':
+ switch(s[1]) { /* JF: I hate floating point! */
+ case 'j':
+ tmpreg=70;
+ break;
+ case '8':
+ tmpreg=20;
+ break;
+ case 'C':
+ tmpreg=50;
+ break;
+ case '3':
+ default:
+ tmpreg=80;
+ break;
+ }
+ tmpreg=get_num(opP->con1,tmpreg);
+ if(isvar(opP->con1))
+ add_fix(s[1],opP->con1,0);
+ switch(s[1]) {
+ case 'b': /* Danger: These do no check for
+ certain types of overflow.
+ user beware! */
+ if(!isbyte(tmpreg))
+ opP->error="out of range";
+ insop(tmpreg);
+ if(isvar(opP->con1))
+ the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2;
+ break;
+ case 'w':
+ if(!isword(tmpreg))
+ opP->error="out of range";
+ insop(tmpreg);
+ if(isvar(opP->con1))
+ the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2;
+ break;
+ case 'l':
+ insop(tmpreg); /* Because of the way insop works, we put these two out backwards */
+ insop(tmpreg>>16);
+ if(isvar(opP->con1))
+ the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2;
+ break;
+ case '3':
+ tmpreg&=0xFF;
+ case '8':
+ case 'C':
+ install_operand(s[1],tmpreg);
+ break;
+ default:
+ as_fatal("Internal error: Unknown mode #%c in line %s of file \"%s\"", s[1], __LINE__, __FILE__);
+ }
+ break;
+
case '+':
- if(opP->mode!=AINC)
- losing++;
- break;
-
case '-':
- if(opP->mode!=ADEC)
- losing++;
- break;
-
- case '/':
- if(opP->mode==MSCR || opP->mode==AREG ||
- opP->mode==AINC || opP->mode==ADEC || opP->mode==IMMED || opP->mode==REGLST)
- losing++;
- break;
-
- case ';':
- if(opP->mode==MSCR || opP->mode==AREG || opP->mode==REGLST)
- losing++;
- break;
-
- case '?':
- if(opP->mode==MSCR || opP->mode==AREG ||
- opP->mode==AINC || opP->mode==ADEC || opP->mode==IMMED || opP->reg==PC ||
- opP->reg==ZPC || opP->mode==REGLST)
- losing++;
- break;
-
- case '@':
- if(opP->mode==MSCR || opP->mode==AREG ||
- opP->mode==IMMED || opP->mode==REGLST)
- losing++;
- break;
-
- case '~': /* For now! (JF FOO is this right?) */
- if(opP->mode==MSCR || opP->mode==DREG ||
- opP->mode==AREG || opP->mode==IMMED || opP->reg==PC || opP->reg==ZPC || opP->mode==REGLST)
- losing++;
- break;
-
case 'A':
- if(opP->mode!=AREG)
- losing++;
- break;
case 'a':
- if (opP->mode != AINDR) {
- ++losing;
- } /* if not address register indirect */
- break;
- case 'B': /* FOO */
- if(opP->mode!=ABSL || (flagseen['S'] && instring[0] == 'j'
- && instring[1] == 'b'
- && instring[2] == 's'
- && instring[3] == 'r'))
- losing++;
- break;
-
- case 'C':
- if(opP->mode!=MSCR || opP->reg!=CCR)
- losing++;
- break;
-
- case 'd': /* FOO This mode is a KLUDGE!! */
- if(opP->mode!=AOFF && (opP->mode!=ABSL ||
- opP->con1->e_beg[0]!='(' || opP->con1->e_end[0]!=')'))
- losing++;
- break;
-
+ install_operand(s[1],opP->reg-ADDR);
+ break;
+
+ case 'B':
+ tmpreg=get_num(opP->con1,80);
+ switch(s[1]) {
+ case 'B':
+ /* Needs no offsetting */
+ add_fix('B',opP->con1,1);
+ break;
+ case 'W':
+ /* Offset the displacement to be relative to byte disp location */
+ opP->con1->e_exp.X_add_number+=2;
+ add_fix('w',opP->con1,1);
+ addword(0);
+ break;
+ case 'L':
+ long_branch:
+ if (cpu_of_arch(current_architecture) < m68020) /* 68000 or 010 */
+ as_warn("Can't use long branches on 68000/68010");
+ the_ins.opcode[the_ins.numo-1]|=0xff;
+ /* Offset the displacement to be relative to byte disp location */
+ opP->con1->e_exp.X_add_number+=4;
+ add_fix('l',opP->con1,1);
+ addword(0);
+ addword(0);
+ break;
+ case 'g':
+ if(subs(opP->con1)) /* We can't relax it */
+ goto long_branch;
+
+ /* This could either be a symbol, or an
+ absolute address. No matter, the
+ frag hacking will finger it out.
+ Not quite: it can't switch from
+ BRANCH to BCC68000 for the case
+ where opnd is absolute (it needs
+ to use the 68000 hack since no
+ conditional abs jumps). */
+ if (((cpu_of_arch(current_architecture) < m68020) || (0==adds(opP->con1)))
+ && (the_ins.opcode[0] >= 0x6200)
+ && (the_ins.opcode[0] <= 0x6f00)) {
+ add_frag(adds(opP->con1),offs(opP->con1),TAB(BCC68000,SZ_UNDEF));
+ } else {
+ add_frag(adds(opP->con1),offs(opP->con1),TAB(BRANCH,SZ_UNDEF));
+ }
+ break;
+ case 'w':
+ if(isvar(opP->con1)) {
+ /* check for DBcc instruction */
+ if ((the_ins.opcode[0] & 0xf0f8) ==0x50c8) {
+ /* size varies if patch */
+ /* needed for long form */
+ add_frag(adds(opP->con1),offs(opP->con1),TAB(DBCC,SZ_UNDEF));
+ break;
+ }
+
+ /* Don't ask! */
+ opP->con1->e_exp.X_add_number+=2;
+ add_fix('w',opP->con1,1);
+ }
+ addword(0);
+ break;
+ case 'C': /* Fixed size LONG coproc branches */
+ the_ins.opcode[the_ins.numo-1]|=0x40;
+ /* Offset the displacement to be relative to byte disp location */
+ /* Coproc branches don't have a byte disp option, but they are
+ compatible with the ordinary branches, which do... */
+ opP->con1->e_exp.X_add_number+=4;
+ add_fix('l',opP->con1,1);
+ addword(0);
+ addword(0);
+ break;
+ case 'c': /* Var size Coprocesssor branches */
+ if(subs(opP->con1)) {
+ add_fix('l',opP->con1,1);
+ add_frag((symbolS *)0,(long)0,TAB(FBRANCH,LONG));
+ } else if(adds(opP->con1)) {
+ add_frag(adds(opP->con1),offs(opP->con1),TAB(FBRANCH,SZ_UNDEF));
+ } else {
+ /* add_frag((symbolS *)0,offs(opP->con1),TAB(FBRANCH,SHORT)); */
+ the_ins.opcode[the_ins.numo-1]|=0x40;
+ add_fix('l',opP->con1,1);
+ addword(0);
+ addword(4);
+ }
+ break;
+ default:
+ as_fatal("Internal error: operand type B%c unknown in line %s of file \"%s\"",
+ s[1], __LINE__, __FILE__);
+ }
+ break;
+
+ case 'C': /* Ignore it */
+ break;
+
+ case 'd': /* JF this is a kludge */
+ if(opP->mode==AOFF) {
+ install_operand('s',opP->reg-ADDR);
+ } else {
+ char *tmpP;
+
+ tmpP=opP->con1->e_end-2;
+ opP->con1->e_beg++;
+ opP->con1->e_end-=4; /* point to the , */
+ baseo=m68k_reg_parse(&tmpP);
+ if(baseo<ADDR+0 || baseo>ADDR+7) {
+ as_bad("Unknown address reg, using A0");
+ baseo=0;
+ } else baseo-=ADDR;
+ install_operand('s',baseo);
+ }
+ tmpreg=get_num(opP->con1,80);
+ if(!issword(tmpreg)) {
+ as_warn("Expression out of range, using 0");
+ tmpreg=0;
+ }
+ addword(tmpreg);
+ break;
+
case 'D':
- if(opP->mode!=DREG)
- losing++;
- break;
-
+ install_operand(s[1],opP->reg-DATA);
+ break;
+
case 'F':
- if(opP->mode!=MSCR || opP->reg<(FPREG+0) || opP->reg>(FPREG+7))
- losing++;
- break;
-
+ install_operand(s[1],opP->reg-FPREG);
+ break;
+
case 'I':
- if(opP->mode!=MSCR || opP->reg<COPNUM ||
- opP->reg>=COPNUM+7)
- losing++;
- break;
-
- case 'J':
- if (opP->mode != MSCR
- || opP->reg < USP
- || opP->reg > URP
- || cpu_of_arch(current_architecture) < m68010 /* before 68010 had none */
- || (cpu_of_arch(current_architecture) < m68020
- && opP->reg != SFC
- && opP->reg != DFC
- && opP->reg != USP
- && opP->reg != VBR) /* 68010's had only these */
- || (cpu_of_arch(current_architecture) < m68040
- && opP->reg != SFC
- && opP->reg != DFC
- && opP->reg != USP
- && opP->reg != VBR
- && opP->reg != CACR
- && opP->reg != CAAR
- && opP->reg != MSP
- && opP->reg != ISP) /* 680[23]0's have only these */
- || (cpu_of_arch(current_architecture) == m68040 /* 68040 has all but this */
- && opP->reg == CAAR)) {
- losing++;
- } /* doesn't cut it */
- break;
-
+ tmpreg=1+opP->reg-COPNUM;
+ if(tmpreg==8)
+ tmpreg=0;
+ install_operand(s[1],tmpreg);
+ break;
+
+ case 'J': /* JF foo */
+ switch(opP->reg) {
+ case SFC: tmpreg=0x000; break;
+ case DFC: tmpreg=0x001; break;
+ case CACR: tmpreg=0x002; break;
+ case TC: tmpreg=0x003; break;
+ case ITT0: tmpreg=0x004; break;
+ case ITT1: tmpreg=0x005; break;
+ case DTT0: tmpreg=0x006; break;
+ case DTT1: tmpreg=0x007; break;
+
+ case USP: tmpreg=0x800; break;
+ case VBR: tmpreg=0x801; break;
+ case CAAR: tmpreg=0x802; break;
+ case MSP: tmpreg=0x803; break;
+ case ISP: tmpreg=0x804; break;
+ case MMUSR: tmpreg=0x805; break;
+ case URP: tmpreg=0x806; break;
+ case SRP: tmpreg=0x807; break;
+ default:
+ as_fatal("failed sanity check.");
+ }
+ install_operand(s[1],tmpreg);
+ break;
+
case 'k':
- if(opP->mode!=IMMED)
- losing++;
- break;
-
+ tmpreg=get_num(opP->con1,55);
+ install_operand(s[1],tmpreg&0x7f);
+ break;
+
case 'l':
+ tmpreg=opP->reg;
+ if(s[1]=='w') {
+ if(tmpreg&0x7FF0000)
+ as_bad("Floating point register in register list");
+ insop(reverse_16_bits(tmpreg));
+ } else {
+ if(tmpreg&0x700FFFF)
+ as_bad("Wrong register in floating-point reglist");
+ install_operand(s[1],reverse_8_bits(tmpreg>>16));
+ }
+ break;
+
case 'L':
- if(opP->mode==DREG || opP->mode==AREG || opP->mode==FPREG) {
- if(s[1]=='8')
- losing++;
- else {
- opP->mode=REGLST;
- opP->reg=1<<(opP->reg-DATA);
+ tmpreg=opP->reg;
+ if(s[1]=='w') {
+ if(tmpreg&0x7FF0000)
+ as_bad("Floating point register in register list");
+ insop(tmpreg);
+ } else if(s[1]=='8') {
+ if(tmpreg&0x0FFFFFF)
+ as_bad("incorrect register in reglist");
+ install_operand(s[1],tmpreg>>24);
+ } else {
+ if(tmpreg&0x700FFFF)
+ as_bad("wrong register in floating-point reglist");
+ else
+ install_operand(s[1],tmpreg>>16);
}
- } else if(opP->mode!=REGLST) {
- losing++;
- } else if(s[1]=='8' && opP->reg&0x0FFffFF)
- losing++;
- else if(s[1]=='3' && opP->reg&0x7000000)
- losing++;
- break;
-
+ break;
+
case 'M':
- if(opP->mode!=IMMED)
- losing++;
- else {
- long t;
+ install_operand(s[1],get_num(opP->con1,60));
+ break;
- t=get_num(opP->con1,80);
- if(!issbyte(t) || isvar(opP->con1))
- losing++;
- }
- break;
-
case 'O':
- if(opP->mode!=DREG && opP->mode!=IMMED)
- losing++;
- break;
-
+ tmpreg= (opP->mode==DREG)
+ ? 0x20+opP->reg-DATA
+ : (get_num(opP->con1,40)&0x1F);
+ install_operand(s[1],tmpreg);
+ break;
+
case 'Q':
- if(opP->mode!=IMMED)
- losing++;
- else {
- long t;
+ tmpreg=get_num(opP->con1,10);
+ if(tmpreg==8)
+ tmpreg=0;
+ install_operand(s[1],tmpreg);
+ break;
- t=get_num(opP->con1,80);
- if(t<1 || t>8 || isvar(opP->con1))
- losing++;
- }
- break;
-
case 'R':
- if(opP->mode!=DREG && opP->mode!=AREG)
- losing++;
- break;
-
+ /* This depends on the fact that ADDR registers are
+ eight more than their corresponding DATA regs, so
+ the result will have the ADDR_REG bit set */
+ install_operand(s[1],opP->reg-DATA);
+ break;
+
case 's':
- if(opP->mode!=MSCR || !(opP->reg==FPI || opP->reg==FPS || opP->reg==FPC))
- losing++;
- break;
-
- case 'S':
- if(opP->mode!=MSCR || opP->reg!=SR)
- losing++;
- break;
-
- case 'U':
- if(opP->mode!=MSCR || opP->reg!=USP)
- losing++;
- break;
-
- /* JF these are out of order. We could put them
- in order if we were willing to put up with
- bunches of #ifdef m68851s in the code */
-#ifndef NO_68851
- /* Memory addressing mode used by pflushr */
- case '|':
- if(opP->mode==MSCR || opP->mode==DREG ||
- opP->mode==AREG || opP->mode==REGLST)
- losing++;
- break;
-
- case 'f':
- if (opP->mode != MSCR || (opP->reg != SFC && opP->reg != DFC))
- losing++;
- break;
-
- case 'P':
- if (opP->mode != MSCR || (opP->reg != TC && opP->reg != CAL &&
- opP->reg != VAL && opP->reg != SCC && opP->reg != AC))
- losing++;
- break;
-
- case 'V':
- if (opP->reg != VAL)
- losing++;
- break;
-
- case 'W':
- if (opP->mode != MSCR || (opP->reg != DRP && opP->reg != SRP &&
- opP->reg != CRP))
- losing++;
- break;
-
- case 'X':
- if (opP->mode != MSCR ||
- (!(opP->reg >= BAD && opP->reg <= BAD+7) &&
- !(opP->reg >= BAC && opP->reg <= BAC+7)))
- losing++;
- break;
-
- case 'Y':
- if (opP->reg != PSR)
- losing++;
- break;
-
- case 'Z':
- if (opP->reg != PCSR)
- losing++;
- break;
-#endif
+ if(opP->reg==FPI) tmpreg=0x1;
+ else if(opP->reg==FPS) tmpreg=0x2;
+ else if(opP->reg==FPC) tmpreg=0x4;
+ else as_fatal("failed sanity check.");
+ install_operand(s[1],tmpreg);
+ break;
+
+ case 'S': /* Ignore it */
+ break;
+
+ case 'T':
+ install_operand(s[1],get_num(opP->con1,30));
+ break;
+
+ case 'U': /* Ignore it */
+ break;
+
case 'c':
- if (opP->reg != NC
- && opP->reg != IC
- && opP->reg != DC
- && opP->reg != BC) {
- losing++;
- } /* not a cache specifier. */
- break;
-
- case '_':
- if (opP->mode != ABSL) {
- ++losing;
- } /* not absolute */
- break;
-
- default:
- as_fatal("Internal error: Operand mode %c unknown in line %s of file \"%s\"",
- *s, __LINE__, __FILE__);
- } /* switch on type of operand */
-
- if (losing) break;
- } /* for each operand */
- } /* if immediately wrong */
-
- if (!losing) {
- break;
- } /* got it. */
-
-
- if (!opcode->m_next)
- {
- if ((opcode->m_arch & current_architecture) == 0)
- {
- the_ins.error = "Opcode not available on architecture specified";
- addword(0);
-
- }
- else
- {
- the_ins.error = "instruction/operands mismatch";
- }
-
- return;
- } /* Fell off the end */
- opcode = opcode->m_next;
- losing = 0;
- }
-
- /* now assemble it */
-
- the_ins.args=opcode->m_operands;
- the_ins.numargs=opcode->m_opnum;
- the_ins.numo=opcode->m_codenum;
- the_ins.opcode[0]=getone(opcode);
- the_ins.opcode[1]=gettwo(opcode);
-
- for (s = the_ins.args, opP = &the_ins.operands[0]; *s; s += 2, opP++) {
- /* This switch is a doozy.
- Watch the first step; its a big one! */
- switch(s[0]) {
-
- case '*':
- case '~':
- case '%':
- case ';':
- case '@':
- case '!':
- case '&':
- case '$':
- case '?':
- case '/':
+ switch (opP->reg) {
+ case NC: tmpreg = 0; break;
+ case DC: tmpreg = 1; break;
+ case IC: tmpreg = 2; break;
+ case BC: tmpreg = 3; break;
+ default:
+ as_fatal("failed sanity check");
+ } /* switch on cache token */
+ install_operand(s[1], tmpreg);
+ break;
#ifndef NO_68851
- case '|':
-#endif
- switch(opP->mode) {
- case IMMED:
- tmpreg=0x3c; /* 7.4 */
- if (strchr("bwl",s[1])) nextword=get_num(opP->con1,80);
- else nextword=nextword=get_num(opP->con1,0);
- if(isvar(opP->con1))
- add_fix(s[1],opP->con1,0);
- switch(s[1]) {
- case 'b':
- if(!isbyte(nextword))
- opP->error="operand out of range";
- addword(nextword);
- baseo=0;
- break;
- case 'w':
- if(!isword(nextword))
- opP->error="operand out of range";
- addword(nextword);
- baseo=0;
- break;
- case 'l':
- addword(nextword>>16);
- addword(nextword);
- baseo=0;
- break;
-
+ /* JF: These are out of order, I fear. */
case 'f':
- baseo=2;
- outro=8;
- break;
- case 'F':
- baseo=4;
- outro=11;
- break;
- case 'x':
- baseo=6;
- outro=15;
- break;
- case 'p':
- baseo=6;
- outro= -1;
- break;
- default:
- as_fatal("Internal error: Can't decode %c%c in line %s of file \"%s\"",
- *s, s[1], __LINE__, __FILE__);
- }
- if(!baseo)
- break;
-
- /* We gotta put out some float */
- if(seg(opP->con1)!=SEG_BIG) {
- int_to_gen(nextword);
- gen_to_words(words,baseo,(long int)outro);
- for(wordp=words;baseo--;wordp++)
- addword(*wordp);
- break;
- } /* Its BIG */
- if(offs(opP->con1)>0) {
- as_warn("Bignum assumed to be binary bit-pattern");
- if(offs(opP->con1)>baseo) {
- as_warn("Bignum too big for %c format; truncated",s[1]);
- offs(opP->con1)=baseo;
- }
- baseo-=offs(opP->con1);
- for(wordp=generic_bignum+offs(opP->con1)-1;offs(opP->con1)--;--wordp)
- addword(*wordp);
- while(baseo--)
- addword(0);
- break;
- }
- gen_to_words(words,baseo,(long)outro);
- for (wordp=words;baseo--;wordp++)
- addword(*wordp);
- break;
- case DREG:
- tmpreg=opP->reg-DATA; /* 0.dreg */
- break;
- case AREG:
- tmpreg=0x08+opP->reg-ADDR; /* 1.areg */
- break;
- case AINDR:
- tmpreg=0x10+opP->reg-ADDR; /* 2.areg */
- break;
- case ADEC:
- tmpreg=0x20+opP->reg-ADDR; /* 4.areg */
- break;
- case AINC:
- tmpreg=0x18+opP->reg-ADDR; /* 3.areg */
- break;
- case AOFF:
-
- nextword=get_num(opP->con1,80);
- /* Force into index mode. Hope this works */
-
- /* We do the first bit for 32-bit displacements,
- and the second bit for 16 bit ones. It is
- possible that we should make the default be
- WORD instead of LONG, but I think that'd
- break GCC, so we put up with a little
- inefficiency for the sake of working output.
- */
-
- if( !issword(nextword)
- || ( isvar(opP->con1)
- && ( ( opP->con1->e_siz==0
- && flagseen['l']==0)
- || opP->con1->e_siz==3))) {
-
- if(opP->reg==PC)
- tmpreg=0x3B; /* 7.3 */
- else
- tmpreg=0x30+opP->reg-ADDR; /* 6.areg */
- if(isvar(opP->con1)) {
- if(opP->reg==PC) {
- add_frag(adds(opP->con1),
- offs(opP->con1),
- TAB(PCLEA,SZ_UNDEF));
- break;
- } else {
- addword(0x0170);
- add_fix('l',opP->con1,1);
+ switch (opP->reg) {
+ case SFC:
+ tmpreg=0;
+ break;
+ case DFC:
+ tmpreg=1;
+ break;
+ default:
+ as_fatal("failed sanity check.");
}
- } else
- addword(0x0170);
- addword(nextword>>16);
- } else {
- if(opP->reg==PC)
- tmpreg=0x3A; /* 7.2 */
- else
- tmpreg=0x28+opP->reg-ADDR; /* 5.areg */
-
- if(isvar(opP->con1)) {
- if(opP->reg==PC) {
- add_fix('w',opP->con1,1);
- } else
- add_fix('w',opP->con1,0);
- }
- }
- addword(nextword);
- break;
-
- case APODX:
- case AMIND:
- case APRDX:
- know(current_architecture & m68020up);
- /* intentional fall-through */
- case AINDX:
- nextword=0;
- baseo=get_num(opP->con1,80);
- outro=get_num(opP->con2,80);
- /* Figure out the 'addressing mode' */
- /* Also turn on the BASE_DISABLE bit, if needed */
- if(opP->reg==PC || opP->reg==ZPC) {
- tmpreg=0x3b; /* 7.3 */
- if(opP->reg==ZPC)
- nextword|=0x80;
- } else if(opP->reg==FAIL) {
- nextword|=0x80;
- tmpreg=0x30; /* 6.garbage */
- } else tmpreg=0x30+opP->reg-ADDR; /* 6.areg */
-
- siz1= (opP->con1) ? opP->con1->e_siz : 0;
- siz2= (opP->con2) ? opP->con2->e_siz : 0;
-
- /* Index register stuff */
- if(opP->ireg>=DATA+0 && opP->ireg<=ADDR+7) {
- nextword|=(opP->ireg-DATA)<<12;
-
- if(opP->isiz==0 || opP->isiz==3)
- nextword|=0x800;
- switch(opP->imul) {
- case 1: break;
- case 2: nextword|=0x200; break;
- case 4: nextword|=0x400; break;
- case 8: nextword|=0x600; break;
- default: as_fatal("failed sanity check.");
- }
- /* IF its simple,
- GET US OUT OF HERE! */
-
- /* Must be INDEX, with an index
- register. Address register
- cannot be ZERO-PC, and either
- :b was forced, or we know
- it will fit */
- if( opP->mode==AINDX
- && opP->reg!=FAIL
- && opP->reg!=ZPC
- && ( siz1==1
- || ( issbyte(baseo)
- && !isvar(opP->con1)))) {
- nextword +=baseo&0xff;
- addword(nextword);
- if(isvar(opP->con1))
- add_fix('B',opP->con1,0);
+ install_operand(s[1],tmpreg);
break;
- }
- } else
- nextword|=0x40; /* No index reg */
-
- /* It aint simple */
- nextword|=0x100;
- /* If the guy specified a width, we assume that
- it is wide enough. Maybe it isn't. If so, we lose
- */
- switch(siz1) {
- case 0:
- if(isvar(opP->con1) || !issword(baseo)) {
- siz1=3;
- nextword|=0x30;
- } else if(baseo==0)
- nextword|=0x10;
- else {
- nextword|=0x20;
- siz1=2;
- }
- break;
- case 1:
- as_warn("Byte dispacement won't work. Defaulting to :w");
- case 2:
- nextword|=0x20;
- break;
- case 3:
- nextword|=0x30;
- break;
- }
-
- /* Figure out innner displacement stuff */
- if(opP->mode!=AINDX) {
- switch(siz2) {
- case 0:
- if(isvar(opP->con2) || !issword(outro)) {
- siz2=3;
- nextword|=0x3;
- } else if(outro==0)
- nextword|=0x1;
- else {
- nextword|=0x2;
- siz2=2;
+
+ case 'P':
+ switch(opP->reg) {
+ case TC:
+ tmpreg=0;
+ break;
+ case CAL:
+ tmpreg=4;
+ break;
+ case VAL:
+ tmpreg=5;
+ break;
+ case SCC:
+ tmpreg=6;
+ break;
+ case AC:
+ tmpreg=7;
+ break;
+ default:
+ as_fatal("failed sanity check.");
}
+ install_operand(s[1],tmpreg);
break;
- case 1:
- as_warn("Byte dispacement won't work. Defaulting to :w");
- case 2:
- nextword|=0x2;
+
+ case 'V':
+ if (opP->reg == VAL)
+ break;
+ as_fatal("failed sanity check.");
+
+ case 'W':
+ switch(opP->reg) {
+
+ case DRP:
+ tmpreg=1;
+ break;
+ case SRP:
+ tmpreg=2;
+ break;
+ case CRP:
+ tmpreg=3;
+ break;
+ default:
+ as_fatal("failed sanity check.");
+ }
+ install_operand(s[1],tmpreg);
break;
- case 3:
- nextword|=0x3;
+
+ case 'X':
+ switch (opP->reg) {
+ case BAD: case BAD+1: case BAD+2: case BAD+3:
+ case BAD+4: case BAD+5: case BAD+6: case BAD+7:
+ tmpreg = (4 << 10) | ((opP->reg - BAD) << 2);
+ break;
+
+ case BAC: case BAC+1: case BAC+2: case BAC+3:
+ case BAC+4: case BAC+5: case BAC+6: case BAC+7:
+ tmpreg = (5 << 10) | ((opP->reg - BAC) << 2);
+ break;
+
+ default:
+ as_fatal("failed sanity check.");
+ }
+ install_operand(s[1], tmpreg);
break;
- }
- if(opP->mode==APODX) nextword|=0x04;
- else if(opP->mode==AMIND) nextword|=0x40;
- }
- addword(nextword);
-
- if(isvar(opP->con1)) {
- if(opP->reg==PC || opP->reg==ZPC) {
- add_fix(siz1==3 ? 'l' : 'w',opP->con1,1);
- opP->con1->e_exp.X_add_number+=6;
- } else
- add_fix(siz1==3 ? 'l' : 'w',opP->con1,0);
- }
- if(siz1==3)
- addword(baseo>>16);
- if(siz1)
- addword(baseo);
-
- if(isvar(opP->con2)) {
- if(opP->reg==PC || opP->reg==ZPC) {
- add_fix(siz2==3 ? 'l' : 'w',opP->con2,1);
- opP->con1->e_exp.X_add_number+=6;
- } else
- add_fix(siz2==3 ? 'l' : 'w',opP->con2,0);
- }
- if(siz2==3)
- addword(outro>>16);
- if(siz2)
- addword(outro);
-
- break;
-
- case ABSL:
- nextword=get_num(opP->con1,80);
- switch(opP->con1->e_siz) {
- default:
- as_warn("Unknown size for absolute reference");
- case 0:
- if(!isvar(opP->con1) && issword(offs(opP->con1))) {
- tmpreg=0x38; /* 7.0 */
- addword(nextword);
+ case 'Y':
+ know(opP->reg == PSR);
break;
- }
- /* Don't generate pc relative code
- on 68010 and 68000 */
- if(isvar(opP->con1)
- && !subs(opP->con1)
- && seg(opP->con1) == SEG_TEXT
- && now_seg == SEG_TEXT
- && cpu_of_arch(current_architecture) < m68020
- && !flagseen['S']
- && !strchr("~%&$?", s[0])) {
- tmpreg=0x3A; /* 7.2 */
- add_frag(adds(opP->con1),
- offs(opP->con1),
- TAB(PCREL,SZ_UNDEF));
+ case 'Z':
+ know(opP->reg == PCSR);
break;
- }
- case 3: /* Fall through into long */
- if(isvar(opP->con1))
- add_fix('l',opP->con1,0);
-
- tmpreg=0x39; /* 7.1 mode */
- addword(nextword>>16);
- addword(nextword);
- break;
-
- case 2: /* Word */
- if(isvar(opP->con1))
- add_fix('w',opP->con1,0);
-
- tmpreg=0x38; /* 7.0 mode */
- addword(nextword);
- break;
- }
- break;
- case MSCR:
- default:
- as_bad("unknown/incorrect operand");
- /* abort(); */
- }
- install_gen_operand(s[1],tmpreg);
- break;
-
- case '#':
- case '^':
- switch(s[1]) { /* JF: I hate floating point! */
- case 'j':
- tmpreg=70;
- break;
- case '8':
- tmpreg=20;
- break;
- case 'C':
- tmpreg=50;
- break;
- case '3':
- default:
- tmpreg=80;
- break;
- }
- tmpreg=get_num(opP->con1,tmpreg);
- if(isvar(opP->con1))
- add_fix(s[1],opP->con1,0);
- switch(s[1]) {
- case 'b': /* Danger: These do no check for
- certain types of overflow.
- user beware! */
- if(!isbyte(tmpreg))
- opP->error="out of range";
- insop(tmpreg);
- if(isvar(opP->con1))
- the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2;
- break;
- case 'w':
- if(!isword(tmpreg))
- opP->error="out of range";
- insop(tmpreg);
- if(isvar(opP->con1))
- the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2;
- break;
- case 'l':
- insop(tmpreg); /* Because of the way insop works, we put these two out backwards */
- insop(tmpreg>>16);
- if(isvar(opP->con1))
- the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2;
- break;
- case '3':
- tmpreg&=0xFF;
- case '8':
- case 'C':
- install_operand(s[1],tmpreg);
- break;
- default:
- as_fatal("Internal error: Unknown mode #%c in line %s of file \"%s\"", s[1], __LINE__, __FILE__);
- }
- break;
-
- case '+':
- case '-':
- case 'A':
- case 'a':
- install_operand(s[1],opP->reg-ADDR);
- break;
-
- case 'B':
- tmpreg=get_num(opP->con1,80);
- switch(s[1]) {
- case 'B':
- /* Needs no offsetting */
- add_fix('B',opP->con1,1);
- break;
- case 'W':
- /* Offset the displacement to be relative to byte disp location */
- opP->con1->e_exp.X_add_number+=2;
- add_fix('w',opP->con1,1);
- addword(0);
- break;
- case 'L':
- long_branch:
- if (cpu_of_arch(current_architecture) < m68020) /* 68000 or 010 */
- as_warn("Can't use long branches on 68000/68010");
- the_ins.opcode[the_ins.numo-1]|=0xff;
- /* Offset the displacement to be relative to byte disp location */
- opP->con1->e_exp.X_add_number+=4;
- add_fix('l',opP->con1,1);
- addword(0);
- addword(0);
- break;
- case 'g':
- if(subs(opP->con1)) /* We can't relax it */
- goto long_branch;
-
- /* This could either be a symbol, or an
- absolute address. No matter, the
- frag hacking will finger it out.
- Not quite: it can't switch from
- BRANCH to BCC68000 for the case
- where opnd is absolute (it needs
- to use the 68000 hack since no
- conditional abs jumps). */
- if (((cpu_of_arch(current_architecture) < m68020) || (0==adds(opP->con1)))
- && (the_ins.opcode[0] >= 0x6200)
- && (the_ins.opcode[0] <= 0x6f00)) {
- add_frag(adds(opP->con1),offs(opP->con1),TAB(BCC68000,SZ_UNDEF));
- } else {
- add_frag(adds(opP->con1),offs(opP->con1),TAB(BRANCH,SZ_UNDEF));
- }
- break;
- case 'w':
- if(isvar(opP->con1)) {
- /* check for DBcc instruction */
- if ((the_ins.opcode[0] & 0xf0f8) ==0x50c8) {
- /* size varies if patch */
- /* needed for long form */
- add_frag(adds(opP->con1),offs(opP->con1),TAB(DBCC,SZ_UNDEF));
+#endif /* m68851 */
+ case '_':
+ tmpreg=get_num(opP->con1,80);
+ install_operand(s[1], tmpreg);
break;
- }
-
- /* Don't ask! */
- opP->con1->e_exp.X_add_number+=2;
- add_fix('w',opP->con1,1);
- }
- addword(0);
- break;
- case 'C': /* Fixed size LONG coproc branches */
- the_ins.opcode[the_ins.numo-1]|=0x40;
- /* Offset the displacement to be relative to byte disp location */
- /* Coproc branches don't have a byte disp option, but they are
- compatible with the ordinary branches, which do... */
- opP->con1->e_exp.X_add_number+=4;
- add_fix('l',opP->con1,1);
- addword(0);
- addword(0);
- break;
- case 'c': /* Var size Coprocesssor branches */
- if(subs(opP->con1)) {
- add_fix('l',opP->con1,1);
- add_frag((symbolS *)0,(long)0,TAB(FBRANCH,LONG));
- } else if(adds(opP->con1)) {
- add_frag(adds(opP->con1),offs(opP->con1),TAB(FBRANCH,SZ_UNDEF));
- } else {
- /* add_frag((symbolS *)0,offs(opP->con1),TAB(FBRANCH,SHORT)); */
- the_ins.opcode[the_ins.numo-1]|=0x40;
- add_fix('l',opP->con1,1);
- addword(0);
- addword(4);
+ default:
+ as_fatal("Internal error: Operand type %c unknown in line %s of file \"%s\"", s[0], __LINE__, __FILE__);
}
- break;
- default:
- as_fatal("Internal error: operand type B%c unknown in line %s of file \"%s\"",
- s[1], __LINE__, __FILE__);
- }
- break;
-
- case 'C': /* Ignore it */
- break;
-
- case 'd': /* JF this is a kludge */
- if(opP->mode==AOFF) {
- install_operand('s',opP->reg-ADDR);
- } else {
- char *tmpP;
-
- tmpP=opP->con1->e_end-2;
- opP->con1->e_beg++;
- opP->con1->e_end-=4; /* point to the , */
- baseo=m68k_reg_parse(&tmpP);
- if(baseo<ADDR+0 || baseo>ADDR+7) {
- as_bad("Unknown address reg, using A0");
- baseo=0;
- } else baseo-=ADDR;
- install_operand('s',baseo);
- }
- tmpreg=get_num(opP->con1,80);
- if(!issword(tmpreg)) {
- as_warn("Expression out of range, using 0");
- tmpreg=0;
- }
- addword(tmpreg);
- break;
-
- case 'D':
- install_operand(s[1],opP->reg-DATA);
- break;
-
- case 'F':
- install_operand(s[1],opP->reg-FPREG);
- break;
-
- case 'I':
- tmpreg=1+opP->reg-COPNUM;
- if(tmpreg==8)
- tmpreg=0;
- install_operand(s[1],tmpreg);
- break;
-
- case 'J': /* JF foo */
- switch(opP->reg) {
- case SFC: tmpreg=0x000; break;
- case DFC: tmpreg=0x001; break;
- case CACR: tmpreg=0x002; break;
- case TC: tmpreg=0x003; break;
- case ITT0: tmpreg=0x004; break;
- case ITT1: tmpreg=0x005; break;
- case DTT0: tmpreg=0x006; break;
- case DTT1: tmpreg=0x007; break;
-
- case USP: tmpreg=0x800; break;
- case VBR: tmpreg=0x801; break;
- case CAAR: tmpreg=0x802; break;
- case MSP: tmpreg=0x803; break;
- case ISP: tmpreg=0x804; break;
- case MMUSR: tmpreg=0x805; break;
- case URP: tmpreg=0x806; break;
- case SRP: tmpreg=0x807; break;
- default:
- as_fatal("failed sanity check.");
- }
- install_operand(s[1],tmpreg);
- break;
-
- case 'k':
- tmpreg=get_num(opP->con1,55);
- install_operand(s[1],tmpreg&0x7f);
- break;
-
- case 'l':
- tmpreg=opP->reg;
- if(s[1]=='w') {
- if(tmpreg&0x7FF0000)
- as_bad("Floating point register in register list");
- insop(reverse_16_bits(tmpreg));
- } else {
- if(tmpreg&0x700FFFF)
- as_bad("Wrong register in floating-point reglist");
- install_operand(s[1],reverse_8_bits(tmpreg>>16));
- }
- break;
-
- case 'L':
- tmpreg=opP->reg;
- if(s[1]=='w') {
- if(tmpreg&0x7FF0000)
- as_bad("Floating point register in register list");
- insop(tmpreg);
- } else if(s[1]=='8') {
- if(tmpreg&0x0FFFFFF)
- as_bad("incorrect register in reglist");
- install_operand(s[1],tmpreg>>24);
- } else {
- if(tmpreg&0x700FFFF)
- as_bad("wrong register in floating-point reglist");
- else
- install_operand(s[1],tmpreg>>16);
- }
- break;
-
- case 'M':
- install_operand(s[1],get_num(opP->con1,60));
- break;
-
- case 'O':
- tmpreg= (opP->mode==DREG)
- ? 0x20+opP->reg-DATA
- : (get_num(opP->con1,40)&0x1F);
- install_operand(s[1],tmpreg);
- break;
-
- case 'Q':
- tmpreg=get_num(opP->con1,10);
- if(tmpreg==8)
- tmpreg=0;
- install_operand(s[1],tmpreg);
- break;
-
- case 'R':
- /* This depends on the fact that ADDR registers are
- eight more than their corresponding DATA regs, so
- the result will have the ADDR_REG bit set */
- install_operand(s[1],opP->reg-DATA);
- break;
-
- case 's':
- if(opP->reg==FPI) tmpreg=0x1;
- else if(opP->reg==FPS) tmpreg=0x2;
- else if(opP->reg==FPC) tmpreg=0x4;
- else as_fatal("failed sanity check.");
- install_operand(s[1],tmpreg);
- break;
-
- case 'S': /* Ignore it */
- break;
-
- case 'T':
- install_operand(s[1],get_num(opP->con1,30));
- break;
-
- case 'U': /* Ignore it */
- break;
-
- case 'c':
- switch (opP->reg) {
- case NC: tmpreg = 0; break;
- case DC: tmpreg = 1; break;
- case IC: tmpreg = 2; break;
- case BC: tmpreg = 3; break;
- default:
- as_fatal("failed sanity check");
- } /* switch on cache token */
- install_operand(s[1], tmpreg);
- break;
-#ifndef NO_68851
- /* JF: These are out of order, I fear. */
- case 'f':
- switch (opP->reg) {
- case SFC:
- tmpreg=0;
- break;
- case DFC:
- tmpreg=1;
- break;
- default:
- as_fatal("failed sanity check.");
- }
- install_operand(s[1],tmpreg);
- break;
-
- case 'P':
- switch(opP->reg) {
- case TC:
- tmpreg=0;
- break;
- case CAL:
- tmpreg=4;
- break;
- case VAL:
- tmpreg=5;
- break;
- case SCC:
- tmpreg=6;
- break;
- case AC:
- tmpreg=7;
- break;
- default:
- as_fatal("failed sanity check.");
- }
- install_operand(s[1],tmpreg);
- break;
-
- case 'V':
- if (opP->reg == VAL)
- break;
- as_fatal("failed sanity check.");
-
- case 'W':
- switch(opP->reg) {
-
- case DRP:
- tmpreg=1;
- break;
- case SRP:
- tmpreg=2;
- break;
- case CRP:
- tmpreg=3;
- break;
- default:
- as_fatal("failed sanity check.");
- }
- install_operand(s[1],tmpreg);
- break;
-
- case 'X':
- switch (opP->reg) {
- case BAD: case BAD+1: case BAD+2: case BAD+3:
- case BAD+4: case BAD+5: case BAD+6: case BAD+7:
- tmpreg = (4 << 10) | ((opP->reg - BAD) << 2);
- break;
-
- case BAC: case BAC+1: case BAC+2: case BAC+3:
- case BAC+4: case BAC+5: case BAC+6: case BAC+7:
- tmpreg = (5 << 10) | ((opP->reg - BAC) << 2);
- break;
-
- default:
- as_fatal("failed sanity check.");
- }
- install_operand(s[1], tmpreg);
- break;
- case 'Y':
- know(opP->reg == PSR);
- break;
- case 'Z':
- know(opP->reg == PCSR);
- break;
-#endif /* m68851 */
- case '_':
- tmpreg=get_num(opP->con1,80);
- install_operand(s[1], tmpreg);
- break;
- default:
- as_fatal("Internal error: Operand type %c unknown in line %s of file \"%s\"", s[0], __LINE__, __FILE__);
}
- }
- /* By the time whe get here (FINALLY) the_ins contains the complete
- instruction, ready to be emitted. . . */
+ /* By the time whe get here (FINALLY) the_ins contains the complete
+ instruction, ready to be emitted. . . */
} /* m68k_ip() */
/*
@@ -2756,201 +2756,201 @@ while (ISSPACE(*p)) ++p;
*/
static int get_regs(i,str,opP)
- int i;
- struct m68k_op *opP;
- char *str;
+int i;
+struct m68k_op *opP;
+char *str;
{
- /* 26, 25, 24, 23-16, 15-8, 0-7 */
- /* Low order 24 bits encoded fpc,fps,fpi,fp7-fp0,a7-a0,d7-d0 */
- unsigned long cur_regs = 0;
- int reg1,
- reg2;
-
+ /* 26, 25, 24, 23-16, 15-8, 0-7 */
+ /* Low order 24 bits encoded fpc,fps,fpi,fp7-fp0,a7-a0,d7-d0 */
+ unsigned long cur_regs = 0;
+ int reg1,
+ reg2;
+
#define ADD_REG(x) { if(x==FPI) cur_regs|=(1<<24);\
else if(x==FPS) cur_regs|=(1<<25);\
else if(x==FPC) cur_regs|=(1<<26);\
else cur_regs|=(1<<(x-1)); }
-
- reg1=i;
- for(;;) {
- if(*str=='/') {
- ADD_REG(reg1);
- str++;
- } else if(*str=='-') {
- str++;
- reg2=m68k_reg_parse(&str);
- if(reg2<DATA || reg2>=FPREG+8 || reg1==FPI || reg1==FPS || reg1==FPC) {
- opP->error="unknown register in register list";
- return FAIL;
- }
- while(reg1<=reg2) {
- ADD_REG(reg1);
- reg1++;
- }
- if(*str=='\0')
- break;
- } else if(*str=='\0') {
- ADD_REG(reg1);
- break;
- } else {
- opP->error="unknow character in register list";
- return FAIL;
- }
- /* DJA -- Bug Fix. Did't handle d1-d2/a1 until the following instruction was added */
- if (*str=='/')
- str ++;
- reg1=m68k_reg_parse(&str);
- if((reg1<DATA || reg1>=FPREG+8) && !(reg1==FPI || reg1==FPS || reg1==FPC)) {
- opP->error="unknown register in register list";
- return FAIL;
+
+ reg1=i;
+ for(;;) {
+ if(*str=='/') {
+ ADD_REG(reg1);
+ str++;
+ } else if(*str=='-') {
+ str++;
+ reg2=m68k_reg_parse(&str);
+ if(reg2<DATA || reg2>=FPREG+8 || reg1==FPI || reg1==FPS || reg1==FPC) {
+ opP->error="unknown register in register list";
+ return FAIL;
+ }
+ while(reg1<=reg2) {
+ ADD_REG(reg1);
+ reg1++;
+ }
+ if(*str=='\0')
+ break;
+ } else if(*str=='\0') {
+ ADD_REG(reg1);
+ break;
+ } else {
+ opP->error="unknow character in register list";
+ return FAIL;
+ }
+ /* DJA -- Bug Fix. Did't handle d1-d2/a1 until the following instruction was added */
+ if (*str=='/')
+ str ++;
+ reg1=m68k_reg_parse(&str);
+ if((reg1<DATA || reg1>=FPREG+8) && !(reg1==FPI || reg1==FPS || reg1==FPC)) {
+ opP->error="unknown register in register list";
+ return FAIL;
+ }
}
- }
- opP->reg=cur_regs;
- return OK;
+ opP->reg=cur_regs;
+ return OK;
} /* get_regs() */
static int reverse_16_bits(in)
- int in;
+int in;
{
- int out=0;
- int n;
-
- static int mask[16] = {
- 0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080,
- 0x0100,0x0200,0x0400,0x0800,0x1000,0x2000,0x4000,0x8000
- };
- for(n=0;n<16;n++) {
- if(in&mask[n])
- out|=mask[15-n];
- }
- return out;
+ int out=0;
+ int n;
+
+ static int mask[16] = {
+ 0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080,
+ 0x0100,0x0200,0x0400,0x0800,0x1000,0x2000,0x4000,0x8000
+ };
+ for(n=0;n<16;n++) {
+ if(in&mask[n])
+ out|=mask[15-n];
+ }
+ return out;
} /* reverse_16_bits() */
static int reverse_8_bits(in)
- int in;
+int in;
{
- int out=0;
- int n;
-
- static int mask[8] = {
- 0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080,
- };
-
- for(n=0;n<8;n++) {
- if(in&mask[n])
- out|=mask[7-n];
- }
- return out;
+ int out=0;
+ int n;
+
+ static int mask[8] = {
+ 0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080,
+ };
+
+ for(n=0;n<8;n++) {
+ if(in&mask[n])
+ out|=mask[7-n];
+ }
+ return out;
} /* reverse_8_bits() */
static void install_operand(mode,val)
- int mode;
- int val;
+int mode;
+int val;
{
- switch(mode) {
- case 's':
- the_ins.opcode[0]|=val & 0xFF; /* JF FF is for M kludge */
- break;
- case 'd':
- the_ins.opcode[0]|=val<<9;
- break;
- case '1':
- the_ins.opcode[1]|=val<<12;
- break;
- case '2':
- the_ins.opcode[1]|=val<<6;
- break;
- case '3':
- the_ins.opcode[1]|=val;
- break;
- case '4':
- the_ins.opcode[2]|=val<<12;
- break;
- case '5':
- the_ins.opcode[2]|=val<<6;
- break;
- case '6':
- /* DANGER! This is a hack to force cas2l and cas2w cmds
- to be three words long! */
- the_ins.numo++;
- the_ins.opcode[2]|=val;
- break;
- case '7':
- the_ins.opcode[1]|=val<<7;
- break;
- case '8':
- the_ins.opcode[1]|=val<<10;
- break;
+ switch(mode) {
+ case 's':
+ the_ins.opcode[0]|=val & 0xFF; /* JF FF is for M kludge */
+ break;
+ case 'd':
+ the_ins.opcode[0]|=val<<9;
+ break;
+ case '1':
+ the_ins.opcode[1]|=val<<12;
+ break;
+ case '2':
+ the_ins.opcode[1]|=val<<6;
+ break;
+ case '3':
+ the_ins.opcode[1]|=val;
+ break;
+ case '4':
+ the_ins.opcode[2]|=val<<12;
+ break;
+ case '5':
+ the_ins.opcode[2]|=val<<6;
+ break;
+ case '6':
+ /* DANGER! This is a hack to force cas2l and cas2w cmds
+ to be three words long! */
+ the_ins.numo++;
+ the_ins.opcode[2]|=val;
+ break;
+ case '7':
+ the_ins.opcode[1]|=val<<7;
+ break;
+ case '8':
+ the_ins.opcode[1]|=val<<10;
+ break;
#ifndef NO_68851
- case '9':
- the_ins.opcode[1]|=val<<5;
- break;
+ case '9':
+ the_ins.opcode[1]|=val<<5;
+ break;
#endif
-
- case 't':
- the_ins.opcode[1]|=(val<<10)|(val<<7);
- break;
- case 'D':
- the_ins.opcode[1]|=(val<<12)|val;
- break;
- case 'g':
- the_ins.opcode[0]|=val=0xff;
- break;
- case 'i':
- the_ins.opcode[0]|=val<<9;
- break;
- case 'C':
- the_ins.opcode[1]|=val;
- break;
- case 'j':
- the_ins.opcode[1]|=val;
- the_ins.numo++; /* What a hack */
- break;
- case 'k':
- the_ins.opcode[1]|=val<<4;
- break;
- case 'b':
- case 'w':
- case 'l':
- break;
- case 'e':
- the_ins.opcode[0] |= (val << 6);
- break;
- case 'L':
- the_ins.opcode[1] = (val >> 16);
- the_ins.opcode[2] = val & 0xffff;
- break;
- case 'c':
- default:
- as_fatal("failed sanity check.");
- }
+
+ case 't':
+ the_ins.opcode[1]|=(val<<10)|(val<<7);
+ break;
+ case 'D':
+ the_ins.opcode[1]|=(val<<12)|val;
+ break;
+ case 'g':
+ the_ins.opcode[0]|=val=0xff;
+ break;
+ case 'i':
+ the_ins.opcode[0]|=val<<9;
+ break;
+ case 'C':
+ the_ins.opcode[1]|=val;
+ break;
+ case 'j':
+ the_ins.opcode[1]|=val;
+ the_ins.numo++; /* What a hack */
+ break;
+ case 'k':
+ the_ins.opcode[1]|=val<<4;
+ break;
+ case 'b':
+ case 'w':
+ case 'l':
+ break;
+ case 'e':
+ the_ins.opcode[0] |= (val << 6);
+ break;
+ case 'L':
+ the_ins.opcode[1] = (val >> 16);
+ the_ins.opcode[2] = val & 0xffff;
+ break;
+ case 'c':
+ default:
+ as_fatal("failed sanity check.");
+ }
} /* install_operand() */
static void install_gen_operand(mode,val)
- int mode;
- int val;
+int mode;
+int val;
{
- switch(mode) {
- case 's':
- the_ins.opcode[0]|=val;
- break;
- case 'd':
- /* This is a kludge!!! */
- the_ins.opcode[0]|=(val&0x07)<<9|(val&0x38)<<3;
- break;
- case 'b':
- case 'w':
- case 'l':
- case 'f':
- case 'F':
- case 'x':
- case 'p':
- the_ins.opcode[0]|=val;
- break;
- /* more stuff goes here */
- default:
- as_fatal("failed sanity check.");
- }
+ switch(mode) {
+ case 's':
+ the_ins.opcode[0]|=val;
+ break;
+ case 'd':
+ /* This is a kludge!!! */
+ the_ins.opcode[0]|=(val&0x07)<<9|(val&0x38)<<3;
+ break;
+ case 'b':
+ case 'w':
+ case 'l':
+ case 'f':
+ case 'F':
+ case 'x':
+ case 'p':
+ the_ins.opcode[0]|=val;
+ break;
+ /* more stuff goes here */
+ default:
+ as_fatal("failed sanity check.");
+ }
} /* install_gen_operand() */
/*
@@ -2959,109 +2959,109 @@ static void install_gen_operand(mode,val)
*/
static char *crack_operand(str,opP)
- register char *str;
- register struct m68k_op *opP;
+register char *str;
+register struct m68k_op *opP;
{
- register int parens;
- register int c;
- register char *beg_str;
-
- if(!str) {
- return str;
- }
- beg_str=str;
- for(parens=0;*str && (parens>0 || notend(str));str++) {
- if(*str=='(') parens++;
- else if(*str==')') {
- if(!parens) { /* ERROR */
- opP->error="Extra )";
+ register int parens;
+ register int c;
+ register char *beg_str;
+
+ if(!str) {
+ return str;
+ }
+ beg_str=str;
+ for(parens=0;*str && (parens>0 || notend(str));str++) {
+ if(*str=='(') parens++;
+ else if(*str==')') {
+ if(!parens) { /* ERROR */
+ opP->error="Extra )";
+ return str;
+ }
+ --parens;
+ }
+ }
+ if(!*str && parens) { /* ERROR */
+ opP->error="Missing )";
+ return str;
+ }
+ c= *str;
+ *str='\0';
+ if(m68k_ip_op(beg_str,opP)==FAIL) {
+ *str=c;
return str;
- }
- --parens;
}
- }
- if(!*str && parens) { /* ERROR */
- opP->error="Missing )";
- return str;
- }
- c= *str;
- *str='\0';
- if(m68k_ip_op(beg_str,opP)==FAIL) {
*str=c;
+
+ if(c=='}')
+ c= *++str; /* JF bitfield hack */
+
+ if(c) {
+ c= *++str;
+ if(!c)
+ as_bad("Missing operand");
+ }
return str;
- }
- *str=c;
-
- if(c=='}')
- c= *++str; /* JF bitfield hack */
-
- if(c) {
- c= *++str;
- if(!c)
- as_bad("Missing operand");
- }
- return str;
}
/* See the comment up above where the #define notend(... is */
#if 0
notend(s)
- char *s;
+char *s;
{
- if(*s==',') return 0;
- if(*s=='{' || *s=='}')
- return 0;
- if(*s!=':') return 1;
- /* This kludge here is for the division cmd, which is a kludge */
- if(index("aAdD#",s[1])) return 0;
- return 1;
+ if(*s==',') return 0;
+ if(*s=='{' || *s=='}')
+ return 0;
+ if(*s!=':') return 1;
+ /* This kludge here is for the division cmd, which is a kludge */
+ if(index("aAdD#",s[1])) return 0;
+ return 1;
}
#endif
int done_pseudo(str)
- char *str;
+char *str;
{
- extern struct hash_control * po_hash;
- char *ptr = str;
- char *null_ptr;
- pseudo_typeS * pop;
-
- char c;
-
- is_end_of_line[0] = 1;
- /* Skip over name of pseudo, change to lower case */
- while (isalpha(*ptr) || *ptr == '.')
- {
- if (isupper(*ptr)) {
- *ptr = tolower(*ptr);
- }
- ptr++;
- }
- null_ptr = ptr;
- c = *null_ptr;
- *null_ptr = 0;
-
-
- pop = (pseudo_typeS *)hash_find(po_hash, str);
-
- *null_ptr = c;
- if (pop != (pseudo_typeS *)NULL)
- {
- input_line_pointer = null_ptr+1;
- SKIP_WHITESPACE();
- /* Now we point to first non-blank char after pseudo op */
- (*pop->poc_handler)(pop->poc_val);
- input_line_pointer--;
+ extern struct hash_control * po_hash;
+ char *ptr = str;
+ char *null_ptr;
+ pseudo_typeS * pop;
- return 1;
+ char c;
+
+ is_end_of_line[0] = 1;
+ /* Skip over name of pseudo, change to lower case */
+ while (isalpha(*ptr) || *ptr == '.')
+ {
+ if (isupper(*ptr)) {
+ *ptr = tolower(*ptr);
+ }
+ ptr++;
+ }
+ null_ptr = ptr;
+ c = *null_ptr;
+ *null_ptr = 0;
+
+
+ pop = (pseudo_typeS *)hash_find(po_hash, str);
+
+ *null_ptr = c;
+ if (pop != (pseudo_typeS *)NULL)
+ {
+ input_line_pointer = null_ptr+1;
+ SKIP_WHITESPACE();
+ /* Now we point to first non-blank char after pseudo op */
+ (*pop->poc_handler)(pop->poc_val);
+ input_line_pointer--;
+
+ return 1;
+
+ }
+ /* Just put back the char where the null was put and return as if nothing had happened */
+
+ *null_ptr = c;
+ return 0;
- }
- /* Just put back the char where the null was put and return as if nothing had happened */
-
- *null_ptr = c;
- return 0;
-
}
@@ -3073,154 +3073,154 @@ void
md_assemble(str)
char *str;
{
- char *er;
- short *fromP;
- char *toP = NULL;
- int m,n = 0;
- char *to_beg_P;
- int shorts_this_frag;
-
- /* if (done_pseudo(str)) return ;*/
-
-
-
- if (current_architecture == 0) {
- current_architecture = (m68020
+ char *er;
+ short *fromP;
+ char *toP = NULL;
+ int m,n = 0;
+ char *to_beg_P;
+ int shorts_this_frag;
+
+ /* if (done_pseudo(str)) return ;*/
+
+
+
+ if (current_architecture == 0) {
+ current_architecture = (m68020
#ifndef NO_68881
- | m68881
+ | m68881
#endif
#ifndef NO_68851
- | m68851
+ | m68851
#endif
- );
- } /* default current_architecture */
-
- bzero((char *)(&the_ins),sizeof(the_ins)); /* JF for paranoia sake */
-
- m68k_ip(str);
- er=the_ins.error;
- if(!er) {
- for(n=the_ins.numargs;n;--n)
- if(the_ins.operands[n].error) {
- er=the_ins.operands[n].error;
- break;
- }
- }
- if(er) {
- as_bad("\"%s\" -- Statement '%s' ignored",er,str);
- return;
- }
-
- if(the_ins.nfrag==0) { /* No frag hacking involved; just put it out */
- toP=frag_more(2*the_ins.numo);
- fromP= &the_ins.opcode[0];
- for(m=the_ins.numo;m;--m) {
- md_number_to_chars(toP,(long)(*fromP),2);
- toP+=2;
- fromP++;
+ );
+ } /* default current_architecture */
+
+ memset((char *)(&the_ins), '\0', sizeof(the_ins)); /* JF for paranoia sake */
+
+ m68k_ip(str);
+ er=the_ins.error;
+ if(!er) {
+ for(n=the_ins.numargs;n;--n)
+ if(the_ins.operands[n].error) {
+ er=the_ins.operands[n].error;
+ break;
+ }
}
- /* put out symbol-dependent info */
- for(m=0;m<the_ins.nrel;m++) {
- switch(the_ins.reloc[m].wid) {
- case 'B':
- n=1;
- break;
- case 'b':
- n=1;
- break;
- case '3':
- n=2;
- break;
- case 'w':
- n=2;
- break;
- case 'l':
- n=4;
- break;
- default:
- as_fatal("Don't know how to figure width of %c in md_assemble()",the_ins.reloc[m].wid);
- }
-
- fix_new(frag_now,
- (toP-frag_now->fr_literal)-the_ins.numo*2+the_ins.reloc[m].n,
- n,
- the_ins.reloc[m].add,
- the_ins.reloc[m].sub,
- the_ins.reloc[m].off,
- the_ins.reloc[m].pcrel,
- NO_RELOC);
+ if(er) {
+ as_bad("\"%s\" -- Statement '%s' ignored",er,str);
+ return;
}
- return;
- }
-
- /* There's some frag hacking */
- for(n=0,fromP= &the_ins.opcode[0];n<the_ins.nfrag;n++) {
- int wid;
-
- if(n==0) wid=2*the_ins.fragb[n].fragoff;
- else wid=2*(the_ins.numo-the_ins.fragb[n-1].fragoff);
- toP=frag_more(wid);
- to_beg_P=toP;
+
+ if(the_ins.nfrag==0) { /* No frag hacking involved; just put it out */
+ toP=frag_more(2*the_ins.numo);
+ fromP= &the_ins.opcode[0];
+ for(m=the_ins.numo;m;--m) {
+ md_number_to_chars(toP,(long)(*fromP),2);
+ toP+=2;
+ fromP++;
+ }
+ /* put out symbol-dependent info */
+ for(m=0;m<the_ins.nrel;m++) {
+ switch(the_ins.reloc[m].wid) {
+ case 'B':
+ n=1;
+ break;
+ case 'b':
+ n=1;
+ break;
+ case '3':
+ n=2;
+ break;
+ case 'w':
+ n=2;
+ break;
+ case 'l':
+ n=4;
+ break;
+ default:
+ as_fatal("Don't know how to figure width of %c in md_assemble()",the_ins.reloc[m].wid);
+ }
+
+ fix_new(frag_now,
+ (toP-frag_now->fr_literal)-the_ins.numo*2+the_ins.reloc[m].n,
+ n,
+ the_ins.reloc[m].add,
+ the_ins.reloc[m].sub,
+ the_ins.reloc[m].off,
+ the_ins.reloc[m].pcrel,
+ NO_RELOC);
+ }
+ return;
+ }
+
+ /* There's some frag hacking */
+ for(n=0,fromP= &the_ins.opcode[0];n<the_ins.nfrag;n++) {
+ int wid;
+
+ if(n==0) wid=2*the_ins.fragb[n].fragoff;
+ else wid=2*(the_ins.numo-the_ins.fragb[n-1].fragoff);
+ toP=frag_more(wid);
+ to_beg_P=toP;
+ shorts_this_frag=0;
+ for(m=wid/2;m;--m) {
+ md_number_to_chars(toP,(long)(*fromP),2);
+ toP+=2;
+ fromP++;
+ shorts_this_frag++;
+ }
+ for(m=0;m<the_ins.nrel;m++) {
+ if((the_ins.reloc[m].n)>= 2*shorts_this_frag /* 2*the_ins.fragb[n].fragoff */) {
+ the_ins.reloc[m].n-= 2*shorts_this_frag /* 2*the_ins.fragb[n].fragoff */;
+ break;
+ }
+ wid=the_ins.reloc[m].wid;
+ if(wid==0)
+ continue;
+ the_ins.reloc[m].wid=0;
+ wid = (wid=='b') ? 1 : (wid=='w') ? 2 : (wid=='l') ? 4 : 4000;
+
+ fix_new(frag_now,
+ (toP-frag_now->fr_literal)-the_ins.numo*2+the_ins.reloc[m].n,
+ wid,
+ the_ins.reloc[m].add,
+ the_ins.reloc[m].sub,
+ the_ins.reloc[m].off,
+ the_ins.reloc[m].pcrel,
+ NO_RELOC);
+ }
+ /* know(the_ins.fragb[n].fadd); */
+ (void)frag_var(rs_machine_dependent,10,0,(relax_substateT)(the_ins.fragb[n].fragty),
+ the_ins.fragb[n].fadd,the_ins.fragb[n].foff,to_beg_P);
+ }
+ n=(the_ins.numo-the_ins.fragb[n-1].fragoff);
shorts_this_frag=0;
- for(m=wid/2;m;--m) {
- md_number_to_chars(toP,(long)(*fromP),2);
- toP+=2;
- fromP++;
- shorts_this_frag++;
+ if(n) {
+ toP=frag_more(n*sizeof(short));
+ while(n--) {
+ md_number_to_chars(toP,(long)(*fromP),2);
+ toP+=2;
+ fromP++;
+ shorts_this_frag++;
+ }
}
for(m=0;m<the_ins.nrel;m++) {
- if((the_ins.reloc[m].n)>= 2*shorts_this_frag /* 2*the_ins.fragb[n].fragoff */) {
- the_ins.reloc[m].n-= 2*shorts_this_frag /* 2*the_ins.fragb[n].fragoff */;
- break;
- }
- wid=the_ins.reloc[m].wid;
- if(wid==0)
- continue;
- the_ins.reloc[m].wid=0;
- wid = (wid=='b') ? 1 : (wid=='w') ? 2 : (wid=='l') ? 4 : 4000;
-
- fix_new(frag_now,
- (toP-frag_now->fr_literal)-the_ins.numo*2+the_ins.reloc[m].n,
- wid,
- the_ins.reloc[m].add,
- the_ins.reloc[m].sub,
- the_ins.reloc[m].off,
- the_ins.reloc[m].pcrel,
- NO_RELOC);
- }
- /* know(the_ins.fragb[n].fadd); */
- (void)frag_var(rs_machine_dependent,10,0,(relax_substateT)(the_ins.fragb[n].fragty),
- the_ins.fragb[n].fadd,the_ins.fragb[n].foff,to_beg_P);
- }
- n=(the_ins.numo-the_ins.fragb[n-1].fragoff);
- shorts_this_frag=0;
- if(n) {
- toP=frag_more(n*sizeof(short));
- while(n--) {
- md_number_to_chars(toP,(long)(*fromP),2);
- toP+=2;
- fromP++;
- shorts_this_frag++;
+ int wid;
+
+ wid=the_ins.reloc[m].wid;
+ if(wid==0)
+ continue;
+ the_ins.reloc[m].wid=0;
+ wid = (wid=='b') ? 1 : (wid=='w') ? 2 : (wid=='l') ? 4 : 4000;
+
+ fix_new(frag_now,
+ (the_ins.reloc[m].n + toP-frag_now->fr_literal)- /* the_ins.numo */ shorts_this_frag*2,
+ wid,
+ the_ins.reloc[m].add,
+ the_ins.reloc[m].sub,
+ the_ins.reloc[m].off,
+ the_ins.reloc[m].pcrel,
+ NO_RELOC);
}
- }
- for(m=0;m<the_ins.nrel;m++) {
- int wid;
-
- wid=the_ins.reloc[m].wid;
- if(wid==0)
- continue;
- the_ins.reloc[m].wid=0;
- wid = (wid=='b') ? 1 : (wid=='w') ? 2 : (wid=='l') ? 4 : 4000;
-
- fix_new(frag_now,
- (the_ins.reloc[m].n + toP-frag_now->fr_literal)- /* the_ins.numo */ shorts_this_frag*2,
- wid,
- the_ins.reloc[m].add,
- the_ins.reloc[m].sub,
- the_ins.reloc[m].off,
- the_ins.reloc[m].pcrel,
- NO_RELOC);
- }
}
/* This function is called once, at assembler startup time. This should
@@ -3229,77 +3229,77 @@ char *str;
void
md_begin()
{
- /*
- * md_begin -- set up hash tables with 68000 instructions.
- * similar to what the vax assembler does. ---phr
- */
- /* RMS claims the thing to do is take the m68k-opcode.h table, and make
- a copy of it at runtime, adding in the information we want but isn't
- there. I think it'd be better to have an awk script hack the table
- at compile time. Or even just xstr the table and use it as-is. But
- my lord ghod hath spoken, so we do it this way. Excuse the ugly var
- names. */
-
- register const struct m68k_opcode *ins;
- register struct m68k_incant *hack,
- *slak;
- register char *retval = 0; /* empty string, or error msg text */
- register unsigned int i;
- register char c;
-
- if ((op_hash = hash_new()) == NULL)
- as_fatal("Virtual memory exhausted");
-
- obstack_begin(&robyn,4000);
- for (ins = m68k_opcodes; ins < endop; ins++) {
- hack=slak=(struct m68k_incant *)obstack_alloc(&robyn,sizeof(struct m68k_incant));
- do {
- /* we *could* ignore insns that don't match our
- arch here but just leaving them out of the
- hash. */
- slak->m_operands=ins->args;
- slak->m_opnum=strlen(slak->m_operands)/2;
- slak->m_arch = ins->arch;
- slak->m_opcode=ins->opcode;
- /* This is kludgey */
- slak->m_codenum=((ins->match)&0xffffL) ? 2 : 1;
- if((ins+1)!=endop && !strcmp(ins->name,(ins+1)->name)) {
- slak->m_next=(struct m68k_incant *) obstack_alloc(&robyn,sizeof(struct m68k_incant));
- ins++;
- } else
- slak->m_next=0;
- slak=slak->m_next;
- } while(slak);
-
- retval = hash_insert (op_hash, ins->name,(char *)hack);
- /* Didn't his mommy tell him about null pointers? */
- if(retval && *retval)
- as_fatal("Internal Error: Can't hash %s: %s",ins->name,retval);
- }
-
- for (i = 0; i < sizeof(mklower_table) ; i++)
- mklower_table[i] = (isupper(c = (char) i)) ? tolower(c) : c;
-
- for (i = 0 ; i < sizeof(notend_table) ; i++) {
- notend_table[i] = 0;
- alt_notend_table[i] = 0;
- }
- notend_table[','] = 1;
- notend_table['{'] = 1;
- notend_table['}'] = 1;
- alt_notend_table['a'] = 1;
- alt_notend_table['A'] = 1;
- alt_notend_table['d'] = 1;
- alt_notend_table['D'] = 1;
- alt_notend_table['#'] = 1;
- alt_notend_table['f'] = 1;
- alt_notend_table['F'] = 1;
-
+ /*
+ * md_begin -- set up hash tables with 68000 instructions.
+ * similar to what the vax assembler does. ---phr
+ */
+ /* RMS claims the thing to do is take the m68k-opcode.h table, and make
+ a copy of it at runtime, adding in the information we want but isn't
+ there. I think it'd be better to have an awk script hack the table
+ at compile time. Or even just xstr the table and use it as-is. But
+ my lord ghod hath spoken, so we do it this way. Excuse the ugly var
+ names. */
+
+ register const struct m68k_opcode *ins;
+ register struct m68k_incant *hack,
+ *slak;
+ register char *retval = 0; /* empty string, or error msg text */
+ register unsigned int i;
+ register char c;
+
+ if ((op_hash = hash_new()) == NULL)
+ as_fatal("Virtual memory exhausted");
+
+ obstack_begin(&robyn,4000);
+ for (ins = m68k_opcodes; ins < endop; ins++) {
+ hack=slak=(struct m68k_incant *)obstack_alloc(&robyn,sizeof(struct m68k_incant));
+ do {
+ /* we *could* ignore insns that don't match our
+ arch here but just leaving them out of the
+ hash. */
+ slak->m_operands=ins->args;
+ slak->m_opnum=strlen(slak->m_operands)/2;
+ slak->m_arch = ins->arch;
+ slak->m_opcode=ins->opcode;
+ /* This is kludgey */
+ slak->m_codenum=((ins->match)&0xffffL) ? 2 : 1;
+ if((ins+1)!=endop && !strcmp(ins->name,(ins+1)->name)) {
+ slak->m_next=(struct m68k_incant *) obstack_alloc(&robyn,sizeof(struct m68k_incant));
+ ins++;
+ } else
+ slak->m_next=0;
+ slak=slak->m_next;
+ } while(slak);
+
+ retval = hash_insert (op_hash, ins->name,(char *)hack);
+ /* Didn't his mommy tell him about null pointers? */
+ if(retval && *retval)
+ as_fatal("Internal Error: Can't hash %s: %s",ins->name,retval);
+ }
+
+ for (i = 0; i < sizeof(mklower_table) ; i++)
+ mklower_table[i] = (isupper(c = (char) i)) ? tolower(c) : c;
+
+ for (i = 0 ; i < sizeof(notend_table) ; i++) {
+ notend_table[i] = 0;
+ alt_notend_table[i] = 0;
+ }
+ notend_table[','] = 1;
+ notend_table['{'] = 1;
+ notend_table['}'] = 1;
+ alt_notend_table['a'] = 1;
+ alt_notend_table['A'] = 1;
+ alt_notend_table['d'] = 1;
+ alt_notend_table['D'] = 1;
+ alt_notend_table['#'] = 1;
+ alt_notend_table['f'] = 1;
+ alt_notend_table['F'] = 1;
+
#ifdef REGISTER_PREFIX
- alt_notend_table[REGISTER_PREFIX] = 1;
+ alt_notend_table[REGISTER_PREFIX] = 1;
#endif
-
-
+
+
}
#if 0
@@ -3329,51 +3329,51 @@ char type;
char *litP;
int *sizeP;
{
- int prec;
- LITTLENUM_TYPE words[MAX_LITTLENUMS];
- LITTLENUM_TYPE *wordP;
- char *t;
- char *atof_ieee();
-
- switch(type) {
- case 'f':
- case 'F':
- case 's':
- case 'S':
- prec = 2;
- break;
-
- case 'd':
- case 'D':
- case 'r':
- case 'R':
- prec = 4;
- break;
+ int prec;
+ LITTLENUM_TYPE words[MAX_LITTLENUMS];
+ LITTLENUM_TYPE *wordP;
+ char *t;
+ char *atof_ieee();
- case 'x':
- case 'X':
- prec = 6;
- break;
-
- case 'p':
- case 'P':
- prec = 6;
- break;
+ switch(type) {
+ case 'f':
+ case 'F':
+ case 's':
+ case 'S':
+ prec = 2;
+ break;
+
+ case 'd':
+ case 'D':
+ case 'r':
+ case 'R':
+ prec = 4;
+ break;
+
+ case 'x':
+ case 'X':
+ prec = 6;
+ break;
+
+ case 'p':
+ case 'P':
+ prec = 6;
+ break;
+
+ default:
+ *sizeP=0;
+ return "Bad call to MD_ATOF()";
+ }
+ t=atof_ieee(input_line_pointer,type,words);
+ if(t)
+ input_line_pointer=t;
- default:
- *sizeP=0;
- return "Bad call to MD_ATOF()";
- }
- t=atof_ieee(input_line_pointer,type,words);
- if(t)
- input_line_pointer=t;
-
- *sizeP=prec * sizeof(LITTLENUM_TYPE);
- for(wordP=words;prec--;) {
- md_number_to_chars(litP,(long)(*wordP++),sizeof(LITTLENUM_TYPE));
- litP+=sizeof(LITTLENUM_TYPE);
- }
- return ""; /* Someone should teach Dean about null pointers */
+ *sizeP=prec * sizeof(LITTLENUM_TYPE);
+ for(wordP=words;prec--;) {
+ md_number_to_chars(litP,(long)(*wordP++),sizeof(LITTLENUM_TYPE));
+ litP+=sizeof(LITTLENUM_TYPE);
+ }
+ return ""; /* Someone should teach Dean about null pointers */
}
/* Turn an integer of n bytes (in val) into a stream of bytes appropriate
@@ -3389,23 +3389,23 @@ char *buf;
long val;
int n;
{
- switch(n) {
- case 1:
- *buf++=val;
- break;
- case 2:
- *buf++=(val>>8);
- *buf++=val;
- break;
- case 4:
- *buf++=(val>>24);
- *buf++=(val>>16);
- *buf++=(val>>8);
- *buf++=val;
- break;
- default:
- as_fatal("failed sanity check.");
- }
+ switch(n) {
+ case 1:
+ *buf++=val;
+ break;
+ case 2:
+ *buf++=(val>>8);
+ *buf++=val;
+ break;
+ case 4:
+ *buf++=(val>>24);
+ *buf++=(val>>16);
+ *buf++=(val>>8);
+ *buf++=val;
+ break;
+ default:
+ as_fatal("failed sanity check.");
+ }
}
void
@@ -3413,25 +3413,25 @@ void
fixS *fixP;
long val;
{
- char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
-
- switch(fixP->fx_size) {
- case 1:
- *buf++=val;
- break;
- case 2:
- *buf++=(val>>8);
- *buf++=val;
- break;
- case 4:
- *buf++=(val>>24);
- *buf++=(val>>16);
- *buf++=(val>>8);
- *buf++=val;
- break;
- default:
- BAD_CASE (fixP->fx_size);
- }
+ char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
+
+ switch(fixP->fx_size) {
+ case 1:
+ *buf++=val;
+ break;
+ case 2:
+ *buf++=(val>>8);
+ *buf++=val;
+ break;
+ case 4:
+ *buf++=(val>>24);
+ *buf++=(val>>16);
+ *buf++=(val>>8);
+ *buf++=val;
+ break;
+ default:
+ BAD_CASE (fixP->fx_size);
+ }
}
@@ -3444,30 +3444,30 @@ void
object_headers *headers;
register fragS *fragP;
{
- long disp;
- long ext = 0;
-
- /* Address in object code of the displacement. */
- register int object_address = fragP -> fr_fix + fragP -> fr_address;
-
+ long disp;
+ long ext = 0;
+
+ /* Address in object code of the displacement. */
+ register int object_address = fragP -> fr_fix + fragP -> fr_address;
+
#ifdef IBM_COMPILER_SUX
- /* This is wrong but it convinces the native rs6000 compiler to
- generate the code we want. */
- register char *buffer_address = fragP -> fr_literal;
- buffer_address += fragP -> fr_fix;
+ /* This is wrong but it convinces the native rs6000 compiler to
+ generate the code we want. */
+ register char *buffer_address = fragP -> fr_literal;
+ buffer_address += fragP -> fr_fix;
#else /* IBM_COMPILER_SUX */
- /* Address in gas core of the place to store the displacement. */
- register char *buffer_address = fragP->fr_fix + fragP->fr_literal;
+ /* Address in gas core of the place to store the displacement. */
+ register char *buffer_address = fragP->fr_fix + fragP->fr_literal;
#endif /* IBM_COMPILER_SUX */
-
- /* No longer true: know(fragP->fr_symbol); */
-
- /* The displacement of the address, from current location. */
- disp = fragP->fr_symbol ? S_GET_VALUE(fragP->fr_symbol) : 0;
- disp = (disp + fragP->fr_offset) - object_address;
-
- switch(fragP->fr_subtype) {
- case TAB(BCC68000,BYTE):
+
+ /* No longer true: know(fragP->fr_symbol); */
+
+ /* The displacement of the address, from current location. */
+ disp = fragP->fr_symbol ? S_GET_VALUE(fragP->fr_symbol) : 0;
+ disp = (disp + fragP->fr_offset) - object_address;
+
+ switch(fragP->fr_subtype) {
+ case TAB(BCC68000,BYTE):
case TAB(BRANCH,BYTE):
know(issbyte(disp));
if(disp==0)
@@ -3475,54 +3475,54 @@ register fragS *fragP;
fragP->fr_opcode[1]=disp;
ext=0;
break;
- case TAB(DBCC,SHORT):
- know(issword(disp));
+ case TAB(DBCC,SHORT):
+ know(issword(disp));
ext=2;
break;
- case TAB(BCC68000,SHORT):
- case TAB(BRANCH,SHORT):
- know(issword(disp));
+ case TAB(BCC68000,SHORT):
+ case TAB(BRANCH,SHORT):
+ know(issword(disp));
fragP->fr_opcode[1]=0x00;
ext=2;
break;
- case TAB(BRANCH,LONG):
- if (cpu_of_arch(current_architecture) < m68020) {
- if (fragP->fr_opcode[0]==0x61) {
- fragP->fr_opcode[0]= 0x4E;
- fragP->fr_opcode[1]= 0xB9; /* JBSR with ABSL LONG offset */
- subseg_change(SEG_TEXT, 0);
-
- fix_new(fragP,
- fragP->fr_fix,
- 4,
- fragP->fr_symbol,
- 0,
- fragP->fr_offset,
- 0,
- NO_RELOC);
-
- fragP->fr_fix+=4;
- ext=0;
- } else if (fragP->fr_opcode[0]==0x60) {
- fragP->fr_opcode[0]= 0x4E;
- fragP->fr_opcode[1]= 0xF9; /* JMP with ABSL LONG offset */
- subseg_change(SEG_TEXT, 0);
- fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, fragP->fr_offset,0,
- NO_RELOC);
- fragP->fr_fix+=4;
- ext=0;
- } else {
- as_bad("Long branch offset not supported.");
- }
- } else {
- fragP->fr_opcode[1]=0xff;
- ext=4;
- }
+ case TAB(BRANCH,LONG):
+ if (cpu_of_arch(current_architecture) < m68020) {
+ if (fragP->fr_opcode[0]==0x61) {
+ fragP->fr_opcode[0]= 0x4E;
+ fragP->fr_opcode[1]= 0xB9; /* JBSR with ABSL LONG offset */
+ subseg_change(SEG_TEXT, 0);
+
+ fix_new(fragP,
+ fragP->fr_fix,
+ 4,
+ fragP->fr_symbol,
+ 0,
+ fragP->fr_offset,
+ 0,
+ NO_RELOC);
+
+ fragP->fr_fix+=4;
+ ext=0;
+ } else if (fragP->fr_opcode[0]==0x60) {
+ fragP->fr_opcode[0]= 0x4E;
+ fragP->fr_opcode[1]= 0xF9; /* JMP with ABSL LONG offset */
+ subseg_change(SEG_TEXT, 0);
+ fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, fragP->fr_offset,0,
+ NO_RELOC);
+ fragP->fr_fix+=4;
+ ext=0;
+ } else {
+ as_bad("Long branch offset not supported.");
+ }
+ } else {
+ fragP->fr_opcode[1]=0xff;
+ ext=4;
+ }
break;
- case TAB(BCC68000,LONG):
- /* only Bcc 68000 instructions can come here */
- /* change bcc into b!cc/jmp absl long */
- fragP->fr_opcode[0] ^= 0x01; /* invert bcc */
+ case TAB(BCC68000,LONG):
+ /* only Bcc 68000 instructions can come here */
+ /* change bcc into b!cc/jmp absl long */
+ fragP->fr_opcode[0] ^= 0x01; /* invert bcc */
fragP->fr_opcode[1] = 0x6; /* branch offset = 6 */
/* JF: these used to be fr_opcode[2,3], but they may be in a
@@ -3538,11 +3538,11 @@ register fragS *fragP;
fragP->fr_fix += 4;
ext=0;
break;
- case TAB(DBCC,LONG):
- /* only DBcc 68000 instructions can come here */
- /* change dbcc into dbcc/jmp absl long */
- /* JF: these used to be fr_opcode[2-7], but that's wrong */
- *buffer_address++ = 0x00; /* branch offset = 4 */
+ case TAB(DBCC,LONG):
+ /* only DBcc 68000 instructions can come here */
+ /* change dbcc into dbcc/jmp absl long */
+ /* JF: these used to be fr_opcode[2-7], but that's wrong */
+ *buffer_address++ = 0x00; /* branch offset = 4 */
*buffer_address++ = 0x04;
*buffer_address++ = 0x60; /* put in bra pc+6 */
*buffer_address++ = 0x06;
@@ -3557,22 +3557,22 @@ register fragS *fragP;
fragP->fr_fix += 4;
ext=0;
break;
- case TAB(FBRANCH,SHORT):
- know((fragP->fr_opcode[1]&0x40)==0);
+ case TAB(FBRANCH,SHORT):
+ know((fragP->fr_opcode[1]&0x40)==0);
ext=2;
break;
- case TAB(FBRANCH,LONG):
- fragP->fr_opcode[1]|=0x40; /* Turn on LONG bit */
+ case TAB(FBRANCH,LONG):
+ fragP->fr_opcode[1]|=0x40; /* Turn on LONG bit */
ext=4;
break;
- case TAB(PCREL,SHORT):
- ext=2;
+ case TAB(PCREL,SHORT):
+ ext=2;
break;
- case TAB(PCREL,LONG):
- /* The thing to do here is force it to ABSOLUTE LONG, since
- PCREL is really trying to shorten an ABSOLUTE address anyway */
- /* JF FOO This code has not been tested */
- subseg_change(SEG_TEXT,0);
+ case TAB(PCREL,LONG):
+ /* The thing to do here is force it to ABSOLUTE LONG, since
+ PCREL is really trying to shorten an ABSOLUTE address anyway */
+ /* JF FOO This code has not been tested */
+ subseg_change(SEG_TEXT,0);
fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, fragP->fr_offset, 0, NO_RELOC);
if((fragP->fr_opcode[1] & 0x3F) != 0x3A)
as_bad("Internal error (long PC-relative operand) for insn 0x%04lx at 0x%lx",
@@ -3585,16 +3585,16 @@ register fragS *fragP;
4); */
ext=0;
break;
- case TAB(PCLEA,SHORT):
- subseg_change(SEG_TEXT,0);
+ case TAB(PCLEA,SHORT):
+ subseg_change(SEG_TEXT,0);
fix_new(fragP,(int)(fragP->fr_fix),2,fragP->fr_symbol,(symbolS *)0,fragP->fr_offset,1,
NO_RELOC);
fragP->fr_opcode[1] &= ~0x3F;
fragP->fr_opcode[1] |= 0x3A;
ext=2;
break;
- case TAB(PCLEA,LONG):
- subseg_change(SEG_TEXT,0);
+ case TAB(PCLEA,LONG):
+ subseg_change(SEG_TEXT,0);
fix_new(fragP,(int)(fragP->fr_fix)+2,4,fragP->fr_symbol,(symbolS *)0,fragP->fr_offset+2,1,
NO_RELOC);
*buffer_address++ = 0x01;
@@ -3604,198 +3604,198 @@ register fragS *fragP;
ext=4;
break;
- } /* switch on subtype */
-
- if (ext) {
- md_number_to_chars(buffer_address, (long) disp, (int) ext);
- fragP->fr_fix += ext;
- /* H_SET_TEXT_SIZE(headers, H_GET_TEXT_SIZE(headers) + ext); */
- } /* if extending */
-
- return;
+} /* switch on subtype */
+
+ if (ext) {
+ md_number_to_chars(buffer_address, (long) disp, (int) ext);
+ fragP->fr_fix += ext;
+ /* H_SET_TEXT_SIZE(headers, H_GET_TEXT_SIZE(headers) + ext); */
+ } /* if extending */
+
+ return;
} /* md_convert_frag() */
/* Force truly undefined symbols to their maximum size, and generally set up
the frag list to be relaxed
*/
int md_estimate_size_before_relax(fragP, segment)
- register fragS *fragP;
- segT segment;
+register fragS *fragP;
+segT segment;
{
- int old_fix;
- register char *buffer_address = fragP->fr_fix + fragP->fr_literal;
-
- old_fix = fragP->fr_fix;
-
- /* handle SZ_UNDEF first, it can be changed to BYTE or SHORT */
- switch(fragP->fr_subtype) {
-
- case TAB(BRANCH,SZ_UNDEF): {
- if((fragP->fr_symbol != NULL) /* Not absolute */
- && S_GET_SEGMENT(fragP->fr_symbol) == segment) {
- fragP->fr_subtype=TAB(TABTYPE(fragP->fr_subtype),BYTE);
- break;
- } else if((fragP->fr_symbol == 0) || (cpu_of_arch(current_architecture) < m68020)) {
- /* On 68000, or for absolute value, switch to abs long */
- /* FIXME, we should check abs val, pick short or long */
- if(fragP->fr_opcode[0]==0x61) {
- fragP->fr_opcode[0]= 0x4E;
- fragP->fr_opcode[1]= 0xB9; /* JBSR with ABSL LONG offset */
- subseg_change(SEG_TEXT, 0);
- fix_new(fragP, fragP->fr_fix, 4,
- fragP->fr_symbol, 0, fragP->fr_offset, 0, NO_RELOC);
- fragP->fr_fix+=4;
- frag_wane(fragP);
- } else if(fragP->fr_opcode[0]==0x60) {
- fragP->fr_opcode[0]= 0x4E;
- fragP->fr_opcode[1]= 0xF9; /* JMP with ABSL LONG offset */
- subseg_change(SEG_TEXT, 0);
- fix_new(fragP, fragP->fr_fix, 4,
- fragP->fr_symbol, 0, fragP->fr_offset, 0, NO_RELOC);
- fragP->fr_fix+=4;
- frag_wane(fragP);
- } else {
- as_warn("Long branch offset to extern symbol not supported.");
- }
- } else { /* Symbol is still undefined. Make it simple */
- fix_new(fragP, (int)(fragP->fr_fix), 4, fragP->fr_symbol,
- (symbolS *)0, fragP->fr_offset+4, 1, NO_RELOC);
- fragP->fr_fix+=4;
- fragP->fr_opcode[1]=0xff;
- frag_wane(fragP);
- break;
- }
-
- break;
- } /* case TAB(BRANCH,SZ_UNDEF) */
+ int old_fix;
+ register char *buffer_address = fragP->fr_fix + fragP->fr_literal;
- case TAB(FBRANCH,SZ_UNDEF): {
- if(S_GET_SEGMENT(fragP->fr_symbol) == segment || flagseen['l']) {
- fragP->fr_subtype = TAB(FBRANCH,SHORT);
- fragP->fr_var += 2;
- } else {
- fragP->fr_subtype = TAB(FBRANCH,LONG);
- fragP->fr_var += 4;
- }
- break;
- } /* TAB(FBRANCH,SZ_UNDEF) */
+ old_fix = fragP->fr_fix;
- case TAB(PCREL,SZ_UNDEF): {
- if(S_GET_SEGMENT(fragP->fr_symbol) == segment || flagseen['l']) {
- fragP->fr_subtype = TAB(PCREL,SHORT);
- fragP->fr_var += 2;
- } else {
- fragP->fr_subtype = TAB(PCREL,LONG);
- fragP->fr_var += 4;
- }
- break;
- } /* TAB(PCREL,SZ_UNDEF) */
-
- case TAB(BCC68000,SZ_UNDEF): {
- if((fragP->fr_symbol != NULL)
- && S_GET_SEGMENT(fragP->fr_symbol) == segment) {
- fragP->fr_subtype=TAB(BCC68000,BYTE);
- break;
- }
- /* only Bcc 68000 instructions can come here */
- /* change bcc into b!cc/jmp absl long */
- fragP->fr_opcode[0] ^= 0x01; /* invert bcc */
- if(flagseen['l']) {
- fragP->fr_opcode[1] = 0x04; /* branch offset = 6 */
- /* JF: these were fr_opcode[2,3] */
- buffer_address[0] = 0x4e; /* put in jmp long (0x4ef9) */
- buffer_address[1] = 0xf8;
- fragP->fr_fix += 2; /* account for jmp instruction */
- subseg_change(SEG_TEXT,0);
- fix_new(fragP, fragP->fr_fix, 2, fragP->fr_symbol, 0,
- fragP->fr_offset, 0, NO_RELOC);
- fragP->fr_fix += 2;
- } else {
- fragP->fr_opcode[1] = 0x06; /* branch offset = 6 */
- /* JF: these were fr_opcode[2,3] */
- buffer_address[2] = 0x4e; /* put in jmp long (0x4ef9) */
- buffer_address[3] = 0xf9;
- fragP->fr_fix += 2; /* account for jmp instruction */
- subseg_change(SEG_TEXT,0);
- fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0,
- fragP->fr_offset, 0, NO_RELOC);
- fragP->fr_fix += 4;
- }
- frag_wane(fragP);
- break;
- } /* case TAB(BCC68000,SZ_UNDEF) */
-
- case TAB(DBCC,SZ_UNDEF): {
- if (fragP->fr_symbol != NULL && S_GET_SEGMENT(fragP->fr_symbol) == segment) {
- fragP->fr_subtype=TAB(DBCC,SHORT);
- fragP->fr_var+=2;
- break;
- }
- /* only DBcc 68000 instructions can come here */
- /* change dbcc into dbcc/jmp absl long */
- /* JF: these used to be fr_opcode[2-4], which is wrong. */
- buffer_address[0] = 0x00; /* branch offset = 4 */
- buffer_address[1] = 0x04;
- buffer_address[2] = 0x60; /* put in bra pc + ... */
-
- if(flagseen['l']) {
- /* JF: these were fr_opcode[5-7] */
- buffer_address[3] = 0x04; /* plus 4 */
- buffer_address[4] = 0x4e;/* Put in Jump Word */
- buffer_address[5] = 0xf8;
- fragP->fr_fix += 6; /* account for bra/jmp instruction */
- subseg_change(SEG_TEXT,0);
- fix_new(fragP, fragP->fr_fix, 2, fragP->fr_symbol, 0,
- fragP->fr_offset, 0, NO_RELOC);
- fragP->fr_fix += 2;
- } else {
- /* JF: these were fr_opcode[5-7] */
- buffer_address[3] = 0x06; /* Plus 6 */
- buffer_address[4] = 0x4e; /* put in jmp long (0x4ef9) */
- buffer_address[5] = 0xf9;
- fragP->fr_fix += 6; /* account for bra/jmp instruction */
- subseg_change(SEG_TEXT,0);
- fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0,
- fragP->fr_offset, 0, NO_RELOC);
- fragP->fr_fix += 4;
- }
-
- frag_wane(fragP);
- break;
- } /* case TAB(DBCC,SZ_UNDEF) */
-
- case TAB(PCLEA,SZ_UNDEF): {
- if ((S_GET_SEGMENT(fragP->fr_symbol))==segment || flagseen['l']) {
- fragP->fr_subtype=TAB(PCLEA,SHORT);
- fragP->fr_var+=2;
- } else {
- fragP->fr_subtype=TAB(PCLEA,LONG);
- fragP->fr_var+=6;
- }
- break;
- } /* TAB(PCLEA,SZ_UNDEF) */
-
- default:
- break;
+ /* handle SZ_UNDEF first, it can be changed to BYTE or SHORT */
+ switch(fragP->fr_subtype) {
+
+ case TAB(BRANCH,SZ_UNDEF): {
+ if((fragP->fr_symbol != NULL) /* Not absolute */
+ && S_GET_SEGMENT(fragP->fr_symbol) == segment) {
+ fragP->fr_subtype=TAB(TABTYPE(fragP->fr_subtype),BYTE);
+ break;
+ } else if((fragP->fr_symbol == 0) || (cpu_of_arch(current_architecture) < m68020)) {
+ /* On 68000, or for absolute value, switch to abs long */
+ /* FIXME, we should check abs val, pick short or long */
+ if(fragP->fr_opcode[0]==0x61) {
+ fragP->fr_opcode[0]= 0x4E;
+ fragP->fr_opcode[1]= 0xB9; /* JBSR with ABSL LONG offset */
+ subseg_change(SEG_TEXT, 0);
+ fix_new(fragP, fragP->fr_fix, 4,
+ fragP->fr_symbol, 0, fragP->fr_offset, 0, NO_RELOC);
+ fragP->fr_fix+=4;
+ frag_wane(fragP);
+ } else if(fragP->fr_opcode[0]==0x60) {
+ fragP->fr_opcode[0]= 0x4E;
+ fragP->fr_opcode[1]= 0xF9; /* JMP with ABSL LONG offset */
+ subseg_change(SEG_TEXT, 0);
+ fix_new(fragP, fragP->fr_fix, 4,
+ fragP->fr_symbol, 0, fragP->fr_offset, 0, NO_RELOC);
+ fragP->fr_fix+=4;
+ frag_wane(fragP);
+ } else {
+ as_warn("Long branch offset to extern symbol not supported.");
+ }
+ } else { /* Symbol is still undefined. Make it simple */
+ fix_new(fragP, (int)(fragP->fr_fix), 4, fragP->fr_symbol,
+ (symbolS *)0, fragP->fr_offset+4, 1, NO_RELOC);
+ fragP->fr_fix+=4;
+ fragP->fr_opcode[1]=0xff;
+ frag_wane(fragP);
+ break;
+ }
+
+ break;
+ } /* case TAB(BRANCH,SZ_UNDEF) */
+
+ case TAB(FBRANCH,SZ_UNDEF): {
+ if(S_GET_SEGMENT(fragP->fr_symbol) == segment || flagseen['l']) {
+ fragP->fr_subtype = TAB(FBRANCH,SHORT);
+ fragP->fr_var += 2;
+ } else {
+ fragP->fr_subtype = TAB(FBRANCH,LONG);
+ fragP->fr_var += 4;
+ }
+ break;
+ } /* TAB(FBRANCH,SZ_UNDEF) */
+
+ case TAB(PCREL,SZ_UNDEF): {
+ if(S_GET_SEGMENT(fragP->fr_symbol) == segment || flagseen['l']) {
+ fragP->fr_subtype = TAB(PCREL,SHORT);
+ fragP->fr_var += 2;
+ } else {
+ fragP->fr_subtype = TAB(PCREL,LONG);
+ fragP->fr_var += 4;
+ }
+ break;
+ } /* TAB(PCREL,SZ_UNDEF) */
+
+ case TAB(BCC68000,SZ_UNDEF): {
+ if((fragP->fr_symbol != NULL)
+ && S_GET_SEGMENT(fragP->fr_symbol) == segment) {
+ fragP->fr_subtype=TAB(BCC68000,BYTE);
+ break;
+ }
+ /* only Bcc 68000 instructions can come here */
+ /* change bcc into b!cc/jmp absl long */
+ fragP->fr_opcode[0] ^= 0x01; /* invert bcc */
+ if(flagseen['l']) {
+ fragP->fr_opcode[1] = 0x04; /* branch offset = 6 */
+ /* JF: these were fr_opcode[2,3] */
+ buffer_address[0] = 0x4e; /* put in jmp long (0x4ef9) */
+ buffer_address[1] = 0xf8;
+ fragP->fr_fix += 2; /* account for jmp instruction */
+ subseg_change(SEG_TEXT,0);
+ fix_new(fragP, fragP->fr_fix, 2, fragP->fr_symbol, 0,
+ fragP->fr_offset, 0, NO_RELOC);
+ fragP->fr_fix += 2;
+ } else {
+ fragP->fr_opcode[1] = 0x06; /* branch offset = 6 */
+ /* JF: these were fr_opcode[2,3] */
+ buffer_address[2] = 0x4e; /* put in jmp long (0x4ef9) */
+ buffer_address[3] = 0xf9;
+ fragP->fr_fix += 2; /* account for jmp instruction */
+ subseg_change(SEG_TEXT,0);
+ fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0,
+ fragP->fr_offset, 0, NO_RELOC);
+ fragP->fr_fix += 4;
+ }
+ frag_wane(fragP);
+ break;
+ } /* case TAB(BCC68000,SZ_UNDEF) */
+
+ case TAB(DBCC,SZ_UNDEF): {
+ if (fragP->fr_symbol != NULL && S_GET_SEGMENT(fragP->fr_symbol) == segment) {
+ fragP->fr_subtype=TAB(DBCC,SHORT);
+ fragP->fr_var+=2;
+ break;
+ }
+ /* only DBcc 68000 instructions can come here */
+ /* change dbcc into dbcc/jmp absl long */
+ /* JF: these used to be fr_opcode[2-4], which is wrong. */
+ buffer_address[0] = 0x00; /* branch offset = 4 */
+ buffer_address[1] = 0x04;
+ buffer_address[2] = 0x60; /* put in bra pc + ... */
+
+ if(flagseen['l']) {
+ /* JF: these were fr_opcode[5-7] */
+ buffer_address[3] = 0x04; /* plus 4 */
+ buffer_address[4] = 0x4e;/* Put in Jump Word */
+ buffer_address[5] = 0xf8;
+ fragP->fr_fix += 6; /* account for bra/jmp instruction */
+ subseg_change(SEG_TEXT,0);
+ fix_new(fragP, fragP->fr_fix, 2, fragP->fr_symbol, 0,
+ fragP->fr_offset, 0, NO_RELOC);
+ fragP->fr_fix += 2;
+ } else {
+ /* JF: these were fr_opcode[5-7] */
+ buffer_address[3] = 0x06; /* Plus 6 */
+ buffer_address[4] = 0x4e; /* put in jmp long (0x4ef9) */
+ buffer_address[5] = 0xf9;
+ fragP->fr_fix += 6; /* account for bra/jmp instruction */
+ subseg_change(SEG_TEXT,0);
+ fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0,
+ fragP->fr_offset, 0, NO_RELOC);
+ fragP->fr_fix += 4;
+ }
+
+ frag_wane(fragP);
+ break;
+ } /* case TAB(DBCC,SZ_UNDEF) */
+
+ case TAB(PCLEA,SZ_UNDEF): {
+ if ((S_GET_SEGMENT(fragP->fr_symbol))==segment || flagseen['l']) {
+ fragP->fr_subtype=TAB(PCLEA,SHORT);
+ fragP->fr_var+=2;
+ } else {
+ fragP->fr_subtype=TAB(PCLEA,LONG);
+ fragP->fr_var+=6;
+ }
+ break;
+ } /* TAB(PCLEA,SZ_UNDEF) */
+
+ default:
+ break;
+
+ } /* switch on subtype looking for SZ_UNDEF's. */
- } /* switch on subtype looking for SZ_UNDEF's. */
-
- /* now that SZ_UNDEF are taken care of, check others */
- switch(fragP->fr_subtype) {
- case TAB(BCC68000,BYTE):
+ /* now that SZ_UNDEF are taken care of, check others */
+ switch(fragP->fr_subtype) {
+ case TAB(BCC68000,BYTE):
case TAB(BRANCH,BYTE):
/* We can't do a short jump to the next instruction,
so we force word mode. */
if (fragP->fr_symbol && S_GET_VALUE(fragP->fr_symbol)==0 &&
fragP->fr_symbol->sy_frag==fragP->fr_next) {
- fragP->fr_subtype=TAB(TABTYPE(fragP->fr_subtype),SHORT);
- fragP->fr_var+=2;
+ fragP->fr_subtype=TAB(TABTYPE(fragP->fr_subtype),SHORT);
+ fragP->fr_var+=2;
}
break;
- default:
+ default:
break;
- }
- return fragP->fr_var + fragP->fr_fix - old_fix;
+}
+ return fragP->fr_var + fragP->fr_fix - old_fix;
}
#if defined(OBJ_AOUT) | defined(OBJ_BOUT)
@@ -3815,53 +3815,53 @@ void
char *the_bytes;
struct reloc_info_generic *ri;
{
- /* this is easy */
- md_number_to_chars(the_bytes, ri->r_address, 4);
- /* now the fun stuff */
- the_bytes[4] = (ri->r_symbolnum >> 16) & 0x0ff;
- the_bytes[5] = (ri->r_symbolnum >> 8) & 0x0ff;
- the_bytes[6] = ri->r_symbolnum & 0x0ff;
- the_bytes[7] = (((ri->r_pcrel << 7) & 0x80) | ((ri->r_length << 5) & 0x60) |
- ((ri->r_extern << 4) & 0x10));
+ /* this is easy */
+ md_number_to_chars(the_bytes, ri->r_address, 4);
+ /* now the fun stuff */
+ the_bytes[4] = (ri->r_symbolnum >> 16) & 0x0ff;
+ the_bytes[5] = (ri->r_symbolnum >> 8) & 0x0ff;
+ the_bytes[6] = ri->r_symbolnum & 0x0ff;
+ the_bytes[7] = (((ri->r_pcrel << 7) & 0x80) | ((ri->r_length << 5) & 0x60) |
+ ((ri->r_extern << 4) & 0x10));
}
#endif /* comment */
void tc_aout_fix_to_chars(where, fixP, segment_address_in_file)
- char *where;
- fixS *fixP;
- relax_addressT segment_address_in_file;
+char *where;
+fixS *fixP;
+relax_addressT segment_address_in_file;
{
- /*
- * In: length of relocation (or of address) in chars: 1, 2 or 4.
- * Out: GNU LD relocation length code: 0, 1, or 2.
- */
-
- static unsigned char nbytes_r_length [] = { 42, 0, 1, 42, 2 };
-
- long r_extern;
- long r_symbolnum;
-
- /* this is easy */
- md_number_to_chars(where,
- fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file,
- 4);
-
- /* now the fun stuff */
- if (S_GET_TYPE(fixP->fx_addsy) == N_UNDF) {
- r_extern = 1;
- r_symbolnum = fixP->fx_addsy->sy_number;
- } else {
- r_extern = 0;
- r_symbolnum = S_GET_TYPE(fixP->fx_addsy);
- }
-
- where[4] = (r_symbolnum >> 16) & 0x0ff;
- where[5] = (r_symbolnum >> 8) & 0x0ff;
- where[6] = r_symbolnum & 0x0ff;
- where[7] = (((fixP->fx_pcrel << 7) & 0x80) | ((nbytes_r_length[fixP->fx_size] << 5) & 0x60) |
- ((r_extern << 4) & 0x10));
-
- return;
+ /*
+ * In: length of relocation (or of address) in chars: 1, 2 or 4.
+ * Out: GNU LD relocation length code: 0, 1, or 2.
+ */
+
+ static unsigned char nbytes_r_length [] = { 42, 0, 1, 42, 2 };
+
+ long r_extern;
+ long r_symbolnum;
+
+ /* this is easy */
+ md_number_to_chars(where,
+ fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file,
+ 4);
+
+ /* now the fun stuff */
+ if (S_GET_TYPE(fixP->fx_addsy) == N_UNDF) {
+ r_extern = 1;
+ r_symbolnum = fixP->fx_addsy->sy_number;
+ } else {
+ r_extern = 0;
+ r_symbolnum = S_GET_TYPE(fixP->fx_addsy);
+ }
+
+ where[4] = (r_symbolnum >> 16) & 0x0ff;
+ where[5] = (r_symbolnum >> 8) & 0x0ff;
+ where[6] = r_symbolnum & 0x0ff;
+ where[7] = (((fixP->fx_pcrel << 7) & 0x80) | ((nbytes_r_length[fixP->fx_size] << 5) & 0x60) |
+ ((r_extern << 4) & 0x10));
+
+ return;
} /* tc_aout_fix_to_chars() */
#endif /* OBJ_AOUT or OBJ_BOUT */
@@ -3878,12 +3878,12 @@ long from_addr,
fragS *frag;
symbolS *to_symbol;
{
- long offset;
-
- offset = to_addr - (from_addr+2);
-
- md_number_to_chars(ptr ,(long)0x6000,2);
- md_number_to_chars(ptr+2,(long)offset,2);
+ long offset;
+
+ offset = to_addr - (from_addr+2);
+
+ md_number_to_chars(ptr ,(long)0x6000,2);
+ md_number_to_chars(ptr+2,(long)offset,2);
}
void
@@ -3894,19 +3894,19 @@ long from_addr,
fragS *frag;
symbolS *to_symbol;
{
- long offset;
-
- if (cpu_of_arch(current_architecture) < m68020) {
- offset=to_addr-S_GET_VALUE(to_symbol);
- md_number_to_chars(ptr ,(long)0x4EF9,2);
- md_number_to_chars(ptr+2,(long)offset,4);
- fix_new(frag,(ptr+2)-frag->fr_literal,4,to_symbol,(symbolS *)0,(long)0,0,
- NO_RELOC);
- } else {
- offset=to_addr - (from_addr+2);
- md_number_to_chars(ptr ,(long)0x60ff,2);
- md_number_to_chars(ptr+2,(long)offset,4);
- }
+ long offset;
+
+ if (cpu_of_arch(current_architecture) < m68020) {
+ offset=to_addr-S_GET_VALUE(to_symbol);
+ md_number_to_chars(ptr ,(long)0x4EF9,2);
+ md_number_to_chars(ptr+2,(long)offset,4);
+ fix_new(frag,(ptr+2)-frag->fr_literal,4,to_symbol,(symbolS *)0,(long)0,0,
+ NO_RELOC);
+ } else {
+ offset=to_addr - (from_addr+2);
+ md_number_to_chars(ptr ,(long)0x60ff,2);
+ md_number_to_chars(ptr+2,(long)offset,4);
+ }
}
#endif
@@ -3926,178 +3926,178 @@ symbolS *to_symbol;
*/
static int get_num(exp,ok)
- struct m68k_exp *exp;
- int ok;
+struct m68k_exp *exp;
+int ok;
{
#ifdef TEST2
- long l = 0;
-
- if(!exp->e_beg)
- return 0;
- if(*exp->e_beg=='0') {
- if(exp->e_beg[1]=='x')
- sscanf(exp->e_beg+2,"%x",&l);
- else
- sscanf(exp->e_beg+1,"%O",&l);
- return l;
- }
- return atol(exp->e_beg);
+ long l = 0;
+
+ if(!exp->e_beg)
+ return 0;
+ if(*exp->e_beg=='0') {
+ if(exp->e_beg[1]=='x')
+ sscanf(exp->e_beg+2,"%x",&l);
+ else
+ sscanf(exp->e_beg+1,"%O",&l);
+ return l;
+ }
+ return atol(exp->e_beg);
#else
- char *save_in;
- char c_save;
-
- if(!exp) {
- /* Can't do anything */
- return 0;
- }
- if(!exp->e_beg || !exp->e_end) {
- seg(exp)=SEG_ABSOLUTE;
- adds(exp)=0;
- subs(exp)=0;
- offs(exp)= (ok==10) ? 1 : 0;
- as_warn("Null expression defaults to %ld",offs(exp));
- return 0;
- }
-
- exp->e_siz=0;
- if(/* ok!=80 && */exp->e_end[-1]==SIZER && (exp->e_end-exp->e_beg)>=2) {
- switch(exp->e_end[0]) {
- case 's':
- case 'S':
- case 'b':
- case 'B':
- exp->e_siz=1;
- break;
- case 'w':
- case 'W':
- exp->e_siz=2;
- break;
- case 'l':
- case 'L':
- exp->e_siz=3;
- break;
- default:
- as_bad("Unknown size for expression \"%c\"",exp->e_end[0]);
+ char *save_in;
+ char c_save;
+
+ if(!exp) {
+ /* Can't do anything */
+ return 0;
+ }
+ if(!exp->e_beg || !exp->e_end) {
+ seg(exp)=SEG_ABSOLUTE;
+ adds(exp)=0;
+ subs(exp)=0;
+ offs(exp)= (ok==10) ? 1 : 0;
+ as_warn("Null expression defaults to %ld",offs(exp));
+ return 0;
}
- exp->e_end-=2;
- }
- c_save=exp->e_end[1];
- exp->e_end[1]='\0';
- save_in=input_line_pointer;
- input_line_pointer=exp->e_beg;
- switch(expression(&(exp->e_exp))) {
- case SEG_PASS1:
- seg(exp)=SEG_ABSOLUTE;
- adds(exp)=0;
- subs(exp)=0;
- offs(exp)= (ok==10) ? 1 : 0;
- as_warn("Unknown expression: '%s' defaulting to %d",exp->e_beg,offs(exp));
- break;
- case SEG_ABSENT:
- /* Do the same thing the VAX asm does */
- seg(exp)=SEG_ABSOLUTE;
- adds(exp)=0;
- subs(exp)=0;
- offs(exp)=0;
- if(ok==10) {
- as_warn("expression out of range: defaulting to 1");
- offs(exp)=1;
+ exp->e_siz=0;
+ if(/* ok!=80 && */exp->e_end[-1]==SIZER && (exp->e_end-exp->e_beg)>=2) {
+ switch(exp->e_end[0]) {
+ case 's':
+ case 'S':
+ case 'b':
+ case 'B':
+ exp->e_siz=1;
+ break;
+ case 'w':
+ case 'W':
+ exp->e_siz=2;
+ break;
+ case 'l':
+ case 'L':
+ exp->e_siz=3;
+ break;
+ default:
+ as_bad("Unknown size for expression \"%c\"",exp->e_end[0]);
+ }
+ exp->e_end-=2;
}
- break;
- case SEG_ABSOLUTE:
- switch(ok) {
- case 10:
- if(offs(exp)<1 || offs(exp)>8) {
- as_warn("expression out of range: defaulting to 1");
- offs(exp)=1;
- }
- break;
- case 20:
- if(offs(exp)<0 || offs(exp)>7)
- goto outrange;
- break;
- case 30:
- if(offs(exp)<0 || offs(exp)>15)
- goto outrange;
- break;
- case 40:
- if(offs(exp)<0 || offs(exp)>32)
- goto outrange;
- break;
- case 50:
- if(offs(exp)<0 || offs(exp)>127)
- goto outrange;
- break;
- case 55:
- if(offs(exp)<-64 || offs(exp)>63)
- goto outrange;
- break;
- case 60:
- if(offs(exp)<-128 || offs(exp)>127)
- goto outrange;
- break;
- case 70:
- if(offs(exp)<0 || offs(exp)>4095) {
- outrange:
- as_warn("expression out of range: defaulting to 0");
+ c_save=exp->e_end[1];
+ exp->e_end[1]='\0';
+ save_in=input_line_pointer;
+ input_line_pointer=exp->e_beg;
+ switch(expression(&(exp->e_exp))) {
+ case SEG_PASS1:
+ seg(exp)=SEG_ABSOLUTE;
+ adds(exp)=0;
+ subs(exp)=0;
+ offs(exp)= (ok==10) ? 1 : 0;
+ as_warn("Unknown expression: '%s' defaulting to %d",exp->e_beg,offs(exp));
+ break;
+
+ case SEG_ABSENT:
+ /* Do the same thing the VAX asm does */
+ seg(exp)=SEG_ABSOLUTE;
+ adds(exp)=0;
+ subs(exp)=0;
offs(exp)=0;
- }
- break;
+ if(ok==10) {
+ as_warn("expression out of range: defaulting to 1");
+ offs(exp)=1;
+ }
+ break;
+ case SEG_ABSOLUTE:
+ switch(ok) {
+ case 10:
+ if(offs(exp)<1 || offs(exp)>8) {
+ as_warn("expression out of range: defaulting to 1");
+ offs(exp)=1;
+ }
+ break;
+ case 20:
+ if(offs(exp)<0 || offs(exp)>7)
+ goto outrange;
+ break;
+ case 30:
+ if(offs(exp)<0 || offs(exp)>15)
+ goto outrange;
+ break;
+ case 40:
+ if(offs(exp)<0 || offs(exp)>32)
+ goto outrange;
+ break;
+ case 50:
+ if(offs(exp)<0 || offs(exp)>127)
+ goto outrange;
+ break;
+ case 55:
+ if(offs(exp)<-64 || offs(exp)>63)
+ goto outrange;
+ break;
+ case 60:
+ if(offs(exp)<-128 || offs(exp)>127)
+ goto outrange;
+ break;
+ case 70:
+ if(offs(exp)<0 || offs(exp)>4095) {
+ outrange:
+ as_warn("expression out of range: defaulting to 0");
+ offs(exp)=0;
+ }
+ break;
+ default:
+ break;
+ }
+ break;
+ case SEG_TEXT:
+ case SEG_DATA:
+ case SEG_BSS:
+ case SEG_UNKNOWN:
+ case SEG_DIFFERENCE:
+ if(ok>=10 && ok<=70) {
+ seg(exp)=SEG_ABSOLUTE;
+ adds(exp)=0;
+ subs(exp)=0;
+ offs(exp)= (ok==10) ? 1 : 0;
+ as_warn("Can't deal with expression \"%s\": defaulting to %ld",exp->e_beg,offs(exp));
+ }
+ break;
+ case SEG_BIG:
+ if(ok==80 && offs(exp)<0) { /* HACK! Turn it into a long */
+ LITTLENUM_TYPE words[6];
+
+ gen_to_words(words,2,8L);/* These numbers are magic! */
+ seg(exp)=SEG_ABSOLUTE;
+ adds(exp)=0;
+ subs(exp)=0;
+ offs(exp)=words[1]|(words[0]<<16);
+ } else if(ok!=0) {
+ seg(exp)=SEG_ABSOLUTE;
+ adds(exp)=0;
+ subs(exp)=0;
+ offs(exp)= (ok==10) ? 1 : 0;
+ as_warn("Can't deal with expression \"%s\": defaulting to %ld",exp->e_beg,offs(exp));
+ }
+ break;
default:
- break;
- }
- break;
- case SEG_TEXT:
- case SEG_DATA:
- case SEG_BSS:
- case SEG_UNKNOWN:
- case SEG_DIFFERENCE:
- if(ok>=10 && ok<=70) {
- seg(exp)=SEG_ABSOLUTE;
- adds(exp)=0;
- subs(exp)=0;
- offs(exp)= (ok==10) ? 1 : 0;
- as_warn("Can't deal with expression \"%s\": defaulting to %ld",exp->e_beg,offs(exp));
- }
- break;
- case SEG_BIG:
- if(ok==80 && offs(exp)<0) { /* HACK! Turn it into a long */
- LITTLENUM_TYPE words[6];
-
- gen_to_words(words,2,8L);/* These numbers are magic! */
- seg(exp)=SEG_ABSOLUTE;
- adds(exp)=0;
- subs(exp)=0;
- offs(exp)=words[1]|(words[0]<<16);
- } else if(ok!=0) {
- seg(exp)=SEG_ABSOLUTE;
- adds(exp)=0;
- subs(exp)=0;
- offs(exp)= (ok==10) ? 1 : 0;
- as_warn("Can't deal with expression \"%s\": defaulting to %ld",exp->e_beg,offs(exp));
+ as_fatal("failed sanity check.");
}
- break;
- default:
- as_fatal("failed sanity check.");
- }
- if(input_line_pointer!=exp->e_end+1)
- as_bad("Ignoring junk after expression");
- exp->e_end[1]=c_save;
- input_line_pointer=save_in;
- if(exp->e_siz) {
- switch(exp->e_siz) {
- case 1:
- if(!isbyte(offs(exp)))
- as_warn("expression doesn't fit in BYTE");
- break;
- case 2:
- if(!isword(offs(exp)))
- as_warn("expression doesn't fit in WORD");
- break;
+ if(input_line_pointer!=exp->e_end+1)
+ as_bad("Ignoring junk after expression");
+ exp->e_end[1]=c_save;
+ input_line_pointer=save_in;
+ if(exp->e_siz) {
+ switch(exp->e_siz) {
+ case 1:
+ if(!isbyte(offs(exp)))
+ as_warn("expression doesn't fit in BYTE");
+ break;
+ case 2:
+ if(!isword(offs(exp)))
+ as_warn("expression doesn't fit in WORD");
+ break;
+ }
}
- }
- return offs(exp);
+ return offs(exp);
#endif
} /* get_num() */
@@ -4105,35 +4105,35 @@ static int get_num(exp,ok)
void demand_empty_rest_of_line(); /* Hate those extra verbose names */
static void s_data1() {
- subseg_new(SEG_DATA,1);
- demand_empty_rest_of_line();
+ subseg_new(SEG_DATA,1);
+ demand_empty_rest_of_line();
} /* s_data1() */
static void s_data2() {
- subseg_new(SEG_DATA,2);
- demand_empty_rest_of_line();
+ subseg_new(SEG_DATA,2);
+ demand_empty_rest_of_line();
} /* s_data2() */
static void s_bss() {
- /* We don't support putting frags in the BSS segment, but we
- can put them into initialized data for now... */
- subseg_new(SEG_DATA,255); /* FIXME-SOON */
- demand_empty_rest_of_line();
+ /* We don't support putting frags in the BSS segment, but we
+ can put them into initialized data for now... */
+ subseg_new(SEG_DATA,255); /* FIXME-SOON */
+ demand_empty_rest_of_line();
} /* s_bss() */
static void s_even() {
- register int temp;
- register long temp_fill;
-
- temp = 1; /* JF should be 2? */
- temp_fill = get_absolute_expression ();
- if ( ! need_pass_2 ) /* Never make frag if expect extra pass. */
- frag_align (temp, (int)temp_fill);
- demand_empty_rest_of_line();
+ register int temp;
+ register long temp_fill;
+
+ temp = 1; /* JF should be 2? */
+ temp_fill = get_absolute_expression ();
+ if ( ! need_pass_2 ) /* Never make frag if expect extra pass. */
+ frag_align (temp, (int)temp_fill);
+ demand_empty_rest_of_line();
} /* s_even() */
static void s_proc() {
- demand_empty_rest_of_line();
+ demand_empty_rest_of_line();
} /* s_proc() */
/* s_space is defined in read.c .skip is simply an alias to it. */
@@ -4163,79 +4163,79 @@ static void s_proc() {
#endif
int md_parse_option(argP,cntP,vecP)
- char **argP;
- int *cntP;
- char ***vecP;
+char **argP;
+int *cntP;
+char ***vecP;
{
- switch(**argP) {
- case 'l': /* -l means keep external to 2 bit offset
- rather than 16 bit one */
- break;
-
- case 'S': /* -S means that jbsr's always turn into jsr's. */
- break;
-
- case 'A':
- (*argP)++;
- /* intentional fall-through */
- case 'm':
- (*argP)++;
-
- if (**argP=='c') {
- (*argP)++;
- } /* allow an optional "c" */
-
- if (!strcmp(*argP, "68000")
- || !strcmp(*argP, "68008")) {
- current_architecture |= m68000;
- } else if (!strcmp(*argP, "68010")) {
+ switch(**argP) {
+ case 'l': /* -l means keep external to 2 bit offset
+ rather than 16 bit one */
+ break;
+
+ case 'S': /* -S means that jbsr's always turn into jsr's. */
+ break;
+
+ case 'A':
+ (*argP)++;
+ /* intentional fall-through */
+ case 'm':
+ (*argP)++;
+
+ if (**argP=='c') {
+ (*argP)++;
+ } /* allow an optional "c" */
+
+ if (!strcmp(*argP, "68000")
+ || !strcmp(*argP, "68008")) {
+ current_architecture |= m68000;
+ } else if (!strcmp(*argP, "68010")) {
#ifdef TE_SUN
- omagic= 1<<16|OMAGIC;
+ omagic= 1<<16|OMAGIC;
#endif
- current_architecture |= m68010;
-
- } else if (!strcmp(*argP, "68020")) {
- current_architecture |= m68020 | MAYBE_FLOAT_TOO;
-
- } else if (!strcmp(*argP, "68030")) {
- current_architecture |= m68030 | MAYBE_FLOAT_TOO;
-
- } else if (!strcmp(*argP, "68040")) {
- current_architecture |= m68040 | MAYBE_FLOAT_TOO;
-
+ current_architecture |= m68010;
+
+ } else if (!strcmp(*argP, "68020")) {
+ current_architecture |= m68020 | MAYBE_FLOAT_TOO;
+
+ } else if (!strcmp(*argP, "68030")) {
+ current_architecture |= m68030 | MAYBE_FLOAT_TOO;
+
+ } else if (!strcmp(*argP, "68040")) {
+ current_architecture |= m68040 | MAYBE_FLOAT_TOO;
+
#ifndef NO_68881
- } else if (!strcmp(*argP, "68881")) {
- current_architecture |= m68881;
-
- } else if (!strcmp(*argP, "68882")) {
- current_architecture |= m68882;
-
+ } else if (!strcmp(*argP, "68881")) {
+ current_architecture |= m68881;
+
+ } else if (!strcmp(*argP, "68882")) {
+ current_architecture |= m68882;
+
#endif /* NO_68881 */
#ifndef NO_68851
- } else if (!strcmp(*argP,"68851")) {
- current_architecture |= m68851;
-
+ } else if (!strcmp(*argP,"68851")) {
+ current_architecture |= m68851;
+
#endif /* NO_68851 */
- } else {
- as_warn("Unknown architecture, \"%s\". option ignored", *argP);
- } /* switch on architecture */
-
- while(**argP) (*argP)++;
-
- break;
-
- case 'p':
- if (!strcmp(*argP,"pic")) {
- (*argP) += 3;
- break; /* -pic, Position Independent Code */
- } else {
- return(0);
- } /* pic or not */
-
- default:
- return 0;
- }
- return 1;
+ } else {
+ as_warn("Unknown architecture, \"%s\". option ignored", *argP);
+ } /* switch on architecture */
+
+ while(**argP) (*argP)++;
+
+ break;
+
+ case 'p':
+ if (!strcmp(*argP,"pic")) {
+ (*argP) += 3;
+ break; /* -pic, Position Independent Code */
+ } else {
+ return(0);
+ } /* pic or not */
+
+ default:
+ return 0;
+ }
+ return 1;
}
@@ -4246,62 +4246,62 @@ int md_parse_option(argP,cntP,vecP)
main()
{
- struct m68k_it the_ins;
- char buf[120];
- char *cp;
- int n;
-
- m68k_ip_begin();
- for(;;) {
- if(!gets(buf) || !*buf)
- break;
- if(buf[0]=='|' || buf[1]=='.')
- continue;
- for(cp=buf;*cp;cp++)
- if(*cp=='\t')
- *cp=' ';
- if(is_label(buf))
- continue;
- bzero(&the_ins,sizeof(the_ins));
- m68k_ip(&the_ins,buf);
- if(the_ins.error) {
- printf("Error %s in %s\n",the_ins.error,buf);
- } else {
- printf("Opcode(%d.%s): ",the_ins.numo,the_ins.args);
- for(n=0;n<the_ins.numo;n++)
- printf(" 0x%x",the_ins.opcode[n]&0xffff);
- printf(" ");
- print_the_insn(&the_ins.opcode[0],stdout);
- (void)putchar('\n');
- }
- for(n=0;n<strlen(the_ins.args)/2;n++) {
- if(the_ins.operands[n].error) {
- printf("op%d Error %s in %s\n",n,the_ins.operands[n].error,buf);
- continue;
- }
- printf("mode %d, reg %d, ",the_ins.operands[n].mode,the_ins.operands[n].reg);
- if(the_ins.operands[n].b_const)
- printf("Constant: '%.*s', ",1+the_ins.operands[n].e_const-the_ins.operands[n].b_const,the_ins.operands[n].b_const);
- printf("ireg %d, isiz %d, imul %d, ",the_ins.operands[n].ireg,the_ins.operands[n].isiz,the_ins.operands[n].imul);
- if(the_ins.operands[n].b_iadd)
- printf("Iadd: '%.*s',",1+the_ins.operands[n].e_iadd-the_ins.operands[n].b_iadd,the_ins.operands[n].b_iadd);
- (void)putchar('\n');
+ struct m68k_it the_ins;
+ char buf[120];
+ char *cp;
+ int n;
+
+ m68k_ip_begin();
+ for(;;) {
+ if(!gets(buf) || !*buf)
+ break;
+ if(buf[0]=='|' || buf[1]=='.')
+ continue;
+ for(cp=buf;*cp;cp++)
+ if(*cp=='\t')
+ *cp=' ';
+ if(is_label(buf))
+ continue;
+ memset(&the_ins, '\0', sizeof(the_ins));
+ m68k_ip(&the_ins,buf);
+ if(the_ins.error) {
+ printf("Error %s in %s\n",the_ins.error,buf);
+ } else {
+ printf("Opcode(%d.%s): ",the_ins.numo,the_ins.args);
+ for(n=0;n<the_ins.numo;n++)
+ printf(" 0x%x",the_ins.opcode[n]&0xffff);
+ printf(" ");
+ print_the_insn(&the_ins.opcode[0],stdout);
+ (void)putchar('\n');
+ }
+ for(n=0;n<strlen(the_ins.args)/2;n++) {
+ if(the_ins.operands[n].error) {
+ printf("op%d Error %s in %s\n",n,the_ins.operands[n].error,buf);
+ continue;
+ }
+ printf("mode %d, reg %d, ",the_ins.operands[n].mode,the_ins.operands[n].reg);
+ if(the_ins.operands[n].b_const)
+ printf("Constant: '%.*s', ",1+the_ins.operands[n].e_const-the_ins.operands[n].b_const,the_ins.operands[n].b_const);
+ printf("ireg %d, isiz %d, imul %d, ",the_ins.operands[n].ireg,the_ins.operands[n].isiz,the_ins.operands[n].imul);
+ if(the_ins.operands[n].b_iadd)
+ printf("Iadd: '%.*s',",1+the_ins.operands[n].e_iadd-the_ins.operands[n].b_iadd,the_ins.operands[n].b_iadd);
+ (void)putchar('\n');
+ }
}
- }
- m68k_ip_end();
- return 0;
+ m68k_ip_end();
+ return 0;
}
is_label(str)
- char *str;
+char *str;
{
- while(ISSPACE(*str))
- str++;
- while(*str && !ISSPACE(*str))
- str++;
- if(str[-1]==':' || str[1]=='=')
- return 1;
- return 0;
+ while(ISSPACE(*str))
+ str++;
+ while(*str && !ISSPACE(*str))
+ str++;
+ if(str[-1]==':' || str[1]=='=')
+ return 1;
+ return 0;
}
#endif
@@ -4328,52 +4328,35 @@ is_label(str)
#ifdef DONTDEF
abort()
{
- printf("ABORT!\n");
- exit(12);
-}
-
-char *index(s,c)
- char *s;
-{
- while(*s!=c) {
- if(!*s) return 0;
- s++;
- }
- return s;
-}
-
-bzero(s,n)
- char *s;
-{
- while(n--)
- *s++=0;
+ printf("ABORT!\n");
+ exit(12);
}
print_frags()
{
- fragS *fragP;
- extern fragS *text_frag_root;
-
- for(fragP=text_frag_root;fragP;fragP=fragP->fr_next) {
- printf("addr %lu next 0x%x fix %ld var %ld symbol 0x%x offset %ld\n",
- fragP->fr_address,fragP->fr_next,fragP->fr_fix,fragP->fr_var,fragP->fr_symbol,fragP->fr_offset);
- printf("opcode 0x%x type %d subtype %d\n\n",fragP->fr_opcode,fragP->fr_type,fragP->fr_subtype);
- }
- fflush(stdout);
- return 0;
+ fragS *fragP;
+ extern fragS *text_frag_root;
+
+ for(fragP=text_frag_root;fragP;fragP=fragP->fr_next) {
+ printf("addr %lu next 0x%x fix %ld var %ld symbol 0x%x offset %ld\n",
+ fragP->fr_address,fragP->fr_next,fragP->fr_fix,fragP->fr_var,fragP->fr_symbol,fragP->fr_offset);
+ printf("opcode 0x%x type %d subtype %d\n\n",fragP->fr_opcode,fragP->fr_type,fragP->fr_subtype);
+ }
+ fflush(stdout);
+ return 0;
}
#endif
#ifdef DONTDEF
/*VARARGS1*/
panic(format,args)
- char *format;
+char *format;
{
- fputs("Internal error:",stderr);
- _doprnt(format,&args,stderr);
- (void)putc('\n',stderr);
- as_where();
- abort();
+ fputs("Internal error:",stderr);
+ _doprnt(format,&args,stderr);
+ (void)putc('\n',stderr);
+ as_where();
+ abort();
}
#endif
@@ -4384,7 +4367,7 @@ symbolS *
md_undefined_symbol (name)
char *name;
{
- return 0;
+ return 0;
}
/* Parse an operand that is machine-specific.
@@ -4404,7 +4387,7 @@ long
segT segment;
long size;
{
- return size; /* Byte alignment is fine */
+ return size; /* Byte alignment is fine */
}
/* Exactly what point is a PC-relative offset relative TO?
@@ -4414,89 +4397,89 @@ long
md_pcrel_from (fixP)
fixS *fixP;
{
- return fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address;
+ return fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address;
}
#ifdef MRI
void s_ds(size)
{
- unsigned int fill = get_absolute_expression() * size;
- char *p = frag_var (rs_fill, fill, fill, (relax_substateT)0, (symbolS *)0,
- 1, (char *)0);
- * p = 0;
- demand_empty_rest_of_line();
+ unsigned int fill = get_absolute_expression() * size;
+ char *p = frag_var (rs_fill, fill, fill, (relax_substateT)0, (symbolS *)0,
+ 1, (char *)0);
+ * p = 0;
+ demand_empty_rest_of_line();
}
void s_dc(size)
{
-
- cons(size);
-
-
+
+ cons(size);
+
+
}
void s_dcb(size)
{
- int repeat = get_absolute_expression();
- int fill;
-
- if (*input_line_pointer == ',')
- {
- char *p;
- input_line_pointer++;
-
- fill = get_absolute_expression();
- p = frag_var(rs_fill,
- size,
- size,
- (relax_substateT)0,
- (symbolS *)0,
- repeat,
- 0);
- md_number_to_chars(p, fill, size);
- }
- demand_empty_rest_of_line();
-
-
+ int repeat = get_absolute_expression();
+ int fill;
+
+ if (*input_line_pointer == ',')
+ {
+ char *p;
+ input_line_pointer++;
+
+ fill = get_absolute_expression();
+ p = frag_var(rs_fill,
+ size,
+ size,
+ (relax_substateT)0,
+ (symbolS *)0,
+ repeat,
+ 0);
+ md_number_to_chars(p, fill, size);
+ }
+ demand_empty_rest_of_line();
+
+
}
void s_chip()
{
- unsigned int target = get_absolute_expression();
+ unsigned int target = get_absolute_expression();
#define MACHINE_MASK (m68000 | m68008 | m68010 | m68020 | m68040)
- switch (target)
- {
- case 68000:
- case 68008:
- current_architecture = (current_architecture & ~ MACHINE_MASK) | m68000;
- break;
- case 68010:
- current_architecture = (current_architecture & ~ MACHINE_MASK) | m68010;
- break;
- case 68020:
- current_architecture = (current_architecture & ~ MACHINE_MASK) | m68020;
- break;
- case 68030:
- current_architecture = (current_architecture & ~ MACHINE_MASK) | m68030;
- break;
- case 68040:
- current_architecture = (current_architecture & ~ MACHINE_MASK) | m68040;
- break;
- case 68881:
- current_architecture |= m68881;
- break;
- case 68882:
- current_architecture |= m68882;
- break;
- case 68851:
- current_architecture |= m68851;
- break;
-
- default:
- as_bad("Unrecognised CHIP %d\n", target);
-
- }
- demand_empty_rest_of_line();
+ switch (target)
+ {
+ case 68000:
+ case 68008:
+ current_architecture = (current_architecture & ~ MACHINE_MASK) | m68000;
+ break;
+ case 68010:
+ current_architecture = (current_architecture & ~ MACHINE_MASK) | m68010;
+ break;
+ case 68020:
+ current_architecture = (current_architecture & ~ MACHINE_MASK) | m68020;
+ break;
+ case 68030:
+ current_architecture = (current_architecture & ~ MACHINE_MASK) | m68030;
+ break;
+ case 68040:
+ current_architecture = (current_architecture & ~ MACHINE_MASK) | m68040;
+ break;
+ case 68881:
+ current_architecture |= m68881;
+ break;
+ case 68882:
+ current_architecture |= m68882;
+ break;
+ case 68851:
+ current_architecture |= m68851;
+ break;
+
+ default:
+ as_bad("Unrecognised CHIP %d\n", target);
+
+ }
+ demand_empty_rest_of_line();
}
#endif
diff --git a/gas/config/tc-m68kmote.h b/gas/config/tc-m68kmote.h
index e1904ff..95e0c15 100644
--- a/gas/config/tc-m68kmote.h
+++ b/gas/config/tc-m68kmote.h
@@ -45,7 +45,7 @@
#define LISTING_LHS_WIDTH 3 /* 3 word on the first line */
#define LISTING_LHS_WIDTH_SECOND 3 /* One word on the second line */
#define LISTING_LHS_CONT_LINES 4 /* And 4 lines max */
-#define LISTING_HEADER "TANDEM ST-2000 68K GAS "
+#define LISTING_HEADER "68K GAS "
/* Copied from write.c */
#define M68K_AIM_KLUDGE(aim, this_state,this_type) \
diff --git a/gas/config/tc-ns32k.c b/gas/config/tc-ns32k.c
index 9676852..e34a204 100644
--- a/gas/config/tc-ns32k.c
+++ b/gas/config/tc-ns32k.c
@@ -33,10 +33,10 @@
#include "obstack.h"
/* Macros */
-#define IIF_ENTRIES 13 /* number of entries in iif */
-#define PRIVATE_SIZE 256 /* size of my garbage memory */
+#define IIF_ENTRIES 13 /* number of entries in iif */
+#define PRIVATE_SIZE 256 /* size of my garbage memory */
#define MAX_ARGS 4
-#define DEFAULT -1 /* addr_mode returns this value when plain constant or label is encountered */
+#define DEFAULT -1 /* addr_mode returns this value when plain constant or label is encountered */
#define IIF(ptr,a1,c1,e1,g1,i1,k1,m1,o1,q1,s1,u1) \
iif.iifP[ptr].type= a1; \
@@ -68,17 +68,17 @@ char line_comment_chars[] = LINE_COMMENT_CHARS;
#endif
struct addr_mode {
- char mode; /* addressing mode of operand (0-31) */
- char scaled_mode; /* mode combined with scaled mode */
- char scaled_reg; /* register used in scaled+1 (1-8) */
- char float_flag; /* set if R0..R7 was F0..F7 ie a floating-point-register */
- char am_size; /* estimated max size of general addr-mode parts*/
- char im_disp; /* if im_disp==1 we have a displacement */
- char pcrel; /* 1 if pcrel, this is really redundant info */
- char disp_suffix[2]; /* length of displacement(s), 0=undefined */
- char *disp[2]; /* pointer(s) at displacement(s)
+ char mode; /* addressing mode of operand (0-31) */
+ char scaled_mode; /* mode combined with scaled mode */
+ char scaled_reg; /* register used in scaled+1 (1-8) */
+ char float_flag; /* set if R0..R7 was F0..F7 ie a floating-point-register */
+ char am_size; /* estimated max size of general addr-mode parts*/
+ char im_disp; /* if im_disp==1 we have a displacement */
+ char pcrel; /* 1 if pcrel, this is really redundant info */
+ char disp_suffix[2]; /* length of displacement(s), 0=undefined */
+ char *disp[2]; /* pointer(s) at displacement(s)
or immediates(s) (ascii) */
- char index_byte; /* index byte */
+ char index_byte; /* index byte */
};
typedef struct addr_mode addr_modeS;
@@ -100,27 +100,30 @@ char FLT_CHARS[] = "fd"; /* we don't want to support lowercase, do we */
/* internal structs */
struct option {
- char *pattern;
- unsigned long or;
- unsigned long and;
+ char *pattern;
+ unsigned long or;
+ unsigned long and;
};
typedef struct {
- int type; /* how to interpret object */
- int size; /* Estimated max size of object */
- unsigned long object; /* binary data */
- int object_adjust; /* number added to object */
- int pcrel; /* True if object is pcrel */
- int pcrel_adjust; /* It's value reflects the length in bytes from the instruction start to the displacement */
- int im_disp; /* True if the object is a displacement */
- relax_substateT relax_substate; /* Initial relaxsubstate */
- bit_fixS *bit_fixP; /* Pointer at bit_fix struct */
- int addr_mode; /* What addrmode do we associate with this iif-entry */
- char bsr; /* Sequent hack */
-}iif_entryT; /* Internal Instruction Format */
+ int type; /* how to interpret object */
+ int size; /* Estimated max size of object */
+ unsigned long object; /* binary data */
+ int object_adjust; /* number added to object */
+ int pcrel; /* True if object is pcrel */
+ int pcrel_adjust; /* length in bytes from the
+ instruction start to the
+ displacement */
+ int im_disp; /* True if the object is a displacement */
+ relax_substateT relax_substate; /* Initial relaxsubstate */
+ bit_fixS *bit_fixP; /* Pointer at bit_fix struct */
+ int addr_mode; /* What addrmode do we associate with this iif-entry */
+ char bsr; /* Sequent hack */
+}iif_entryT; /* Internal Instruction Format */
+
struct int_ins_form {
- int instr_size; /* Max size of instruction in bytes. */
- iif_entryT iifP[IIF_ENTRIES+1];
+ int instr_size; /* Max size of instruction in bytes. */
+ iif_entryT iifP[IIF_ENTRIES + 1];
};
struct int_ins_form iif;
expressionS exprP;
@@ -175,124 +178,124 @@ char *input_line_pointer;
struct option opt1[]= /* restore, exit */
{
-{ "r0", 0x80, 0xff },
-{ "r1", 0x40, 0xff },
-{ "r2", 0x20, 0xff },
-{ "r3", 0x10, 0xff },
-{ "r4", 0x08, 0xff },
-{ "r5", 0x04, 0xff },
-{ "r6", 0x02, 0xff },
-{ "r7", 0x01, 0xff },
-{ 0 , 0x00, 0xff }
+ { "r0", 0x80, 0xff },
+ { "r1", 0x40, 0xff },
+ { "r2", 0x20, 0xff },
+ { "r3", 0x10, 0xff },
+ { "r4", 0x08, 0xff },
+ { "r5", 0x04, 0xff },
+ { "r6", 0x02, 0xff },
+ { "r7", 0x01, 0xff },
+ { 0 , 0x00, 0xff }
};
struct option opt2[]= /* save, enter */
{
-{ "r0", 0x01, 0xff },
-{ "r1", 0x02, 0xff },
-{ "r2", 0x04, 0xff },
-{ "r3", 0x08, 0xff },
-{ "r4", 0x10, 0xff },
-{ "r5", 0x20, 0xff },
-{ "r6", 0x40, 0xff },
-{ "r7", 0x80, 0xff },
-{ 0 , 0x00, 0xff }
+ { "r0", 0x01, 0xff },
+ { "r1", 0x02, 0xff },
+ { "r2", 0x04, 0xff },
+ { "r3", 0x08, 0xff },
+ { "r4", 0x10, 0xff },
+ { "r5", 0x20, 0xff },
+ { "r6", 0x40, 0xff },
+ { "r7", 0x80, 0xff },
+ { 0 , 0x00, 0xff }
};
struct option opt3[]= /* setcfg */
{
-{ "c", 0x8, 0xff },
-{ "m", 0x4, 0xff },
-{ "f", 0x2, 0xff },
-{ "i", 0x1, 0xff },
-{ 0 , 0x0, 0xff }
+ { "c", 0x8, 0xff },
+ { "m", 0x4, 0xff },
+ { "f", 0x2, 0xff },
+ { "i", 0x1, 0xff },
+ { 0 , 0x0, 0xff }
};
struct option opt4[]= /* cinv */
{
-{ "a", 0x4, 0xff },
-{ "i", 0x2, 0xff },
-{ "d", 0x1, 0xff },
-{ 0 , 0x0, 0xff }
+ { "a", 0x4, 0xff },
+ { "i", 0x2, 0xff },
+ { "d", 0x1, 0xff },
+ { 0 , 0x0, 0xff }
};
struct option opt5[]= /* string inst */
{
-{ "b", 0x2, 0xff },
-{ "u", 0xc, 0xff },
-{ "w", 0x4, 0xff },
-{ 0 , 0x0, 0xff }
+ { "b", 0x2, 0xff },
+ { "u", 0xc, 0xff },
+ { "w", 0x4, 0xff },
+ { 0 , 0x0, 0xff }
};
struct option opt6[]= /* plain reg ext,cvtp etc */
{
-{ "r0", 0x00, 0xff },
-{ "r1", 0x01, 0xff },
-{ "r2", 0x02, 0xff },
-{ "r3", 0x03, 0xff },
-{ "r4", 0x04, 0xff },
-{ "r5", 0x05, 0xff },
-{ "r6", 0x06, 0xff },
-{ "r7", 0x07, 0xff },
-{ 0 , 0x00, 0xff }
+ { "r0", 0x00, 0xff },
+ { "r1", 0x01, 0xff },
+ { "r2", 0x02, 0xff },
+ { "r3", 0x03, 0xff },
+ { "r4", 0x04, 0xff },
+ { "r5", 0x05, 0xff },
+ { "r6", 0x06, 0xff },
+ { "r7", 0x07, 0xff },
+ { 0 , 0x00, 0xff }
};
#if !defined(NS32032) && !defined(NS32532)
#define NS32032
#endif
-
- struct option cpureg_532[]= /* lpr spr */
+
+struct option cpureg_532[]= /* lpr spr */
{
-{ "us", 0x0, 0xff },
-{ "dcr", 0x1, 0xff },
-{ "bpc", 0x2, 0xff },
-{ "dsr", 0x3, 0xff },
-{ "car", 0x4, 0xff },
-{ "fp", 0x8, 0xff },
-{ "sp", 0x9, 0xff },
-{ "sb", 0xa, 0xff },
-{ "usp", 0xb, 0xff },
-{ "cfg", 0xc, 0xff },
-{ "psr", 0xd, 0xff },
-{ "intbase", 0xe, 0xff },
-{ "mod", 0xf, 0xff },
-{ 0 , 0x00, 0xff }
+ { "us", 0x0, 0xff },
+ { "dcr", 0x1, 0xff },
+ { "bpc", 0x2, 0xff },
+ { "dsr", 0x3, 0xff },
+ { "car", 0x4, 0xff },
+ { "fp", 0x8, 0xff },
+ { "sp", 0x9, 0xff },
+ { "sb", 0xa, 0xff },
+ { "usp", 0xb, 0xff },
+ { "cfg", 0xc, 0xff },
+ { "psr", 0xd, 0xff },
+ { "intbase", 0xe, 0xff },
+ { "mod", 0xf, 0xff },
+ { 0 , 0x00, 0xff }
};
struct option mmureg_532[]= /* lmr smr */
{
-{ "mcr", 0x9, 0xff },
-{ "msr", 0xa, 0xff },
-{ "tear", 0xb, 0xff },
-{ "ptb0", 0xc, 0xff },
-{ "ptb1", 0xd, 0xff },
-{ "ivar0", 0xe, 0xff },
-{ "ivar1", 0xf, 0xff },
-{ 0 , 0x0, 0xff }
+ { "mcr", 0x9, 0xff },
+ { "msr", 0xa, 0xff },
+ { "tear", 0xb, 0xff },
+ { "ptb0", 0xc, 0xff },
+ { "ptb1", 0xd, 0xff },
+ { "ivar0", 0xe, 0xff },
+ { "ivar1", 0xf, 0xff },
+ { 0 , 0x0, 0xff }
};
struct option cpureg_032[]= /* lpr spr */
{
-{ "upsr", 0x0, 0xff },
-{ "fp", 0x8, 0xff },
-{ "sp", 0x9, 0xff },
-{ "sb", 0xa, 0xff },
-{ "psr", 0xd, 0xff },
-{ "intbase", 0xe, 0xff },
-{ "mod", 0xf, 0xff },
-{ 0 , 0x0, 0xff }
+ { "upsr", 0x0, 0xff },
+ { "fp", 0x8, 0xff },
+ { "sp", 0x9, 0xff },
+ { "sb", 0xa, 0xff },
+ { "psr", 0xd, 0xff },
+ { "intbase", 0xe, 0xff },
+ { "mod", 0xf, 0xff },
+ { 0 , 0x0, 0xff }
};
struct option mmureg_032[]= /* lmr smr */
{
-{ "bpr0", 0x0, 0xff },
-{ "bpr1", 0x1, 0xff },
-{ "pf0", 0x4, 0xff },
-{ "pf1", 0x5, 0xff },
-{ "sc", 0x8, 0xff },
-{ "msr", 0xa, 0xff },
-{ "bcnt", 0xb, 0xff },
-{ "ptb0", 0xc, 0xff },
-{ "ptb1", 0xd, 0xff },
-{ "eia", 0xf, 0xff },
-{ 0 , 0x0, 0xff }
+ { "bpr0", 0x0, 0xff },
+ { "bpr1", 0x1, 0xff },
+ { "pf0", 0x4, 0xff },
+ { "pf1", 0x5, 0xff },
+ { "sc", 0x8, 0xff },
+ { "msr", 0xa, 0xff },
+ { "bcnt", 0xb, 0xff },
+ { "ptb0", 0xc, 0xff },
+ { "ptb1", 0xd, 0xff },
+ { "eia", 0xf, 0xff },
+ { 0 , 0x0, 0xff }
};
#if defined(NS32532)
- struct option *cpureg = cpureg_532;
+struct option *cpureg = cpureg_532;
struct option *mmureg = mmureg_532;
#else
struct option *cpureg = cpureg_032;
@@ -301,57 +304,57 @@ struct option *mmureg = mmureg_032;
const pseudo_typeS md_pseudo_table[]={ /* so far empty */
-{ 0, 0, 0 }
+ { 0, 0, 0 }
};
#define IND(x,y) (((x)<<2)+(y))
-
- /* those are index's to relax groups in md_relax_table
- ie it must be multiplied by 4 to point at a group start. Viz IND(x,y)
- Se function relax_segment in write.c for more info */
-
+
+/* those are index's to relax groups in md_relax_table
+ ie it must be multiplied by 4 to point at a group start. Viz IND(x,y)
+ Se function relax_segment in write.c for more info */
+
#define BRANCH 1
#define PCREL 2
-
- /* those are index's to entries in a relax group */
-
+
+/* those are index's to entries in a relax group */
+
#define BYTE 0
#define WORD 1
#define DOUBLE 2
#define UNDEF 3
- /* Those limits are calculated from the displacement start in memory.
- The ns32k uses the begining of the instruction as displacement base.
- This type of displacements could be handled here by moving the limit window
- up or down. I choose to use an internal displacement base-adjust as there
- are other routines that must consider this. Also, as we have two various
- offset-adjusts in the ns32k (acb versus br/brs/jsr/bcond), two set of limits
- would have had to be used.
- Now we dont have to think about that. */
-
-
- const relax_typeS md_relax_table[]={
-{ 1, 1, 0, 0 },
-{ 1, 1, 0, 0 },
-{ 1, 1, 0, 0 },
-{ 1, 1, 0, 0 },
-
-{ (63), (-64), 1, IND(BRANCH,WORD) },
-{ (8192), (-8192), 2, IND(BRANCH,DOUBLE) },
-{ 0, 0, 4, 0 },
-{ 1, 1, 0, 0 }
+/* Those limits are calculated from the displacement start in memory.
+ The ns32k uses the begining of the instruction as displacement base.
+ This type of displacements could be handled here by moving the limit window
+ up or down. I choose to use an internal displacement base-adjust as there
+ are other routines that must consider this. Also, as we have two various
+ offset-adjusts in the ns32k (acb versus br/brs/jsr/bcond), two set of limits
+ would have had to be used.
+ Now we dont have to think about that. */
+
+
+const relax_typeS md_relax_table[] = {
+ { 1, 1, 0, 0 },
+ { 1, 1, 0, 0 },
+ { 1, 1, 0, 0 },
+ { 1, 1, 0, 0 },
+
+ { (63), (-64), 1, IND(BRANCH,WORD) },
+ { (8192), (-8192), 2, IND(BRANCH,DOUBLE) },
+ { 0, 0, 4, 0 },
+ { 1, 1, 0, 0 }
};
/* Array used to test if mode contains displacements.
Value is true if mode contains displacement. */
-char disp_test[]={ 0,0,0,0,0,0,0,0,
- 1,1,1,1,1,1,1,1,
- 1,1,1,0,0,1,1,0,
- 1,1,1,1,1,1,1,1 };
+char disp_test[] = { 0,0,0,0,0,0,0,0,
+ 1,1,1,1,1,1,1,1,
+ 1,1,1,0,0,1,1,0,
+ 1,1,1,1,1,1,1,1 };
/* Array used to calculate max size of displacements */
-char disp_size[]={ 4,1,2,0,4 };
+char disp_size[] = { 4,1,2,0,4 };
#if __STDC__ == 1
@@ -377,201 +380,201 @@ static void md_number_to_imm();
out: data in addr_mode struct
*/
int addr_mode(operand,addr_modeP,recursive_level)
- char *operand;
- register addr_modeS *addr_modeP;
- int recursive_level;
+char *operand;
+register addr_modeS *addr_modeP;
+int recursive_level;
{
- register char *str;
- register int i;
- register int strl;
- register int mode;
- int j;
- mode = DEFAULT; /* default */
- addr_modeP->scaled_mode=0; /* why not */
- addr_modeP->scaled_reg=0; /* if 0, not scaled index */
- addr_modeP->float_flag=0;
- addr_modeP->am_size=0;
- addr_modeP->im_disp=0;
- addr_modeP->pcrel=0; /* not set in this function */
- addr_modeP->disp_suffix[0]=0;
- addr_modeP->disp_suffix[1]=0;
- addr_modeP->disp[0]=NULL;
- addr_modeP->disp[1]=NULL;
- str=operand;
- if (str[0]==0) {return (0);} /* we don't want this */
- strl=strlen(str);
- switch (str[0]) {
- /* the following three case statements controls the mode-chars
- this is the place to ed if you want to change them */
+ register char *str;
+ register int i;
+ register int strl;
+ register int mode;
+ int j;
+ mode = DEFAULT; /* default */
+ addr_modeP->scaled_mode=0; /* why not */
+ addr_modeP->scaled_reg=0; /* if 0, not scaled index */
+ addr_modeP->float_flag=0;
+ addr_modeP->am_size=0;
+ addr_modeP->im_disp=0;
+ addr_modeP->pcrel=0; /* not set in this function */
+ addr_modeP->disp_suffix[0]=0;
+ addr_modeP->disp_suffix[1]=0;
+ addr_modeP->disp[0]=NULL;
+ addr_modeP->disp[1]=NULL;
+ str=operand;
+ if (str[0]==0) {return (0);} /* we don't want this */
+ strl=strlen(str);
+ switch (str[0]) {
+ /* the following three case statements controls the mode-chars
+ this is the place to ed if you want to change them */
#ifdef ABSOLUTE_PREFIX
- case ABSOLUTE_PREFIX:
- if (str[strl-1]==']') break;
- addr_modeP->mode=21; /* absolute */
- addr_modeP->disp[0]=str+1;
- return (-1);
+ case ABSOLUTE_PREFIX:
+ if (str[strl-1]==']') break;
+ addr_modeP->mode=21; /* absolute */
+ addr_modeP->disp[0]=str+1;
+ return (-1);
#endif
#ifdef IMMEDIATE_PREFIX
- case IMMEDIATE_PREFIX:
- if (str[strl-1]==']') break;
- addr_modeP->mode=20; /* immediate */
- addr_modeP->disp[0]=str+1;
- return (-1);
+ case IMMEDIATE_PREFIX:
+ if (str[strl-1]==']') break;
+ addr_modeP->mode=20; /* immediate */
+ addr_modeP->disp[0]=str+1;
+ return (-1);
#endif
- case '.':
- if (str[strl-1]!=']') {
- switch (str[1]) {
- case'-':case'+':
- if (str[2]!='\000') {
- addr_modeP->mode=27; /* pc-relativ */
- addr_modeP->disp[0]=str+2;
- return (-1);
+ case '.':
+ if (str[strl-1]!=']') {
+ switch (str[1]) {
+ case'-':case'+':
+ if (str[2]!='\000') {
+ addr_modeP->mode=27; /* pc-relativ */
+ addr_modeP->disp[0]=str+2;
+ return (-1);
+ }
+ default:
+ as_warn("Invalid syntax in PC-relative addressing mode");
+ return(0);
+ }
}
- default:
- as_warn("Invalid syntax in PC-relative addressing mode");
- return(0);
- }
- }
- break;
- case'e':
- if (str[strl-1]!=']') {
- if((!strncmp(str,"ext(",4)) && strl>7) { /* external */
- addr_modeP->disp[0]=str+4;
- i=0;
- j=2;
- do { /* disp[0]'s termination point */
- j+=1;
- if (str[j]=='(') i++;
- if (str[j]==')') i--;
- } while (j<strl && i!=0);
- if (i!=0 || !(str[j+1]=='-' || str[j+1]=='+') ) {
- as_warn("Invalid syntax in External addressing mode");
- return(0);
+ break;
+ case'e':
+ if (str[strl-1]!=']') {
+ if((!strncmp(str,"ext(",4)) && strl>7) { /* external */
+ addr_modeP->disp[0]=str+4;
+ i=0;
+ j=2;
+ do { /* disp[0]'s termination point */
+ j+=1;
+ if (str[j]=='(') i++;
+ if (str[j]==')') i--;
+ } while (j<strl && i!=0);
+ if (i!=0 || !(str[j+1]=='-' || str[j+1]=='+') ) {
+ as_warn("Invalid syntax in External addressing mode");
+ return(0);
+ }
+ str[j]='\000'; /* null terminate disp[0] */
+ addr_modeP->disp[1]=str+j+2;
+ addr_modeP->mode=22;
+ return (-1);
+ }
}
- str[j]='\000'; /* null terminate disp[0] */
- addr_modeP->disp[1]=str+j+2;
- addr_modeP->mode=22;
- return (-1);
- }
- }
- break;
- default:;
- }
- strl=strlen(str);
- switch(strl) {
- case 2:
- switch (str[0]) {
- case'f':addr_modeP->float_flag=1;
- case'r':
- if (str[1]>='0' && str[1]<'8') {
- addr_modeP->mode=str[1]-'0';
- return (-1);
- }
- }
- case 3:
- if (!strncmp(str,"tos",3)) {
- addr_modeP->mode=23; /* TopOfStack */
- return (-1);
+ break;
+ default:;
}
- default:;
- }
- if (strl>4) {
- if (str[strl-1]==')') {
- if (str[strl-2]==')') {
- if (!strncmp(&str[strl-5],"(fp",3)) {
- mode=16; /* Memory Relative */
- }
- if (!strncmp(&str[strl-5],"(sp",3)) {
- mode=17;
- }
- if (!strncmp(&str[strl-5],"(sb",3)) {
- mode=18;
- }
- if (mode!=DEFAULT) { /* memory relative */
- addr_modeP->mode=mode;
- j=strl-5; /* temp for end of disp[0] */
- i=0;
- do {
- strl-=1;
- if (str[strl]==')') i++;
- if (str[strl]=='(') i--;
- } while (strl>-1 && i!=0);
- if (i!=0) {
- as_warn("Invalid syntax in Memory Relative addressing mode");
- return(0);
- }
- addr_modeP->disp[1]=str;
- addr_modeP->disp[0]=str+strl+1;
- str[j]='\000'; /* null terminate disp[0] */
- str[strl]='\000'; /* null terminate disp[1] */
- return (-1);
- }
- }
- switch (str[strl-3]) {
- case'r':case'R':
- if (str[strl-2]>='0' && str[strl-2]<'8' && str[strl-4]=='(') {
- addr_modeP->mode=str[strl-2]-'0'+8;
- addr_modeP->disp[0]=str;
- str[strl-4]=0;
- return (-1); /* reg rel */
- }
- default:
- if (!strncmp(&str[strl-4],"(fp",3)) {
- mode=24;
- }
- if (!strncmp(&str[strl-4],"(sp",3)) {
- mode=25;
- }
- if (!strncmp(&str[strl-4],"(sb",3)) {
- mode=26;
- }
- if (!strncmp(&str[strl-4],"(pc",3)) {
- mode=27;
+ strl=strlen(str);
+ switch(strl) {
+ case 2:
+ switch (str[0]) {
+ case'f':addr_modeP->float_flag=1;
+ case'r':
+ if (str[1]>='0' && str[1]<'8') {
+ addr_modeP->mode=str[1]-'0';
+ return (-1);
+ }
}
- if (mode!=DEFAULT) {
- addr_modeP->mode=mode;
- addr_modeP->disp[0]=str;
- str[strl-4]='\0';
- return (-1); /* memory space */
+ case 3:
+ if (!strncmp(str,"tos",3)) {
+ addr_modeP->mode=23; /* TopOfStack */
+ return (-1);
}
- }
+ default:;
}
- /* no trailing ')' do we have a ']' ? */
- if (str[strl-1]==']') {
- switch (str[strl-2]) {
- case'b':mode=28;break;
- case'w':mode=29;break;
- case'd':mode=30;break;
- case'q':mode=31;break;
- default:;
- as_warn("Invalid scaled-indexed mode, use (b,w,d,q)");
- if (str[strl-3]!=':' || str[strl-6]!='[' ||
- str[strl-5]=='r' || str[strl-4]<'0' || str[strl-4]>'7') {
- as_warn("Syntax in scaled-indexed mode, use [Rn:m] where n=[0..7] m={b,w,d,q}");
+ if (strl>4) {
+ if (str[strl-1]==')') {
+ if (str[strl-2]==')') {
+ if (!strncmp(&str[strl-5],"(fp",3)) {
+ mode=16; /* Memory Relative */
+ }
+ if (!strncmp(&str[strl-5],"(sp",3)) {
+ mode=17;
+ }
+ if (!strncmp(&str[strl-5],"(sb",3)) {
+ mode=18;
+ }
+ if (mode!=DEFAULT) { /* memory relative */
+ addr_modeP->mode=mode;
+ j=strl-5; /* temp for end of disp[0] */
+ i=0;
+ do {
+ strl-=1;
+ if (str[strl]==')') i++;
+ if (str[strl]=='(') i--;
+ } while (strl>-1 && i!=0);
+ if (i!=0) {
+ as_warn("Invalid syntax in Memory Relative addressing mode");
+ return(0);
+ }
+ addr_modeP->disp[1]=str;
+ addr_modeP->disp[0]=str+strl+1;
+ str[j]='\000'; /* null terminate disp[0] */
+ str[strl]='\000'; /* null terminate disp[1] */
+ return (-1);
+ }
+ }
+ switch (str[strl-3]) {
+ case'r':case'R':
+ if (str[strl-2]>='0' && str[strl-2]<'8' && str[strl-4]=='(') {
+ addr_modeP->mode=str[strl-2]-'0'+8;
+ addr_modeP->disp[0]=str;
+ str[strl-4]=0;
+ return (-1); /* reg rel */
+ }
+ default:
+ if (!strncmp(&str[strl-4],"(fp",3)) {
+ mode=24;
+ }
+ if (!strncmp(&str[strl-4],"(sp",3)) {
+ mode=25;
+ }
+ if (!strncmp(&str[strl-4],"(sb",3)) {
+ mode=26;
+ }
+ if (!strncmp(&str[strl-4],"(pc",3)) {
+ mode=27;
+ }
+ if (mode!=DEFAULT) {
+ addr_modeP->mode=mode;
+ addr_modeP->disp[0]=str;
+ str[strl-4]='\0';
+ return (-1); /* memory space */
+ }
+ }
+ }
+ /* no trailing ')' do we have a ']' ? */
+ if (str[strl-1]==']') {
+ switch (str[strl-2]) {
+ case'b':mode=28;break;
+ case'w':mode=29;break;
+ case'd':mode=30;break;
+ case'q':mode=31;break;
+ default:;
+ as_warn("Invalid scaled-indexed mode, use (b,w,d,q)");
+ if (str[strl-3]!=':' || str[strl-6]!='[' ||
+ str[strl-5]=='r' || str[strl-4]<'0' || str[strl-4]>'7') {
+ as_warn("Syntax in scaled-indexed mode, use [Rn:m] where n=[0..7] m={b,w,d,q}");
+ }
+ } /* scaled index */
+ {
+ if (recursive_level>0) {
+ as_warn("Scaled-indexed addressing mode combined with scaled-index");
+ return(0);
+ }
+ addr_modeP->am_size+=1; /* scaled index byte */
+ j=str[strl-4]-'0'; /* store temporary */
+ str[strl-6]='\000'; /* nullterminate for recursive call */
+ i=addr_mode(str,addr_modeP,1);
+ if (!i || addr_modeP->mode==20) {
+ as_warn("Invalid or illegal addressing mode combined with scaled-index");
+ return(0);
+ }
+ addr_modeP->scaled_mode=addr_modeP->mode; /* store the inferior mode */
+ addr_modeP->mode=mode;
+ addr_modeP->scaled_reg=j+1;
+ return (-1);
+ }
}
- } /* scaled index */
- {
- if (recursive_level>0) {
- as_warn("Scaled-indexed addressing mode combined with scaled-index");
- return(0);
- }
- addr_modeP->am_size+=1; /* scaled index byte */
- j=str[strl-4]-'0'; /* store temporary */
- str[strl-6]='\000'; /* nullterminate for recursive call */
- i=addr_mode(str,addr_modeP,1);
- if (!i || addr_modeP->mode==20) {
- as_warn("Invalid or illegal addressing mode combined with scaled-index");
- return(0);
- }
- addr_modeP->scaled_mode=addr_modeP->mode; /* store the inferior mode */
- addr_modeP->mode=mode;
- addr_modeP->scaled_reg=j+1;
- return (-1);
- }
}
- }
- addr_modeP->mode = DEFAULT; /* default to whatever */
- addr_modeP->disp[0]=str;
- return (-1);
+ addr_modeP->mode = DEFAULT; /* default to whatever */
+ addr_modeP->disp[0]=str;
+ return (-1);
}
/* ptr points at string
@@ -582,127 +585,127 @@ int addr_mode(operand,addr_modeP,recursive_level)
Also builds index bytes if needed.
*/
int get_addr_mode(ptr,addr_modeP)
- char *ptr;
- addr_modeS *addr_modeP;
+char *ptr;
+addr_modeS *addr_modeP;
{
- int tmp;
- addr_mode(ptr,addr_modeP,0);
- if (addr_modeP->mode == DEFAULT || addr_modeP->scaled_mode == -1) {
- /* resolve ambigious operands, this shouldn't
- be necessary if one uses standard NSC operand
- syntax. But the sequent compiler doesn't!!!
- This finds a proper addressinging mode if it
- is implicitly stated. See ns32k-opcode.h */
- (void)evaluate_expr(&exprP,ptr); /* this call takes time Sigh! */
- if (addr_modeP->mode == DEFAULT) {
- if (exprP.X_add_symbol || exprP.X_subtract_symbol) {
- addr_modeP->mode=desc->default_model; /* we have a label */
- } else {
- addr_modeP->mode=desc->default_modec; /* we have a constant */
- }
- } else {
- if (exprP.X_add_symbol || exprP.X_subtract_symbol) {
- addr_modeP->scaled_mode=desc->default_model;
- } else {
- addr_modeP->scaled_mode=desc->default_modec;
- }
+ int tmp;
+ addr_mode(ptr,addr_modeP,0);
+ if (addr_modeP->mode == DEFAULT || addr_modeP->scaled_mode == -1) {
+ /* resolve ambigious operands, this shouldn't
+ be necessary if one uses standard NSC operand
+ syntax. But the sequent compiler doesn't!!!
+ This finds a proper addressinging mode if it
+ is implicitly stated. See ns32k-opcode.h */
+ (void)evaluate_expr(&exprP,ptr); /* this call takes time Sigh! */
+ if (addr_modeP->mode == DEFAULT) {
+ if (exprP.X_add_symbol || exprP.X_subtract_symbol) {
+ addr_modeP->mode=desc->default_model; /* we have a label */
+ } else {
+ addr_modeP->mode=desc->default_modec; /* we have a constant */
+ }
+ } else {
+ if (exprP.X_add_symbol || exprP.X_subtract_symbol) {
+ addr_modeP->scaled_mode=desc->default_model;
+ } else {
+ addr_modeP->scaled_mode=desc->default_modec;
+ }
+ }
+ /* must put this mess down in addr_mode to handle the scaled case better */
}
- /* must put this mess down in addr_mode to handle the scaled case better */
- }
- /* It appears as the sequent compiler wants an absolute when we have a
- label without @. Constants becomes immediates besides the addr case.
- Think it does so with local labels too, not optimum, pcrel is better.
- When I have time I will make gas check this and select pcrel when possible
- Actually that is trivial.
- */
- if (tmp=addr_modeP->scaled_reg) { /* build indexbyte */
- tmp--; /* remember regnumber comes incremented for flagpurpose */
- tmp|=addr_modeP->scaled_mode<<3;
- addr_modeP->index_byte=(char)tmp;
- addr_modeP->am_size+=1;
- }
- if (disp_test[addr_modeP->mode]) { /* there was a displacement, probe for length specifying suffix*/
- {
- register char c;
- register char suffix;
- register char suffix_sub;
- register int i;
- register char *toP;
- register char *fromP;
-
- addr_modeP->pcrel=0;
- if (disp_test[addr_modeP->mode]) { /* there is a displacement */
- if (addr_modeP->mode==27 || addr_modeP->scaled_mode==27) { /* do we have pcrel. mode */
- addr_modeP->pcrel=1;
- }
- addr_modeP->im_disp=1;
- for(i=0;i<2;i++) {
- suffix_sub=suffix=0;
- if (toP=addr_modeP->disp[i]) { /* suffix of expression, the largest size rules */
- fromP=toP;
- while (c = *fromP++) {
- *toP++=c;
- if (c==':') {
- switch (*fromP) {
- case '\0':
- as_warn("Premature end of suffix--Defaulting to d");
- suffix=4;
- continue;
- case 'b':suffix_sub=1;break;
- case 'w':suffix_sub=2;break;
- case 'd':suffix_sub=4;break;
- default:
- as_warn("Bad suffix after ':' use {b|w|d} Defaulting to d");
- suffix=4;
- }
- fromP++;
- toP--; /* So we write over the ':' */
- if (suffix<suffix_sub) suffix=suffix_sub;
+ /* It appears as the sequent compiler wants an absolute when we have a
+ label without @. Constants becomes immediates besides the addr case.
+ Think it does so with local labels too, not optimum, pcrel is better.
+ When I have time I will make gas check this and select pcrel when possible
+ Actually that is trivial.
+ */
+ if (tmp=addr_modeP->scaled_reg) { /* build indexbyte */
+ tmp--; /* remember regnumber comes incremented for flagpurpose */
+ tmp|=addr_modeP->scaled_mode<<3;
+ addr_modeP->index_byte=(char)tmp;
+ addr_modeP->am_size+=1;
+ }
+ if (disp_test[addr_modeP->mode]) { /* there was a displacement, probe for length specifying suffix*/
+ {
+ register char c;
+ register char suffix;
+ register char suffix_sub;
+ register int i;
+ register char *toP;
+ register char *fromP;
+
+ addr_modeP->pcrel=0;
+ if (disp_test[addr_modeP->mode]) { /* there is a displacement */
+ if (addr_modeP->mode==27 || addr_modeP->scaled_mode==27) { /* do we have pcrel. mode */
+ addr_modeP->pcrel=1;
+ }
+ addr_modeP->im_disp=1;
+ for(i=0;i<2;i++) {
+ suffix_sub=suffix=0;
+ if (toP=addr_modeP->disp[i]) { /* suffix of expression, the largest size rules */
+ fromP=toP;
+ while (c = *fromP++) {
+ *toP++=c;
+ if (c==':') {
+ switch (*fromP) {
+ case '\0':
+ as_warn("Premature end of suffix--Defaulting to d");
+ suffix=4;
+ continue;
+ case 'b':suffix_sub=1;break;
+ case 'w':suffix_sub=2;break;
+ case 'd':suffix_sub=4;break;
+ default:
+ as_warn("Bad suffix after ':' use {b|w|d} Defaulting to d");
+ suffix=4;
+ }
+ fromP++;
+ toP--; /* So we write over the ':' */
+ if (suffix<suffix_sub) suffix=suffix_sub;
+ }
+ }
+ *toP='\0'; /* terminate properly */
+ addr_modeP->disp_suffix[i]=suffix;
+ addr_modeP->am_size+=suffix ? suffix : 4;
+ }
+ }
}
- }
- *toP='\0'; /* terminate properly */
- addr_modeP->disp_suffix[i]=suffix;
- addr_modeP->am_size+=suffix ? suffix : 4;
}
- }
+ } else {
+ if (addr_modeP->mode==20) { /* look in ns32k_opcode for size */
+ addr_modeP->disp_suffix[0]=addr_modeP->am_size=desc->im_size;
+ addr_modeP->im_disp=0;
+ }
}
- }
-} else {
- if (addr_modeP->mode==20) { /* look in ns32k_opcode for size */
- addr_modeP->disp_suffix[0]=addr_modeP->am_size=desc->im_size;
- addr_modeP->im_disp=0;
- }
-}
- return addr_modeP->mode;
+ return addr_modeP->mode;
}
/* read an optionlist */
void optlist(str,optionP,default_map)
- char *str; /* the string to extract options from */
- struct option *optionP; /* how to search the string */
- unsigned long *default_map; /* default pattern and output */
+char *str; /* the string to extract options from */
+struct option *optionP; /* how to search the string */
+unsigned long *default_map; /* default pattern and output */
{
- register int i,j,k,strlen1,strlen2;
- register char *patternP,*strP;
- strlen1=strlen(str);
- if (strlen1<1) {
- as_fatal("Very short instr to option, ie you can't do it on a NULLstr");
- }
- for (i=0;optionP[i].pattern!=0;i++) {
- strlen2=strlen(optionP[i].pattern);
- for (j=0;j<strlen1;j++) {
- patternP=optionP[i].pattern;
- strP = &str[j];
- for (k=0;k<strlen2;k++) {
- if (*(strP++)!=*(patternP++)) break;
- }
- if (k==strlen2) { /* match */
- *default_map|=optionP[i].or;
- *default_map&=optionP[i].and;
- }
+ register int i,j,k,strlen1,strlen2;
+ register char *patternP,*strP;
+ strlen1=strlen(str);
+ if (strlen1<1) {
+ as_fatal("Very short instr to option, ie you can't do it on a NULLstr");
+ }
+ for (i=0;optionP[i].pattern!=0;i++) {
+ strlen2=strlen(optionP[i].pattern);
+ for (j=0;j<strlen1;j++) {
+ patternP=optionP[i].pattern;
+ strP = &str[j];
+ for (k=0;k<strlen2;k++) {
+ if (*(strP++)!=*(patternP++)) break;
+ }
+ if (k==strlen2) { /* match */
+ *default_map|=optionP[i].or;
+ *default_map&=optionP[i].and;
+ }
+ }
}
- }
}
/* search struct for symbols
This function is used to get the short integer form of reg names
@@ -710,32 +713,32 @@ void optlist(str,optionP,default_map)
return true if str is found in list */
int list_search(str,optionP,default_map)
- char *str; /* the string to match */
- struct option *optionP; /* list to search */
- unsigned long *default_map; /* default pattern and output */
+char *str; /* the string to match */
+struct option *optionP; /* list to search */
+unsigned long *default_map; /* default pattern and output */
{
- register int i;
- for (i=0;optionP[i].pattern!=0;i++) {
- if (!strncmp(optionP[i].pattern,str,20)) { /* use strncmp to be safe */
- *default_map|=optionP[i].or;
- *default_map&=optionP[i].and;
- return -1;
+ register int i;
+ for (i=0;optionP[i].pattern!=0;i++) {
+ if (!strncmp(optionP[i].pattern,str,20)) { /* use strncmp to be safe */
+ *default_map|=optionP[i].or;
+ *default_map&=optionP[i].and;
+ return -1;
+ }
}
- }
- as_warn("No such entry in list. (cpu/mmu register)");
- return 0;
+ as_warn("No such entry in list. (cpu/mmu register)");
+ return 0;
}
static segT evaluate_expr(resultP,ptr)
- expressionS *resultP;
- char *ptr;
+expressionS *resultP;
+char *ptr;
{
- register char *tmp_line;
- register segT segment;
- tmp_line=input_line_pointer;
- input_line_pointer=ptr;
- segment=expression(&exprP);
- input_line_pointer=tmp_line;
- return (segment);
+ register char *tmp_line;
+ register segT segment;
+ tmp_line=input_line_pointer;
+ input_line_pointer=ptr;
+ segment=expression(&exprP);
+ input_line_pointer=tmp_line;
+ return (segment);
}
/* Convert operands to iif-format and adds bitfields to the opcode.
@@ -746,145 +749,147 @@ static segT evaluate_expr(resultP,ptr)
*/
void encode_operand(argc,argv,operandsP,suffixP,im_size,opcode_bit_ptr)
- int argc;
- char **argv;
- char *operandsP;
- char *suffixP;
- char im_size;
- char opcode_bit_ptr;
+int argc;
+char **argv;
+char *operandsP;
+char *suffixP;
+char im_size;
+char opcode_bit_ptr;
{
- register int i,j;
- int pcrel,tmp,b,loop,pcrel_adjust;
- for(loop=0;loop<argc;loop++) {
- i=operandsP[loop<<1]-'1'; /* what operand are we supposed to work on */
- if (i>3) as_fatal("Internal consistency error. check ns32k-opcode.h");
- pcrel=0;
- pcrel_adjust=0;
- tmp=0;
- switch (operandsP[(loop<<1)+1]) {
- case 'f': /* operand of sfsr turns out to be a nasty specialcase */
- opcode_bit_ptr-=5;
- case 'F': /* 32 bit float general form */
- case 'L': /* 64 bit float */
- case 'Q': /* quad-word */
- case 'B': /* byte */
- case 'W': /* word */
- case 'D': /* double-word */
- case 'A': /* double-word gen-address-form ie no regs allowed */
- get_addr_mode(argv[i],&addr_modeP);
- iif.instr_size+=addr_modeP.am_size;
- if (opcode_bit_ptr==desc->opcode_size) b=4; else b=6;
- for (j=b;j<(b+2);j++) {
- if (addr_modeP.disp[j-b]) {
- IIF(j,
- 2,
- addr_modeP.disp_suffix[j-b],
- (unsigned long)addr_modeP.disp[j-b],
- 0,
- addr_modeP.pcrel,
- iif.instr_size-addr_modeP.am_size, /* this aint used (now) */
- addr_modeP.im_disp,
- IND(BRANCH,BYTE),
- NULL,
- addr_modeP.scaled_reg ? addr_modeP.scaled_mode:addr_modeP.mode,
- 0);
+ register int i,j;
+ int pcrel,tmp,b,loop,pcrel_adjust;
+ for(loop=0;loop<argc;loop++) {
+ i=operandsP[loop<<1]-'1'; /* what operand are we supposed to work on */
+ if (i>3) as_fatal("Internal consistency error. check ns32k-opcode.h");
+ pcrel=0;
+ pcrel_adjust=0;
+ tmp=0;
+ switch (operandsP[(loop<<1)+1]) {
+ case 'f': /* operand of sfsr turns out to be a nasty specialcase */
+ opcode_bit_ptr-=5;
+ case 'F': /* 32 bit float general form */
+ case 'L': /* 64 bit float */
+ case 'Q': /* quad-word */
+ case 'B': /* byte */
+ case 'W': /* word */
+ case 'D': /* double-word */
+ case 'A': /* double-word gen-address-form ie no regs allowed */
+ get_addr_mode(argv[i],&addr_modeP);
+ iif.instr_size+=addr_modeP.am_size;
+ if (opcode_bit_ptr==desc->opcode_size) b=4; else b=6;
+ for (j=b;j<(b+2);j++) {
+ if (addr_modeP.disp[j-b]) {
+ IIF(j,
+ 2,
+ addr_modeP.disp_suffix[j-b],
+ (unsigned long)addr_modeP.disp[j-b],
+ 0,
+ addr_modeP.pcrel,
+ iif.instr_size-addr_modeP.am_size, /* this aint used (now) */
+ addr_modeP.im_disp,
+ IND(BRANCH,BYTE),
+ NULL,
+ addr_modeP.scaled_reg ? addr_modeP.scaled_mode:addr_modeP.mode,
+ 0);
+ }
+ }
+ opcode_bit_ptr-=5;
+ iif.iifP[1].object|=((long)addr_modeP.mode)<<opcode_bit_ptr;
+ if (addr_modeP.scaled_reg) {
+ j=b/2;
+ IIF(j,1,1, (unsigned long)addr_modeP.index_byte,0,0,0,0,0, NULL,-1,0);
+ }
+ break;
+ case 'b': /* multiple instruction disp */
+ freeptr++; /* OVE:this is an useful hack */
+ tmp = (int) sprintf(freeptr,
+ "((%s-1)*%d)\000",
+ argv[i], desc->im_size);
+ argv[i]=freeptr;
+ freeptr=(char*)tmp;
+ pcrel-=1; /* make pcrel 0 inspite of what case 'p': wants */
+ /* fall thru */
+ case 'p': /* displacement - pc relative addressing */
+ pcrel+=1;
+ /* fall thru */
+ case 'd': /* displacement */
+ iif.instr_size+=suffixP[i] ? suffixP[i] : 4;
+ IIF(12, 2, suffixP[i], (unsigned long)argv[i], 0,
+ pcrel, pcrel_adjust, 1, IND(BRANCH,BYTE), NULL,-1,0);
+ break;
+ case 'H': /* sequent-hack: the linker wants a bit set when bsr */
+ pcrel=1;
+ iif.instr_size+=suffixP[i] ? suffixP[i] : 4;
+ IIF(12, 2, suffixP[i], (unsigned long)argv[i], 0,
+ pcrel, pcrel_adjust, 1, IND(BRANCH,BYTE), NULL,-1,1);break;
+ case 'q': /* quick */
+ opcode_bit_ptr-=4;
+ IIF(11,2,42,(unsigned long)argv[i],0,0,0,0,0,
+ bit_fix_new(4,opcode_bit_ptr,-8,7,0,1,0),-1,0);
+ break;
+ case 'r': /* register number (3 bits) */
+ list_search(argv[i],opt6,&tmp);
+ opcode_bit_ptr-=3;
+ iif.iifP[1].object|=tmp<<opcode_bit_ptr;
+ break;
+ case 'O': /* setcfg instruction optionslist */
+ optlist(argv[i],opt3,&tmp);
+ opcode_bit_ptr-=4;
+ iif.iifP[1].object|=tmp<<15;
+ break;
+ case 'C': /* cinv instruction optionslist */
+ optlist(argv[i],opt4,&tmp);
+ opcode_bit_ptr-=4;
+ iif.iifP[1].object|=tmp<<15;/*insert the regtype in opcode */
+ break;
+ case 'S': /* stringinstruction optionslist */
+ optlist(argv[i],opt5,&tmp);
+ opcode_bit_ptr-=4;
+ iif.iifP[1].object|=tmp<<15;
+ break;
+ case 'u':case 'U': /* registerlist */
+ IIF(10,1,1,0,0,0,0,0,0,NULL,-1,0);
+ switch (operandsP[(i<<1)+1]) {
+ case 'u': /* restore, exit */
+ optlist(argv[i],opt1,&iif.iifP[10].object);
+ break;
+ case 'U': /* save,enter */
+ optlist(argv[i],opt2,&iif.iifP[10].object);
+ break;
+ }
+ iif.instr_size+=1;
+ break;
+ case 'M': /* mmu register */
+ list_search(argv[i],mmureg,&tmp);
+ opcode_bit_ptr-=4;
+ iif.iifP[1].object|=tmp<<opcode_bit_ptr;
+ break;
+ case 'P': /* cpu register */
+ list_search(argv[i],cpureg,&tmp);
+ opcode_bit_ptr-=4;
+ iif.iifP[1].object|=tmp<<opcode_bit_ptr;
+ break;
+ case 'g': /* inss exts */
+ iif.instr_size+=1; /* 1 byte is allocated after the opcode */
+ IIF(10,2,1,
+ (unsigned long)argv[i], /* i always 2 here */
+ 0,0,0,0,0,
+ bit_fix_new(3,5,0,7,0,0,0), /* a bit_fix is targeted to the byte */
+ -1,0);
+ case 'G':
+ IIF(11,2,42,
+ (unsigned long)argv[i], /* i always 3 here */
+ 0,0,0,0,0,
+ bit_fix_new(5,0,1,32,-1,0,-1),-1,0);
+ break;
+ case 'i':
+ iif.instr_size+=1;
+ b=2+i; /* put the extension byte after opcode */
+ IIF(b,2,1,0,0,0,0,0,0,0,-1,0);
+ default:
+ as_fatal("Bad opcode-table-option, check in file ns32k-opcode.h");
}
- }
- opcode_bit_ptr-=5;
- iif.iifP[1].object|=((long)addr_modeP.mode)<<opcode_bit_ptr;
- if (addr_modeP.scaled_reg) {
- j=b/2;
- IIF(j,1,1, (unsigned long)addr_modeP.index_byte,0,0,0,0,0, NULL,-1,0);
- }
- break;
- case 'b': /* multiple instruction disp */
- freeptr++; /* OVE:this is an useful hack */
- tmp=(int)sprintf(freeptr,"((%s-1)*%d)\000",argv[i],desc->im_size);
- argv[i]=freeptr;
- freeptr=(char*)tmp;
- pcrel-=1; /* make pcrel 0 inspite of what case 'p': wants */
- /* fall thru */
- case 'p': /* displacement - pc relative addressing */
- pcrel+=1;
- /* fall thru */
- case 'd': /* displacement */
- iif.instr_size+=suffixP[i] ? suffixP[i] : 4;
- IIF(12, 2, suffixP[i], (unsigned long)argv[i], 0,
- pcrel, pcrel_adjust, 1, IND(BRANCH,BYTE), NULL,-1,0);
- break;
- case 'H': /* sequent-hack: the linker wants a bit set when bsr */
- pcrel=1;
- iif.instr_size+=suffixP[i] ? suffixP[i] : 4;
- IIF(12, 2, suffixP[i], (unsigned long)argv[i], 0,
- pcrel, pcrel_adjust, 1, IND(BRANCH,BYTE), NULL,-1,1);break;
- case 'q': /* quick */
- opcode_bit_ptr-=4;
- IIF(11,2,42,(unsigned long)argv[i],0,0,0,0,0,
- bit_fix_new(4,opcode_bit_ptr,-8,7,0,1,0),-1,0);
- break;
- case 'r': /* register number (3 bits) */
- list_search(argv[i],opt6,&tmp);
- opcode_bit_ptr-=3;
- iif.iifP[1].object|=tmp<<opcode_bit_ptr;
- break;
- case 'O': /* setcfg instruction optionslist */
- optlist(argv[i],opt3,&tmp);
- opcode_bit_ptr-=4;
- iif.iifP[1].object|=tmp<<15;
- break;
- case 'C': /* cinv instruction optionslist */
- optlist(argv[i],opt4,&tmp);
- opcode_bit_ptr-=4;
- iif.iifP[1].object|=tmp<<15;/*insert the regtype in opcode */
- break;
- case 'S': /* stringinstruction optionslist */
- optlist(argv[i],opt5,&tmp);
- opcode_bit_ptr-=4;
- iif.iifP[1].object|=tmp<<15;
- break;
- case 'u':case 'U': /* registerlist */
- IIF(10,1,1,0,0,0,0,0,0,NULL,-1,0);
- switch (operandsP[(i<<1)+1]) {
- case 'u': /* restore, exit */
- optlist(argv[i],opt1,&iif.iifP[10].object);
- break;
- case 'U': /* save,enter */
- optlist(argv[i],opt2,&iif.iifP[10].object);
- break;
- }
- iif.instr_size+=1;
- break;
- case 'M': /* mmu register */
- list_search(argv[i],mmureg,&tmp);
- opcode_bit_ptr-=4;
- iif.iifP[1].object|=tmp<<opcode_bit_ptr;
- break;
- case 'P': /* cpu register */
- list_search(argv[i],cpureg,&tmp);
- opcode_bit_ptr-=4;
- iif.iifP[1].object|=tmp<<opcode_bit_ptr;
- break;
- case 'g': /* inss exts */
- iif.instr_size+=1; /* 1 byte is allocated after the opcode */
- IIF(10,2,1,
- (unsigned long)argv[i], /* i always 2 here */
- 0,0,0,0,0,
- bit_fix_new(3,5,0,7,0,0,0), /* a bit_fix is targeted to the byte */
- -1,0);
- case 'G':
- IIF(11,2,42,
- (unsigned long)argv[i], /* i always 3 here */
- 0,0,0,0,0,
- bit_fix_new(5,0,1,32,-1,0,-1),-1,0);
- break;
- case 'i':
- iif.instr_size+=1;
- b=2+i; /* put the extension byte after opcode */
- IIF(b,2,1,0,0,0,0,0,0,0,-1,0);
- default:
- as_fatal("Bad opcode-table-option, check in file ns32k-opcode.h");
}
- }
}
/* in: instruction line
@@ -895,109 +900,109 @@ void encode_operand(argc,argv,operandsP,suffixP,im_size,opcode_bit_ptr)
*/
/* build iif of one assembly text line */
int parse(line,recursive_level)
- char *line;
- int recursive_level;
+char *line;
+int recursive_level;
{
- register char *lineptr,c,suffix_separator;
- register int i;
- int argc,arg_type;
- char sqr,sep;
- char suffix[MAX_ARGS],*argv[MAX_ARGS];/* no more than 4 operands */
- if (recursive_level<=0) { /* called from md_assemble */
- for (lineptr=line;(*lineptr)!='\0' && (*lineptr)!=' ';lineptr++);
- c = *lineptr;
- *lineptr='\0';
- if (!(desc=(struct ns32k_opcode*)hash_find(inst_hash_handle,line))) {
- as_fatal("No such opcode");
+ register char *lineptr,c,suffix_separator;
+ register int i;
+ int argc,arg_type;
+ char sqr,sep;
+ char suffix[MAX_ARGS],*argv[MAX_ARGS];/* no more than 4 operands */
+ if (recursive_level<=0) { /* called from md_assemble */
+ for (lineptr=line;(*lineptr)!='\0' && (*lineptr)!=' ';lineptr++);
+ c = *lineptr;
+ *lineptr='\0';
+ if (!(desc=(struct ns32k_opcode*)hash_find(inst_hash_handle,line))) {
+ as_fatal("No such opcode");
+ }
+ *lineptr=c;
+ } else {
+ lineptr=line;
}
- *lineptr=c;
- } else {
- lineptr=line;
- }
- argc=0;
- if (*desc->operands) {
- if (*lineptr++!='\0') {
- sqr='[';
- sep=',';
- while (*lineptr!='\0') {
- if (desc->operands[argc<<1]) {
- suffix[argc]=0;
- arg_type=desc->operands[(argc<<1)+1];
- switch (arg_type) {
- case 'd': case 'b': case 'p': case 'H': /* the operand is supposed to be a displacement */
- /* Hackwarning: do not forget to update the 4 cases above when editing ns32k-opcode.h */
- suffix_separator=':';
- break;
- default:
- suffix_separator='\255'; /* if this char occurs we loose */
- }
- suffix[argc]=0; /* 0 when no ':' is encountered */
- argv[argc]=freeptr;
- *freeptr='\0';
- while ((c = *lineptr)!='\0' && c!=sep) {
- if (c==sqr) {
- if (sqr=='[') {
- sqr=']';sep='\0';
- } else {
- sqr='[';sep=',';
- }
- }
- if (c==suffix_separator) { /* ':' - label/suffix separator */
- switch (lineptr[1]) {
- case 'b':suffix[argc]=1;break;
- case 'w':suffix[argc]=2;break;
- case 'd':suffix[argc]=4;break;
- default: as_warn("Bad suffix, defaulting to d");
- suffix[argc]=4;
- if (lineptr[1]=='\0' || lineptr[1]==sep) {
- lineptr+=1;
- continue;
+ argc=0;
+ if (*desc->operands) {
+ if (*lineptr++!='\0') {
+ sqr='[';
+ sep=',';
+ while (*lineptr!='\0') {
+ if (desc->operands[argc<<1]) {
+ suffix[argc]=0;
+ arg_type=desc->operands[(argc<<1)+1];
+ switch (arg_type) {
+ case 'd': case 'b': case 'p': case 'H': /* the operand is supposed to be a displacement */
+ /* Hackwarning: do not forget to update the 4 cases above when editing ns32k-opcode.h */
+ suffix_separator=':';
+ break;
+ default:
+ suffix_separator='\255'; /* if this char occurs we loose */
+ }
+ suffix[argc]=0; /* 0 when no ':' is encountered */
+ argv[argc]=freeptr;
+ *freeptr='\0';
+ while ((c = *lineptr)!='\0' && c!=sep) {
+ if (c==sqr) {
+ if (sqr=='[') {
+ sqr=']';sep='\0';
+ } else {
+ sqr='[';sep=',';
+ }
+ }
+ if (c==suffix_separator) { /* ':' - label/suffix separator */
+ switch (lineptr[1]) {
+ case 'b':suffix[argc]=1;break;
+ case 'w':suffix[argc]=2;break;
+ case 'd':suffix[argc]=4;break;
+ default: as_warn("Bad suffix, defaulting to d");
+ suffix[argc]=4;
+ if (lineptr[1]=='\0' || lineptr[1]==sep) {
+ lineptr+=1;
+ continue;
+ }
+ }
+ lineptr+=2;
+ continue;
+ }
+ *freeptr++=c;
+ lineptr++;
+ }
+ *freeptr++='\0';
+ argc+=1;
+ if (*lineptr=='\0') continue;
+ lineptr+=1;
+ } else {
+ as_fatal("Too many operands passed to instruction");
}
- }
- lineptr+=2;
- continue;
}
- *freeptr++=c;
- lineptr++;
- }
- *freeptr++='\0';
- argc+=1;
- if (*lineptr=='\0') continue;
- lineptr+=1;
+ }
+ }
+ if (argc!=strlen(desc->operands)/2) {
+ if (strlen(desc->default_args)) { /* we can apply default, dont goof */
+ if (parse(desc->default_args,1)!=1) { /* check error in default */
+ as_fatal("Wrong numbers of operands in default, check ns32k-opcodes.h");
+ }
} else {
- as_fatal("Too many operands passed to instruction");
+ as_fatal("Wrong number of operands");
}
- }
+
}
- }
- if (argc!=strlen(desc->operands)/2) {
- if (strlen(desc->default_args)) { /* we can apply default, dont goof */
- if (parse(desc->default_args,1)!=1) { /* check error in default */
- as_fatal("Wrong numbers of operands in default, check ns32k-opcodes.h");
- }
- } else {
- as_fatal("Wrong number of operands");
+ for (i=0;i<IIF_ENTRIES;i++) {
+ iif.iifP[i].type=0; /* mark all entries as void*/
}
- }
- for (i=0;i<IIF_ENTRIES;i++) {
- iif.iifP[i].type=0; /* mark all entries as void*/
- }
-
- /* build opcode iif-entry */
- iif.instr_size=desc->opcode_size/8;
- IIF(1,1,iif.instr_size,desc->opcode_seed,0,0,0,0,0,0,-1,0);
-
- /* this call encodes operands to iif format */
- if (argc) {
- encode_operand(argc,
- argv,
- &desc->operands[0],
- &suffix[0],
- desc->im_size,
- desc->opcode_size);
- }
- return recursive_level;
+ /* build opcode iif-entry */
+ iif.instr_size=desc->opcode_size/8;
+ IIF(1,1,iif.instr_size,desc->opcode_seed,0,0,0,0,0,0,-1,0);
+
+ /* this call encodes operands to iif format */
+ if (argc) {
+ encode_operand(argc,
+ argv,
+ &desc->operands[0],
+ &suffix[0],
+ desc->im_size,
+ desc->opcode_size);
+ }
+ return recursive_level;
}
@@ -1011,254 +1016,257 @@ int parse(line,recursive_level)
Note that iif was invented for the clean ns32k`s architecure.
*/
void convert_iif() {
- register int i,j;
- fragS *inst_frag;
- char *inst_offset,*inst_opcode;
- char *memP;
- segT segment;
- int l,k;
- register int rem_size; /* count the remaining bytes of instruction */
- register char type;
- register char size = 0;
- int size_so_far=0; /* used to calculate pcrel_adjust */
-
- rem_size=iif.instr_size;
- memP=frag_more(iif.instr_size); /* make sure we have enough bytes for instruction */
- inst_opcode=memP;
- inst_offset=(char*)(memP-frag_now->fr_literal);
- inst_frag=frag_now;
- for (i=0;i<IIF_ENTRIES;i++) {
- if (type=iif.iifP[i].type) { /* the object exist, so handle it */
- switch (size=iif.iifP[i].size) {
- case 42: size=0; /* it's a bitfix that operates on an existing object*/
- if (iif.iifP[i].bit_fixP->fx_bit_base) { /* expand fx_bit_base to point at opcode */
- iif.iifP[i].bit_fixP->fx_bit_base=(long)inst_opcode;
- }
- case 8: /* bignum or doublefloat */
- bzero (memP,8);
- case 1:case 2:case 3:case 4:/* the final size in objectmemory is known */
- j=(unsigned long)iif.iifP[i].bit_fixP;
- switch (type) {
- case 1: /* the object is pure binary */
- if (j || iif.iifP[i].pcrel) {
- fix_new_ns32k(frag_now,
- (long)(memP-frag_now->fr_literal),
- size,
- 0,
- 0,
- iif.iifP[i].object,
- iif.iifP[i].pcrel,
- (char)size_so_far, /*iif.iifP[i].pcrel_adjust,*/
- iif.iifP[i].im_disp,
- j,
- iif.iifP[i].bsr); /* sequent hack */
- } else { /* good, just put them bytes out */
- switch (iif.iifP[i].im_disp) {
- case 0:
- md_number_to_chars(memP,iif.iifP[i].object,size);break;
- case 1:
- md_number_to_disp(memP,iif.iifP[i].object,size);break;
- default: as_fatal("iif convert internal pcrel/binary");
- }
- }
- memP+=size;
- rem_size-=size;
- break;
- case 2: /* the object is a pointer at an expression, so unpack
- it, note that bignums may result from the expression
- */
- if ((segment=evaluate_expr(&exprP,(char*)iif.iifP[i].object))==SEG_BIG || size==8) {
- if ((k=exprP.X_add_number)>0) { /* we have a bignum ie a quad */
- /* this can only happens in a long suffixed instruction */
- bzero(memP,size); /* size normally is 8 */
- if (k*2>size) as_warn("Bignum too big for long");
- if (k==3) memP+=2;
- for (l=0;k>0;k--,l+=2) {
- md_number_to_chars(memP+l,generic_bignum[l>>1],sizeof(LITTLENUM_TYPE));
- }
- } else { /* flonum */
- LITTLENUM_TYPE words[4];
-
- switch(size) {
- case 4:
- gen_to_words(words,2,8);
- md_number_to_imm(memP ,(long)words[0],sizeof(LITTLENUM_TYPE));
- md_number_to_imm(memP+sizeof(LITTLENUM_TYPE),(long)words[1],sizeof(LITTLENUM_TYPE));
+ int i;
+ int j;
+ fragS *inst_frag;
+ char *inst_offset;
+ char **inst_opcode;
+ char *memP;
+ segT segment;
+ int l;
+ int k;
+ int rem_size; /* count the remaining bytes of instruction */
+ char type;
+ char size = 0;
+ int size_so_far = 0; /* used to calculate pcrel_adjust */
+
+ rem_size=iif.instr_size;
+ memP=frag_more(iif.instr_size); /* make sure we have enough bytes for instruction */
+ inst_opcode=memP;
+ inst_offset=(char*)(memP-frag_now->fr_literal);
+ inst_frag=frag_now;
+ for (i=0;i<IIF_ENTRIES;i++) {
+ if (type=iif.iifP[i].type) { /* the object exist, so handle it */
+ switch (size=iif.iifP[i].size) {
+ case 42: size=0; /* it's a bitfix that operates on an existing object*/
+ if (iif.iifP[i].bit_fixP->fx_bit_base) { /* expand fx_bit_base to point at opcode */
+ iif.iifP[i].bit_fixP->fx_bit_base=(long)inst_opcode;
+ }
+ case 8: /* bignum or doublefloat */
+ memset(memP, '\0', 8);
+ case 1:case 2:case 3:case 4:/* the final size in objectmemory is known */
+ j=(unsigned long)iif.iifP[i].bit_fixP;
+ switch (type) {
+ case 1: /* the object is pure binary */
+ if (j || iif.iifP[i].pcrel) {
+ fix_new_ns32k(frag_now,
+ (long)(memP-frag_now->fr_literal),
+ size,
+ 0,
+ 0,
+ iif.iifP[i].object,
+ iif.iifP[i].pcrel,
+ (char)size_so_far, /*iif.iifP[i].pcrel_adjust,*/
+ iif.iifP[i].im_disp,
+ j,
+ iif.iifP[i].bsr); /* sequent hack */
+ } else { /* good, just put them bytes out */
+ switch (iif.iifP[i].im_disp) {
+ case 0:
+ md_number_to_chars(memP,iif.iifP[i].object,size);break;
+ case 1:
+ md_number_to_disp(memP,iif.iifP[i].object,size);break;
+ default: as_fatal("iif convert internal pcrel/binary");
+ }
+ }
+ memP+=size;
+ rem_size-=size;
+ break;
+ case 2: /* the object is a pointer at an expression, so unpack
+ it, note that bignums may result from the expression
+ */
+ if ((segment=evaluate_expr(&exprP,(char*)iif.iifP[i].object))==SEG_BIG || size==8) {
+ if ((k=exprP.X_add_number)>0) { /* we have a bignum ie a quad */
+ /* this can only happens in a long suffixed instruction */
+ memset(memP, '\0', size); /* size normally is 8 */
+ if (k*2>size) as_warn("Bignum too big for long");
+ if (k==3) memP+=2;
+ for (l=0;k>0;k--,l+=2) {
+ md_number_to_chars(memP+l,generic_bignum[l>>1],sizeof(LITTLENUM_TYPE));
+ }
+ } else { /* flonum */
+ LITTLENUM_TYPE words[4];
+
+ switch(size) {
+ case 4:
+ gen_to_words(words,2,8);
+ md_number_to_imm(memP ,(long)words[0],sizeof(LITTLENUM_TYPE));
+ md_number_to_imm(memP+sizeof(LITTLENUM_TYPE),(long)words[1],sizeof(LITTLENUM_TYPE));
+ break;
+ case 8:
+ gen_to_words(words,4,11);
+ md_number_to_imm(memP ,(long)words[0],sizeof(LITTLENUM_TYPE));
+ md_number_to_imm(memP+sizeof(LITTLENUM_TYPE) ,(long)words[1],sizeof(LITTLENUM_TYPE));
+ md_number_to_imm(memP+2*sizeof(LITTLENUM_TYPE),(long)words[2],sizeof(LITTLENUM_TYPE));
+ md_number_to_imm(memP+3*sizeof(LITTLENUM_TYPE),(long)words[3],sizeof(LITTLENUM_TYPE));
+ break;
+ }
+ }
+ memP+=size;
+ rem_size-=size;
+ break;
+ }
+ if (j ||
+ exprP.X_add_symbol ||
+ exprP.X_subtract_symbol ||
+ iif.iifP[i].pcrel) { /* fixit */
+ /* the expression was undefined due to an undefined label */
+ /* create a fix so we can fix the object later */
+ exprP.X_add_number+=iif.iifP[i].object_adjust;
+ fix_new_ns32k(frag_now,
+ (long)(memP-frag_now->fr_literal),
+ size,
+ exprP.X_add_symbol,
+ exprP.X_subtract_symbol,
+ exprP.X_add_number,
+ iif.iifP[i].pcrel,
+ (char)size_so_far, /*iif.iifP[i].pcrel_adjust,*/
+ iif.iifP[i].im_disp,
+ j,
+ iif.iifP[i].bsr); /* sequent hack */
+
+ } else { /* good, just put them bytes out */
+ switch (iif.iifP[i].im_disp) {
+ case 0:
+ md_number_to_imm(memP,exprP.X_add_number,size);break;
+ case 1:
+ md_number_to_disp(memP,exprP.X_add_number,size);break;
+ default: as_fatal("iif convert internal pcrel/pointer");
+ }
+ }
+ memP+=size;
+ rem_size-=size;
+ break;
+ default: as_fatal("Internal logic error in iif.iifP[n].type");
+ }
break;
- case 8:
- gen_to_words(words,4,11);
- md_number_to_imm(memP ,(long)words[0],sizeof(LITTLENUM_TYPE));
- md_number_to_imm(memP+sizeof(LITTLENUM_TYPE) ,(long)words[1],sizeof(LITTLENUM_TYPE));
- md_number_to_imm(memP+2*sizeof(LITTLENUM_TYPE),(long)words[2],sizeof(LITTLENUM_TYPE));
- md_number_to_imm(memP+3*sizeof(LITTLENUM_TYPE),(long)words[3],sizeof(LITTLENUM_TYPE));
+ case 0: /* To bad, the object may be undefined as far as its final
+ nsize in object memory is concerned. The size of the object
+ in objectmemory is not explicitly given.
+ If the object is defined its length can be determined and
+ a fix can replace the frag.
+ */
+ {
+ int temp;
+ segment=evaluate_expr(&exprP,(char*)iif.iifP[i].object);
+ if ((exprP.X_add_symbol || exprP.X_subtract_symbol) &&
+ !iif.iifP[i].pcrel) { /* OVE: hack, clamp to 4 bytes */
+ size=4; /* we dont wan't to frag this, use 4 so it reaches */
+ fix_new_ns32k(frag_now,
+ (long)(memP-frag_now->fr_literal),
+ size,
+ exprP.X_add_symbol,
+ exprP.X_subtract_symbol,
+ exprP.X_add_number,
+ 0, /* never iif.iifP[i].pcrel, */
+ (char)size_so_far, /*iif.iifP[i].pcrel_adjust,*/
+ 1, /* always iif.iifP[i].im_disp, */
+ 0,0);
+ memP+=size;
+ rem_size-=4;
+ break; /* exit this absolute hack */
+ }
+
+ if (exprP.X_add_symbol || exprP.X_subtract_symbol) { /* frag it */
+ if (exprP.X_subtract_symbol) { /* We cant relax this case */
+ as_fatal("Can't relax difference");
+ }
+ else {
+ /* at this stage we must undo some of the effect caused
+ by frag_more, ie we must make sure that frag_var causes
+ frag_new to creat a valid fix-size in the frag it`s closing
+ */
+ temp = -(rem_size-4);
+ obstack_blank_fast(&frags,temp);
+ /* we rewind none, some or all of the requested size we
+ requested by the first frag_more for this iif chunk.
+ Note: that we allocate 4 bytes to an object we NOT YET
+ know the size of, thus rem_size-4.
+ */
+ (void)frag_variant(rs_machine_dependent,
+ 4,
+ 0,
+ IND(BRANCH,UNDEF), /* expecting the worst */
+ exprP.X_add_symbol,
+ exprP.X_add_number,
+ (char*)inst_opcode,
+ (char)size_so_far, /*iif.iifP[i].pcrel_adjust);*/
+ iif.iifP[i].bsr); /* sequent linker hack */
+ rem_size-=4;
+ if (rem_size>0) {
+ memP=frag_more(rem_size);
+ }
+ }
+ }
+ else {/* Double work, this is done in md_number_to_disp */
+ /* exprP.X_add_number; what was this supposed to be?
+ xoxorich. */
+ if (-64<=exprP.X_add_number && exprP.X_add_number<=63) {
+ size=1;
+ } else {
+ if (-8192<=exprP.X_add_number && exprP.X_add_number<=8191) {
+ size=2;
+ } else {
+ if (-0x1f000000<=exprP.X_add_number &&
+ exprP.X_add_number<=0x1fffffff)
+ /* if (-0x40000000<=exprP.X_add_number &&
+ exprP.X_add_number<=0x3fffffff) */
+ {
+ size=4;
+ } else {
+ as_warn("Displacement to large for :d");
+ size=4;
+ }
+ }
+ }
+ /* rewind the bytes not used */
+ temp = -(4-size);
+ md_number_to_disp(memP,exprP.X_add_number,size);
+ obstack_blank_fast(&frags,temp);
+ memP+=size;
+ rem_size-=4; /* we allocated this amount */
+ }
+ }
break;
- }
- }
- memP+=size;
- rem_size-=size;
- break;
- }
- if (j ||
- exprP.X_add_symbol ||
- exprP.X_subtract_symbol ||
- iif.iifP[i].pcrel) { /* fixit */
- /* the expression was undefined due to an undefined label */
- /* create a fix so we can fix the object later */
- exprP.X_add_number+=iif.iifP[i].object_adjust;
- fix_new_ns32k(frag_now,
- (long)(memP-frag_now->fr_literal),
- size,
- exprP.X_add_symbol,
- exprP.X_subtract_symbol,
- exprP.X_add_number,
- iif.iifP[i].pcrel,
- (char)size_so_far, /*iif.iifP[i].pcrel_adjust,*/
- iif.iifP[i].im_disp,
- j,
- iif.iifP[i].bsr); /* sequent hack */
-
- } else { /* good, just put them bytes out */
- switch (iif.iifP[i].im_disp) {
- case 0:
- md_number_to_imm(memP,exprP.X_add_number,size);break;
- case 1:
- md_number_to_disp(memP,exprP.X_add_number,size);break;
- default: as_fatal("iif convert internal pcrel/pointer");
- }
- }
- memP+=size;
- rem_size-=size;
- break;
- default: as_fatal("Internal logic error in iif.iifP[n].type");
- }
- break;
- case 0: /* To bad, the object may be undefined as far as its final
- nsize in object memory is concerned. The size of the object
- in objectmemory is not explicitly given.
- If the object is defined its length can be determined and
- a fix can replace the frag.
- */
- {
- int temp;
- segment=evaluate_expr(&exprP,(char*)iif.iifP[i].object);
- if ((exprP.X_add_symbol || exprP.X_subtract_symbol) &&
- !iif.iifP[i].pcrel) { /* OVE: hack, clamp to 4 bytes */
- size=4; /* we dont wan't to frag this, use 4 so it reaches */
- fix_new_ns32k(frag_now,
- (long)(memP-frag_now->fr_literal),
- size,
- exprP.X_add_symbol,
- exprP.X_subtract_symbol,
- exprP.X_add_number,
- 0, /* never iif.iifP[i].pcrel, */
- (char)size_so_far, /*iif.iifP[i].pcrel_adjust,*/
- 1, /* always iif.iifP[i].im_disp, */
- 0,0);
- memP+=size;
- rem_size-=4;
- break; /* exit this absolute hack */
- }
-
- if (exprP.X_add_symbol || exprP.X_subtract_symbol) { /* frag it */
- if (exprP.X_subtract_symbol) { /* We cant relax this case */
- as_fatal("Can't relax difference");
- }
- else {
- /* at this stage we must undo some of the effect caused
- by frag_more, ie we must make sure that frag_var causes
- frag_new to creat a valid fix-size in the frag it`s closing
- */
- temp = -(rem_size-4);
- obstack_blank_fast(&frags,temp);
- /* we rewind none, some or all of the requested size we
- requested by the first frag_more for this iif chunk.
- Note: that we allocate 4 bytes to an object we NOT YET
- know the size of, thus rem_size-4.
- */
- (void)frag_variant(rs_machine_dependent,
- 4,
- 0,
- IND(BRANCH,UNDEF), /* expecting the worst */
- exprP.X_add_symbol,
- exprP.X_add_number,
- (char*)inst_opcode,
- (char)size_so_far, /*iif.iifP[i].pcrel_adjust);*/
- iif.iifP[i].bsr); /* sequent linker hack */
- rem_size-=4;
- if (rem_size>0) {
- memP=frag_more(rem_size);
- }
- }
- }
- else {/* Double work, this is done in md_number_to_disp */
- /* exprP.X_add_number; what was this supposed to be?
- xoxorich. */
- if (-64<=exprP.X_add_number && exprP.X_add_number<=63) {
- size=1;
- } else {
- if (-8192<=exprP.X_add_number && exprP.X_add_number<=8191) {
- size=2;
- } else {
- if (-0x1f000000<=exprP.X_add_number &&
- exprP.X_add_number<=0x1fffffff)
- /* if (-0x40000000<=exprP.X_add_number &&
- exprP.X_add_number<=0x3fffffff) */
- {
- size=4;
- } else {
- as_warn("Displacement to large for :d");
- size=4;
- }
+ default:
+ as_fatal("Internal logic error in iif.iifP[].type");
}
- }
- /* rewind the bytes not used */
- temp = -(4-size);
- md_number_to_disp(memP,exprP.X_add_number,size);
- obstack_blank_fast(&frags,temp);
- memP+=size;
- rem_size-=4; /* we allocated this amount */
+ size_so_far+=size;
+ size=0;
}
- }
- break;
- default:
- as_fatal("Internal logic error in iif.iifP[].type");
- }
- size_so_far+=size;
- size=0;
}
- }
}
void md_assemble(line)
- char *line;
+char *line;
{
- freeptr=freeptr_static;
- parse(line,0); /* explode line to more fix form in iif */
- convert_iif(); /* convert iif to frags, fix's etc */
+ freeptr=freeptr_static;
+ parse(line,0); /* explode line to more fix form in iif */
+ convert_iif(); /* convert iif to frags, fix's etc */
#ifdef SHOW_NUM
- printf(" \t\t\t%s\n",line);
+ printf(" \t\t\t%s\n",line);
#endif
}
void md_begin() {
- /* build a hashtable of the instructions */
- register const struct ns32k_opcode *ptr;
- register char *stat;
- inst_hash_handle=hash_new();
- for (ptr=ns32k_opcodes;ptr<endop;ptr++) {
- if (*(stat=hash_insert(inst_hash_handle,ptr->name,(char*)ptr))) {
- as_fatal("Can't hash %s: %s", ptr->name,stat); /*fatal*/
- exit(0);
+ /* build a hashtable of the instructions */
+ register const struct ns32k_opcode *ptr;
+ register char *stat;
+ inst_hash_handle=hash_new();
+ for (ptr=ns32k_opcodes;ptr<endop;ptr++) {
+ if (*(stat=hash_insert(inst_hash_handle,ptr->name,(char*)ptr))) {
+ as_fatal("Can't hash %s: %s", ptr->name,stat); /*fatal*/
+ exit(0);
+ }
}
- }
- freeptr_static=(char*)malloc(PRIVATE_SIZE); /* some private space please! */
+ freeptr_static=(char*)malloc(PRIVATE_SIZE); /* some private space please! */
}
void
md_end() {
- free(freeptr_static);
+ free(freeptr_static);
}
/* Must be equal to MAX_PRECISON in atof-ieee.c */
@@ -1274,54 +1282,51 @@ char type;
char *litP;
int *sizeP;
{
- int prec;
- LITTLENUM_TYPE words[MAX_LITTLENUMS];
- LITTLENUM_TYPE *wordP;
- char *t;
-
- switch(type) {
- case 'f':
- prec = 2;
- break;
+ int prec;
+ LITTLENUM_TYPE words[MAX_LITTLENUMS];
+ LITTLENUM_TYPE *wordP;
+ char *t;
- case 'd':
- prec = 4;
- break;
- default:
- *sizeP=0;
- return "Bad call to MD_ATOF()";
- }
- t=atof_ieee(input_line_pointer,type,words);
- if(t)
- input_line_pointer=t;
-
- *sizeP=prec * sizeof(LITTLENUM_TYPE);
- for(wordP=words+prec;prec--;) {
- md_number_to_chars(litP,(long)(*--wordP),sizeof(LITTLENUM_TYPE));
- litP+=sizeof(LITTLENUM_TYPE);
- }
- return ""; /* Someone should teach Dean about null pointers */
+ switch(type) {
+ case 'f':
+ prec = 2;
+ break;
+
+ case 'd':
+ prec = 4;
+ break;
+ default:
+ *sizeP=0;
+ return "Bad call to MD_ATOF()";
+ }
+ t=atof_ieee(input_line_pointer,type,words);
+ if(t)
+ input_line_pointer=t;
+
+ *sizeP=prec * sizeof(LITTLENUM_TYPE);
+ for(wordP=words+prec;prec--;) {
+ md_number_to_chars(litP,(long)(*--wordP),sizeof(LITTLENUM_TYPE));
+ litP+=sizeof(LITTLENUM_TYPE);
+ }
+ return ""; /* Someone should teach Dean about null pointers */
}
/* Convert number to chars in correct order */
void
md_number_to_chars (buf, value, nbytes)
-char *buf;
-long value;
-int nbytes;
+char *buf;
+long value;
+int nbytes;
{
- while (nbytes--)
- {
+ while (nbytes--) {
#ifdef SHOW_NUM
- printf("%x ",value & 0xff);
+ printf("%x ",value & 0xff);
#endif
- *buf++ = value; /* Lint wants & MASK_CHAR. */
- value >>= BITS_PER_CHAR;
- }
-}
-/* Convert number to chars in correct order */
-
+ *buf++ = value; /* Lint wants & MASK_CHAR. */
+ value >>= BITS_PER_CHAR;
+ }
+} /* md_number_to_chars() */
/* This is a variant of md_numbers_to_chars. The reason for its' existence
@@ -1329,111 +1334,112 @@ int nbytes;
that the bit order is reversed in displacements and that they are prefixed
with a size-tag.
- binary: msb -> lsb 0xxxxxxx byte
+ binary: msb -> lsb
+ 0xxxxxxx byte
10xxxxxx xxxxxxxx word
11xxxxxx xxxxxxxx xxxxxxxx xxxxxxxx double word
This must be taken care of and we do it here!
*/
-static void md_number_to_disp(buf,val,n)
- char *buf;
- long val;
- char n;
+static void md_number_to_disp(buf, val, n)
+char *buf;
+long val;
+char n;
{
- switch(n) {
- case 1:
- if (val < -64 || val > 63)
- as_warn("Byte displacement out of range. line number not valid");
- val&=0x7f;
+ switch(n) {
+ case 1:
+ if (val < -64 || val > 63)
+ as_warn("Byte displacement out of range. line number not valid");
+ val&=0x7f;
#ifdef SHOW_NUM
- printf("%x ",val & 0xff);
+ printf("%x ",val & 0xff);
#endif
- *buf++=val;
- break;
- case 2:
- if (val < -8192 || val > 8191)
- as_warn("Word displacement out of range. line number not valid");
- val&=0x3fff;
- val|=0x8000;
+ *buf++=val;
+ break;
+ case 2:
+ if (val < -8192 || val > 8191)
+ as_warn("Word displacement out of range. line number not valid");
+ val&=0x3fff;
+ val|=0x8000;
#ifdef SHOW_NUM
- printf("%x ",val>>8 & 0xff);
+ printf("%x ",val>>8 & 0xff);
#endif
- *buf++=(val>>8);
+ *buf++=(val>>8);
#ifdef SHOW_NUM
- printf("%x ",val & 0xff);
+ printf("%x ",val & 0xff);
#endif
- *buf++=val;
- break;
- case 4:
- if (val < -0x1f000000 || val >= 0x20000000)
- /* if (val < -0x20000000 || val >= 0x20000000) */
- as_warn("Double word displacement out of range");
- val|=0xc0000000;
+ *buf++=val;
+ break;
+ case 4:
+ if (val < -0x1f000000 || val >= 0x20000000)
+ /* if (val < -0x20000000 || val >= 0x20000000) */
+ as_warn("Double word displacement out of range");
+ val|=0xc0000000;
#ifdef SHOW_NUM
- printf("%x ",val>>24 & 0xff);
+ printf("%x ",val>>24 & 0xff);
#endif
- *buf++=(val>>24);
+ *buf++=(val>>24);
#ifdef SHOW_NUM
- printf("%x ",val>>16 & 0xff);
+ printf("%x ",val>>16 & 0xff);
#endif
- *buf++=(val>>16);
+ *buf++=(val>>16);
#ifdef SHOW_NUM
- printf("%x ",val>>8 & 0xff);
+ printf("%x ",val>>8 & 0xff);
#endif
- *buf++=(val>>8);
+ *buf++=(val>>8);
#ifdef SHOW_NUM
- printf("%x ",val & 0xff);
+ printf("%x ",val & 0xff);
#endif
- *buf++=val;
- break;
- default:
- as_fatal("Internal logic error. line %s, file \"%s\"", __LINE__, __FILE__);
- }
+ *buf++=val;
+ break;
+ default:
+ as_fatal("Internal logic error. line %s, file \"%s\"", __LINE__, __FILE__);
+ }
}
static void md_number_to_imm(buf,val,n)
- char *buf;
- long val;
- char n;
+char *buf;
+long val;
+char n;
{
- switch(n) {
- case 1:
+ switch(n) {
+ case 1:
#ifdef SHOW_NUM
- printf("%x ",val & 0xff);
+ printf("%x ",val & 0xff);
#endif
- *buf++=val;
- break;
- case 2:
+ *buf++=val;
+ break;
+ case 2:
#ifdef SHOW_NUM
- printf("%x ",val>>8 & 0xff);
+ printf("%x ",val>>8 & 0xff);
#endif
- *buf++=(val>>8);
+ *buf++=(val>>8);
#ifdef SHOW_NUM
- printf("%x ",val & 0xff);
+ printf("%x ",val & 0xff);
#endif
- *buf++=val;
- break;
- case 4:
+ *buf++=val;
+ break;
+ case 4:
#ifdef SHOW_NUM
- printf("%x ",val>>24 & 0xff);
+ printf("%x ",val>>24 & 0xff);
#endif
- *buf++=(val>>24);
+ *buf++=(val>>24);
#ifdef SHOW_NUM
- printf("%x ",val>>16 & 0xff);
+ printf("%x ",val>>16 & 0xff);
#endif
- *buf++=(val>>16);
+ *buf++=(val>>16);
#ifdef SHOW_NUM
- printf("%x ",val>>8 & 0xff);
+ printf("%x ",val>>8 & 0xff);
#endif
- *buf++=(val>>8);
+ *buf++=(val>>8);
#ifdef SHOW_NUM
- printf("%x ",val & 0xff);
+ printf("%x ",val & 0xff);
#endif
- *buf++=val;
- break;
- default:
- as_fatal("Internal logic error. line %s, file \"%s\"", __LINE__, __FILE__);
- }
+ *buf++=val;
+ break;
+ default:
+ as_fatal("Internal logic error. line %s, file \"%s\"", __LINE__, __FILE__);
+ }
}
/* Translate internal representation of relocation info into target format.
@@ -1447,24 +1453,25 @@ static void md_number_to_imm(buf,val,n)
This md_ri.... is tailored for sequent.
*/
+#ifdef comment
void
md_ri_to_chars(the_bytes, ri)
char *the_bytes;
struct reloc_info_generic *ri;
{
- if (ri->r_bsr) {ri->r_pcrel=0;} /* sequent seems to want this */
- md_number_to_chars(the_bytes, ri->r_address, sizeof(ri->r_address));
- md_number_to_chars(the_bytes+4,
- (long)(ri->r_symbolnum ) |
- (long)(ri->r_pcrel << 24 ) |
- (long)(ri->r_length << 25 ) |
- (long)(ri->r_extern << 27 ) |
- (long)(ri->r_bsr << 28 ) |
- (long)(ri->r_disp << 29 ),
- 4);
- /* the first and second md_number_to_chars never overlaps (32bit cpu case) */
+ if (ri->r_bsr) { ri->r_pcrel = 0; } /* sequent seems to want this */
+ md_number_to_chars(the_bytes, ri->r_address, sizeof(ri->r_address));
+ md_number_to_chars(the_bytes+4, ((long)(ri->r_symbolnum )
+ | (long)(ri->r_pcrel << 24 )
+ | (long)(ri->r_length << 25 )
+ | (long)(ri->r_extern << 27 )
+ | (long)(ri->r_bsr << 28 )
+ | (long)(ri->r_disp << 29 )),
+ 4);
+ /* the first and second md_number_to_chars never overlaps (32bit cpu case) */
}
-
+#endif /* comment */
+
/* fast bitfiddling support */
/* mask used to zero bitfield before oring in the true field */
@@ -1476,7 +1483,7 @@ static unsigned long l_mask[]={ 0xffffffff, 0xfffffffe, 0xfffffffc, 0xfffffff8,
0xfff00000, 0xffe00000, 0xffc00000, 0xff800000,
0xff000000, 0xfe000000, 0xfc000000, 0xf8000000,
0xf0000000, 0xe0000000, 0xc0000000, 0x80000000,
- };
+ };
static unsigned long r_mask[]={ 0x00000000, 0x00000001, 0x00000003, 0x00000007,
0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f,
0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff,
@@ -1485,7 +1492,7 @@ static unsigned long r_mask[]={ 0x00000000, 0x00000001, 0x00000003, 0x00000007,
0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff,
0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff,
0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff,
- };
+ };
#define MASK_BITS 31
/* Insert bitfield described by field_ptr and val at buf
This routine is written for modification of the first 4 bytes pointed
@@ -1500,62 +1507,62 @@ register char *buf;
register long val;
register bit_fixS *field_ptr;
{
- register unsigned long object;
- register unsigned long mask;
- /* define ENDIAN on a ns32k machine */
+ register unsigned long object;
+ register unsigned long mask;
+ /* define ENDIAN on a ns32k machine */
#ifdef ENDIAN
- register unsigned long *mem_ptr;
+ register unsigned long *mem_ptr;
#else
- register char *mem_ptr;
+ register char *mem_ptr;
#endif
- if (field_ptr->fx_bit_min<=val && val<=field_ptr->fx_bit_max) {
+ if (field_ptr->fx_bit_min<=val && val<=field_ptr->fx_bit_max) {
#ifdef ENDIAN
- if (field_ptr->fx_bit_base) { /* override buf */
- mem_ptr=(unsigned long*)field_ptr->fx_bit_base;
- } else {
- mem_ptr=(unsigned long*)buf;
- }
+ if (field_ptr->fx_bit_base) { /* override buf */
+ mem_ptr=(unsigned long*)field_ptr->fx_bit_base;
+ } else {
+ mem_ptr=(unsigned long*)buf;
+ }
#else
- if (field_ptr->fx_bit_base) { /* override buf */
- mem_ptr=(char*)field_ptr->fx_bit_base;
- } else {
- mem_ptr=buf;
- }
+ if (field_ptr->fx_bit_base) { /* override buf */
+ mem_ptr=(char*)field_ptr->fx_bit_base;
+ } else {
+ mem_ptr=buf;
+ }
#endif
- mem_ptr+=field_ptr->fx_bit_base_adj;
+ mem_ptr+=field_ptr->fx_bit_base_adj;
#ifdef ENDIAN /* we have a nice ns32k machine with lowbyte at low-physical mem */
- object = *mem_ptr; /* get some bytes */
+ object = *mem_ptr; /* get some bytes */
#else /* OVE Goof! the machine is a m68k or dito */
- /* That takes more byte fiddling */
- object=0;
- object|=mem_ptr[3] & 0xff;
- object<<=8;
- object|=mem_ptr[2] & 0xff;
- object<<=8;
- object|=mem_ptr[1] & 0xff;
- object<<=8;
- object|=mem_ptr[0] & 0xff;
+ /* That takes more byte fiddling */
+ object=0;
+ object|=mem_ptr[3] & 0xff;
+ object<<=8;
+ object|=mem_ptr[2] & 0xff;
+ object<<=8;
+ object|=mem_ptr[1] & 0xff;
+ object<<=8;
+ object|=mem_ptr[0] & 0xff;
#endif
- mask=0;
- mask|=(r_mask[field_ptr->fx_bit_offset]);
- mask|=(l_mask[field_ptr->fx_bit_offset+field_ptr->fx_bit_size]);
- object&=mask;
- val+=field_ptr->fx_bit_add;
- object|=((val<<field_ptr->fx_bit_offset) & (mask ^ 0xffffffff));
+ mask=0;
+ mask|=(r_mask[field_ptr->fx_bit_offset]);
+ mask|=(l_mask[field_ptr->fx_bit_offset+field_ptr->fx_bit_size]);
+ object&=mask;
+ val+=field_ptr->fx_bit_add;
+ object|=((val<<field_ptr->fx_bit_offset) & (mask ^ 0xffffffff));
#ifdef ENDIAN
- *mem_ptr=object;
+ *mem_ptr=object;
#else
- mem_ptr[0]=(char)object;
- object>>=8;
- mem_ptr[1]=(char)object;
- object>>=8;
- mem_ptr[2]=(char)object;
- object>>=8;
- mem_ptr[3]=(char)object;
+ mem_ptr[0]=(char)object;
+ object>>=8;
+ mem_ptr[1]=(char)object;
+ object>>=8;
+ mem_ptr[2]=(char)object;
+ object>>=8;
+ mem_ptr[3]=(char)object;
#endif
- } else {
- as_warn("Bit field out of range");
- }
+ } else {
+ as_warn("Bit field out of range");
+ }
}
/* Apply a fixS (fixup of an instruction or data that we didn't have
@@ -1570,26 +1577,26 @@ void
fixS *fixP;
long val;
{
- char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
-
- if (fixP->fx_bit_fixP) { /* Bitfields to fix, sigh */
- md_number_to_field (buf, val, fixP->fx_bit_fixP);
- } else switch (fixP->fx_im_disp) {
-
- case 0: /* Immediate field */
- md_number_to_imm (buf, val, fixP->fx_size);
- break;
+ char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
- case 1: /* Displacement field */
- md_number_to_disp (buf,
- fixP->fx_pcrel? val + fixP->fx_pcrel_adjust: val,
- fixP->fx_size);
- break;
-
- case 2: /* Pointer in a data object */
- md_number_to_chars (buf, val, fixP->fx_size);
- break;
- }
+ if (fixP->fx_bit_fixP) { /* Bitfields to fix, sigh */
+ md_number_to_field (buf, val, fixP->fx_bit_fixP);
+ } else switch (fixP->fx_im_disp) {
+
+ case 0: /* Immediate field */
+ md_number_to_imm (buf, val, fixP->fx_size);
+ break;
+
+ case 1: /* Displacement field */
+ md_number_to_disp (buf,
+ fixP->fx_pcrel? val + fixP->fx_pcrel_adjust: val,
+ fixP->fx_size);
+ break;
+
+ case 2: /* Pointer in a data object */
+ md_number_to_chars (buf, val, fixP->fx_size);
+ break;
+ }
}
/* Convert a relaxed displacement to ditto in final output */
@@ -1599,35 +1606,35 @@ void
object_headers *headers;
register fragS *fragP;
{
- long disp;
- long ext;
-
- /* Address in gas core of the place to store the displacement. */
- register char *buffer_address = fragP -> fr_fix + fragP -> fr_literal;
- /* Address in object code of the displacement. */
- register int object_address = fragP -> fr_fix + fragP -> fr_address;
-
- know(fragP->fr_symbol);
-
- /* The displacement of the address, from current location. */
- disp = (S_GET_VALUE(fragP->fr_symbol) + fragP->fr_offset) - object_address;
- disp+= fragP->fr_pcrel_adjust;
-
- switch(fragP->fr_subtype) {
- case IND(BRANCH,BYTE):
- ext=1;
- break;
+ long disp;
+ long ext = 0;
+
+ /* Address in gas core of the place to store the displacement. */
+ register char *buffer_address = fragP->fr_fix + fragP->fr_literal;
+ /* Address in object code of the displacement. */
+ register int object_address = fragP->fr_fix + fragP->fr_address;
+
+ know(fragP->fr_symbol);
+
+ /* The displacement of the address, from current location. */
+ disp = (S_GET_VALUE(fragP->fr_symbol) + fragP->fr_offset) - object_address;
+ disp+= fragP->fr_pcrel_adjust;
+
+ switch(fragP->fr_subtype) {
+ case IND(BRANCH,BYTE):
+ ext=1;
+ break;
case IND(BRANCH,WORD):
ext=2;
- break;
+ break;
case IND(BRANCH,DOUBLE):
ext=4;
- break;
- }
- if(ext) {
- md_number_to_disp(buffer_address,(long)disp,(int)ext);
- fragP->fr_fix+=ext;
+ break;
}
+ if(ext) {
+ md_number_to_disp(buffer_address,(long)disp,(int)ext);
+ fragP->fr_fix+=ext;
+ }
}
@@ -1637,42 +1644,42 @@ register fragS *fragP;
actually know it */
int md_estimate_size_before_relax(fragP, segment)
- register fragS *fragP;
- segT segment;
+register fragS *fragP;
+segT segment;
{
- int old_fix;
- old_fix=fragP->fr_fix;
- switch(fragP->fr_subtype) {
- case IND(BRANCH,UNDEF):
- if(S_GET_SEGMENT(fragP->fr_symbol) == segment) {
- /* the symbol has been assigned a value */
- fragP->fr_subtype=IND(BRANCH,BYTE);
- } else {
- /* we don't relax symbols defined in an other segment
- the thing to do is to assume the object will occupy 4 bytes */
- fix_new_ns32k(fragP,
- (int)(fragP->fr_fix),
- 4,
- fragP->fr_symbol,
- (symbolS *)0,
- fragP->fr_offset,
- 1,
- fragP->fr_pcrel_adjust,
- 1,
- 0,
- fragP->fr_bsr); /*sequent hack */
- fragP->fr_fix+=4;
- /* fragP->fr_opcode[1]=0xff; */
- frag_wane(fragP);
- break;
- }
+ int old_fix;
+ old_fix=fragP->fr_fix;
+ switch(fragP->fr_subtype) {
+ case IND(BRANCH,UNDEF):
+ if(S_GET_SEGMENT(fragP->fr_symbol) == segment) {
+ /* the symbol has been assigned a value */
+ fragP->fr_subtype=IND(BRANCH,BYTE);
+ } else {
+ /* we don't relax symbols defined in an other segment
+ the thing to do is to assume the object will occupy 4 bytes */
+ fix_new_ns32k(fragP,
+ (int)(fragP->fr_fix),
+ 4,
+ fragP->fr_symbol,
+ (symbolS *)0,
+ fragP->fr_offset,
+ 1,
+ fragP->fr_pcrel_adjust,
+ 1,
+ 0,
+ fragP->fr_bsr); /*sequent hack */
+ fragP->fr_fix+=4;
+ /* fragP->fr_opcode[1]=0xff; */
+ frag_wane(fragP);
+ break;
+ }
case IND(BRANCH,BYTE):
fragP->fr_var+=1;
- break;
+ break;
default:
- break;
+ break;
}
- return fragP->fr_var + fragP->fr_fix - old_fix;
+ return fragP->fr_var + fragP->fr_fix - old_fix;
}
int md_short_jump_size = 3;
@@ -1687,11 +1694,11 @@ long from_addr,
fragS *frag;
symbolS *to_symbol;
{
- long offset;
-
- offset = to_addr - from_addr;
- md_number_to_chars(ptr, (long)0xEA ,1);
- md_number_to_disp(ptr+1,(long)offset,2);
+ long offset;
+
+ offset = to_addr - from_addr;
+ md_number_to_chars(ptr, (long)0xEA ,1);
+ md_number_to_disp(ptr+1,(long)offset,2);
}
void
@@ -1702,11 +1709,11 @@ long from_addr,
fragS *frag;
symbolS *to_symbol;
{
- long offset;
-
- offset= to_addr - from_addr;
- md_number_to_chars(ptr, (long)0xEA, 2);
- md_number_to_disp(ptr+2,(long)offset,4);
+ long offset;
+
+ offset= to_addr - from_addr;
+ md_number_to_chars(ptr, (long)0xEA, 2);
+ md_number_to_disp(ptr+2,(long)offset,4);
}
/* JF this is a new function to parse machine-dep options */
@@ -1716,27 +1723,27 @@ char **argP;
int *cntP;
char ***vecP;
{
- switch(**argP) {
- case 'm':
- (*argP)++;
-
- if(!strcmp(*argP,"32032")) {
- cpureg = cpureg_032;
- mmureg = mmureg_032;
- } else if(!strcmp(*argP, "32532")) {
- cpureg = cpureg_532;
- mmureg = mmureg_532;
- } else
- as_warn("Unknown -m option ignored");
-
- while(**argP)
- (*argP)++;
- break;
-
- default:
- return 0;
- }
- return 1;
+ switch(**argP) {
+ case 'm':
+ (*argP)++;
+
+ if(!strcmp(*argP,"32032")) {
+ cpureg = cpureg_032;
+ mmureg = mmureg_032;
+ } else if(!strcmp(*argP, "32532")) {
+ cpureg = cpureg_532;
+ mmureg = mmureg_532;
+ } else
+ as_warn("Unknown -m option ignored");
+
+ while(**argP)
+ (*argP)++;
+ break;
+
+ default:
+ return 0;
+ }
+ return 1;
}
/*
@@ -1746,64 +1753,54 @@ char ***vecP;
* This struct is used to profile the normal fix. If the bit_fixP is a
* valid pointer (not NULL) the bit_fix data will be used to format the fix.
*/
-bit_fixS *bit_fix_new (size,offset,min,max,add,base_type,base_adj)
- char size; /* Length of bitfield */
- char offset; /* Bit offset to bitfield */
- long base_type; /* 0 or 1, if 1 it's exploded to opcode ptr */
- long base_adj;
- long min; /* Signextended min for bitfield */
- long max; /* Signextended max for bitfield */
- long add; /* Add mask, used for huffman prefix */
+bit_fixS *bit_fix_new(size, offset, min, max, add, base_type, base_adj)
+char size; /* Length of bitfield */
+char offset; /* Bit offset to bitfield */
+long base_type; /* 0 or 1, if 1 it's exploded to opcode ptr */
+long base_adj;
+long min; /* Signextended min for bitfield */
+long max; /* Signextended max for bitfield */
+long add; /* Add mask, used for huffman prefix */
{
- register bit_fixS * bit_fixP;
-
- bit_fixP = (bit_fixS *)obstack_alloc(&notes,sizeof(bit_fixS));
-
- bit_fixP -> fx_bit_size = size;
- bit_fixP -> fx_bit_offset = offset;
- bit_fixP -> fx_bit_base = base_type;
- bit_fixP -> fx_bit_base_adj = base_adj;
- bit_fixP -> fx_bit_max = max;
- bit_fixP -> fx_bit_min = min;
- bit_fixP -> fx_bit_add = add;
-
- return bit_fixP;
+ register bit_fixS * bit_fixP;
+
+ bit_fixP = (bit_fixS *)obstack_alloc(&notes,sizeof(bit_fixS));
+
+ bit_fixP->fx_bit_size = size;
+ bit_fixP->fx_bit_offset = offset;
+ bit_fixP->fx_bit_base = base_type;
+ bit_fixP->fx_bit_base_adj = base_adj;
+ bit_fixP->fx_bit_max = max;
+ bit_fixP->fx_bit_min = min;
+ bit_fixP->fx_bit_add = add;
+
+ return(bit_fixP);
}
void
- fix_new_ns32k (frag, where, size, add_symbol, sub_symbol, offset, pcrel,
+ fix_new_ns32k(frag, where, size, add_symbol, sub_symbol, offset, pcrel,
pcrel_adjust, im_disp, bit_fixP, bsr)
-fragS * frag; /* Which frag? */
-int where; /* Where in that frag? */
-short int size; /* 1, 2 or 4 usually. */
-symbolS * add_symbol; /* X_add_symbol. */
-symbolS * sub_symbol; /* X_subtract_symbol. */
-long offset; /* X_add_number. */
-int pcrel; /* TRUE if PC-relative relocation. */
-char pcrel_adjust; /* not zero if adjustment of pcrel offset is needed */
-char im_disp; /* true if the value to write is a displacement */
-bit_fixS *bit_fixP; /* pointer at struct of bit_fix's, ignored if NULL */
-char bsr; /* sequent-linker-hack: 1 when relocobject is a bsr */
+fragS *frag; /* Which frag? */
+int where; /* Where in that frag? */
+int size; /* 1, 2 or 4 usually. */
+symbolS *add_symbol; /* X_add_symbol. */
+symbolS *sub_symbol; /* X_subtract_symbol. */
+long offset; /* X_add_number. */
+int pcrel; /* TRUE if PC-relative relocation. */
+char pcrel_adjust; /* not zero if adjustment of pcrel offset is needed */
+char im_disp; /* true if the value to write is a displacement */
+bit_fixS *bit_fixP; /* pointer at struct of bit_fix's, ignored if NULL */
+char bsr; /* sequent-linker-hack: 1 when relocobject is a bsr */
{
- register fixS * fixP;
-
- fixP = (fixS *)obstack_alloc(&notes,sizeof(fixS));
- fixP -> fx_frag = frag;
- fixP -> fx_where = where;
- fixP -> fx_size = size;
- fixP -> fx_addsy = add_symbol;
- fixP -> fx_subsy = sub_symbol;
- fixP -> fx_offset = offset;
- fixP -> fx_pcrel = pcrel;
- fixP -> fx_pcrel_adjust = pcrel_adjust;
- fixP -> fx_im_disp = im_disp;
- fixP -> fx_bit_fixP = bit_fixP;
- fixP -> fx_bsr = bsr;
- fixP -> fx_next = * seg_fix_rootP;
-
- * seg_fix_rootP = fixP;
-}
+ fixS *fixP = fix_new(frag, where, size, add_symbol, sub_symbol,
+ offset, pcrel, NO_RELOC);
+
+ fixP->fx_pcrel_adjust = pcrel_adjust;
+ fixP->fx_im_disp = im_disp;
+ fixP->fx_bit_fixP = bit_fixP;
+ fixP->fx_bsr = bsr;
+} /* fix_new_ns32k() */
/* We have no need to default values of symbols. */
@@ -1811,7 +1808,7 @@ symbolS *
md_undefined_symbol (name)
char *name;
{
- return 0;
+ return 0;
}
/* Parse an operand that is machine-specific.
@@ -1831,7 +1828,7 @@ long
segT segment;
long size;
{
- return size; /* Byte alignment is fine */
+ return size; /* Byte alignment is fine */
}
/* Exactly what point is a PC-relative offset relative TO?
@@ -1842,13 +1839,18 @@ long
md_pcrel_from (fixP)
fixS *fixP;
{
- long res;
- res = fixP->fx_where + fixP->fx_frag->fr_address;
+ long res;
+ res = fixP->fx_where + fixP->fx_frag->fr_address;
#ifdef SEQUENT_COMPATABILITY
- if (fixP->fx_frag->fr_bsr)
- res += 0x12 /* FOO Kludge alert! */
+ if (fixP->fx_frag->fr_bsr)
+ res += 0x12 /* FOO Kludge alert! */
#endif
- return res;
+ return res;
+}
+
+void tc_aout_fix_to_chars(char *where, struct fix *fixP,
+ relax_addressT segment_address) {
+ know(0); /* know nothing */
}
/*
diff --git a/gas/config/tc-sparc.c b/gas/config/tc-sparc.c
index f17a7dc..b52043f 100644
--- a/gas/config/tc-sparc.c
+++ b/gas/config/tc-sparc.c
@@ -516,7 +516,7 @@ static void sparc_ip(str)
argsStart = s;
for (;;) {
opcode = insn->match;
- bzero(&the_insn, sizeof(the_insn));
+ memset(&the_insn, '\0', sizeof(the_insn));
the_insn.reloc = NO_RELOC;
/*
@@ -1645,7 +1645,7 @@ void emit_sparc_reloc(fixP, segment_address_in_file)
extern char *next_object_file_charP;
/* long add_number; */
- bzero((char *) &ri, sizeof(ri));
+ memset((char *) &ri, '\0', sizeof(ri));
for (; fixP; fixP = fixP->fx_next) {
if (fixP->fx_r_type >= NO_RELOC) {