#define COERCE_SIGNED_CHAR(ch) ((int) (((ch) ^ 0x80) & 0xFF) - 128)
#endif
+/* Error code of print_insn_arg's return value. */
+
+enum print_insn_arg_error
+ {
+ /* An invalid operand is found. */
+ PRINT_INSN_ARG_INVALID_OPERAND = -1,
+
+ /* An opcode table error. */
+ PRINT_INSN_ARG_INVALID_OP_TABLE = -2,
+
+ /* A memory error. */
+ PRINT_INSN_ARG_MEMORY_ERROR = -3,
+ };
+
/* Get a 1 byte signed integer. */
#define NEXTBYTE(p, val) \
do \
{ \
p += 2; \
if (!FETCH_DATA (info, p)) \
- return -3; \
+ return PRINT_INSN_ARG_MEMORY_ERROR; \
val = COERCE_SIGNED_CHAR (p[-1]); \
} \
while (0)
{ \
p += 4; \
if (!FETCH_DATA (info, p)) \
- return -3; \
+ return PRINT_INSN_ARG_MEMORY_ERROR; \
val = (unsigned int) ((((((p[-4] << 8) + p[-3]) << 8) + p[-2]) << 8) + p[-1]); \
} \
while (0)
{ \
p += 4; \
if (!FETCH_DATA (info, p)) \
- return -3; \
+ return PRINT_INSN_ARG_MEMORY_ERROR; \
floatformat_to_double (& floatformat_ieee_single_big, \
(char *) p - 4, & val); \
} \
{ \
p += 8; \
if (!FETCH_DATA (info, p)) \
- return -3; \
+ return PRINT_INSN_ARG_MEMORY_ERROR; \
floatformat_to_double (& floatformat_ieee_double_big, \
(char *) p - 8, & val); \
} \
{ \
p += 12; \
if (!FETCH_DATA (info, p)) \
- return -3; \
+ return PRINT_INSN_ARG_MEMORY_ERROR; \
floatformat_to_double (& floatformat_m68881_ext, \
(char *) p - 12, & val); \
} \
{ \
p += 12; \
if (!FETCH_DATA (info, p)) \
- return -3; \
+ return PRINT_INSN_ARG_MEMORY_ERROR; \
val = 0.0; \
} \
while (0)
};
/* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive)
- to ADDR (exclusive) are valid. Returns 1 for success, 0 on error. */
+ to ADDR (exclusive) are valid. Returns 1 for success, 0 on memory
+ error. */
#define FETCH_DATA(info, addr) \
((addr) <= ((struct private *) (info->private_data))->max_fetched \
? 1 : fetch_data ((info), (addr)))
{ \
val = fetch_arg (buffer, place, size, info); \
if (val < 0) \
- return -3; \
+ return PRINT_INSN_ARG_MEMORY_ERROR; \
} \
while (0)
/* Returns number of bytes "eaten" by the operand, or
- return -1 if an invalid operand was found, or -2 if
- an opcode tabe error was found or -3 to simply abort.
- ADDR is the pc for this arg to be relative to. */
+ return enum print_insn_arg_error. ADDR is the pc for this arg to be
+ relative to. */
static int
print_insn_arg (const char *d,
(*info->fprintf_func) (info->stream, "{#%d}", val);
}
else
- return -1;
+ return PRINT_INSN_ARG_INVALID_OPERAND;
break;
case '#':
else if (place == 'b')
NEXTBYTE (p1, val);
else if (place == 'w' || place == 'W')
- NEXTWORD (p1, val, -3);
+ NEXTWORD (p1, val, PRINT_INSN_ARG_MEMORY_ERROR);
else if (place == 'l')
- NEXTLONG (p1, val, -3);
+ NEXTLONG (p1, val, PRINT_INSN_ARG_MEMORY_ERROR);
else
- return -2;
+ return PRINT_INSN_ARG_INVALID_OP_TABLE;
(*info->fprintf_func) (info->stream, "#%d", val);
break;
else if (place == 'B')
disp = COERCE_SIGNED_CHAR (buffer[1]);
else if (place == 'w' || place == 'W')
- NEXTWORD (p, disp, -3);
+ NEXTWORD (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
else if (place == 'l' || place == 'L' || place == 'C')
- NEXTLONG (p, disp, -3);
+ NEXTLONG (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
else if (place == 'g')
{
NEXTBYTE (buffer, disp);
if (disp == 0)
- NEXTWORD (p, disp, -3);
+ NEXTWORD (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
else if (disp == -1)
- NEXTLONG (p, disp, -3);
+ NEXTLONG (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
}
else if (place == 'c')
{
if (buffer[1] & 0x40) /* If bit six is one, long offset. */
- NEXTLONG (p, disp, -3);
+ NEXTLONG (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
else
- NEXTWORD (p, disp, -3);
+ NEXTWORD (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
}
else
- return -2;
+ return PRINT_INSN_ARG_INVALID_OP_TABLE;
(*info->print_address_func) (addr + disp, info);
break;
{
int val1;
- NEXTWORD (p, val, -3);
+ NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
FETCH_ARG (3, val1);
(*info->fprintf_func) (info->stream, "%s@(%d)", reg_names[val1 + 8], val);
break;
else if (val == 3)
(*info->fprintf_func) (info->stream, ">>");
else
- return -1;
+ return PRINT_INSN_ARG_INVALID_OPERAND;
break;
case 'I':
/* Get coprocessor ID... */
val = fetch_arg (buffer, 'd', 3, info);
if (val < 0)
- return -3;
+ return PRINT_INSN_ARG_MEMORY_ERROR;
if (val != 1) /* Unusual coprocessor ID? */
(*info->fprintf_func) (info->stream, "(cpid=%d) ", val);
break;
{
val = fetch_arg (buffer, 'x', 6, info);
if (val < 0)
- return -3;
+ return PRINT_INSN_ARG_MEMORY_ERROR;
val = ((val & 7) << 3) + ((val >> 3) & 7);
}
else
{
val = fetch_arg (buffer, 's', 6, info);
if (val < 0)
- return -3;
+ return PRINT_INSN_ARG_MEMORY_ERROR;
}
/* If the <ea> is invalid for *d, then reject this match. */
if (!m68k_valid_ea (*d, val))
- return -1;
+ return PRINT_INSN_ARG_INVALID_OPERAND;
/* Get register number assuming address register. */
regno = (val & 7) + 8;
break;
case 5:
- NEXTWORD (p, val, -3);
+ NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
(*info->fprintf_func) (info->stream, "%s@(%d)", regname, val);
break;
case 6:
p = print_indexed (regno, p, addr, info);
if (p == NULL)
- return -3;
+ return PRINT_INSN_ARG_MEMORY_ERROR;
break;
case 7:
switch (val & 7)
{
case 0:
- NEXTWORD (p, val, -3);
+ NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
(*info->print_address_func) (val, info);
break;
break;
case 2:
- NEXTWORD (p, val, -3);
+ NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
(*info->fprintf_func) (info->stream, "%%pc@(");
(*info->print_address_func) (addr + val, info);
(*info->fprintf_func) (info->stream, ")");
case 3:
p = print_indexed (-1, p, addr, info);
if (p == NULL)
- return -3;
+ return PRINT_INSN_ARG_MEMORY_ERROR;
break;
case 4:
break;
case 'w':
- NEXTWORD (p, val, -3);
+ NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
flt_p = 0;
break;
case 'l':
- NEXTLONG (p, val, -3);
+ NEXTLONG (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
flt_p = 0;
break;
break;
default:
- return -1;
+ return PRINT_INSN_ARG_INVALID_OPERAND;
}
if (flt_p) /* Print a float? */
(*info->fprintf_func) (info->stream, "#0e%g", flval);
break;
default:
- return -1;
+ return PRINT_INSN_ARG_INVALID_OPERAND;
}
}
{
char doneany;
p1 = buffer + 2;
- NEXTWORD (p1, val, -3);
+ NEXTWORD (p1, val, PRINT_INSN_ARG_MEMORY_ERROR);
/* Move the pointer ahead if this point is farther ahead
than the last. */
p = p1 > p ? p1 : p;
(*info->fprintf_func) (info->stream, "%s", fpcr_names[val]);
}
else
- return -2;
+ return PRINT_INSN_ARG_INVALID_OP_TABLE;
break;
case 'X':
break;
default:
- return -2;
+ return PRINT_INSN_ARG_INVALID_OP_TABLE;
}
return p - p0;
if (eaten >= 0)
p += eaten;
- else if (eaten == -1 || eaten == -3)
+ else if (eaten == PRINT_INSN_ARG_INVALID_OPERAND
+ || eaten == PRINT_INSN_ARG_MEMORY_ERROR)
{
info->fprintf_func = save_printer;
info->print_address_func = save_print_address;