* 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.
This commit is contained in:
Jeff Law
1996-08-31 07:28:22 +00:00
parent 6cff464b3a
commit 574b9cb3d3
2 changed files with 33 additions and 2 deletions

View File

@ -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 <jtc@hippo.cygnus.com>
* v850-opc.c (v850_operands): Add V850_OPERAND_SIGNED flag

View File

@ -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);
}