aboutsummaryrefslogtreecommitdiff
path: root/opcodes/v850-opc.c
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>1996-08-31 07:28:22 +0000
committerJeff Law <law@redhat.com>1996-08-31 07:28:22 +0000
commit574b9cb3d3471eba6dab1e1492ad4b265a7babf8 (patch)
tree763ccf351bb25fab59abb99d6bf676c42a857470 /opcodes/v850-opc.c
parent6cff464b3a78db1a38ff8e9f40221f342c37993d (diff)
downloadgdb-574b9cb3d3471eba6dab1e1492ad4b265a7babf8.zip
gdb-574b9cb3d3471eba6dab1e1492ad4b265a7babf8.tar.gz
gdb-574b9cb3d3471eba6dab1e1492ad4b265a7babf8.tar.bz2
* 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.
Diffstat (limited to 'opcodes/v850-opc.c')
-rw-r--r--opcodes/v850-opc.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/opcodes/v850-opc.c b/opcodes/v850-opc.c
index 2cd98e8..5239d80 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);
+}