x86: X86_immediate_size() returns uint8

This commit is contained in:
Nguyen Anh Quynh 2018-07-04 23:02:22 +08:00
parent 795ffa39e7
commit 97f34c87c7
4 changed files with 7 additions and 7 deletions

View File

@ -658,7 +658,7 @@ static void printOperand(MCInst *MI, unsigned OpNo, SStream *O)
// Print X86 immediates as signed values.
uint8_t encsize;
int64_t imm = MCOperand_getImm(Op);
int opsize = X86_immediate_size(MCInst_getOpcode(MI), &encsize);
uint8_t opsize = X86_immediate_size(MCInst_getOpcode(MI), &encsize);
if (opsize == 1) // print 1 byte immediate in positive form
imm = imm & 0xff;
@ -739,7 +739,7 @@ static void printOperand(MCInst *MI, unsigned OpNo, SStream *O)
MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].imm = imm;
if (opsize > 0) {
MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = (uint8_t)opsize;
MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = opsize;
MI->flat_insn->detail->x86.encoding.imm_size = encsize;
} else if (MI->op1_size > 0)
MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->op1_size;

View File

@ -803,7 +803,7 @@ static void printPCRelImm(MCInst *MI, unsigned OpNo, SStream *O)
MCOperand *Op = MCInst_getOperand(MI, OpNo);
if (MCOperand_isImm(Op)) {
int64_t imm = MCOperand_getImm(Op) + MI->flat_insn->size + MI->address;
int opsize = X86_immediate_size(MI->Opcode, NULL);
uint8_t opsize = X86_immediate_size(MI->Opcode, NULL);
// truncat imm for non-64bit
if (MI->csh->mode != CS_MODE_64) {
@ -835,7 +835,7 @@ static void printPCRelImm(MCInst *MI, unsigned OpNo, SStream *O)
if (MI->flat_insn->detail->x86.op_count > 0)
MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->flat_insn->detail->x86.operands[0].size;
else if (opsize > 0)
MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = (uint8_t)opsize;
MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = opsize;
else
MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->imm_size;
MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].imm = imm;
@ -887,7 +887,7 @@ static void printOperand(MCInst *MI, unsigned OpNo, SStream *O)
} else if (MCOperand_isImm(Op)) {
uint8_t encsize;
int64_t imm = MCOperand_getImm(Op);
int opsize = X86_immediate_size(MCInst_getOpcode(MI), &encsize);
uint8_t opsize = X86_immediate_size(MCInst_getOpcode(MI), &encsize);
if (opsize == 1) // print 1 byte immediate in positive form
imm = imm & 0xff;

View File

@ -3572,7 +3572,7 @@ static struct size_id {
};
// given the instruction name, return the size of its immediate operand (or 0)
int X86_immediate_size(unsigned int id, uint8_t *enc_size)
uint8_t X86_immediate_size(unsigned int id, uint8_t *enc_size)
{
#if 0
// linear searching

View File

@ -69,6 +69,6 @@ void X86_reg_access(const cs_insn *insn,
cs_regs regs_write, uint8_t *regs_write_count);
// given the instruction id, return the size of its immediate operand (or 0)
int X86_immediate_size(unsigned int id, uint8_t *enc_size);
uint8_t X86_immediate_size(unsigned int id, uint8_t *enc_size);
#endif