complain_overflow_dont, 0, "r_imm32", TRUE, 0xffffffff, 0xffffffff,
FALSE);
+static reloc_howto_type r_imm24 =
+HOWTO (R_IMM24, 0, 1, 24, FALSE, 0,
+ complain_overflow_dont, 0, "r_imm24", TRUE, 0x00ffffff, 0x00ffffff,
+ FALSE);
+
static reloc_howto_type r_imm16 =
HOWTO (R_IMM16, 0, 1, 16, FALSE, 0,
complain_overflow_dont, 0, "r_imm16", TRUE, 0x0000ffff, 0x0000ffff,
case R_IMM16:
internal->howto = &r_imm16;
break;
+ case R_IMM24:
+ internal->howto = &r_imm24;
+ break;
case R_IMM32:
internal->howto = &r_imm32;
break;
{
case BFD_RELOC_8: return & r_imm8;
case BFD_RELOC_16: return & r_imm16;
+ case BFD_RELOC_24: return & r_imm24;
case BFD_RELOC_32: return & r_imm32;
case BFD_RELOC_8_PCREL: return & r_jr;
case BFD_RELOC_Z80_DISP8: return & r_off8;
break;
case R_IMM8:
- val = bfd_get_16 ( in_abfd, data+*src_ptr)
+ val = bfd_get_8 ( in_abfd, data+*src_ptr)
+ bfd_coff_reloc16_get_value (reloc, link_info, input_section);
bfd_put_8 (in_abfd, val, data + *dst_ptr);
(*dst_ptr) += 1;
(*src_ptr) += 2;
break;
+ case R_IMM24:
+ val = bfd_get_16 ( in_abfd, data+*src_ptr)
+ + (bfd_get_8 ( in_abfd, data+*src_ptr+2) << 16)
+ + bfd_coff_reloc16_get_value (reloc, link_info, input_section);
+ bfd_put_16 (in_abfd, val, data + *dst_ptr);
+ bfd_put_8 (in_abfd, val >> 16, data + *dst_ptr+2);
+ (*dst_ptr) += 3;
+ (*src_ptr) += 3;
+ break;
+
case R_IMM32:
val = bfd_get_32 ( in_abfd, data+*src_ptr)
+ bfd_coff_reloc16_get_value (reloc, link_info, input_section);
bfd_set_arch_mach (stdoutput, TARGET_ARCH, mach_type);
}
-/* Port specific features. */
-const pseudo_typeS md_pseudo_table[] =
-{
- { "defs", s_space, 1}, /* Synonym for ds on some assemblers. */
- { "ds", s_space, 1}, /* Fill with bytes rather than words. */
- { "psect", obj_coff_section, 0}, /* TODO: Translate attributes. */
- { "set", 0, 0}, /* Real instruction on z80. */
- { NULL, 0, 0 }
-} ;
-
static const char *
skip_space (const char *s)
{
break;
}
}
- /* Check for <label>[:] (EQU|DEFL) <value>. */
+ /* Check for <label>[:] [.](EQU|DEFL) <value>. */
if (is_name_beginner (*input_line_pointer))
{
char c, *rest, *line_start;
++rest;
if (*rest == ' ' || *rest == '\t')
++rest;
+ if (*rest == '.')
+ ++rest;
if (strncasecmp (rest, "EQU", 3) == 0)
len = 3;
else if (strncasecmp (rest, "DEFL", 4) == 0)
if (S_IS_DEFINED (symbolP) || symbol_equated_p (symbolP))
as_bad (_("symbol `%s' is already defined"), line_start);
}
- /* All symbols may be redefined. */
equals (line_start, 1);
return 1;
}
p = "instruction only works R800";
break;
default:
- p = 0; /* Not reachables. */
+ p = 0; /* Not reachable. */
}
if (ins_type & ins_err)
return args;
}
+void z80_cons_fix_new (fragS *frag_p, int offset, int nbytes, expressionS *exp)
+{
+ bfd_reloc_code_real_type r[4] =
+ {
+ BFD_RELOC_8,
+ BFD_RELOC_16,
+ BFD_RELOC_24,
+ BFD_RELOC_32
+ };
+
+ if (nbytes < 1 || nbytes > 4)
+ {
+ as_bad (_("unsupported BFD relocation size %u"), nbytes);
+ }
+ else
+ {
+ fix_new_exp (frag_p, offset, nbytes, exp, 0, r[nbytes-1]);
+ }
+}
+
static void
emit_byte (expressionS * val, bfd_reloc_code_real_type r_type)
{
p = frag_more (1);
*p = val->X_add_number;
- if ((r_type != BFD_RELOC_8_PCREL) && (val->X_op == O_constant))
+ if ((r_type == BFD_RELOC_8_PCREL) && (val->X_op == O_constant))
+ {
+ as_bad(_("cannot make a relative jump to an absolute location"));
+ }
+ else if (val->X_op == O_constant)
{
lo = -128;
hi = (BFD_RELOC_8 == r_type) ? 255 : 127;
return p;
}
-static const char *
-emit_data (char prefix ATTRIBUTE_UNUSED, char opcode, const char * args)
+static void
+emit_data (int size ATTRIBUTE_UNUSED)
{
const char *p, *q;
char *u, quote;
int cnt;
expressionS exp;
- p = skip_space (args);
- if (!*p)
- error (_("missing operand"));
+ if (is_it_end_of_statement ())
+ {
+ demand_empty_rest_of_line ();
+ return;
+ }
+ p = skip_space (input_line_pointer);
- while (*p)
+ do
{
if (*p == '\"' || *p == '\'')
{
- if (opcode == 1)
- {
- for (quote = *p, q = ++p, cnt = 0; *p && quote != *p; ++p, ++cnt)
- ;
- u = frag_more (cnt);
- memcpy (u, q, cnt);
- if (!*p)
- as_warn (_("unterminated string"));
- else
- p = skip_space (p+1);
- }
- else
- {
- ill_op ();
- break;
- }
+ for (quote = *p, q = ++p, cnt = 0; *p && quote != *p; ++p, ++cnt)
+ ;
+ u = frag_more (cnt);
+ memcpy (u, q, cnt);
+ if (!*p)
+ as_warn (_("unterminated string"));
+ else
+ p = skip_space (p+1);
}
else
{
}
if (exp.X_md)
as_warn (_("parentheses ignored"));
- if (opcode == 1)
- emit_byte (&exp, BFD_RELOC_8);
- else
- emit_word (&exp);
+ emit_byte (&exp, BFD_RELOC_8);
p = skip_space (p);
}
- if (*p)
- {
- if (*p != ',')
- as_warn (_("missing ','"));
- else
- ++p;
- }
}
- return p;
+ while (*p++ == ',') ;
+ input_line_pointer = (char *)(p-1);
}
static const char *
return p;
}
+/* Port specific pseudo ops. */
+const pseudo_typeS md_pseudo_table[] =
+{
+ { "db" , emit_data, 1},
+ { "d24", cons, 3},
+ { "d32", cons, 4},
+ { "def24", cons, 3},
+ { "def32", cons, 4},
+ { "defb", emit_data, 1},
+ { "defs", s_space, 1}, /* Synonym for ds on some assemblers. */
+ { "defw", cons, 2},
+ { "ds", s_space, 1}, /* Fill with bytes rather than words. */
+ { "dw", cons, 2},
+ { "psect", obj_coff_section, 0}, /* TODO: Translate attributes. */
+ { "set", 0, 0}, /* Real instruction on z80. */
+ { NULL, 0, 0 }
+} ;
+
static table_t instab[] =
{
{ "adc", 0x88, 0x4A, emit_adc },
{ "cpir", 0xED, 0xB1, emit_insn },
{ "cpl", 0x00, 0x2F, emit_insn },
{ "daa", 0x00, 0x27, emit_insn },
- { "db", 0x00, 0x01, emit_data },
{ "dec", 0x0B, 0x05, emit_incdec },
- { "defb", 0x00, 0x01, emit_data },
- { "defw", 0x00, 0x02, emit_data },
{ "di", 0x00, 0xF3, emit_insn },
{ "djnz", 0x00, 0x10, emit_jr },
- { "dw", 0x00, 0x02, emit_data },
{ "ei", 0x00, 0xFB, emit_insn },
{ "ex", 0x00, 0x00, emit_ex},
{ "exx", 0x00, 0xD9, emit_insn },
for (i = 0; (i < BUFLEN) && (ISALPHA (*p));)
buf[i++] = TOLOWER (*p++);
- if ((i == BUFLEN)
- || ((*p) && (!ISSPACE (*p))))
- as_bad (_("illegal instruction '%s'"), buf);
-
- buf[i] = 0;
- p = skip_space (p);
- key = buf;
-
- insp = bsearch (&key, instab, ARRAY_SIZE (instab),
- sizeof (instab[0]), key_cmp);
- if (!insp)
- as_bad (_("illegal instruction '%s'"), buf);
- else
+ if (i == BUFLEN)
+ {
+ buf[BUFLEN-3] = buf[BUFLEN-2] = '.'; /* Mark opcode as abbreviated. */
+ buf[BUFLEN-1] = 0;
+ as_bad (_("Unknown instruction '%s'"), buf);
+ }
+ else if ((*p) && (!ISSPACE (*p)))
+ as_bad (_("syntax error"));
+ else
{
- p = insp->fp (insp->prefix, insp->opcode, p);
+ buf[i] = 0;
p = skip_space (p);
- if ((!err_flag) && *p)
- as_bad (_("junk at end of line, first unrecognized character is `%c'"),
- *p);
+ key = buf;
+
+ insp = bsearch (&key, instab, ARRAY_SIZE (instab),
+ sizeof (instab[0]), key_cmp);
+ if (!insp)
+ as_bad (_("Unknown instruction '%s'"), buf);
+ else
+ {
+ p = insp->fp (insp->prefix, insp->opcode, p);
+ p = skip_space (p);
+ if ((!err_flag) && *p)
+ as_bad (_("junk at end of line, first unrecognized character is `%c'"),
+ *p);
+ }
}
input_line_pointer = old_ptr;
}
if (val > 255 || val < -128)
as_warn_where (fixP->fx_file, fixP->fx_line, _("overflow"));
*buf++ = val;
+ fixP->fx_no_overflow = 1;
if (fixP->fx_addsy == NULL)
fixP->fx_done = 1;
break;
case BFD_RELOC_16:
*buf++ = val;
*buf++ = (val >> 8);
+ fixP->fx_no_overflow = 1;
+ if (fixP->fx_addsy == NULL)
+ fixP->fx_done = 1;
+ break;
+
+ case BFD_RELOC_24: /* Def24 may produce this. */
+ *buf++ = val;
+ *buf++ = (val >> 8);
+ *buf++ = (val >> 16);
+ fixP->fx_no_overflow = 1;
if (fixP->fx_addsy == NULL)
fixP->fx_done = 1;
break;
- case BFD_RELOC_32: /* .Long may produce this. */
+ case BFD_RELOC_32: /* Def32 and .long may produce this. */
*buf++ = val;
*buf++ = (val >> 8);
*buf++ = (val >> 16);