capstone-engine / capstone

Capstone disassembly/disassembler framework for ARM, ARM64 (ARMv8), Alpha, BPF, Ethereum VM, HPPA, LoongArch, M68K, M680X, Mips, MOS65XX, PPC, RISC-V(rv32G/rv64G), SH, Sparc, SystemZ, TMS320C64X, TriCore, Webassembly, XCore and X86.
http://www.capstone-engine.org
7.61k stars 1.56k forks source link

Disassembly Error, repne movsd #2491

Open jskew opened 1 month ago

jskew commented 1 month ago
import capstone

print(capstone.__version__)
md = capstone.Cs( capstone.CS_ARCH_X86, capstone.CS_MODE_32 )
insn = next(md.disasm(b'\xf2\xa4', 0, 1)); print('%s %s %s' % (insn.bytes.hex(), insn.mnemonic, insn.op_str))
insn = next(md.disasm(b'\xf2\xa5', 0, 1)); print('%s %s %s' % (insn.bytes.hex(), insn.mnemonic, insn.op_str))

5.0.3

f2a4 repne movsb byte ptr es:[edi], byte ptr [esi]
f2a5 movsd dword ptr es:[edi], dword ptr [esi]

It should be:

f2a4 repne movsb byte ptr es:[edi], byte ptr [esi]
f2a5 repne movsd dword ptr es:[edi], dword ptr [esi]
jskew commented 17 hours ago

x:\capstone\arch\X86\X86Mapping.c

static bool valid_repne(cs_struct *h, unsigned int opcode)

//if (opcode == X86_MOVSW) // REP MOVSB replace if (opcode == X86_MOVSL) // REP MOVSD