disasm.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. /////////////////////////////////////////////////////////////////////////
  2. // $Id: disasm.h 12420 2014-07-18 11:14:25Z sshwarts $
  3. /////////////////////////////////////////////////////////////////////////
  4. //
  5. // Copyright (c) 2005-2014 Stanislav Shwartsman
  6. // Written by Stanislav Shwartsman [sshwarts at sourceforge net]
  7. //
  8. // This library is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU Lesser General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. // Lesser General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Lesser General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  21. //
  22. /////////////////////////////////////////////////////////////////////////
  23. #ifndef _BX_DISASM_H_
  24. #define _BX_DISASM_H_
  25. #include "config.h"
  26. #define BX_DECODE_MODRM(modrm_byte, mod, opcode, rm) { \
  27. mod = (modrm_byte >> 6) & 0x03; \
  28. opcode = (modrm_byte >> 3) & 0x07; \
  29. rm = modrm_byte & 0x07; \
  30. }
  31. #define BX_DECODE_SIB(sib_byte, scale, index, base) { \
  32. scale = sib_byte >> 6; \
  33. index = (sib_byte >> 3) & 0x07; \
  34. base = sib_byte & 0x07; \
  35. }
  36. /* Instruction set attributes (duplicated in cpu.h) */
  37. #define IA_X87 (BX_CONST64(1) << 0) /* FPU (X87) instruction */
  38. #define IA_486 (BX_CONST64(1) << 1) /* 486 new instruction */
  39. #define IA_PENTIUM (BX_CONST64(1) << 2) /* Pentium new instruction */
  40. #define IA_P6 (BX_CONST64(1) << 3) /* P6 new instruction */
  41. #define IA_MMX (BX_CONST64(1) << 4) /* MMX instruction */
  42. #define IA_3DNOW (BX_CONST64(1) << 5) /* 3DNow! instruction (AMD) */
  43. #define IA_SYSCALL_SYSRET (BX_CONST64(1) << 6) /* SYSCALL/SYSRET in legacy mode (AMD) */
  44. #define IA_SYSENTER_SYSEXIT (BX_CONST64(1) << 7) /* SYSENTER/SYSEXIT instruction */
  45. #define IA_CLFLUSH (BX_CONST64(1) << 8) /* CLFLUSH instruction */
  46. #define IA_SSE (BX_CONST64(1) << 9) /* SSE instruction */
  47. #define IA_SSE2 (BX_CONST64(1) << 10) /* SSE2 instruction */
  48. #define IA_SSE3 (BX_CONST64(1) << 11) /* SSE3 instruction */
  49. #define IA_SSSE3 (BX_CONST64(1) << 12) /* SSSE3 instruction */
  50. #define IA_SSE4_1 (BX_CONST64(1) << 13) /* SSE4_1 instruction */
  51. #define IA_SSE4_2 (BX_CONST64(1) << 14) /* SSE4_2 instruction */
  52. #define IA_POPCNT (BX_CONST64(1) << 15) /* POPCNT instruction */
  53. #define IA_MONITOR_MWAIT (BX_CONST64(1) << 16) /* MONITOR/MWAIT instruction */
  54. #define IA_VMX (BX_CONST64(1) << 17) /* VMX instruction */
  55. #define IA_SMX (BX_CONST64(1) << 18) /* SMX instruction */
  56. #define IA_LM_LAHF_SAHF (BX_CONST64(1) << 19) /* Long Mode LAHF/SAHF instruction */
  57. #define IA_CMPXCHG16B (BX_CONST64(1) << 20) /* CMPXCHG16B instruction */
  58. #define IA_RDTSCP (BX_CONST64(1) << 21) /* RDTSCP instruction */
  59. #define IA_XSAVE (BX_CONST64(1) << 22) /* XSAVE/XRSTOR extensions instruction */
  60. #define IA_XSAVEOPT (BX_CONST64(1) << 23) /* XSAVEOPT instruction */
  61. #define IA_AES_PCLMULQDQ (BX_CONST64(1) << 24) /* AES+PCLMULQDQ instruction */
  62. #define IA_MOVBE (BX_CONST64(1) << 25) /* MOVBE Intel Atom(R) instruction */
  63. #define IA_FSGSBASE (BX_CONST64(1) << 26) /* FS/GS BASE access instruction */
  64. #define IA_INVPCID (BX_CONST64(1) << 27) /* INVPCID instruction */
  65. #define IA_AVX (BX_CONST64(1) << 28) /* AVX instruction */
  66. #define IA_AVX2 (BX_CONST64(1) << 29) /* AVX2 instruction */
  67. #define IA_AVX_F16C (BX_CONST64(1) << 30) /* AVX F16 convert instruction */
  68. #define IA_AVX_FMA (BX_CONST64(1) << 31) /* AVX FMA instruction */
  69. #define IA_SSE4A (BX_CONST64(1) << 32) /* SSE4A instruction (AMD) */
  70. #define IA_LZCNT (BX_CONST64(1) << 33) /* LZCNT instruction */
  71. #define IA_BMI1 (BX_CONST64(1) << 34) /* BMI1 instruction */
  72. #define IA_BMI2 (BX_CONST64(1) << 35) /* BMI2 instruction */
  73. #define IA_FMA4 (BX_CONST64(1) << 36) /* FMA4 instruction (AMD) */
  74. #define IA_XOP (BX_CONST64(1) << 37) /* XOP instruction (AMD) */
  75. #define IA_TBM (BX_CONST64(1) << 38) /* TBM instruction (AMD) */
  76. #define IA_SVM (BX_CONST64(1) << 39) /* SVM instruction (AMD) */
  77. #define IA_RDRAND (BX_CONST64(1) << 40) /* RDRAND instruction */
  78. #define IA_ADX (BX_CONST64(1) << 41) /* ADCX/ADOX instruction */
  79. #define IA_SMAP (BX_CONST64(1) << 42) /* SMAP support */
  80. #define IA_RDSEED (BX_CONST64(1) << 43) /* RDSEED instruction */
  81. #define IA_SHA (BX_CONST64(1) << 44) /* SHA instruction */
  82. #define IA_AVX512 (BX_CONST64(1) << 45) /* AVX-512 instruction */
  83. #define IA_AVX512_CD (BX_CONST64(1) << 46) /* AVX-512 Conflict Detection instruction */
  84. #define IA_AVX512_PF (BX_CONST64(1) << 47) /* AVX-512 Sparse Prefetch instruction */
  85. #define IA_AVX512_ER (BX_CONST64(1) << 48) /* AVX-512 Exponential/Reciprocal instruction */
  86. #define IA_AVX512_DQ (BX_CONST64(1) << 49) /* AVX-512DQ instruction */
  87. #define IA_AVX512_BW (BX_CONST64(1) << 50) /* AVX-512 Byte/Word instruction */
  88. #define IA_CLFLUSHOPT (BX_CONST64(1) << 51) /* CLFLUSHOPT instruction */
  89. #define IA_XSAVEC (BX_CONST64(1) << 52) /* XSAVEC instruction */
  90. #define IA_XSAVES (BX_CONST64(1) << 53) /* XSAVES instruction */
  91. /* general purpose bit register */
  92. enum {
  93. rAX_REG,
  94. rCX_REG,
  95. rDX_REG,
  96. rBX_REG,
  97. rSP_REG,
  98. rBP_REG,
  99. rSI_REG,
  100. rDI_REG
  101. };
  102. /* segment register */
  103. enum {
  104. ES_REG,
  105. CS_REG,
  106. SS_REG,
  107. DS_REG,
  108. FS_REG,
  109. GS_REG,
  110. INVALID_SEG1,
  111. INVALID_SEG2
  112. };
  113. class disassembler;
  114. struct x86_insn;
  115. typedef void (disassembler::*BxDisasmPtr_t)(const x86_insn *insn);
  116. typedef void (disassembler::*BxDisasmResolveModrmPtr_t)(const x86_insn *insn, unsigned attr);
  117. struct BxDisasmOpcodeInfo_t
  118. {
  119. const char *IntelOpcode;
  120. const char *AttOpcode;
  121. BxDisasmPtr_t Operand1;
  122. BxDisasmPtr_t Operand2;
  123. BxDisasmPtr_t Operand3;
  124. BxDisasmPtr_t Operand4;
  125. Bit64u Feature;
  126. };
  127. struct BxDisasmOpcodeTable_t
  128. {
  129. Bit32u Attr;
  130. const void *OpcodeInfo;
  131. };
  132. // segment override not used
  133. #define NO_SEG_OVERRIDE 0xFF
  134. // datasize attributes
  135. #define X_SIZE 0x00 /* no size */
  136. #define B_SIZE 0x01 /* byte */
  137. #define W_SIZE 0x02 /* word */
  138. #define D_SIZE 0x03 /* double word */
  139. #define Q_SIZE 0x04 /* quad word */
  140. #define Z_SIZE 0x05 /* double word in 32-bit mode, quad word in 64-bit mode */
  141. #define T_SIZE 0x06 /* 10-byte x87 floating point */
  142. #define XMM_SIZE 0x07 /* double quad word (XMM) */
  143. #define YMM_SIZE 0x08 /* quadruple quad word (YMM) */
  144. #define VSIB_Index 0x80
  145. // branch hint attribute
  146. #define BRANCH_HINT 0x1000
  147. struct x86_insn
  148. {
  149. public:
  150. x86_insn(bx_bool is32, bx_bool is64);
  151. bx_bool is_seg_override() const {
  152. return (seg_override != NO_SEG_OVERRIDE);
  153. }
  154. public:
  155. bx_bool is_32, is_64;
  156. bx_bool as_32, as_64;
  157. bx_bool os_32, os_64;
  158. Bit8u extend8b;
  159. Bit8u rex_r, rex_x, rex_b;
  160. Bit8u seg_override;
  161. unsigned b1;
  162. unsigned ilen;
  163. #define BX_AVX_VL128 0
  164. #define BX_AVX_VL256 1
  165. Bit8u vex_vvv, vex_l, vex_w;
  166. int is_vex; // 0 - no VEX used, 1 - VEX is used, -1 - invalid VEX
  167. int is_evex; // 0 - no EVEX used, 1 - EVEX is used, -1 - invalid EVEX
  168. int is_xop; // 0 - no XOP used, 1 - XOP is used, -1 - invalid XOP
  169. Bit8u modrm, mod, nnn, rm;
  170. Bit8u sib, scale, index, base;
  171. union {
  172. Bit16u displ16;
  173. Bit32u displ32;
  174. } displacement;
  175. bx_bool evex_b;
  176. bx_bool evex_z;
  177. unsigned evex_ll_rc;
  178. };
  179. BX_CPP_INLINE x86_insn::x86_insn(bx_bool is32, bx_bool is64)
  180. {
  181. is_32 = is32;
  182. is_64 = is64;
  183. if (is_64) {
  184. os_64 = 0;
  185. as_64 = 1;
  186. os_32 = 1;
  187. as_32 = 1;
  188. }
  189. else {
  190. os_64 = 0;
  191. as_64 = 0;
  192. os_32 = is_32;
  193. as_32 = is_32;
  194. }
  195. extend8b = 0;
  196. rex_r = rex_b = rex_x = 0;
  197. seg_override = NO_SEG_OVERRIDE;
  198. ilen = 0;
  199. b1 = 0;
  200. is_vex = 0;
  201. is_evex = 0;
  202. is_xop = 0;
  203. vex_vvv = 0;
  204. vex_l = BX_AVX_VL128;
  205. vex_w = 0;
  206. modrm = mod = nnn = rm = 0;
  207. sib = scale = index = base = 0;
  208. displacement.displ32 = 0;
  209. evex_b = 0;
  210. evex_ll_rc = 0;
  211. evex_z = 0;
  212. }
  213. class disassembler {
  214. public:
  215. disassembler(): offset_mode_hex(0), print_mem_datasize(1) { set_syntax_intel(); }
  216. unsigned disasm(bx_bool is_32, bx_bool is_64, bx_address cs_base, bx_address ip, const Bit8u *instr, char *disbuf);
  217. unsigned disasm16(bx_address cs_base, bx_address ip, const Bit8u *instr, char *disbuf)
  218. { return disasm(0, 0, cs_base, ip, instr, disbuf); }
  219. unsigned disasm32(bx_address cs_base, bx_address ip, const Bit8u *instr, char *disbuf)
  220. { return disasm(1, 0, cs_base, ip, instr, disbuf); }
  221. unsigned disasm64(bx_address cs_base, bx_address ip, const Bit8u *instr, char *disbuf)
  222. { return disasm(1, 1, cs_base, ip, instr, disbuf); }
  223. x86_insn decode(bx_bool is_32, bx_bool is_64, bx_address cs_base, bx_address ip, const Bit8u *instr, char *disbuf);
  224. x86_insn decode16(bx_address cs_base, bx_address ip, const Bit8u *instr, char *disbuf)
  225. { return decode(0, 0, cs_base, ip, instr, disbuf); }
  226. x86_insn decode32(bx_address cs_base, bx_address ip, const Bit8u *instr, char *disbuf)
  227. { return decode(1, 0, cs_base, ip, instr, disbuf); }
  228. x86_insn decode64(bx_address cs_base, bx_address ip, const Bit8u *instr, char *disbuf)
  229. { return decode(1, 1, cs_base, ip, instr, disbuf); }
  230. void set_syntax_intel();
  231. void set_syntax_att();
  232. void set_offset_mode_hex(bx_bool mode) { offset_mode_hex = mode; }
  233. void set_mem_datasize_print(bx_bool mode) { print_mem_datasize = mode; }
  234. void toggle_syntax_mode();
  235. private:
  236. bx_bool intel_mode, offset_mode_hex, print_mem_datasize;
  237. const char **general_16bit_regname;
  238. const char **general_8bit_regname;
  239. const char **general_32bit_regname;
  240. const char **general_8bit_regname_rex;
  241. const char **general_64bit_regname;
  242. const char **segment_name;
  243. const char **index16;
  244. const char **vector_reg_name;
  245. const char *sreg_mod00_base32[16];
  246. const char *sreg_mod01or10_base32[16];
  247. const char *sreg_mod00_rm16[8];
  248. const char *sreg_mod01or10_rm16[8];
  249. private:
  250. bx_address db_eip, db_cs_base;
  251. const Bit8u *instruction; // for fetching of next byte of instruction
  252. char *disbufptr;
  253. BxDisasmResolveModrmPtr_t resolve_modrm;
  254. BX_CPP_INLINE Bit8u fetch_byte() {
  255. db_eip++;
  256. return(*instruction++);
  257. };
  258. BX_CPP_INLINE Bit8u peek_byte() {
  259. return(*instruction);
  260. };
  261. BX_CPP_INLINE Bit16u fetch_word() {
  262. Bit8u b0 = * (Bit8u *) instruction++;
  263. Bit8u b1 = * (Bit8u *) instruction++;
  264. Bit16u ret16 = (b1<<8) | b0;
  265. db_eip += 2;
  266. return(ret16);
  267. };
  268. BX_CPP_INLINE Bit32u fetch_dword() {
  269. Bit8u b0 = * (Bit8u *) instruction++;
  270. Bit8u b1 = * (Bit8u *) instruction++;
  271. Bit8u b2 = * (Bit8u *) instruction++;
  272. Bit8u b3 = * (Bit8u *) instruction++;
  273. Bit32u ret32 = (b3<<24) | (b2<<16) | (b1<<8) | b0;
  274. db_eip += 4;
  275. return(ret32);
  276. };
  277. BX_CPP_INLINE Bit64u fetch_qword() {
  278. Bit64u d0 = fetch_dword();
  279. Bit64u d1 = fetch_dword();
  280. Bit64u ret64 = (d1<<32) | d0;
  281. return(ret64);
  282. };
  283. void dis_putc(char symbol);
  284. void dis_sprintf(const char *fmt, ...);
  285. void decode_modrm(x86_insn *insn);
  286. unsigned decode_vex(x86_insn *insn);
  287. unsigned decode_evex(x86_insn *insn);
  288. unsigned decode_xop(x86_insn *insn);
  289. void resolve16_mod0 (const x86_insn *insn, unsigned mode);
  290. void resolve16_mod1or2(const x86_insn *insn, unsigned mode);
  291. void resolve32_mod0 (const x86_insn *insn, unsigned mode);
  292. void resolve32_mod1or2(const x86_insn *insn, unsigned mode);
  293. void resolve32_mod0_rm4 (const x86_insn *insn, unsigned mode);
  294. void resolve32_mod1or2_rm4(const x86_insn *insn, unsigned mode);
  295. void resolve64_mod0 (const x86_insn *insn, unsigned mode);
  296. void resolve64_mod1or2(const x86_insn *insn, unsigned mode);
  297. void resolve64_mod0_rm4 (const x86_insn *insn, unsigned mode);
  298. void resolve64_mod1or2_rm4(const x86_insn *insn, unsigned mode);
  299. void initialize_modrm_segregs();
  300. void print_datasize(unsigned mode);
  301. void print_memory_access16(int datasize,
  302. const char *seg, const char *index, Bit16u disp);
  303. void print_memory_access32(int datasize,
  304. const char *seg, const char *base, const char *index, int scale, Bit32s disp);
  305. void print_memory_access64(int datasize,
  306. const char *seg, const char *base, const char *index, int scale, Bit32s disp);
  307. void print_disassembly_intel(const x86_insn *insn, const BxDisasmOpcodeInfo_t *entry);
  308. void print_disassembly_att (const x86_insn *insn, const BxDisasmOpcodeInfo_t *entry);
  309. public:
  310. /*
  311. * Codes for Addressing Method:
  312. * ---------------------------
  313. * A - Direct address. The instruction has no ModR/M byte; the address
  314. * of the operand is encoded in the instruction; and no base register,
  315. * index register, or scaling factor can be applied.
  316. * C - The reg field of the ModR/M byte selects a control register.
  317. * D - The reg field of the ModR/M byte selects a debug register.
  318. * E - A ModR/M byte follows the opcode and specifies the operand. The
  319. * operand is either a general-purpose register or a memory address.
  320. * In case of the register operand, the R/M field of the ModR/M byte
  321. * selects a general register.
  322. * F - Flags Register.
  323. * G - The reg field of the ModR/M byte selects a general register.
  324. * I - Immediate data. The operand value is encoded in subsequent bytes of
  325. * the instruction.
  326. * J - The instruction contains a relative offset to be added to the
  327. * instruction pointer register.
  328. * M - The ModR/M byte may refer only to memory.
  329. * N - The R/M field of the ModR/M byte selects a packed-quadword MMX
  330. technology register.
  331. * O - The instruction has no ModR/M byte; the offset of the operand is
  332. * coded as a word or double word (depending on address size attribute)
  333. * in the instruction. No base register, index register, or scaling
  334. * factor can be applied.
  335. * P - The reg field of the ModR/M byte selects a packed quadword MMX
  336. * technology register.
  337. * Q - A ModR/M byte follows the opcode and specifies the operand. The
  338. * operand is either an MMX technology register or a memory address.
  339. * If it is a memory address, the address is computed from a segment
  340. * register and any of the following values: a base register, an
  341. * index register, a scaling factor, and a displacement.
  342. * R - The mod field of the ModR/M byte may refer only to a general register.
  343. * S - The reg field of the ModR/M byte selects a segment register.
  344. * T - The reg field of the ModR/M byte selects a test register.
  345. * U - The R/M field of the ModR/M byte selects a 128-bit XMM/256-bit YMM register.
  346. * V - The reg field of the ModR/M byte selects a 128-bit XMM/256-bit YMM register.
  347. * W - A ModR/M byte follows the opcode and specifies the operand. The
  348. * operand is either a 128-bit XMM/256-bit YMM register or a memory address.
  349. * If it is a memory address, the address is computed from a segment
  350. * register and any of the following values: a base register, an
  351. * index register, a scaling factor, and a displacement.
  352. * X - Memory addressed by the DS:rSI register pair.
  353. * Y - Memory addressed by the ES:rDI register pair.
  354. */
  355. /*
  356. * Codes for Operand Type:
  357. * ----------------------
  358. * a - Two one-word operands in memory or two double-word operands in
  359. * memory, depending on operand-size attribute (used only by the BOUND
  360. * instruction).
  361. * b - Byte, regardless of operand-size attribute.
  362. * d - Doubleword, regardless of operand-size attribute.
  363. * dq - Double-quadword, regardless of operand-size attribute.
  364. * p - 32-bit or 48-bit pointer, depending on operand-size attribute.
  365. * pd - 128-bit/256-bit packed double-precision floating-point data.
  366. * pi - Quadword MMX technology register (packed integer)
  367. * ps - 128-bit/256-bit packed single-precision floating-point data.
  368. * q - Quadword, regardless of operand-size attribute.
  369. * s - 6-byte or 10-byte pseudo-descriptor.
  370. * si - Doubleword integer register (scalar integer)
  371. * ss - Scalar element of a packed single-precision floating data.
  372. * sd - Scalar element of a packed double-precision floating data.
  373. * v - Word, doubleword or quadword, depending on operand-size attribute.
  374. * w - Word, regardless of operand-size attr.
  375. * y - Doubleword or quadword (in 64-bit mode) depending on 32/64 bit
  376. * operand size.
  377. */
  378. // far call/jmp
  379. void Apw(const x86_insn *insn);
  380. void Apd(const x86_insn *insn);
  381. // 8-bit general purpose registers
  382. void AL_Reg(const x86_insn *insn);
  383. void CL_Reg(const x86_insn *insn);
  384. // 16-bit general purpose registers
  385. void AX_Reg(const x86_insn *insn);
  386. void DX_Reg(const x86_insn *insn);
  387. // 32-bit general purpose registers
  388. void EAX_Reg(const x86_insn *insn);
  389. // 64-bit general purpose registers
  390. void RAX_Reg(const x86_insn *insn);
  391. void RCX_Reg(const x86_insn *insn);
  392. // segment registers
  393. void CS(const x86_insn *insn);
  394. void DS(const x86_insn *insn);
  395. void ES(const x86_insn *insn);
  396. void SS(const x86_insn *insn);
  397. void FS(const x86_insn *insn);
  398. void GS(const x86_insn *insn);
  399. // segment registers
  400. void Sw(const x86_insn *insn);
  401. // control register
  402. void Cd(const x86_insn *insn);
  403. void Cq(const x86_insn *insn);
  404. // debug register
  405. void Dd(const x86_insn *insn);
  406. void Dq(const x86_insn *insn);
  407. // 8-bit general purpose register
  408. void Reg8(const x86_insn *insn);
  409. // 16-bit general purpose register
  410. void RX(const x86_insn *insn);
  411. // 32-bit general purpose register
  412. void ERX(const x86_insn *insn);
  413. // 64-bit general purpose register
  414. void RRX(const x86_insn *insn);
  415. // general purpose register or memory operand
  416. void Eb(const x86_insn *insn);
  417. void Ew(const x86_insn *insn);
  418. void Ed(const x86_insn *insn);
  419. void Eq(const x86_insn *insn);
  420. void Ey(const x86_insn *insn);
  421. void Ebd(const x86_insn *insn);
  422. void Ewd(const x86_insn *insn);
  423. void Edq(const x86_insn *insn);
  424. // general purpose register
  425. void Gb(const x86_insn *insn);
  426. void Gw(const x86_insn *insn);
  427. void Gd(const x86_insn *insn);
  428. void Gq(const x86_insn *insn);
  429. void Gy(const x86_insn *insn);
  430. // vex encoded general purpose register
  431. void By(const x86_insn *insn);
  432. // immediate
  433. void I1(const x86_insn *insn);
  434. void Ib(const x86_insn *insn);
  435. void Iw(const x86_insn *insn);
  436. void Id(const x86_insn *insn);
  437. void Iq(const x86_insn *insn);
  438. // double immediate
  439. void IbIb(const x86_insn *insn);
  440. void IwIb(const x86_insn *insn);
  441. // sign extended immediate
  442. void sIbw(const x86_insn *insn);
  443. void sIbd(const x86_insn *insn);
  444. void sIbq(const x86_insn *insn);
  445. void sIdq(const x86_insn *insn);
  446. // floating point
  447. void ST0(const x86_insn *insn);
  448. void STi(const x86_insn *insn);
  449. // general purpose register
  450. void Rw(const x86_insn *insn);
  451. void Rd(const x86_insn *insn);
  452. void Rq(const x86_insn *insn);
  453. void Ry(const x86_insn *insn);
  454. // mmx register
  455. void Pq(const x86_insn *insn);
  456. // mmx register or memory operand
  457. void Qd(const x86_insn *insn);
  458. void Qq(const x86_insn *insn);
  459. void Vq(const x86_insn *insn);
  460. void Nq(const x86_insn *insn);
  461. // xmm/ymm register
  462. void Ups(const x86_insn *insn);
  463. void Upd(const x86_insn *insn);
  464. void Udq(const x86_insn *insn);
  465. void Uq(const x86_insn *insn);
  466. void Vdq(const x86_insn *insn);
  467. void Vss(const x86_insn *insn);
  468. void Vsd(const x86_insn *insn);
  469. void Vps(const x86_insn *insn);
  470. void Vpd(const x86_insn *insn);
  471. // xmm/ymm register through imm byte
  472. void VIb(const x86_insn *insn);
  473. // xmm/ymm register or memory operand
  474. void Wb(const x86_insn *insn);
  475. void Ww(const x86_insn *insn);
  476. void Wd(const x86_insn *insn);
  477. void Wq(const x86_insn *insn);
  478. void Wdq(const x86_insn *insn);
  479. void Wss(const x86_insn *insn);
  480. void Wsd(const x86_insn *insn);
  481. void Wps(const x86_insn *insn);
  482. void Wpd(const x86_insn *insn);
  483. // vex encoded xmm/ymm register
  484. void Hdq(const x86_insn *insn);
  485. void Hps(const x86_insn *insn);
  486. void Hpd(const x86_insn *insn);
  487. void Hss(const x86_insn *insn);
  488. void Hsd(const x86_insn *insn);
  489. // direct memory access
  490. void OP_O(const x86_insn *insn, unsigned size);
  491. void Ob(const x86_insn *insn);
  492. void Ow(const x86_insn *insn);
  493. void Od(const x86_insn *insn);
  494. void Oq(const x86_insn *insn);
  495. // memory operand
  496. void OP_M(const x86_insn *insn, unsigned size);
  497. void Ma(const x86_insn *insn);
  498. void Mp(const x86_insn *insn);
  499. void Ms(const x86_insn *insn);
  500. void Mx(const x86_insn *insn);
  501. void Mb(const x86_insn *insn);
  502. void Mw(const x86_insn *insn);
  503. void Md(const x86_insn *insn);
  504. void Mq(const x86_insn *insn);
  505. void Mt(const x86_insn *insn);
  506. void Mdq(const x86_insn *insn);
  507. void Mps(const x86_insn *insn);
  508. void Mpd(const x86_insn *insn);
  509. void Mss(const x86_insn *insn);
  510. void Msd(const x86_insn *insn);
  511. // gather VSib
  512. void VSib(const x86_insn *insn);
  513. // string instructions
  514. void OP_X(const x86_insn *insn, unsigned size);
  515. void Xb(const x86_insn *insn);
  516. void Xw(const x86_insn *insn);
  517. void Xd(const x86_insn *insn);
  518. void Xq(const x86_insn *insn);
  519. // string instructions
  520. void OP_Y(const x86_insn *insn, unsigned size);
  521. void Yb(const x86_insn *insn);
  522. void Yw(const x86_insn *insn);
  523. void Yd(const x86_insn *insn);
  524. void Yq(const x86_insn *insn);
  525. // maskmovdq/maskmovdqu
  526. void OP_sY(const x86_insn *insn, unsigned size);
  527. void sYq(const x86_insn *insn);
  528. void sYdq(const x86_insn *insn);
  529. // jump offset
  530. void Jb(const x86_insn *insn);
  531. void Jw(const x86_insn *insn);
  532. void Jd(const x86_insn *insn);
  533. };
  534. #endif