Fixed handling of the AOF_IMPLICIT flag
This commit is contained in:
parent
a3402c25d7
commit
b15f7b60fe
@ -67,6 +67,8 @@ typedef enum _ArchOperandType
|
||||
# define AOM_VALUE 0x000000ff
|
||||
|
||||
/* flags */
|
||||
/* constants */
|
||||
# define AOF_IMPLICIT 0x1
|
||||
/* for immediate */
|
||||
# define AOF_SIGNED 0x1
|
||||
/* for registers */
|
||||
|
@ -28,6 +28,8 @@ static int _i386_write(ArchPlugin * plugin, ArchInstruction * instruction,
|
||||
|
||||
|
||||
/* functions */
|
||||
static int _write_constant(ArchPlugin * plugin,
|
||||
ArchOperandDefinition definition, ArchOperand * operand);
|
||||
static int _write_dregister(ArchPlugin * plugin, uint32_t * i,
|
||||
ArchOperandDefinition * definitions, ArchOperand * operands);
|
||||
static int _write_immediate(ArchPlugin * plugin,
|
||||
@ -62,6 +64,15 @@ static int _i386_write(ArchPlugin * plugin, ArchInstruction * instruction,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _write_constant(ArchPlugin * plugin,
|
||||
ArchOperandDefinition definition, ArchOperand * operand)
|
||||
{
|
||||
if(AO_GET_FLAGS(definition) & AOF_IMPLICIT)
|
||||
return 0;
|
||||
definition &= ~(AOM_FLAGS);
|
||||
return _write_immediate(plugin, definition, operand);
|
||||
}
|
||||
|
||||
static int _write_dregister(ArchPlugin * plugin, uint32_t * i,
|
||||
ArchOperandDefinition * definitions, ArchOperand * operands)
|
||||
{
|
||||
@ -126,8 +137,6 @@ static int _write_immediate(ArchPlugin * plugin,
|
||||
{
|
||||
uint64_t value = operand->value.immediate.value;
|
||||
|
||||
if(AO_GET_FLAGS(definition) & AOF_IMPLICIT)
|
||||
return 0;
|
||||
if((AO_GET_FLAGS(definition) & AOF_SIGNED)
|
||||
&& operand->value.immediate.negative != 0)
|
||||
value = -value;
|
||||
@ -217,9 +226,8 @@ static int _write_operand(ArchPlugin * plugin, uint32_t * i,
|
||||
{
|
||||
switch(operands[*i].type)
|
||||
{
|
||||
break;
|
||||
case AOT_CONSTANT: /* consider it an immediate value */
|
||||
return _write_immediate(plugin, definitions[*i],
|
||||
case AOT_CONSTANT:
|
||||
return _write_constant(plugin, definitions[*i],
|
||||
&operands[*i]);
|
||||
case AOT_DREGISTER:
|
||||
return _write_dregister(plugin, i, definitions,
|
||||
|
@ -103,7 +103,7 @@
|
||||
#define OP_RMW_RW_R AO_REGISTER(AOF_I386_MODRM, W, 8) /* 0xc0 */
|
||||
|
||||
/* constant values */
|
||||
#define OP_C3 AO_CONSTANT(AOF_IMPLICIT, 8, 3)
|
||||
#define OP_C3 AO_CONSTANT(AOF_IMPLICIT, 8, 0x03)
|
||||
|
||||
/* immediate values */
|
||||
#define OP_S8 AO_IMMEDIATE(AOF_SIGNED, 0, 8)
|
||||
|
Loading…
Reference in New Issue
Block a user