From d3bbd9dc3ed36503c0afb53379af8241ac5d08b5 Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Fri, 25 Oct 1996 01:14:34 +0000 Subject: [PATCH] * 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. Trying to get nec's sample code to assemble. Why oh why didn't JT try to assemble any of their code... --- gas/ChangeLog | 10 ++++++ gas/config/tc-v850.c | 72 +++++++++++++++++++++++++++++++------------- 2 files changed, 61 insertions(+), 21 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index 3621240dc6..22b0ece297 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,6 +1,16 @@ 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. diff --git a/gas/config/tc-v850.c b/gas/config/tc-v850.c index 355815b158..44dff2b5ee 100644 --- a/gas/config/tc-v850.c +++ b/gas/config/tc-v850.c @@ -459,39 +459,72 @@ v850_reloc_prefix() { 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; } @@ -570,19 +603,20 @@ md_assemble (str) { 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); @@ -720,7 +754,8 @@ md_assemble (str) str = input_line_pointer; input_line_pointer = hold; - while (*str == ' ' || *str == ',' || *str == '[' || *str == ']') + while (*str == ' ' || *str == ',' || *str == '[' || *str == ']' + || *str == ')') ++str; } match = 1; @@ -1019,11 +1054,6 @@ parse_cons_expression_v850 (exp) /* 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