Reduce space required by instruction width
This commit is contained in:
16
decode.c
16
decode.c
@@ -567,35 +567,37 @@ decode(const uint8_t* buffer, int len, DecodeMode mode, Instr* instr)
|
||||
instr->segment = RI_DS;
|
||||
}
|
||||
|
||||
uint8_t op_size = 0;
|
||||
uint8_t op_size_log = 0;
|
||||
if (desc->gp_size_8)
|
||||
{
|
||||
op_size = 1;
|
||||
op_size_log = 1;
|
||||
}
|
||||
#if defined(ARCH_X86_64)
|
||||
else if (prefixes & PREFIX_REXW)
|
||||
{
|
||||
op_size = 8;
|
||||
op_size_log = 4;
|
||||
}
|
||||
#endif
|
||||
else if (prefixes & PREFIX_OPSZ)
|
||||
{
|
||||
op_size = 2;
|
||||
op_size_log = 2;
|
||||
}
|
||||
#if defined(ARCH_X86_64)
|
||||
else if (mode == DECODE_64 && desc->gp_size_def64)
|
||||
{
|
||||
op_size = 8;
|
||||
op_size_log = 4;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
op_size = 4;
|
||||
op_size_log = 3;
|
||||
}
|
||||
|
||||
uint8_t op_size = (1 << op_size_log) >> 1;
|
||||
|
||||
if (UNLIKELY(desc->gp_instr_width))
|
||||
{
|
||||
instr->width = op_size;
|
||||
instr->width = op_size_log;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
4
decode.h
4
decode.h
@@ -117,7 +117,7 @@ struct Instr
|
||||
uint16_t type;
|
||||
struct Operand operands[4];
|
||||
uint8_t segment : 3;
|
||||
uint8_t width : 5;
|
||||
uint8_t width : 3;
|
||||
|
||||
/**
|
||||
* Encoded as 1 << (scale - 1) **or** no scaled register at all if zero.
|
||||
@@ -136,7 +136,7 @@ struct Instr
|
||||
typedef struct Instr Instr;
|
||||
|
||||
#define INSTR_SEGMENT(instr) ((instr)->segment)
|
||||
#define INSTR_WIDTH(instr) ((instr)->width)
|
||||
#define INSTR_WIDTH(instr) ((1 << (instr)->width) >> 1)
|
||||
#define INSTR_HAS_REP(instr) ((instr)->prefixes & PREFIX_REP)
|
||||
#define INSTR_HAS_REPNZ(instr) ((instr)->prefixes & PREFIX_REPNZ)
|
||||
#define INSTR_HAS_LOCK(instr) ((instr)->prefixes & PREFIX_LOCK)
|
||||
|
||||
4
format.c
4
format.c
@@ -83,10 +83,10 @@ instr_format(const Instr* instr, char buffer[128])
|
||||
*(cur++) = *(mnemonic++);
|
||||
}
|
||||
|
||||
if (instr->width != 0)
|
||||
if (INSTR_WIDTH(instr))
|
||||
{
|
||||
*(cur++) = '_';
|
||||
instr_format_decimal(&cur, instr->width);
|
||||
instr_format_decimal(&cur, INSTR_WIDTH(instr));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
|
||||
Reference in New Issue
Block a user