parseinstrs: Respect mem-only/reg-only encodings

This commit is contained in:
Alexis Engelke
2021-01-10 12:02:08 +01:00
parent 111769832f
commit af9188e267
2 changed files with 2 additions and 5 deletions

View File

@@ -358,9 +358,6 @@ prefix_end:
if (mod == 3 || is_cr || is_dr)
{
if (op_modrm->misc == FD_RT_MEM)
return FD_ERR_UD;
uint8_t reg_idx = rm;
if (LIKELY(op_modrm->misc == FD_RT_GPL || op_modrm->misc == FD_RT_VEC))
reg_idx += prefix_rex & PREFIX_REXB ? 8 : 0;

View File

@@ -285,8 +285,8 @@ class Opcode(NamedTuple):
if self.opcext:
opcode.append((EntryKind.TABLE16, [((self.opcext - 0xc0) >> 3) | 8]))
opcode.append((EntryKind.TABLE8E, [self.opcext & 7]))
if self.modreg and self.modreg[0] is not None:
# TODO: support for /r and /m specifiers, currently adds ~1.9kiB size
if self.modreg:
# TODO: optimize for /r and /m specifiers to reduce size
mod = {"m": [0], "r": [1<<3], "rm": [0, 1<<3]}[self.modreg[1]]
reg = [self.modreg[0]] if self.modreg[0] is not None else list(range(8))
opcode.append((EntryKind.TABLE16, [x + y for x in mod for y in reg]))