Define ARO_COUNT for the amount of operands supported

This commit is contained in:
Pierre Pronchery 2018-09-09 20:37:54 +02:00
parent 936db21b44
commit 862be04125
2 changed files with 5 additions and 2 deletions

View File

@ -175,7 +175,8 @@ typedef struct _AsmArchInstructionCall
{ {
char const * prefix; char const * prefix;
char const * name; char const * name;
AsmArchOperand operands[5]; # define ARO_COUNT 5
AsmArchOperand operands[ARO_COUNT];
uint32_t operands_cnt; uint32_t operands_cnt;
/* meta information */ /* meta information */

View File

@ -522,7 +522,7 @@ static int _i386_encode(AsmArchPlugin * plugin,
AsmArchInstructionCall const * call) AsmArchInstructionCall const * call)
{ {
uint32_t i; uint32_t i;
AsmArchOperandDefinition definitions[3]; AsmArchOperandDefinition definitions[ARO_COUNT];
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, instruction->name); fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, instruction->name);
@ -534,6 +534,8 @@ static int _i386_encode(AsmArchPlugin * plugin,
definitions[0] = instruction->op1; definitions[0] = instruction->op1;
definitions[1] = instruction->op2; definitions[1] = instruction->op2;
definitions[2] = instruction->op3; definitions[2] = instruction->op3;
for(i = 3; i < sizeof(definitions) / sizeof(*definitions); i++)
definitions[i] = 0x0;
for(i = 0; i < call->operands_cnt; i++) for(i = 0; i < call->operands_cnt; i++)
if(_encode_operand(plugin, &i, definitions, call->operands) if(_encode_operand(plugin, &i, definitions, call->operands)
!= 0) != 0)