start-sanitize-v850
Thu Oct 24 14:31:04 1996 Jeffrey A Law (law@cygnus.com)
+ * config/tc-v850.c (v850_reloc_prefix): Several disgusting
+ hacks to improve parsing of complex hi, lo, zda, etc
+ expressions.
+ (md_assemble): Don't demand and eat a trailing ')' after finding
+ a v850 relocation prefix. Sign extend the constant in a
+ BFD_RELOC_LO16 expression. Do eat a trailing ')' after a complete
+ operand.
+ (parse_cons_expression_v850): Don't eat a trailing ')' after
+ finding a v850 relocation prefix.
+
* config/tc-v850.h (TC_PARSE_CONS_EXPRESSION): Define.
(TC_CONS_FIX_NEW): Likewise.
* config/tc-v850.c (parse_cons_expression_v850): New function.
{
if (strncmp(input_line_pointer, "hi0(", 4) == 0)
{
- input_line_pointer += 4;
+ input_line_pointer += 3;
return BFD_RELOC_HI16;
}
if (strncmp(input_line_pointer, "hi(", 3) == 0)
{
- input_line_pointer += 3;
+ input_line_pointer += 2;
return BFD_RELOC_HI16_S;
}
if (strncmp (input_line_pointer, "lo(", 3) == 0)
{
- input_line_pointer += 3;
+ input_line_pointer += 2;
return BFD_RELOC_LO16;
}
if (strncmp (input_line_pointer, "sdaoff(", 7) == 0)
{
- input_line_pointer += 7;
+ input_line_pointer += 6;
return BFD_RELOC_V850_SDA_OFFSET;
}
if (strncmp (input_line_pointer, "zdaoff(", 7) == 0)
{
- input_line_pointer += 7;
+ input_line_pointer += 6;
return BFD_RELOC_V850_ZDA_OFFSET;
}
if (strncmp (input_line_pointer, "tdaoff(", 7) == 0)
{
- input_line_pointer += 7;
+ input_line_pointer += 6;
return BFD_RELOC_V850_TDA_OFFSET;
}
- /* FIXME: implement sda, tda, zda here */
+ /* Disgusting */
+ if (strncmp(input_line_pointer, "(hi0(", 5) == 0)
+ {
+ input_line_pointer += 4;
+ return BFD_RELOC_HI16;
+ }
+ if (strncmp(input_line_pointer, "(hi(", 4) == 0)
+ {
+ input_line_pointer += 3;
+ return BFD_RELOC_HI16_S;
+ }
+ if (strncmp (input_line_pointer, "(lo(", 4) == 0)
+ {
+ input_line_pointer += 3;
+ return BFD_RELOC_LO16;
+ }
+
+ if (strncmp (input_line_pointer, "(sdaoff(", 8) == 0)
+ {
+ input_line_pointer += 7;
+ return BFD_RELOC_V850_SDA_OFFSET;
+ }
+
+ if (strncmp (input_line_pointer, "(zdaoff(", 8) == 0)
+ {
+ input_line_pointer += 7;
+ return BFD_RELOC_V850_ZDA_OFFSET;
+ }
+
+ if (strncmp (input_line_pointer, "(tdaoff(", 8) == 0)
+ {
+ input_line_pointer += 7;
+ return BFD_RELOC_V850_TDA_OFFSET;
+ }
return BFD_RELOC_UNUSED;
}
{
expression(&ex);
- if (*input_line_pointer++ != ')')
- {
- errmsg = "syntax error: expected `)'";
- goto error;
- }
-
if (ex.X_op == O_constant)
{
switch (reloc)
{
case BFD_RELOC_LO16:
- ex.X_add_number &= 0xffff;
- break;
+ {
+ /* Truncate, then sign extend the value. */
+ int temp = ex.X_add_number & 0xffff;
+
+ /* XXX Assumes 32bit ints! */
+ temp = (temp << 16) >> 16;
+ ex.X_add_number = temp;
+ break;
+ }
case BFD_RELOC_HI16:
ex.X_add_number = ((ex.X_add_number >> 16) & 0xffff);
str = input_line_pointer;
input_line_pointer = hold;
- while (*str == ' ' || *str == ',' || *str == '[' || *str == ']')
+ while (*str == ' ' || *str == ',' || *str == '[' || *str == ']'
+ || *str == ')')
++str;
}
match = 1;
/* Do normal expression parsing. */
expression (exp);
-
- /* If we had to handle a reloc prefix, then eat the trailing
- close paren. */
- if (hold_cons_reloc != BFD_RELOC_UNUSED)
- input_line_pointer++;
}
/* Create a fixup for a cons expression. If parse_cons_expression_v850