Moved struct m68k_incant and related macros earlier in the file.

Make insop and add_exp functions for readability.
Whitespace/comment changes.
This commit is contained in:
Ken Raeburn
1993-09-25 09:32:12 +00:00
parent d113e6b28e
commit bcb8dff8d8

View File

@ -1,7 +1,7 @@
/* tc-m68k.c All the m68020 specific stuff in one convenient, huge, /* tc-m68k.c All the m68020 specific stuff in one convenient, huge,
slow to compile, easy to find file. slow to compile, easy to find file.
Copyright (C) 1987, 1991, 1992 Free Software Foundation, Inc. Copyright (C) 1987, 1991, 1992, 1993 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler. This file is part of GAS, the GNU Assembler.
@ -99,6 +99,19 @@ static struct obstack robyn;
#define DBCC 5 #define DBCC 5
#define PCLEA 6 #define PCLEA 6
struct m68k_incant
{
char *m_operands;
unsigned long m_opcode;
short m_opnum;
short m_codenum;
int m_arch;
struct m68k_incant *m_next;
};
#define getone(x) ((((x)->m_opcode)>>16)&0xffff)
#define gettwo(x) (((x)->m_opcode)&0xffff)
/* Operands we can parse: (And associated modes) /* Operands we can parse: (And associated modes)
numb: 8 bit num numb: 8 bit num
@ -176,6 +189,7 @@ struct m68k_exp
{ {
char *e_beg; char *e_beg;
char *e_end; char *e_end;
segT e_seg;
expressionS e_exp; expressionS e_exp;
short e_siz; /* 0== default 1==short/byte 2==word 3==long */ short e_siz; /* 0== default 1==short/byte 2==word 3==long */
}; };
@ -335,8 +349,7 @@ struct m68k_it
struct struct
{ {
int n; int n;
symbolS *add, *sub; expressionS exp;
long off;
char wid; char wid;
char pcrel; char pcrel;
} }
@ -349,9 +362,10 @@ struct m68k_it
static struct m68k_it the_ins; /* the instruction being assembled */ static struct m68k_it the_ins; /* the instruction being assembled */
#define seg(exp) ((exp)->e_exp.X_seg) #define seg(exp) ((exp)->e_seg)
#define op(exp) ((exp)->e_exp.X_op)
#define adds(exp) ((exp)->e_exp.X_add_symbol) #define adds(exp) ((exp)->e_exp.X_add_symbol)
#define subs(exp) ((exp)->e_exp.X_subtract_symbol) #define subs(exp) ((exp)->e_exp.X_op_symbol)
#define offs(exp) ((exp)->e_exp.X_add_number) #define offs(exp) ((exp)->e_exp.X_add_number)
/* Macros for adding things to the m68k_it struct */ /* Macros for adding things to the m68k_it struct */
@ -359,21 +373,29 @@ static struct m68k_it the_ins; /* the instruction being assembled */
#define addword(w) the_ins.opcode[the_ins.numo++]=(w) #define addword(w) the_ins.opcode[the_ins.numo++]=(w)
/* Like addword, but goes BEFORE general operands */ /* Like addword, but goes BEFORE general operands */
#define insop(w) {int z;\ static void
for(z=the_ins.numo;z>opcode->m_codenum;--z)\ insop (w, opcode)
the_ins.opcode[z]=the_ins.opcode[z-1];\ int w;
for(z=0;z<the_ins.nrel;z++)\ struct m68k_incant *opcode;
the_ins.reloc[z].n+=2;\ {
the_ins.opcode[opcode->m_codenum]=w;\ int z;
the_ins.numo++;\ for(z=the_ins.numo;z>opcode->m_codenum;--z)
} the_ins.opcode[z]=the_ins.opcode[z-1];
for(z=0;z<the_ins.nrel;z++)
the_ins.reloc[z].n+=2;
the_ins.opcode[opcode->m_codenum]=w;
the_ins.numo++;
}
static struct m68k_exp *
#define add_exp(beg,end) (\ add_exp (beg, end)
the_ins.exprs[the_ins.nexp].e_beg=beg,\ char *beg;
the_ins.exprs[the_ins.nexp].e_end=end,\ char *end;
&the_ins.exprs[the_ins.nexp++]\ {
) the_ins.exprs[the_ins.nexp].e_beg=beg;
the_ins.exprs[the_ins.nexp].e_end=end;
return &the_ins.exprs[the_ins.nexp++];
}
/* The numo+1 kludge is so we can hit the low order byte of the prev word. /* The numo+1 kludge is so we can hit the low order byte of the prev word.
@ -389,9 +411,7 @@ add_fix (width, exp, pc_rel)
: (((width)=='b') : (((width)=='b')
? ((the_ins.numo-1)*2) ? ((the_ins.numo-1)*2)
: (the_ins.numo*2))); : (the_ins.numo*2)));
the_ins.reloc[the_ins.nrel].add = adds((exp)); the_ins.reloc[the_ins.nrel].exp = exp->e_exp;
the_ins.reloc[the_ins.nrel].sub = subs((exp));
the_ins.reloc[the_ins.nrel].off = offs((exp));
the_ins.reloc[the_ins.nrel].wid = width; the_ins.reloc[the_ins.nrel].wid = width;
the_ins.reloc[the_ins.nrel++].pcrel = pc_rel; the_ins.reloc[the_ins.nrel++].pcrel = pc_rel;
} }
@ -408,23 +428,8 @@ add_frag(add,off,type)
the_ins.fragb[the_ins.nfrag++].fragty=type; the_ins.fragb[the_ins.nfrag++].fragty=type;
} }
#define isvar(exp) ((exp) && (adds(exp) || subs(exp))) #define isvar(exp) \
((exp) && op (exp) != O_constant && op (exp) != O_big)
struct m68k_incant
{
char *m_operands;
unsigned long m_opcode;
short m_opnum;
short m_codenum;
int m_arch;
struct m68k_incant *m_next;
};
#define getone(x) ((((x)->m_opcode)>>16)&0xffff)
#define gettwo(x) (((x)->m_opcode)&0xffff)
static char *crack_operand PARAMS ((char *str, struct m68k_op *opP)); static char *crack_operand PARAMS ((char *str, struct m68k_op *opP));
static int get_num PARAMS ((struct m68k_exp *exp, int ok)); static int get_num PARAMS ((struct m68k_exp *exp, int ok));
@ -434,11 +439,11 @@ static int reverse_8_bits PARAMS ((int in));
static int try_index PARAMS ((char **s, struct m68k_op *opP)); static int try_index PARAMS ((char **s, struct m68k_op *opP));
static void install_gen_operand PARAMS ((int mode, int val)); static void install_gen_operand PARAMS ((int mode, int val));
static void install_operand PARAMS ((int mode, int val)); static void install_operand PARAMS ((int mode, int val));
static void s_bss PARAMS ((void)); static void s_bss PARAMS ((int));
static void s_data1 PARAMS ((void)); static void s_data1 PARAMS ((int));
static void s_data2 PARAMS ((void)); static void s_data2 PARAMS ((int));
static void s_even PARAMS ((void)); static void s_even PARAMS ((int));
static void s_proc PARAMS ((void)); static void s_proc PARAMS ((int));
static int current_architecture; static int current_architecture;
@ -546,7 +551,7 @@ CONST pseudo_typeS mote_pseudo_table[] =
{"sect", obj_coff_section, 0}, {"sect", obj_coff_section, 0},
{"section", obj_coff_section, 0}, {"section", obj_coff_section, 0},
#endif #endif
0, {0, 0, 0}
}; };
#define issbyte(x) ((x)>=-128 && (x)<=127) #define issbyte(x) ((x)>=-128 && (x)<=127)
@ -1006,7 +1011,7 @@ m68k_ip_op (str, opP)
char *stmp; char *stmp;
char *index (); char *index ();
if (stmp = index (str, ',')) if ((stmp = index (str, ',')) != NULL)
{ {
opP->con1 = add_exp (str, stmp - 1); opP->con1 = add_exp (str, stmp - 1);
str = stmp; str = stmp;
@ -1100,7 +1105,7 @@ m68k_ip_op (str, opP)
/* "EXP2" or "EXP2(REG..." */ /* "EXP2" or "EXP2(REG..." */
char *stmp; char *stmp;
char *index (); char *index ();
if (stmp = index (str, '(')) if ((stmp = index (str, '(')) != NULL)
{ {
char *ostr = str; char *ostr = str;
@ -1552,7 +1557,7 @@ m68k_ip (instring)
if (p == instring) if (p == instring)
{ {
the_ins.error = "No operator"; the_ins.error = "No operator";
the_ins.opcode[0] = NULL; the_ins.opcode[0] = 0;
/* the_ins.numo=1; */ /* the_ins.numo=1; */
return; return;
} }
@ -1584,7 +1589,7 @@ m68k_ip (instring)
if (opcode == NULL) if (opcode == NULL)
{ {
the_ins.error = "Unknown operator"; the_ins.error = "Unknown operator";
the_ins.opcode[0] = NULL; the_ins.opcode[0] = 0;
/* the_ins.numo=1; */ /* the_ins.numo=1; */
return; return;
} }
@ -1680,6 +1685,9 @@ m68k_ip (instring)
case REGLST: case REGLST:
case AINDR: case AINDR:
losing++; losing++;
break;
default:
break;
} }
break; break;
@ -1881,8 +1889,7 @@ m68k_ip (instring)
t = get_num (opP->con1, 0); t = get_num (opP->con1, 0);
if (!issbyte (t) if (!issbyte (t)
|| isvar (opP->con1) || isvar (opP->con1))
|| seg (opP->con1) != absolute_section)
losing++; losing++;
} }
break; break;
@ -2059,21 +2066,21 @@ m68k_ip (instring)
default: default:
{ {
int got_one = 0, idx; int got_one = 0, idx;
CONST static struct static const struct
{ {
int arch; int arch;
CONST char *name; const char *name;
} }
archs[] = archs[] =
{ {
m68000, "68000", { m68000, "68000" },
m68010, "68010", { m68010, "68010" },
m68020, "68020", { m68020, "68020" },
m68030, "68030", { m68030, "68030" },
m68040, "68040", { m68040, "68040" },
cpu32, "cpu32", { cpu32, "cpu32" },
m68881, "68881", { m68881, "68881" },
m68851, "68851", { m68851, "68851" }
}; };
for (idx = 0; idx < sizeof (archs) / sizeof (archs[0]); idx++) for (idx = 0; idx < sizeof (archs) / sizeof (archs[0]); idx++)
{ {
@ -2180,28 +2187,33 @@ m68k_ip (instring)
outro = -1; outro = -1;
break; break;
default: default:
as_fatal ("Internal error: Can't decode %c%c in line %s of file \"%s\"", as_fatal ("Internal error: Can't decode %c%c in line %d of file \"%s\"",
*s, s[1], __LINE__, __FILE__); *s, s[1], __LINE__, __FILE__);
} }
if (!baseo) if (!baseo)
break; break;
/* We gotta put out some float */ /* We gotta put out some float */
#if 0 if (op (opP->con1) != O_big)
if (seg (opP->con1) != SEG_BIG)
{ {
int_to_gen (nextword); valueT val;
gen_to_words (words, baseo, (long int) outro); int gencnt;
for (wordp = words; baseo--; wordp++)
addword (*wordp); /* Can other cases happen here? */
break; if (op (opP->con1) != O_constant)
} /* Its BIG */ abort ();
#else
if (seg (opP->con1) != big_section) val = (valueT) offs (opP->con1);
{ gencnt = 0;
abort (); do
{
generic_bignum[gencnt] = (LITTLENUM_TYPE) val;
val >>= LITTLENUM_NUMBER_OF_BITS;
++gencnt;
}
while (val != 0);
offs (opP->con1) = gencnt;
} }
#endif
if (offs (opP->con1) > 0) if (offs (opP->con1) > 0)
{ {
if (offs (opP->con1) > baseo) if (offs (opP->con1) > baseo)
@ -2210,10 +2222,10 @@ m68k_ip (instring)
offs (opP->con1) = baseo; offs (opP->con1) = baseo;
} }
baseo -= offs (opP->con1); baseo -= offs (opP->con1);
for (wordp = generic_bignum + offs (opP->con1) - 1; offs (opP->con1)--; --wordp)
addword (*wordp);
while (baseo--) while (baseo--)
addword (0); addword (0);
for (wordp = generic_bignum + offs (opP->con1) - 1; offs (opP->con1)--; --wordp)
addword (*wordp);
break; break;
} }
gen_to_words (words, baseo, (long) outro); gen_to_words (words, baseo, (long) outro);
@ -2482,8 +2494,8 @@ m68k_ip (instring)
addword (nextword); addword (nextword);
break; break;
} }
/* Don't generate pc relative code /* Don't generate pc relative code on 68010 and
on 68010 and 68000 */ 68000. */
if (isvar (opP->con1) if (isvar (opP->con1)
&& !subs (opP->con1) && !subs (opP->con1)
&& seg (opP->con1) == text_section && seg (opP->con1) == text_section
@ -2555,20 +2567,22 @@ m68k_ip (instring)
user beware! */ user beware! */
if (!isbyte (tmpreg)) if (!isbyte (tmpreg))
opP->error = "out of range"; opP->error = "out of range";
insop (tmpreg); insop (tmpreg, opcode);
if (isvar (opP->con1)) if (isvar (opP->con1))
the_ins.reloc[the_ins.nrel - 1].n = (opcode->m_codenum) * 2; the_ins.reloc[the_ins.nrel - 1].n = (opcode->m_codenum) * 2;
break; break;
case 'w': case 'w':
if (!isword (tmpreg)) if (!isword (tmpreg))
opP->error = "out of range"; opP->error = "out of range";
insop (tmpreg); insop (tmpreg, opcode);
if (isvar (opP->con1)) if (isvar (opP->con1))
the_ins.reloc[the_ins.nrel - 1].n = (opcode->m_codenum) * 2; the_ins.reloc[the_ins.nrel - 1].n = (opcode->m_codenum) * 2;
break; break;
case 'l': case 'l':
insop (tmpreg); /* Because of the way insop works, we put these two out backwards */ /* Because of the way insop works, we put these two out
insop (tmpreg >> 16); backwards. */
insop (tmpreg, opcode);
insop (tmpreg >> 16, opcode);
if (isvar (opP->con1)) if (isvar (opP->con1))
the_ins.reloc[the_ins.nrel - 1].n = (opcode->m_codenum) * 2; the_ins.reloc[the_ins.nrel - 1].n = (opcode->m_codenum) * 2;
break; break;
@ -2579,7 +2593,7 @@ m68k_ip (instring)
install_operand (s[1], tmpreg); install_operand (s[1], tmpreg);
break; break;
default: default:
as_fatal ("Internal error: Unknown mode #%c in line %s of file \"%s\"", s[1], __LINE__, __FILE__); as_fatal ("Internal error: Unknown mode #%c in line %d of file \"%s\"", s[1], __LINE__, __FILE__);
} }
break; break;
@ -2687,7 +2701,7 @@ m68k_ip (instring)
} }
break; break;
default: default:
as_fatal ("Internal error: operand type B%c unknown in line %s of file \"%s\"", as_fatal ("Internal error: operand type B%c unknown in line %d of file \"%s\"",
s[1], __LINE__, __FILE__); s[1], __LINE__, __FILE__);
} }
break; break;
@ -2810,7 +2824,7 @@ m68k_ip (instring)
{ {
if (tmpreg & 0x7FF0000) if (tmpreg & 0x7FF0000)
as_bad ("Floating point register in register list"); as_bad ("Floating point register in register list");
insop (reverse_16_bits (tmpreg)); insop (reverse_16_bits (tmpreg), opcode);
} }
else else
{ {
@ -2826,7 +2840,7 @@ m68k_ip (instring)
{ {
if (tmpreg & 0x7FF0000) if (tmpreg & 0x7FF0000)
as_bad ("Floating point register in register list"); as_bad ("Floating point register in register list");
insop (tmpreg); insop (tmpreg, opcode);
} }
else if (s[1] == '8') else if (s[1] == '8')
{ {
@ -3196,8 +3210,8 @@ install_operand (mode, val)
the_ins.opcode[2] |= val << 6; the_ins.opcode[2] |= val << 6;
break; break;
case '6': case '6':
/* DANGER! This is a hack to force cas2l and cas2w cmds /* DANGER! This is a hack to force cas2l and cas2w cmds to be
to be three words long! */ three words long! */
the_ins.numo++; the_ins.numo++;
the_ins.opcode[2] |= val; the_ins.opcode[2] |= val;
break; break;
@ -3391,123 +3405,121 @@ verify_symbol_chain_2 (s);
struct init_entry struct init_entry
{ {
char *name; const char *name;
int number; int number;
}; };
static CONST struct init_entry init_table[] = static const struct init_entry init_table[] =
{ {
"d0", DATA0, { "d0", DATA0 },
"d1", DATA1, { "d1", DATA1 },
"d2", DATA2, { "d2", DATA2 },
"d3", DATA3, { "d3", DATA3 },
"d4", DATA4, { "d4", DATA4 },
"d5", DATA5, { "d5", DATA5 },
"d6", DATA6, { "d6", DATA6 },
"d7", DATA7, { "d7", DATA7 },
"a0", ADDR0, { "a0", ADDR0 },
"a1", ADDR1, { "a1", ADDR1 },
"a2", ADDR2, { "a2", ADDR2 },
"a3", ADDR3, { "a3", ADDR3 },
"a4", ADDR4, { "a4", ADDR4 },
"a5", ADDR5, { "a5", ADDR5 },
"a6", ADDR6, { "a6", ADDR6 },
"fp", ADDR6, { "fp", ADDR6 },
"a7", ADDR7, { "a7", ADDR7 },
"sp", ADDR7, { "sp", ADDR7 },
"fp0", FP0, { "fp0", FP0 },
"fp1", FP1, { "fp1", FP1 },
"fp2", FP2, { "fp2", FP2 },
"fp3", FP3, { "fp3", FP3 },
"fp4", FP4, { "fp4", FP4 },
"fp5", FP5, { "fp5", FP5 },
"fp6", FP6, { "fp6", FP6 },
"fp7", FP7, { "fp7", FP7 },
"fpi", FPI, { "fpi", FPI },
"fpiar", FPI, { "fpiar", FPI },
"fpc", FPI, { "fpc", FPI },
"fps", FPS, { "fps", FPS },
"fpsr", FPS, { "fpsr", FPS },
"fpc", FPC, { "fpc", FPC },
"fpcr", FPC, { "fpcr", FPC },
"cop0", COP0, { "cop0", COP0 },
"cop1", COP1, { "cop1", COP1 },
"cop2", COP2, { "cop2", COP2 },
"cop3", COP3, { "cop3", COP3 },
"cop4", COP4, { "cop4", COP4 },
"cop5", COP5, { "cop5", COP5 },
"cop6", COP6, { "cop6", COP6 },
"cop7", COP7, { "cop7", COP7 },
"pc", PC, { "pc", PC },
"zpc", ZPC, { "zpc", ZPC },
"sr", SR, { "sr", SR },
"ccr", CCR, { "ccr", CCR },
"cc", CCR, { "cc", CCR },
"usp", USP, { "usp", USP },
"isp", ISP, { "isp", ISP },
"sfc", SFC, { "sfc", SFC },
"dfc", DFC, { "dfc", DFC },
"cacr", CACR, { "cacr", CACR },
"caar", CAAR, { "caar", CAAR },
"vbr", VBR, { "vbr", VBR },
"msp", MSP, { "msp", MSP },
"itt0", ITT0, { "itt0", ITT0 },
"itt1", ITT1, { "itt1", ITT1 },
"dtt0", DTT0, { "dtt0", DTT0 },
"dtt1", DTT1, { "dtt1", DTT1 },
"mmusr", MMUSR, { "mmusr", MMUSR },
"tc", TC, { "tc", TC },
"srp", SRP, { "srp", SRP },
"urp", URP, { "urp", URP },
"ac", AC, { "ac", AC },
"bc", BC, { "bc", BC },
"cal", CAL, { "cal", CAL },
"crp", CRP, { "crp", CRP },
"drp", DRP, { "drp", DRP },
"pcsr", PCSR, { "pcsr", PCSR },
"psr", PSR, { "psr", PSR },
"scc", SCC, { "scc", SCC },
"val", VAL, { "val", VAL },
"bad0", BAD0, { "bad0", BAD0 },
"bad1", BAD1, { "bad1", BAD1 },
"bad2", BAD2, { "bad2", BAD2 },
"bad3", BAD3, { "bad3", BAD3 },
"bad4", BAD4, { "bad4", BAD4 },
"bad5", BAD5, { "bad5", BAD5 },
"bad6", BAD6, { "bad6", BAD6 },
"bad7", BAD7, { "bad7", BAD7 },
"bac0", BAC0, { "bac0", BAC0 },
"bac1", BAC1, { "bac1", BAC1 },
"bac2", BAC2, { "bac2", BAC2 },
"bac3", BAC3, { "bac3", BAC3 },
"bac4", BAC4, { "bac4", BAC4 },
"bac5", BAC5, { "bac5", BAC5 },
"bac6", BAC6, { "bac6", BAC6 },
"bac7", BAC7, { "bac7", BAC7 },
"ic", IC, { "ic", IC },
"dc", DC, { "dc", DC },
"nc", NC, { "nc", NC },
"tt0", TT0, { "tt0", TT0 },
"tt1", TT1, { "tt1", TT1 },
/* 68ec030 versions of same */ /* 68ec030 versions of same */
"ac0", TT0, { "ac0", TT0 },
"ac1", TT1, { "ac1", TT1 },
/* 68ec030 access control unit, identical to 030 MMU status reg */ /* 68ec030 access control unit, identical to 030 MMU status reg */
"acusr", PSR, { "acusr", PSR },
0,
{ 0, 0 }
}; };
void void
init_regtable () init_regtable ()
{ {
@ -3649,14 +3661,13 @@ md_assemble (str)
the_ins.reloc[m].wid); the_ins.reloc[m].wid);
} }
fix_new (frag_now, fix_new_exp (frag_now,
(toP - frag_now->fr_literal) - the_ins.numo * 2 + the_ins.reloc[m].n, ((toP - frag_now->fr_literal)
n, - the_ins.numo * 2 + the_ins.reloc[m].n),
the_ins.reloc[m].add, n,
the_ins.reloc[m].sub, &the_ins.reloc[m].exp,
the_ins.reloc[m].off, the_ins.reloc[m].pcrel,
the_ins.reloc[m].pcrel, NO_RELOC);
NO_RELOC);
} }
return; return;
} }
@ -3693,14 +3704,13 @@ md_assemble (str)
the_ins.reloc[m].wid = 0; the_ins.reloc[m].wid = 0;
wid = (wid == 'b') ? 1 : (wid == 'w') ? 2 : (wid == 'l') ? 4 : 4000; wid = (wid == 'b') ? 1 : (wid == 'w') ? 2 : (wid == 'l') ? 4 : 4000;
fix_new (frag_now, fix_new_exp (frag_now,
(toP - frag_now->fr_literal) - the_ins.numo * 2 + the_ins.reloc[m].n, ((toP - frag_now->fr_literal)
wid, - the_ins.numo * 2 + the_ins.reloc[m].n),
the_ins.reloc[m].add, wid,
the_ins.reloc[m].sub, &the_ins.reloc[m].exp,
the_ins.reloc[m].off, the_ins.reloc[m].pcrel,
the_ins.reloc[m].pcrel, NO_RELOC);
NO_RELOC);
} }
(void) frag_var (rs_machine_dependent, 10, 0, (void) frag_var (rs_machine_dependent, 10, 0,
(relax_substateT) (the_ins.fragb[n].fragty), (relax_substateT) (the_ins.fragb[n].fragty),
@ -3729,14 +3739,13 @@ md_assemble (str)
the_ins.reloc[m].wid = 0; the_ins.reloc[m].wid = 0;
wid = (wid == 'b') ? 1 : (wid == 'w') ? 2 : (wid == 'l') ? 4 : 4000; wid = (wid == 'b') ? 1 : (wid == 'w') ? 2 : (wid == 'l') ? 4 : 4000;
fix_new (frag_now, fix_new_exp (frag_now,
(the_ins.reloc[m].n + toP - frag_now->fr_literal) - shorts_this_frag * 2, ((the_ins.reloc[m].n + toP - frag_now->fr_literal)
wid, - shorts_this_frag * 2),
the_ins.reloc[m].add, wid,
the_ins.reloc[m].sub, &the_ins.reloc[m].exp,
the_ins.reloc[m].off, the_ins.reloc[m].pcrel,
the_ins.reloc[m].pcrel, NO_RELOC);
NO_RELOC);
} }
} }
@ -3769,7 +3778,7 @@ md_begin ()
register CONST struct m68k_opcode *ins; register CONST struct m68k_opcode *ins;
register struct m68k_incant *hack, *slak; register struct m68k_incant *hack, *slak;
register char *retval = 0; /* empty string, or error msg text */ register const char *retval = 0; /* empty string, or error msg text */
register unsigned int i; register unsigned int i;
register char c; register char c;
@ -3836,7 +3845,7 @@ md_begin ()
#ifndef MIT_SYNTAX_ONLY #ifndef MIT_SYNTAX_ONLY
/* Insert pseudo ops, these have to go into the opcode table since /* Insert pseudo ops, these have to go into the opcode table since
gas expects pseudo ops to start with a dot */ gas expects pseudo ops to start with a dot */
{ {
int n = 0; int n = 0;
while (mote_pseudo_table[n].poc_name) while (mote_pseudo_table[n].poc_name)
@ -4091,14 +4100,13 @@ md_convert_frag_1 (fragP)
if (fragP->fr_opcode[0] == 0x61) if (fragP->fr_opcode[0] == 0x61)
{ {
fragP->fr_opcode[0] = 0x4E; fragP->fr_opcode[0] = 0x4E;
fragP->fr_opcode[1] = 0xB9; /* JBSR with ABSL LONG offset */ fragP->fr_opcode[1] = (char) 0xB9; /* JBSR with ABSL LONG offset */
subseg_change (text_section, 0); /* @@ */ subseg_change (text_section, 0); /* @@ */
fix_new (fragP, fix_new (fragP,
fragP->fr_fix, fragP->fr_fix,
4, 4,
fragP->fr_symbol, fragP->fr_symbol,
0,
fragP->fr_offset, fragP->fr_offset,
0, 0,
NO_RELOC); NO_RELOC);
@ -4109,10 +4117,10 @@ md_convert_frag_1 (fragP)
else if (fragP->fr_opcode[0] == 0x60) else if (fragP->fr_opcode[0] == 0x60)
{ {
fragP->fr_opcode[0] = 0x4E; fragP->fr_opcode[0] = 0x4E;
fragP->fr_opcode[1] = 0xF9; /* JMP with ABSL LONG offset */ fragP->fr_opcode[1] = (char) 0xF9; /* JMP with ABSL LONG offset */
subseg_change (text_section, 0); /* @@ */ subseg_change (text_section, 0); /* @@ */
fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, fragP->fr_offset, 0, fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol,
NO_RELOC); fragP->fr_offset, 0, NO_RELOC);
fragP->fr_fix += 4; fragP->fr_fix += 4;
ext = 0; ext = 0;
} }
@ -4123,7 +4131,7 @@ md_convert_frag_1 (fragP)
} }
else else
{ {
fragP->fr_opcode[1] = 0xff; fragP->fr_opcode[1] = (char) 0xff;
ext = 4; ext = 4;
} }
break; break;
@ -4137,12 +4145,11 @@ md_convert_frag_1 (fragP)
different frag, in which case refering to them is a no-no. different frag, in which case refering to them is a no-no.
Only fr_opcode[0,1] are guaranteed to work. */ Only fr_opcode[0,1] are guaranteed to work. */
*buffer_address++ = 0x4e; /* put in jmp long (0x4ef9) */ *buffer_address++ = 0x4e; /* put in jmp long (0x4ef9) */
*buffer_address++ = 0xf9; *buffer_address++ = (char) 0xf9;
fragP->fr_fix += 2; /* account for jmp instruction */ fragP->fr_fix += 2; /* account for jmp instruction */
subseg_change (text_section, 0); subseg_change (text_section, 0);
fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol,
fragP->fr_offset, 0, fragP->fr_offset, 0, NO_RELOC);
NO_RELOC);
fragP->fr_fix += 4; fragP->fr_fix += 4;
ext = 0; ext = 0;
break; break;
@ -4155,11 +4162,11 @@ md_convert_frag_1 (fragP)
*buffer_address++ = 0x60; /* put in bra pc+6 */ *buffer_address++ = 0x60; /* put in bra pc+6 */
*buffer_address++ = 0x06; *buffer_address++ = 0x06;
*buffer_address++ = 0x4e; /* put in jmp long (0x4ef9) */ *buffer_address++ = 0x4e; /* put in jmp long (0x4ef9) */
*buffer_address++ = 0xf9; *buffer_address++ = (char) 0xf9;
fragP->fr_fix += 6; /* account for bra/jmp instructions */ fragP->fr_fix += 6; /* account for bra/jmp instructions */
subseg_change (text_section, 0); subseg_change (text_section, 0);
fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol,
fragP->fr_offset, 0, NO_RELOC); fragP->fr_offset, 0, NO_RELOC);
fragP->fr_fix += 4; fragP->fr_fix += 4;
ext = 0; ext = 0;
@ -4180,11 +4187,12 @@ md_convert_frag_1 (fragP)
PCREL is really trying to shorten an ABSOLUTE address anyway */ PCREL is really trying to shorten an ABSOLUTE address anyway */
/* JF FOO This code has not been tested */ /* JF FOO This code has not been tested */
subseg_change (text_section, 0); subseg_change (text_section, 0);
fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, fragP->fr_offset, fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, fragP->fr_offset,
0, NO_RELOC); 0, NO_RELOC);
if ((fragP->fr_opcode[1] & 0x3F) != 0x3A) if ((fragP->fr_opcode[1] & 0x3F) != 0x3A)
as_bad ("Internal error (long PC-relative operand) for insn 0x%04lx at 0x%lx", as_bad ("Internal error (long PC-relative operand) for insn 0x%04x at 0x%lx",
fragP->fr_opcode[0], fragP->fr_address); (unsigned) fragP->fr_opcode[0],
(unsigned long) fragP->fr_address);
fragP->fr_opcode[1] &= ~0x3F; fragP->fr_opcode[1] &= ~0x3F;
fragP->fr_opcode[1] |= 0x39; /* Mode 7.1 */ fragP->fr_opcode[1] |= 0x39; /* Mode 7.1 */
fragP->fr_fix += 4; fragP->fr_fix += 4;
@ -4193,7 +4201,7 @@ md_convert_frag_1 (fragP)
case TAB (PCLEA, SHORT): case TAB (PCLEA, SHORT):
subseg_change (text_section, 0); subseg_change (text_section, 0);
fix_new (fragP, (int) (fragP->fr_fix), 2, fragP->fr_symbol, fix_new (fragP, (int) (fragP->fr_fix), 2, fragP->fr_symbol,
(symbolS *) 0, fragP->fr_offset, 1, NO_RELOC); fragP->fr_offset, 1, NO_RELOC);
fragP->fr_opcode[1] &= ~0x3F; fragP->fr_opcode[1] &= ~0x3F;
fragP->fr_opcode[1] |= 0x3A; fragP->fr_opcode[1] |= 0x3A;
ext = 2; ext = 2;
@ -4201,7 +4209,7 @@ md_convert_frag_1 (fragP)
case TAB (PCLEA, LONG): case TAB (PCLEA, LONG):
subseg_change (text_section, 0); subseg_change (text_section, 0);
fix_new (fragP, (int) (fragP->fr_fix) + 2, 4, fragP->fr_symbol, fix_new (fragP, (int) (fragP->fr_fix) + 2, 4, fragP->fr_symbol,
(symbolS *) 0, fragP->fr_offset + 2, 1, NO_RELOC); fragP->fr_offset + 2, 1, NO_RELOC);
*buffer_address++ = 0x01; *buffer_address++ = 0x01;
*buffer_address++ = 0x70; *buffer_address++ = 0x70;
fragP->fr_fix += 2; fragP->fr_fix += 2;
@ -4270,20 +4278,20 @@ md_estimate_size_before_relax (fragP, segment)
if (fragP->fr_opcode[0] == 0x61) if (fragP->fr_opcode[0] == 0x61)
{ {
fragP->fr_opcode[0] = 0x4E; fragP->fr_opcode[0] = 0x4E;
fragP->fr_opcode[1] = 0xB9; /* JBSR with ABSL LONG offset */ fragP->fr_opcode[1] = (char) 0xB9; /* JBSR with ABSL LONG offset */
subseg_change (text_section, 0); subseg_change (text_section, 0);
fix_new (fragP, fragP->fr_fix, 4, fix_new (fragP, fragP->fr_fix, 4,
fragP->fr_symbol, 0, fragP->fr_offset, 0, NO_RELOC); fragP->fr_symbol, fragP->fr_offset, 0, NO_RELOC);
fragP->fr_fix += 4; fragP->fr_fix += 4;
frag_wane (fragP); frag_wane (fragP);
} }
else if (fragP->fr_opcode[0] == 0x60) else if (fragP->fr_opcode[0] == 0x60)
{ {
fragP->fr_opcode[0] = 0x4E; fragP->fr_opcode[0] = 0x4E;
fragP->fr_opcode[1] = 0xF9; /* JMP with ABSL LONG offset */ fragP->fr_opcode[1] = (char) 0xF9; /* JMP with ABSL LONG offset */
subseg_change (text_section, 0); subseg_change (text_section, 0);
fix_new (fragP, fragP->fr_fix, 4, fix_new (fragP, fragP->fr_fix, 4,
fragP->fr_symbol, 0, fragP->fr_offset, 0, NO_RELOC); fragP->fr_symbol, fragP->fr_offset, 0, NO_RELOC);
fragP->fr_fix += 4; fragP->fr_fix += 4;
frag_wane (fragP); frag_wane (fragP);
} }
@ -4295,9 +4303,9 @@ md_estimate_size_before_relax (fragP, segment)
else else
{ /* Symbol is still undefined. Make it simple */ { /* Symbol is still undefined. Make it simple */
fix_new (fragP, (int) (fragP->fr_fix), 4, fragP->fr_symbol, fix_new (fragP, (int) (fragP->fr_fix), 4, fragP->fr_symbol,
(symbolS *) 0, fragP->fr_offset + 4, 1, NO_RELOC); fragP->fr_offset + 4, 1, NO_RELOC);
fragP->fr_fix += 4; fragP->fr_fix += 4;
fragP->fr_opcode[1] = 0xff; fragP->fr_opcode[1] = (char) 0xff;
frag_wane (fragP); frag_wane (fragP);
break; break;
} }
@ -4351,10 +4359,10 @@ md_estimate_size_before_relax (fragP, segment)
fragP->fr_opcode[1] = 0x04; /* branch offset = 6 */ fragP->fr_opcode[1] = 0x04; /* branch offset = 6 */
/* JF: these were fr_opcode[2,3] */ /* JF: these were fr_opcode[2,3] */
buffer_address[0] = 0x4e; /* put in jmp long (0x4ef9) */ buffer_address[0] = 0x4e; /* put in jmp long (0x4ef9) */
buffer_address[1] = 0xf8; buffer_address[1] = (char) 0xf8;
fragP->fr_fix += 2; /* account for jmp instruction */ fragP->fr_fix += 2; /* account for jmp instruction */
subseg_change (text_section, 0); subseg_change (text_section, 0);
fix_new (fragP, fragP->fr_fix, 2, fragP->fr_symbol, 0, fix_new (fragP, fragP->fr_fix, 2, fragP->fr_symbol,
fragP->fr_offset, 0, NO_RELOC); fragP->fr_offset, 0, NO_RELOC);
fragP->fr_fix += 2; fragP->fr_fix += 2;
} }
@ -4363,10 +4371,10 @@ md_estimate_size_before_relax (fragP, segment)
fragP->fr_opcode[1] = 0x06; /* branch offset = 6 */ fragP->fr_opcode[1] = 0x06; /* branch offset = 6 */
/* JF: these were fr_opcode[2,3] */ /* JF: these were fr_opcode[2,3] */
buffer_address[0] = 0x4e; /* put in jmp long (0x4ef9) */ buffer_address[0] = 0x4e; /* put in jmp long (0x4ef9) */
buffer_address[1] = 0xf9; buffer_address[1] = (char) 0xf9;
fragP->fr_fix += 2; /* account for jmp instruction */ fragP->fr_fix += 2; /* account for jmp instruction */
subseg_change (text_section, 0); subseg_change (text_section, 0);
fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol,
fragP->fr_offset, 0, NO_RELOC); fragP->fr_offset, 0, NO_RELOC);
fragP->fr_fix += 4; fragP->fr_fix += 4;
} }
@ -4394,12 +4402,10 @@ md_estimate_size_before_relax (fragP, segment)
/* JF: these were fr_opcode[5-7] */ /* JF: these were fr_opcode[5-7] */
buffer_address[3] = 0x04; /* plus 4 */ buffer_address[3] = 0x04; /* plus 4 */
buffer_address[4] = 0x4e; /* Put in Jump Word */ buffer_address[4] = 0x4e; /* Put in Jump Word */
buffer_address[5] = 0xf8; buffer_address[5] = (char) 0xf8;
fragP->fr_fix += 6; /* account for bra/jmp instruction */ fragP->fr_fix += 6; /* account for bra/jmp instruction */
subseg_change (text_section, 0); subseg_change (text_section, 0);
fix_new (fragP, fragP->fr_fix, 2, fragP->fr_symbol, 0, fix_new (fragP, fragP->fr_fix, 2, fragP->fr_symbol,
fragP->fr_offset, 0, NO_RELOC); fragP->fr_offset, 0, NO_RELOC);
fragP->fr_fix += 2; fragP->fr_fix += 2;
} }
@ -4408,10 +4414,10 @@ md_estimate_size_before_relax (fragP, segment)
/* JF: these were fr_opcode[5-7] */ /* JF: these were fr_opcode[5-7] */
buffer_address[3] = 0x06; /* Plus 6 */ buffer_address[3] = 0x06; /* Plus 6 */
buffer_address[4] = 0x4e; /* put in jmp long (0x4ef9) */ buffer_address[4] = 0x4e; /* put in jmp long (0x4ef9) */
buffer_address[5] = 0xf9; buffer_address[5] = (char) 0xf9;
fragP->fr_fix += 6; /* account for bra/jmp instruction */ fragP->fr_fix += 6; /* account for bra/jmp instruction */
subseg_change (text_section, 0); subseg_change (text_section, 0);
fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol,
fragP->fr_offset, 0, NO_RELOC); fragP->fr_offset, 0, NO_RELOC);
fragP->fr_fix += 4; fragP->fr_fix += 4;
} }
@ -4560,8 +4566,8 @@ md_create_long_jump (ptr, from_addr, to_addr, frag, to_symbol)
offset = to_addr - S_GET_VALUE (to_symbol); offset = to_addr - S_GET_VALUE (to_symbol);
md_number_to_chars (ptr, (valueT) 0x4EF9, 2); md_number_to_chars (ptr, (valueT) 0x4EF9, 2);
md_number_to_chars (ptr + 2, (valueT) offset, 4); md_number_to_chars (ptr + 2, (valueT) offset, 4);
fix_new (frag, (ptr + 2) - frag->fr_literal, 4, to_symbol, (symbolS *) 0, (long) 0, 0, fix_new (frag, (ptr + 2) - frag->fr_literal, 4, to_symbol, (offsetT) 0,
NO_RELOC); 0, NO_RELOC);
} }
else else
{ {
@ -4660,18 +4666,12 @@ get_num (exp, ok)
save_in = input_line_pointer; save_in = input_line_pointer;
input_line_pointer = exp->e_beg; input_line_pointer = exp->e_beg;
section = expression (&exp->e_exp); section = expression (&exp->e_exp);
if (section == pass1_section) seg (exp) = section;
{ if (exp->e_exp.X_op == O_absent)
seg (exp) = absolute_section;
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));
}
else if (section == absent_section)
{ {
/* Do the same thing the VAX asm does */ /* Do the same thing the VAX asm does */
seg (exp) = absolute_section; seg (exp) = absolute_section;
op (exp) = O_constant;
adds (exp) = 0; adds (exp) = 0;
subs (exp) = 0; subs (exp) = 0;
offs (exp) = 0; offs (exp) = 0;
@ -4681,7 +4681,7 @@ get_num (exp, ok)
offs (exp) = 1; offs (exp) = 1;
} }
} }
else if (section == absolute_section) else if (exp->e_exp.X_op == O_constant)
{ {
switch (ok) switch (ok)
{ {
@ -4728,9 +4728,9 @@ get_num (exp, ok)
break; break;
} }
} }
else if (section == big_section) else if (exp->e_exp.X_op == O_big)
{ {
if (offs (exp) < 0 /* flonum */ if (offs (exp) <= 0 /* flonum */
&& (ok == 80 /* no bignums */ && (ok == 80 /* no bignums */
|| (ok > 10 /* small-int ranges including 0 ok */ || (ok > 10 /* small-int ranges including 0 ok */
/* If we have a flonum zero, a zero integer should /* If we have a flonum zero, a zero integer should
@ -4743,6 +4743,7 @@ get_num (exp, ok)
gen_to_words (words, 2, 8L); /* These numbers are magic! */ gen_to_words (words, 2, 8L); /* These numbers are magic! */
seg (exp) = absolute_section; seg (exp) = absolute_section;
op (exp) = O_constant;
adds (exp) = 0; adds (exp) = 0;
subs (exp) = 0; subs (exp) = 0;
offs (exp) = words[1] | (words[0] << 16); offs (exp) = words[1] | (words[0] << 16);
@ -4750,6 +4751,7 @@ get_num (exp, ok)
else if (ok != 0) else if (ok != 0)
{ {
seg (exp) = absolute_section; seg (exp) = absolute_section;
op (exp) = O_constant;
adds (exp) = 0; adds (exp) = 0;
subs (exp) = 0; subs (exp) = 0;
offs (exp) = (ok == 10) ? 1 : 0; offs (exp) = (ok == 10) ? 1 : 0;
@ -4761,6 +4763,7 @@ get_num (exp, ok)
if (ok >= 10 && ok <= 70) if (ok >= 10 && ok <= 70)
{ {
seg (exp) = absolute_section; seg (exp) = absolute_section;
op (exp) = O_constant;
adds (exp) = 0; adds (exp) = 0;
subs (exp) = 0; subs (exp) = 0;
offs (exp) = (ok == 10) ? 1 : 0; offs (exp) = (ok == 10) ? 1 : 0;
@ -4794,31 +4797,35 @@ get_num (exp, ok)
void demand_empty_rest_of_line (); /* Hate those extra verbose names */ void demand_empty_rest_of_line (); /* Hate those extra verbose names */
static void static void
s_data1 () s_data1 (ignore)
int ignore;
{ {
subseg_new (data_section, 1); subseg_set (data_section, 1);
demand_empty_rest_of_line (); demand_empty_rest_of_line ();
} }
static void static void
s_data2 () s_data2 (ignore)
int ignore;
{ {
subseg_new (data_section, 2); subseg_set (data_section, 2);
demand_empty_rest_of_line (); demand_empty_rest_of_line ();
} }
static void static void
s_bss () s_bss (ignore)
int ignore;
{ {
/* We don't support putting frags in the BSS segment, we fake it /* We don't support putting frags in the BSS segment, we fake it
by marking in_bss, then looking at s_skip for clues. */ by marking in_bss, then looking at s_skip for clues. */
subseg_new (bss_section, 0); subseg_set (bss_section, 0);
demand_empty_rest_of_line (); demand_empty_rest_of_line ();
} }
static void static void
s_even () s_even (ignore)
int ignore;
{ {
register int temp; register int temp;
register long temp_fill; register long temp_fill;
@ -4831,7 +4838,8 @@ s_even ()
} }
static void static void
s_proc () s_proc (ignore)
int ignore;
{ {
demand_empty_rest_of_line (); demand_empty_rest_of_line ();
} }