From c2617f40672c99c841002496a79d763bbda49bef Mon Sep 17 00:00:00 2001 From: DJ Delorie Date: Tue, 17 Dec 2002 03:57:49 +0000 Subject: [PATCH] * xstormy16-asm.c: Regenerate. --- opcodes/ChangeLog | 4 ++++ opcodes/xstormy16-asm.c | 53 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index 5befb2dd6a3..293884015e1 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,7 @@ +2002-12-16 Andrew MacLeod + + * xstormy16-asm.c: Regenerate. + 2002-12-16 Alan Modra * ns32k-dis.c (print_insn_ns32k): Constify "d", remove register diff --git a/opcodes/xstormy16-asm.c b/opcodes/xstormy16-asm.c index f2118f7fdcb..d4db37c7885 100644 --- a/opcodes/xstormy16-asm.c +++ b/opcodes/xstormy16-asm.c @@ -109,6 +109,9 @@ parse_small_immediate (cd, strp, opindex, valuep) enum cgen_parse_operand_result result; const char *errmsg; + if (**strp == '@') + return _("No relocation for small immediate"); + errmsg = (* cd->parse_operand_fn) (cd, CGEN_PARSE_OPERAND_INTEGER, strp, opindex, BFD_RELOC_NONE, &result, &value); @@ -122,6 +125,54 @@ parse_small_immediate (cd, strp, opindex, valuep) *valuep = value; return NULL; } + +/* Literal scan be either a normal literal, a @hi() or @lo relocation. */ + +static const char * +parse_immediate16 (cd, strp, opindex, valuep) + CGEN_CPU_DESC cd; + const char **strp; + int opindex; + unsigned long *valuep; +{ + const char *errmsg; + enum cgen_parse_operand_result result; + bfd_reloc_code_real_type code = BFD_RELOC_NONE; + bfd_vma value; + + if (strncmp (*strp, "@hi(", 4) == 0) + { + *strp += 4; + code = BFD_RELOC_HI16; + } + else + if (strncmp (*strp, "@lo(", 4) == 0) + { + *strp += 4; + code = BFD_RELOC_LO16; + } + + if (code == BFD_RELOC_NONE) + errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, valuep); + else + { + errmsg = cgen_parse_address (cd, strp, opindex, code, &result, &value); + if ((errmsg == NULL) && + (result != CGEN_PARSE_OPERAND_RESULT_QUEUED)) + errmsg = _("Operand is not a symbol"); + + *valuep = value; + if ((code == BFD_RELOC_HI16 || code == BFD_RELOC_LO16) + && **strp == ')') + *strp += 1; + else + { + errmsg = _("Syntax error: No trailing ')'"); + return errmsg; + } + } + return errmsg; +} /* -- */ const char * xstormy16_cgen_parse_operand @@ -187,7 +238,7 @@ xstormy16_cgen_parse_operand (cd, opindex, strp, fields) errmsg = cgen_parse_signed_integer (cd, strp, XSTORMY16_OPERAND_IMM12, &fields->f_imm12); break; case XSTORMY16_OPERAND_IMM16 : - errmsg = cgen_parse_unsigned_integer (cd, strp, XSTORMY16_OPERAND_IMM16, &fields->f_imm16); + errmsg = parse_immediate16 (cd, strp, XSTORMY16_OPERAND_IMM16, &fields->f_imm16); break; case XSTORMY16_OPERAND_IMM2 : errmsg = cgen_parse_unsigned_integer (cd, strp, XSTORMY16_OPERAND_IMM2, &fields->f_imm2); -- 2.30.2