From: Jeff Law Date: Sat, 31 Aug 1996 07:28:22 +0000 (+0000) Subject: * v850-opc.c (insert_d22, extract_d22): New functions. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=574b9cb3d3471eba6dab1e1492ad4b265a7babf8;p=binutils-gdb.git * v850-opc.c (insert_d22, extract_d22): New functions. (v850_operands): Use insert_d22 and extract_d22 for D22 operands. (insert_d9): Fix range check. --- diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index 4ff0041bc51..f908e3ff21a 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,4 +1,11 @@ start-sanitize-v850 +Sat Aug 31 01:27:26 1996 Jeffrey A Law (law@cygnus.com) + + * v850-opc.c (insert_d22, extract_d22): New functions. + (v850_operands): Use insert_d22 and extract_d22 for + D22 operands. + (insert_d9): Fix range check. + Fri Aug 30 18:01:02 1996 J.T. Conklin * v850-opc.c (v850_operands): Add V850_OPERAND_SIGNED flag diff --git a/opcodes/v850-opc.c b/opcodes/v850-opc.c index 2cd98e87f37..5239d801a73 100644 --- a/opcodes/v850-opc.c +++ b/opcodes/v850-opc.c @@ -4,6 +4,8 @@ /* Local insertion and extraction functions. */ static unsigned long insert_d9 PARAMS ((unsigned long, long, const char **)); static long extract_d9 PARAMS ((unsigned long, int *)); +static unsigned long insert_d22 PARAMS ((unsigned long, long, const char **)); +static long extract_d22 PARAMS ((unsigned long, int *)); /* regular opcode */ #define OP(x) ((x & 0x3f) << 5) @@ -58,7 +60,7 @@ const struct v850_operand v850_operands[] = { /* The DISP22 field in a format 4 insn. */ #define D22 (D16+1) - { 22, 0, 0, 0, V850_OPERAND_SIGNED }, + { 22, 0, insert_d22, extract_d22, V850_OPERAND_SIGNED }, #define B3 (D22+1) /* The 3 bit immediate field in format 8 insn. */ @@ -258,7 +260,7 @@ insert_d9 (insn, value, errmsg) long value; const char **errmsg; { - if (value > 511 || value <= -512) + if (value > 255 || value <= -256) *errmsg = "value out of range"; return (insn | ((value & 0x1f0) << 7) | ((value & 0x0e) << 3)); @@ -276,3 +278,25 @@ extract_d9 (insn, invalid) return ret; } + +static unsigned long +insert_d22 (insn, value, errmsg) + unsigned long insn; + long value; + const char **errmsg; +{ + if (value > 0xfffff || value <= -0x100000) + *errmsg = "value out of range"; + + return (insn | ((value & 0xfffe) << 16) | ((value & 0x3f0000) >> 16)); +} + +static long +extract_d22 (insn, invalid) + unsigned long insn; + int *invalid; +{ + int ret = ((insn & 0xfffe0000) >> 16) | ((insn & 0x3f) << 16); + + return ((ret << 10) >> 10); +}