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