api: Store index register in operand struct

Combined with some reordering of the struct fields, this reduces the
size of an FdInstr from 56 bytes to 48 bytes.
This commit is contained in:
Alexis Engelke
2020-05-17 11:16:48 +02:00
parent 7a364fcada
commit c3df15e19b
2 changed files with 11 additions and 11 deletions

View File

@@ -249,8 +249,7 @@ decode_modrm(const uint8_t* buffer, int len, DecodeMode mode, FdInstr* instr,
}
out_o1->type = FD_OT_MEM;
instr->idx_scale = scale;
instr->idx_reg = !vsib && idx == 4 ? FD_REG_NONE : idx;
out_o1->misc = (scale << 6) | (!vsib && idx == 4 ? FD_REG_NONE : idx);
// RIP-relative addressing only if SIB-byte is absent
if (mod == 0 && rm == 5 && mode == DECODE_64)
@@ -521,7 +520,7 @@ fd_decode(const uint8_t* buffer, size_t len_sz, int mode_int, uintptr_t address,
FdOp* operand = &instr->operands[DESC_IMM_IDX(desc)];
operand->type = FD_OT_MEM;
operand->reg = FD_REG_NONE;
instr->idx_reg = FD_REG_NONE;
operand->misc = FD_REG_NONE;
if (UNLIKELY(off + addr_size > len))
return FD_ERR_PARTIAL;