Disassembling some more i386
This commit is contained in:
parent
fbf01a7e91
commit
37edc4e721
@ -35,9 +35,9 @@ static int _decode_dregister(ArchPlugin * plugin, ArchInstructionCall * call,
|
||||
static int _decode_immediate(ArchPlugin * plugin, ArchInstructionCall * call,
|
||||
size_t i);
|
||||
static int _decode_modrm(ArchPlugin * plugin, ArchInstructionCall * call,
|
||||
size_t i);
|
||||
size_t * i);
|
||||
static int _decode_operand(ArchPlugin * plugin, ArchInstructionCall * call,
|
||||
size_t i);
|
||||
size_t * i);
|
||||
static int _decode_register(ArchPlugin * plugin, ArchInstructionCall * call,
|
||||
size_t i);
|
||||
|
||||
@ -85,7 +85,7 @@ static int _i386_decode(ArchPlugin * plugin, ArchInstructionCall * call)
|
||||
call->operands[1].type = ai->op2;
|
||||
call->operands[2].type = ai->op3;
|
||||
for(i = 0; i < 3 && AO_GET_TYPE(call->operands[i].type) != 0; i++)
|
||||
if(_decode_operand(plugin, call, i) != 0)
|
||||
if(_decode_operand(plugin, call, &i) != 0)
|
||||
return -1;
|
||||
call->operands_cnt = i;
|
||||
return 0;
|
||||
@ -154,10 +154,10 @@ static int _decode_immediate(ArchPlugin * plugin, ArchInstructionCall * call,
|
||||
}
|
||||
|
||||
static int _decode_modrm(ArchPlugin * plugin, ArchInstructionCall * call,
|
||||
size_t i)
|
||||
size_t * i)
|
||||
{
|
||||
ArchPluginHelper * helper = plugin->helper;
|
||||
ArchOperand * ao = &call->operands[i];
|
||||
ArchOperand * ao = &call->operands[*i];
|
||||
uint8_t u8;
|
||||
uint32_t uW; /* XXX should be uintW_t */
|
||||
ArchRegister * ar;
|
||||
@ -202,23 +202,25 @@ static int _decode_modrm(ArchPlugin * plugin, ArchInstructionCall * call,
|
||||
ao->type = AO_DREGISTER(0, 0, W, 0);
|
||||
ao->value.dregister.name = ar->name;
|
||||
}
|
||||
/* FIXME really implement the next operand */
|
||||
(*i)++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _decode_operand(ArchPlugin * plugin, ArchInstructionCall * call,
|
||||
size_t i)
|
||||
size_t * i)
|
||||
{
|
||||
if(AO_GET_FLAGS(call->operands[i].type) & AOF_I386_MODRM)
|
||||
if(AO_GET_FLAGS(call->operands[*i].type) & AOF_I386_MODRM)
|
||||
return _decode_modrm(plugin, call, i);
|
||||
switch(AO_GET_TYPE(call->operands[i].type))
|
||||
switch(AO_GET_TYPE(call->operands[*i].type))
|
||||
{
|
||||
/* FIXME implement the rest */
|
||||
case AOT_DREGISTER:
|
||||
return _decode_dregister(plugin, call, i);
|
||||
return _decode_dregister(plugin, call, *i);
|
||||
case AOT_IMMEDIATE:
|
||||
return _decode_immediate(plugin, call, i);
|
||||
return _decode_immediate(plugin, call, *i);
|
||||
case AOT_REGISTER:
|
||||
return _decode_register(plugin, call, i);
|
||||
return _decode_register(plugin, call, *i);
|
||||
}
|
||||
return -error_set_code(1, "%s", strerror(ENOSYS));
|
||||
}
|
||||
|
@ -51,6 +51,12 @@
|
||||
#define OP_RW AO_REGISTER(0, W, 0)
|
||||
#define OP_al AO_REGISTER(AOF_IMPLICIT, REG_al_size, REG_al_id)
|
||||
#define OP_cl AO_REGISTER(AOF_IMPLICIT, REG_cl_size, REG_cl_id)
|
||||
#define OP_dl AO_REGISTER(AOF_IMPLICIT, REG_dl_size, REG_dl_id)
|
||||
#define OP_bl AO_REGISTER(AOF_IMPLICIT, REG_bl_size, REG_bl_id)
|
||||
#define OP_ah AO_REGISTER(AOF_IMPLICIT, REG_ah_size, REG_ah_id)
|
||||
#define OP_ch AO_REGISTER(AOF_IMPLICIT, REG_ch_size, REG_ch_id)
|
||||
#define OP_dh AO_REGISTER(AOF_IMPLICIT, REG_dh_size, REG_dh_id)
|
||||
#define OP_bh AO_REGISTER(AOF_IMPLICIT, REG_bh_size, REG_bh_id)
|
||||
#define OP_cs AO_REGISTER(AOF_IMPLICIT, REG_cs_size, REG_cs_id)
|
||||
#define OP_ds AO_REGISTER(AOF_IMPLICIT, REG_ds_size, REG_ds_id)
|
||||
#define OP_es AO_REGISTER(AOF_IMPLICIT, REG_es_size, REG_es_id)
|
||||
@ -692,15 +698,43 @@
|
||||
/* LOOPZ 0xe1 1 rel8 */
|
||||
{ "loopz", 0xe1, OP1F, OP_S8, AOT_NONE, AOT_NONE },
|
||||
/* MOV 0x88 1 r/m8 r8 */
|
||||
{ "mov", 0x88, OP1F, OP_RM8_D0_R,OP_R8, AOT_NONE },
|
||||
{ "mov", 0x88, OP1F, OP_RM8_D8_R,OP_R8, AOT_NONE },
|
||||
{ "mov", 0x88, OP1F, OP_RM8_DW_R,OP_R8, AOT_NONE },
|
||||
{ "mov", 0x88, OP1F, OP_RM8_R8_R,OP_R8, AOT_NONE },
|
||||
{ "mov", 0x88, OP1F, OP_RM8_D0, OP_R8, AOT_NONE },
|
||||
{ "mov", 0x88, OP1F, OP_RM8_D8, OP_R8, AOT_NONE },
|
||||
{ "mov", 0x88, OP1F, OP_RM8_DW, OP_R8, AOT_NONE },
|
||||
{ "mov", 0x88, OP1F, OP_RM8_R8, OP_R8, AOT_NONE },
|
||||
/* MOV 0x89 1 r/mW rW */
|
||||
{ "mov", 0x89, OP1F, OP_RMW_D0_R,OP_RW, AOT_NONE },
|
||||
{ "mov", 0x89, OP1F, OP_RMW_D8_R,OP_RW, AOT_NONE },
|
||||
{ "mov", 0x89, OP1F, OP_RMW_DW_R,OP_RW, AOT_NONE },
|
||||
{ "mov", 0x89, OP1F, OP_RMW_RW_R,OP_RW, AOT_NONE },
|
||||
{ "mov", 0x89, OP1F, OP_RMW_D0, OP_RW, AOT_NONE },
|
||||
{ "mov", 0x89, OP1F, OP_RMW_D8, OP_RW, AOT_NONE },
|
||||
{ "mov", 0x89, OP1F, OP_RMW_DW, OP_RW, AOT_NONE },
|
||||
{ "mov", 0x89, OP1F, OP_RMW_RW, OP_RW, AOT_NONE },
|
||||
/* MOV 0xb0 +rb 1 r8 imm8 */
|
||||
{ "mov", 0xb0, OP1F, OP_al, OP_S8, AOT_NONE },
|
||||
{ "mov", 0xb1, OP1F, OP_cl, OP_S8, AOT_NONE },
|
||||
{ "mov", 0xb2, OP1F, OP_dl, OP_S8, AOT_NONE },
|
||||
{ "mov", 0xb3, OP1F, OP_bl, OP_S8, AOT_NONE },
|
||||
{ "mov", 0xb4, OP1F, OP_ah, OP_S8, AOT_NONE },
|
||||
{ "mov", 0xb5, OP1F, OP_ch, OP_S8, AOT_NONE },
|
||||
{ "mov", 0xb6, OP1F, OP_dh, OP_S8, AOT_NONE },
|
||||
{ "mov", 0xb7, OP1F, OP_bh, OP_S8, AOT_NONE },
|
||||
/* MOV 0xb8 +rw 1 rW immW */
|
||||
{ "mov", 0xb8, OP1F, OP_AX, OP_SW, AOT_NONE },
|
||||
{ "mov", 0xb9, OP1F, OP_CX, OP_SW, AOT_NONE },
|
||||
{ "mov", 0xba, OP1F, OP_DX, OP_SW, AOT_NONE },
|
||||
{ "mov", 0xbb, OP1F, OP_BX, OP_SW, AOT_NONE },
|
||||
{ "mov", 0xbc, OP1F, OP_SP, OP_SW, AOT_NONE },
|
||||
{ "mov", 0xbd, OP1F, OP_BP, OP_SW, AOT_NONE },
|
||||
{ "mov", 0xbe, OP1F, OP_SI, OP_SW, AOT_NONE },
|
||||
{ "mov", 0xbf, OP1F, OP_DI, OP_SW, AOT_NONE },
|
||||
/* MOV 0xc6 /0 1 r/m8 imm8 */
|
||||
{ "mov", 0xc6, OP1F, OP_RM8_D0+0,OP_S8, AOT_NONE },
|
||||
{ "mov", 0xc6, OP1F, OP_RM8_D8+0,OP_S8, AOT_NONE },
|
||||
{ "mov", 0xc6, OP1F, OP_RM8_DW+0,OP_S8, AOT_NONE },
|
||||
{ "mov", 0xc6, OP1F, OP_RM8_R8+0,OP_S8, AOT_NONE },
|
||||
/* MOV 0xc7 /0 1 r/mW immW */
|
||||
{ "mov", 0xc7, OP1F, OP_RMW_D0+0,OP_SW, AOT_NONE },
|
||||
{ "mov", 0xc7, OP1F, OP_RMW_D8+0,OP_SW, AOT_NONE },
|
||||
{ "mov", 0xc7, OP1F, OP_RMW_DW+0,OP_SW, AOT_NONE },
|
||||
{ "mov", 0xc7, OP1F, OP_RMW_RW+0,OP_SW, AOT_NONE },
|
||||
/* MOV 0x0f20 /r 2 r32 cr0-cr4 */
|
||||
/* FIXME implement */
|
||||
/* MOV 0x0f22 /r 2 cr0-cr4 r32 */
|
||||
|
Loading…
Reference in New Issue
Block a user