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.54k stars 1.55k forks source link

[X86] Can't decode additional nop instructions #1506

Open Sonicadvance1 opened 5 years ago

Sonicadvance1 commented 5 years ago

This is similar to bug #1335 and even related. Capstone fails to decode multiple nop instructions that take modrm. ./cstool x64 "0f 19 c0" - nop eax, eax Correct ./cstool x64 "0f 1a c0" - ERROR: invalid assembly code Incorrect ./cstool x64 "0f 1b c0" - ERROR: invalid assembly code Incorrect ./cstool x64 "0f 1c c0" - ERROR: invalid assembly code Incorrect ./cstool x64 "0f 1d c0" - ERROR: invalid assembly code Incorrect ./cstool x64 "0f 1e c0" - ERROR: invalid assembly code Incorrect ./cstool x64 "0f 1f c0" - nop eax Correct

All of these are documented in AMD's Architecture programmer's manual Volume 3 Table A-4. Secondary Opcode Map (Two-byte Opcodes), Low Nibble 8–Fh Verified on hardware as well.

aquynh commented 5 years ago

Please provide expected output.

Sonicadvance1 commented 5 years ago

Expected output is is the same as the 0f 1f c0 variant, as it decodes to the same multi-byte no-op NOP r/m32 operation.