}
/* Extracts an operand value from an instruction. */
+/* We do not perform the shift operation for larl-type address
+ operands here since that would lead to an overflow of the 32 bit
+ integer value. Instead the shift operation is done when printing
+ the operand in print_insn_s390. */
static inline unsigned int
s390_extract_operand (unsigned char *insn, const struct s390_operand *operand)
&& (val & (1U << (operand->bits - 1))))
val |= (-1U << (operand->bits - 1)) << 1;
- /* Double value if the operand is pc relative. */
- if (operand->flags & S390_OPERAND_PCREL)
- val <<= 1;
-
/* Length x in an instructions has real length x + 1. */
if (operand->flags & S390_OPERAND_LENGTH)
val++;
if (status == 0)
{
+ const struct s390_opcode *op;
+
/* Find the first match in the opcode table. */
opcode_end = s390_opcodes + s390_num_opcodes;
for (opcode = s390_opcodes + opc_index[(int) buffer[0]];
/* Check architecture. */
if (!(opcode->modes & current_arch_mask))
continue;
+
/* Check signature of the opcode. */
if ((buffer[1] & opcode->mask[1]) != opcode->opcode[1]
|| (buffer[2] & opcode->mask[2]) != opcode->opcode[2]
|| (buffer[5] & opcode->mask[5]) != opcode->opcode[5])
continue;
+ /* Advance to an opcode with a more specific mask. */
+ for (op = opcode + 1; op < opcode_end; op++)
+ {
+ if ((buffer[0] & op->mask[0]) != op->opcode[0])
+ break;
+
+ if ((buffer[1] & op->mask[1]) != op->opcode[1]
+ || (buffer[2] & op->mask[2]) != op->opcode[2]
+ || (buffer[3] & op->mask[3]) != op->opcode[3]
+ || (buffer[4] & op->mask[4]) != op->opcode[4]
+ || (buffer[5] & op->mask[5]) != op->opcode[5])
+ continue;
+
+ if (((int)opcode->mask[0] + opcode->mask[1] +
+ opcode->mask[2] + opcode->mask[3] +
+ opcode->mask[4] + opcode->mask[5]) <
+ ((int)op->mask[0] + op->mask[1] +
+ op->mask[2] + op->mask[3] +
+ op->mask[4] + op->mask[5]))
+ opcode = op;
+ }
+
/* The instruction is valid. */
if (opcode->operands[0] != 0)
(*info->fprintf_func) (info->stream, "%s\t", opcode->name);
separator = 0;
for (opindex = opcode->operands; *opindex != 0; opindex++)
{
- unsigned int value;
-
operand = s390_operands + *opindex;
value = s390_extract_operand (buffer, operand);
else if (operand->flags & S390_OPERAND_CR)
(*info->fprintf_func) (info->stream, "%%c%i", value);
else if (operand->flags & S390_OPERAND_PCREL)
- (*info->print_address_func) (memaddr + (int) value, info);
+ (*info->print_address_func) (memaddr + (int)value + (int)value,
+ info);
else if (operand->flags & S390_OPERAND_SIGNED)
(*info->fprintf_func) (info->stream, "%i", (int) value);
else