+2002-12-16 Andrew MacLeod <amacleod@redhat.com>
+
+ * cpu/xstormy16.cpu (imm16): Call handler immediate16.
+ * cpu/xstormy16.opc (parse_small_immediate): Return on '@'.
+ (parse_immediate16): Handle immediate16 values, which now include
+ @hi(label) and @lo(label)
+
2002-12-03 Alan Modra <amodra@bigpond.net.au>
* desc-cpu.scm (gen-maybe-multi-ifld): Remove superfluous parens.
(dnop imm12 "12 bit signed immediate" () h-sint f-imm12)
(dnf f-imm16 "16 bit" (SIGN-OPT) 16 16)
-(dnop imm16 "16 bit immediate" () h-uint f-imm16)
+(define-operand
+ (name imm16)
+ (comment "16 bit immediate")
+ (attrs)
+ (type h-uint)
+ (index f-imm16)
+ (handlers (parse "immediate16"))
+)
(dnf f-lmem8 "8 bit unsigned low memory" (ABS-ADDR) 8 8)
(define-operand
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);
*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;
+}
/* -- */