Changed register pair handling in M68K header

* instead of using bit operations, we now leverage the size of the
  enclosing union to avoid running code and provide a more convenient
  interface to the library user.
This commit is contained in:
Inokentiy Babushkin 2016-05-08 23:19:47 +02:00
parent f29ee89489
commit 46e10afb24
2 changed files with 18 additions and 9 deletions

View File

@ -979,19 +979,21 @@ static void build_cas2(m68k_info *info, int size)
op0->address_mode = M68K_AM_NONE;
op0->type = M68K_OP_REG_PAIR;
op0->register_bits = (((extension >> 16) & 7) << 4) | (extension & 7);
op0->reg_pair.reg_0 = (extension >> 16) & 7;
op0->reg_pair.reg_1 = extension & 7;
op1->address_mode = M68K_AM_NONE;
op1->type = M68K_OP_REG_PAIR;
op1->register_bits = (((extension >> 22) & 7) << 4) | ((extension >> 6) & 7);
op1->reg_pair.reg_0 = (extension >> 22) & 7;
op1->reg_pair.reg_1 = (extension >> 6) & 7;
reg_0 = (extension >> 28) & 7;
reg_1 = (extension >> 12) & 7;
op2->address_mode = M68K_AM_NONE;
op2->type = M68K_OP_REG_PAIR;
op2->register_bits = ((reg_0 + (BIT_1F(extension) ? 8 : 0)) << 4) |
(reg_1 + (BIT_F(extension) ? 8 : 0));
op2->reg_pair.reg_0 = reg_0 + (BIT_1F(extension) ? 8 : 0);
op2->reg_pair.reg_1 = reg_1 + (BIT_F(extension) ? 8 : 0);
}
static void build_chk2_cmp2(m68k_info *info, int size)
@ -2244,7 +2246,8 @@ static void d68020_divl(m68k_info *info)
op1->address_mode = M68K_AM_NONE;
op1->type = M68K_OP_REG_PAIR;
op1->register_bits = (reg_0 << 4) | reg_1;
op1->reg_pair.reg_0 = reg_0;
op1->reg_pair.reg_1 = reg_1;
if ((reg_0 == reg_1) || !BIT_A(extension)) {
op1->type = M68K_OP_REG;
@ -2789,7 +2792,8 @@ static void d68020_mull(m68k_info *info)
op1->address_mode = M68K_AM_NONE;
op1->type = M68K_OP_REG_PAIR;
op1->register_bits = (reg_0 << 4) | reg_1;
op1->reg_pair.reg_0 = reg_0;
op1->reg_pair.reg_1 = reg_1;
if (!BIT_A(extension)) {
op1->type = M68K_OP_REG;

View File

@ -112,7 +112,8 @@ typedef enum m68k_op_type {
M68K_OP_REG, // = CS_OP_REG (Register operand).
M68K_OP_IMM, // = CS_OP_IMM (Immediate operand).
M68K_OP_MEM, // = CS_OP_MEM (Memory operand).
M68K_OP_FP, // = CS_OP_FP (Floating-Point operand)
M68K_OP_FP_SINGLE, // single precision Floating-Point operand
M68K_OP_FP_DOUBLE, // double precision Floating-Point operand
M68K_OP_REG_BITS, // Register bits move
M68K_OP_REG_PAIR, // Register pair in the same op (upper 4 bits for first reg, lower for second)
} m68k_op_type;
@ -140,8 +141,12 @@ typedef struct cs_m68k_op {
double dimm; // double imm
float simm; // float imm
m68k_reg reg; // register value for REG operand
struct { // register pair in one operand
m68k_reg reg_0;
m68k_reg reg_1;
} reg_pair;
m68k_op_mem mem; // data when operand is targeting memory
uint32_t register_bits; // register bits for movem/cas2/etc (always in d0-d7, a0-a7, fp0 - fp7 order)
uint32_t register_bits; // register bits for movem etc. (always in d0-d7, a0-a7, fp0 - fp7 order)
};
m68k_op_type type;
m68k_address_mode address_mode; // M68K addressing mode for this op