mirror of
https://gitlab.com/qemu-project/capstone.git
synced 2025-09-17 02:01:15 +08:00
x86: more simplification on managing MCOperand. this also fixes a bug in handling memory reference instructions
This commit is contained in:
43
MCInst.c
43
MCInst.c
@ -80,10 +80,6 @@ unsigned MCInst_getNumOperands(const MCInst *inst)
|
||||
// NOTE: this will free @Op argument
|
||||
int MCInst_addOperand(MCInst *inst, MCOperand *Op)
|
||||
{
|
||||
if (inst->size == ARR_SIZE(inst->Operands))
|
||||
// full
|
||||
return -1;
|
||||
|
||||
inst->Operands[inst->size] = *Op;
|
||||
cs_mem_free(Op);
|
||||
|
||||
@ -92,26 +88,9 @@ int MCInst_addOperand(MCInst *inst, MCOperand *Op)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MCInst_addOperand0(MCInst *inst, MCOperand *Op)
|
||||
{
|
||||
if (inst->size == ARR_SIZE(inst->Operands))
|
||||
// full
|
||||
return -1;
|
||||
|
||||
inst->Operands[inst->size] = *Op;
|
||||
|
||||
inst->size++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// This addOperand2 function doesnt free Op
|
||||
int MCInst_addOperand2(MCInst *inst, MCOperand *Op)
|
||||
{
|
||||
if (inst->size == ARR_SIZE(inst->Operands))
|
||||
// full
|
||||
return -1;
|
||||
|
||||
inst->Operands[inst->size] = *Op;
|
||||
|
||||
inst->size++;
|
||||
@ -187,6 +166,7 @@ MCOperand *MCOperand_CreateReg(unsigned Reg)
|
||||
return op;
|
||||
}
|
||||
|
||||
/*
|
||||
MCOperand *MCOperand_CreateReg0(MCInst *mcInst, unsigned Reg)
|
||||
{
|
||||
MCOperand *op = &(mcInst->Operands[MCINST_CACHE]);
|
||||
@ -196,6 +176,16 @@ MCOperand *MCOperand_CreateReg0(MCInst *mcInst, unsigned Reg)
|
||||
|
||||
return op;
|
||||
}
|
||||
*/
|
||||
|
||||
void MCOperand_CreateReg0(MCInst *mcInst, unsigned Reg)
|
||||
{
|
||||
MCOperand *op = &(mcInst->Operands[mcInst->size]);
|
||||
mcInst->size++;
|
||||
|
||||
op->Kind = kRegister;
|
||||
op->RegVal = Reg;
|
||||
}
|
||||
|
||||
MCOperand *MCOperand_CreateImm(int64_t Val)
|
||||
{
|
||||
@ -207,6 +197,7 @@ MCOperand *MCOperand_CreateImm(int64_t Val)
|
||||
return op;
|
||||
}
|
||||
|
||||
/*
|
||||
MCOperand *MCOperand_CreateImm0(MCInst *mcInst, int64_t Val)
|
||||
{
|
||||
MCOperand *op = &(mcInst->Operands[MCINST_CACHE]);
|
||||
@ -216,6 +207,16 @@ MCOperand *MCOperand_CreateImm0(MCInst *mcInst, int64_t Val)
|
||||
|
||||
return op;
|
||||
}
|
||||
*/
|
||||
|
||||
void MCOperand_CreateImm0(MCInst *mcInst, int64_t Val)
|
||||
{
|
||||
MCOperand *op = &(mcInst->Operands[mcInst->size]);
|
||||
mcInst->size++;
|
||||
|
||||
op->Kind = kImmediate;
|
||||
op->ImmVal = Val;
|
||||
}
|
||||
|
||||
MCOperand *MCOperand_CreateFPImm(double Val)
|
||||
{
|
||||
|
Reference in New Issue
Block a user