Properly matching constant values
This commit is contained in:
parent
3477df9859
commit
4b0269c881
26
src/arch.c
26
src/arch.c
@ -173,6 +173,8 @@ ArchInstruction * arch_get_instruction_by_opcode(Arch * arch, uint8_t size,
|
|||||||
/* arch_get_instruction_by_call */
|
/* arch_get_instruction_by_call */
|
||||||
static int _call_operands(Arch * arch, ArchInstruction * instruction,
|
static int _call_operands(Arch * arch, ArchInstruction * instruction,
|
||||||
ArchInstructionCall * call);
|
ArchInstructionCall * call);
|
||||||
|
static int _call_operands_constant(ArchOperandDefinition definition,
|
||||||
|
ArchOperand * operand);
|
||||||
static int _call_operands_dregister(Arch * arch,
|
static int _call_operands_dregister(Arch * arch,
|
||||||
ArchOperandDefinition definition, ArchOperand * operand);
|
ArchOperandDefinition definition, ArchOperand * operand);
|
||||||
static int _call_operands_immediate(ArchOperandDefinition definition,
|
static int _call_operands_immediate(ArchOperandDefinition definition,
|
||||||
@ -224,10 +226,20 @@ static int _call_operands(Arch * arch, ArchInstruction * instruction,
|
|||||||
__func__, i, AO_GET_TYPE(definition),
|
__func__, i, AO_GET_TYPE(definition),
|
||||||
AO_GET_TYPE(operand->type));
|
AO_GET_TYPE(operand->type));
|
||||||
#endif
|
#endif
|
||||||
if(AO_GET_TYPE(definition) != operand->type)
|
if(AO_GET_TYPE(definition) == AOT_CONSTANT)
|
||||||
|
{
|
||||||
|
if(operand->type != AOT_IMMEDIATE)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else if(AO_GET_TYPE(definition) != operand->type)
|
||||||
return -1;
|
return -1;
|
||||||
switch(AO_GET_TYPE(definition))
|
switch(AO_GET_TYPE(definition))
|
||||||
{
|
{
|
||||||
|
case AOT_CONSTANT:
|
||||||
|
if(_call_operands_constant(definition, operand)
|
||||||
|
!= 0)
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
case AOT_IMMEDIATE:
|
case AOT_IMMEDIATE:
|
||||||
if(_call_operands_immediate(definition, operand)
|
if(_call_operands_immediate(definition, operand)
|
||||||
!= 0)
|
!= 0)
|
||||||
@ -248,6 +260,18 @@ static int _call_operands(Arch * arch, ArchInstruction * instruction,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int _call_operands_constant(ArchOperandDefinition definition,
|
||||||
|
ArchOperand * operand)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
fprintf(stderr, "DEBUG: %s() %u %lu\n", __func__,
|
||||||
|
AO_GET_VALUE(definition),
|
||||||
|
operand->value.immediate.value);
|
||||||
|
#endif
|
||||||
|
return (AO_GET_VALUE(definition) == operand->value.immediate.value)
|
||||||
|
? 0 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
static int _call_operands_dregister(Arch * arch,
|
static int _call_operands_dregister(Arch * arch,
|
||||||
ArchOperandDefinition definition, ArchOperand * operand)
|
ArchOperandDefinition definition, ArchOperand * operand)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user