Skip to content

Latest commit

 

History

History

CpuX64

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

X64(-64) Encoder/Decoder

X86 is a pretty messy ISA to target for a compiler backend. Luckily, the X86-64 variant has been cleaned up somewhat and there are excellent encoding/decoding tables we can build on.

The instruction decoder/encoder is based on x86data.js by Petr Kobalicek which is in the Public Domain.

The implementation is far more complete than what is needed for a the code generator component and might be useful by itself.

The currently supported instructions are listed at the beginning of [opcode_tab.py] and should cover > 95% of instructions found in a typical executable.

Tips

Use objdump -d -M intel <file.exe> for intel assembler syntax.

To see the decoder in action try:

objdump -d  -M intel  --insn-width=12   /usr/bin/bash | ./opcode_test.py

Limitations

Unsupported:

  • segment registers, creg, dreg, sreg
  • registers ah, bh, ch, dh
  • MMX(2), AVX instructions
  • Rep prefix
  • sib addressing mode where i=0x4 is handled like a regular sib addressing mode

Planned:

  • Lock prefix support
  • a mechanism for substituting an instruction with an equivalent but shorter one.

References

ASMJIT/ASMDB

SANDPILE

VERY USEFUL

MISC