x86_table.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  1. "use strict";
  2. const { hex } = require("./util");
  3. // http://ref.x86asm.net/coder32.html
  4. const zf = 1 << 6;
  5. const of = 1 << 11;
  6. const cf = 1 << 0;
  7. const af = 1 << 4;
  8. const pf = 1 << 2;
  9. const sf = 1 << 7;
  10. // TODO:
  11. // - describe which registers are written and read
  12. // os: the instruction behaves differently depending on the operand size
  13. const encodings = [
  14. { opcode: 0x06, os: 1, skip: 1, },
  15. { opcode: 0x07, os: 1, skip: 1, },
  16. { opcode: 0x0E, os: 1, skip: 1, },
  17. { opcode: 0x0F, os: 1, prefix: 1, },
  18. { opcode: 0x16, os: 1, skip: 1, },
  19. { opcode: 0x17, block_boundary: 1, os: 1, skip: 1, },
  20. { opcode: 0x1E, os: 1, skip: 1, },
  21. { opcode: 0x1F, block_boundary: 1, os: 1, skip: 1, },
  22. { opcode: 0x26, prefix: 1, },
  23. { opcode: 0x27, nonfaulting: 1, mask_flags: of, },
  24. { opcode: 0x2E, prefix: 1, },
  25. { opcode: 0x2F, nonfaulting: 1, mask_flags: of, },
  26. { opcode: 0x36, prefix: 1, },
  27. { opcode: 0x37, nonfaulting: 1, mask_flags: of | sf | pf | zf, },
  28. { opcode: 0x3E, prefix: 1, },
  29. { opcode: 0x3F, nonfaulting: 1, mask_flags: of | sf | pf | zf, },
  30. { opcode: 0x40, nonfaulting: 1, os: 1, },
  31. { opcode: 0x41, nonfaulting: 1, os: 1, },
  32. { opcode: 0x42, nonfaulting: 1, os: 1, },
  33. { opcode: 0x43, nonfaulting: 1, os: 1, },
  34. { opcode: 0x44, nonfaulting: 1, os: 1, },
  35. { opcode: 0x45, nonfaulting: 1, os: 1, },
  36. { opcode: 0x46, nonfaulting: 1, os: 1, },
  37. { opcode: 0x47, nonfaulting: 1, os: 1, },
  38. { opcode: 0x48, nonfaulting: 1, os: 1, },
  39. { opcode: 0x49, nonfaulting: 1, os: 1, },
  40. { opcode: 0x4A, nonfaulting: 1, os: 1, },
  41. { opcode: 0x4B, nonfaulting: 1, os: 1, },
  42. { opcode: 0x4C, nonfaulting: 1, os: 1, },
  43. { opcode: 0x4D, nonfaulting: 1, os: 1, },
  44. { opcode: 0x4E, nonfaulting: 1, os: 1, },
  45. { opcode: 0x4F, nonfaulting: 1, os: 1, },
  46. { opcode: 0x50, custom: 1, os: 1, },
  47. { opcode: 0x51, custom: 1, os: 1, },
  48. { opcode: 0x52, custom: 1, os: 1, },
  49. { opcode: 0x53, custom: 1, os: 1, },
  50. { opcode: 0x54, custom: 1, os: 1, },
  51. { opcode: 0x55, custom: 1, os: 1, },
  52. { opcode: 0x56, custom: 1, os: 1, },
  53. { opcode: 0x57, custom: 1, os: 1, },
  54. { opcode: 0x58, custom: 1, os: 1, },
  55. { opcode: 0x59, custom: 1, os: 1, },
  56. { opcode: 0x5A, custom: 1, os: 1, },
  57. { opcode: 0x5B, custom: 1, os: 1, },
  58. { opcode: 0x5C, os: 1, },
  59. { opcode: 0x5D, custom: 1, os: 1, },
  60. { opcode: 0x5E, custom: 1, os: 1, },
  61. { opcode: 0x5F, custom: 1, os: 1, },
  62. { opcode: 0x60, os: 1, },
  63. { opcode: 0x61, os: 1, },
  64. { opcode: 0x62, e: 1, skip: 1, },
  65. { opcode: 0x63, e: 1, },
  66. { opcode: 0x64, prefix: 1, },
  67. { opcode: 0x65, prefix: 1, },
  68. { opcode: 0x66, prefix: 1, },
  69. { opcode: 0x67, prefix: 1, },
  70. { opcode: 0x68, custom: 1, os: 1, imm1632: 1, },
  71. { opcode: 0x69, nonfaulting: 1, os: 1, e: 1, imm1632: 1, mask_flags: af, }, // zf?
  72. { opcode: 0x6A, custom: 1, os: 1, imm8s: 1, },
  73. { opcode: 0x6B, nonfaulting: 1, os: 1, e: 1, imm8s: 1, mask_flags: af, }, // zf?
  74. { opcode: 0x6C, block_boundary: 1, is_string: 1, skip: 1, }, // ins
  75. { opcode: 0x6D, block_boundary: 1, is_string: 1, os: 1, skip: 1, },
  76. { opcode: 0x6E, block_boundary: 1, is_string: 1, skip: 1, }, // outs
  77. { opcode: 0x6F, block_boundary: 1, is_string: 1, os: 1, skip: 1, },
  78. { opcode: 0x84, nonfaulting: 1, e: 1, },
  79. { opcode: 0x85, nonfaulting: 1, os: 1, e: 1, },
  80. { opcode: 0x86, nonfaulting: 1, e: 1, },
  81. { opcode: 0x87, nonfaulting: 1, os: 1, e: 1, },
  82. { opcode: 0x88, nonfaulting: 1, e: 1, },
  83. { opcode: 0x89, custom: 1, nonfaulting: 1, os: 1, e: 1, },
  84. { opcode: 0x8A, nonfaulting: 1, e: 1, },
  85. { opcode: 0x8B, custom: 1, nonfaulting: 1, os: 1, e: 1, },
  86. { opcode: 0x8C, os: 1, e: 1, skip: 1, },
  87. { opcode: 0x8D, nonfaulting: 1, os: 1, e: 1, only_mem: 1, requires_prefix_call: 1, custom: 1, }, // lea
  88. { opcode: 0x8E, block_boundary: 1, e: 1, skip: 1, },
  89. { opcode: 0x8F, os: 1, e: 1, fixed_g: 0, requires_prefix_call: 1, custom: 1, }, // pop r/m
  90. { opcode: 0x90, nonfaulting: 1, },
  91. { opcode: 0x91, nonfaulting: 1, os: 1, },
  92. { opcode: 0x92, nonfaulting: 1, os: 1, },
  93. { opcode: 0x93, nonfaulting: 1, os: 1, },
  94. { opcode: 0x94, nonfaulting: 1, os: 1, },
  95. { opcode: 0x95, nonfaulting: 1, os: 1, },
  96. { opcode: 0x96, nonfaulting: 1, os: 1, },
  97. { opcode: 0x97, nonfaulting: 1, os: 1, },
  98. { opcode: 0x98, nonfaulting: 1, os: 1, },
  99. { opcode: 0x99, nonfaulting: 1, os: 1, },
  100. { opcode: 0x9A, os: 1, imm1632: 1, extra_imm16: 1, skip: 1, block_boundary: 1, }, // callf
  101. { opcode: 0x9B, skip: 1, },
  102. { opcode: 0x9C, os: 1, },
  103. // popf: not a jump, but can cause an eip change due to updating the interrupt flag
  104. { opcode: 0x9D, os: 1, block_boundary: 1, skip: 1, },
  105. { opcode: 0x9E, },
  106. { opcode: 0x9F, },
  107. { opcode: 0xA0, immaddr: 1, },
  108. { opcode: 0xA1, os: 1, immaddr: 1, },
  109. { opcode: 0xA2, immaddr: 1, },
  110. { opcode: 0xA3, os: 1, immaddr: 1, },
  111. // string instructions aren't jumps, but they modify eip due to how they're implemented
  112. { opcode: 0xA4, block_boundary: 1, is_string: 1, },
  113. { opcode: 0xA5, block_boundary: 1, is_string: 1, os: 1, },
  114. { opcode: 0xA6, block_boundary: 1, is_string: 1, },
  115. { opcode: 0xA7, block_boundary: 1, is_string: 1, os: 1, },
  116. { opcode: 0xA8, nonfaulting: 1, imm8: 1, },
  117. { opcode: 0xA9, nonfaulting: 1, os: 1, imm1632: 1, },
  118. { opcode: 0xAA, block_boundary: 1, is_string: 1, },
  119. { opcode: 0xAB, block_boundary: 1, is_string: 1, os: 1, },
  120. { opcode: 0xAC, block_boundary: 1, is_string: 1, },
  121. { opcode: 0xAD, block_boundary: 1, is_string: 1, os: 1, },
  122. { opcode: 0xAE, block_boundary: 1, is_string: 1, },
  123. { opcode: 0xAF, block_boundary: 1, is_string: 1, os: 1, },
  124. { opcode: 0xC2, block_boundary: 1, no_next_instruction: 1, os: 1, imm16: 1, skip: 1, }, // ret
  125. { opcode: 0xC3, block_boundary: 1, no_next_instruction: 1, os: 1, skip: 1, },
  126. { opcode: 0xC4, os: 1, e: 1, skip: 1, },
  127. { opcode: 0xC5, block_boundary: 1, os: 1, e: 1, skip: 1, },
  128. { opcode: 0xC6, e: 1, fixed_g: 0, nonfaulting: 1, imm8: 1, },
  129. { opcode: 0xC7, os: 1, e: 1, fixed_g: 0, nonfaulting: 1, imm1632: 1, },
  130. { opcode: 0xC8, os: 1, imm16: 1, extra_imm8: 1, }, // enter
  131. { opcode: 0xC9, os: 1, skip: 1, }, // leave: requires valid ebp
  132. { opcode: 0xCA, block_boundary: 1, no_next_instruction: 1, os: 1, imm16: 1, skip: 1, }, // retf
  133. { opcode: 0xCB, block_boundary: 1, no_next_instruction: 1, os: 1, skip: 1, },
  134. { opcode: 0xCC, block_boundary: 1, skip: 1, }, // int
  135. { opcode: 0xCD, block_boundary: 1, skip: 1, imm8: 1, },
  136. { opcode: 0xCE, block_boundary: 1, skip: 1, },
  137. { opcode: 0xCF, block_boundary: 1, no_next_instruction: 1, os: 1, skip: 1, }, // iret
  138. { opcode: 0xD4, imm8: 1, }, // aam, may trigger #de
  139. { opcode: 0xD5, nonfaulting: 1, imm8: 1, mask_flags: of | cf | af, },
  140. { opcode: 0xD6, nonfaulting: 1, },
  141. { opcode: 0xD7, skip: 1, },
  142. // loop, jcxz, etc.
  143. // Conditional jumps, but condition code not supported by code generator
  144. // (these are never generated by modern compilers)
  145. { opcode: 0xE0, imm8s: 1, skip: 1, block_boundary: 1, /* jump_offset_imm: 1, conditional_jump: 1, */ },
  146. { opcode: 0xE1, imm8s: 1, skip: 1, block_boundary: 1, /* jump_offset_imm: 1, conditional_jump: 1, */ },
  147. { opcode: 0xE2, imm8s: 1, skip: 1, block_boundary: 1, /* jump_offset_imm: 1, conditional_jump: 1, */ },
  148. { opcode: 0xE3, imm8s: 1, skip: 1, block_boundary: 1, /* jump_offset_imm: 1, conditional_jump: 1, */ },
  149. // port functions aren't jumps, but they may modify eip due to how they are implemented
  150. { opcode: 0xE4, block_boundary: 1, imm8: 1, skip: 1, }, // in
  151. { opcode: 0xE5, block_boundary: 1, os: 1, imm8: 1, skip: 1, },
  152. { opcode: 0xE6, block_boundary: 1, imm8: 1, skip: 1, }, // out
  153. { opcode: 0xE7, block_boundary: 1, os: 1, imm8: 1, skip: 1, },
  154. // E8 call: Has immediate jump offset, but we don't really want to follow
  155. // into other functions while generating code
  156. { opcode: 0xE8, block_boundary: 1, /* jump_offset_imm: 1, */ os: 1, imm1632: 1, custom: 1, skip: 1, },
  157. { opcode: 0xE9, block_boundary: 1, jump_offset_imm: 1, no_next_instruction: 1, os: 1, imm1632: 1, custom: 1, skip: 1, },
  158. { opcode: 0xEA, block_boundary: 1, no_next_instruction: 1, os: 1, imm1632: 1, extra_imm16: 1, skip: 1, }, // jmpf
  159. { opcode: 0xEB, block_boundary: 1, jump_offset_imm: 1, no_next_instruction: 1, imm8s: 1, custom: 1, skip: 1, },
  160. { opcode: 0xEC, block_boundary: 1, skip: 1, }, // in
  161. { opcode: 0xED, block_boundary: 1, os: 1, skip: 1, },
  162. { opcode: 0xEE, block_boundary: 1, skip: 1, }, // out
  163. { opcode: 0xEF, block_boundary: 1, os: 1, skip: 1, },
  164. { opcode: 0xF0, prefix: 1, },
  165. { opcode: 0xF1, skip: 1, },
  166. { opcode: 0xF2, prefix: 1, },
  167. { opcode: 0xF3, prefix: 1, },
  168. { opcode: 0xF4, block_boundary: 1, no_next_instruction: 1, skip: 1, }, // hlt
  169. { opcode: 0xF5, nonfaulting: 1, },
  170. { opcode: 0xF6, fixed_g: 0, nonfaulting: 1, imm8: 1, },
  171. { opcode: 0xF6, fixed_g: 1, nonfaulting: 1, imm8: 1, },
  172. { opcode: 0xF6, fixed_g: 2, nonfaulting: 1, },
  173. { opcode: 0xF6, fixed_g: 3, nonfaulting: 1, },
  174. { opcode: 0xF6, fixed_g: 4, nonfaulting: 1, mask_flags: af | zf, },
  175. { opcode: 0xF6, fixed_g: 5, nonfaulting: 1, mask_flags: af | zf, },
  176. { opcode: 0xF6, fixed_g: 6, },
  177. { opcode: 0xF6, fixed_g: 7, },
  178. { opcode: 0xF7, os: 1, fixed_g: 0, nonfaulting: 1, imm1632: 1, },
  179. { opcode: 0xF7, os: 1, fixed_g: 1, nonfaulting: 1, imm1632: 1, },
  180. { opcode: 0xF7, os: 1, fixed_g: 2, nonfaulting: 1, },
  181. { opcode: 0xF7, os: 1, fixed_g: 3, nonfaulting: 1, },
  182. { opcode: 0xF7, os: 1, fixed_g: 4, nonfaulting: 1, mask_flags: zf | af, },
  183. { opcode: 0xF7, os: 1, fixed_g: 5, nonfaulting: 1, mask_flags: zf | af, },
  184. { opcode: 0xF7, os: 1, fixed_g: 6, },
  185. { opcode: 0xF7, os: 1, fixed_g: 7, },
  186. { opcode: 0xF8, nonfaulting: 1, },
  187. { opcode: 0xF9, nonfaulting: 1, },
  188. { opcode: 0xFA, skip: 1, },
  189. // sti: not a jump, but can cause a change in eip
  190. { opcode: 0xFB, block_boundary: 1, skip: 1, },
  191. { opcode: 0xFC, nonfaulting: 1, },
  192. { opcode: 0xFD, nonfaulting: 1, },
  193. { opcode: 0xFE, e: 1, fixed_g: 0, nonfaulting: 1, },
  194. { opcode: 0xFE, e: 1, fixed_g: 1, nonfaulting: 1, },
  195. { opcode: 0xFF, os: 1, e: 1, fixed_g: 0, nonfaulting: 1, },
  196. { opcode: 0xFF, os: 1, e: 1, fixed_g: 1, nonfaulting: 1, },
  197. { opcode: 0xFF, os: 1, e: 1, fixed_g: 2, block_boundary: 1, skip: 1, },
  198. { opcode: 0xFF, os: 1, e: 1, fixed_g: 3, block_boundary: 1, skip: 1, },
  199. { opcode: 0xFF, os: 1, e: 1, fixed_g: 4, block_boundary: 1, no_next_instruction: 1, skip: 1, },
  200. { opcode: 0xFF, os: 1, e: 1, fixed_g: 5, block_boundary: 1, no_next_instruction: 1, skip: 1, },
  201. { opcode: 0xFF, custom: 1, os: 1, e: 1, fixed_g: 6, },
  202. { opcode: 0x0F00, fixed_g: 0, e: 1, skip: 1 },
  203. { opcode: 0x0F00, fixed_g: 1, e: 1, skip: 1 },
  204. { opcode: 0x0F00, fixed_g: 2, e: 1, skip: 1 },
  205. { opcode: 0x0F00, fixed_g: 3, e: 1, skip: 1 },
  206. { opcode: 0x0F00, fixed_g: 4, e: 1, skip: 1 },
  207. { opcode: 0x0F00, fixed_g: 5, e: 1, skip: 1 },
  208. { opcode: 0x0F01, fixed_g: 0, e: 1, skip: 1 },
  209. { opcode: 0x0F01, fixed_g: 1, e: 1, skip: 1 },
  210. { opcode: 0x0F01, fixed_g: 2, e: 1, skip: 1 },
  211. { opcode: 0x0F01, fixed_g: 3, e: 1, skip: 1 },
  212. { opcode: 0x0F01, fixed_g: 4, e: 1, skip: 1 },
  213. { opcode: 0x0F01, fixed_g: 6, e: 1, skip: 1 },
  214. { opcode: 0x0F01, fixed_g: 7, e: 1, skip: 1 },
  215. { opcode: 0x0F02, os: 1, e: 1, skip: 1 },
  216. { opcode: 0x0F03, os: 1, e: 1, skip: 1 },
  217. { opcode: 0x0F04, skip: 1 },
  218. { opcode: 0x0F05, skip: 1 },
  219. { opcode: 0x0F06, skip: 1 },
  220. { opcode: 0x0F07, skip: 1 },
  221. { opcode: 0x0F08, skip: 1 },
  222. { opcode: 0x0F09, skip: 1 },
  223. { opcode: 0x0F0A, skip: 1 },
  224. // ud2
  225. // Technically has a next instruction, but Linux uses this for assertions
  226. // and embeds the assertion message after this instruction, which is likely
  227. // the most common use case of ud2
  228. { opcode: 0x0F0B, skip: 1, block_boundary: 1, no_next_instruction: 1, },
  229. { opcode: 0x0F0C, skip: 1 },
  230. { opcode: 0x0F0D, skip: 1 },
  231. { opcode: 0x0F0E, skip: 1 },
  232. { opcode: 0x0F0F, skip: 1 },
  233. { opcode: 0x0F18, only_mem: 1, e: 1, },
  234. { opcode: 0x0F19, skip: 1 },
  235. { opcode: 0x0F1A, skip: 1 },
  236. { opcode: 0x0F1B, skip: 1 },
  237. { opcode: 0x0F1C, skip: 1 },
  238. { opcode: 0x0F1D, skip: 1 },
  239. { opcode: 0x0F1E, skip: 1 },
  240. { opcode: 0x0F1F, e: 1, },
  241. { opcode: 0x0F20, ignore_mod: 1, e: 1, skip: 1 },
  242. { opcode: 0x0F21, ignore_mod: 1, e: 1, skip: 1 },
  243. { opcode: 0x0F22, ignore_mod: 1, e: 1, skip: 1 },
  244. { opcode: 0x0F23, ignore_mod: 1, e: 1, skip: 1 },
  245. { opcode: 0x0F24, skip: 1 },
  246. { opcode: 0x0F25, skip: 1 },
  247. { opcode: 0x0F26, skip: 1 },
  248. { opcode: 0x0F27, skip: 1 },
  249. { opcode: 0x0F30, skip: 1 },
  250. { opcode: 0x0F31, skip: 1 },
  251. { opcode: 0x0F32, skip: 1 },
  252. { opcode: 0x0F33, skip: 1 },
  253. { opcode: 0x0F34, skip: 1, block_boundary: 1, no_next_instruction: 1, }, // sysenter
  254. { opcode: 0x0F35, skip: 1, block_boundary: 1, no_next_instruction: 1, }, // sysexit
  255. { opcode: 0x0F36, skip: 1 },
  256. { opcode: 0x0F37, skip: 1 },
  257. { opcode: 0x0F38, skip: 1 },
  258. { opcode: 0x0F39, skip: 1 },
  259. { opcode: 0x0F3A, skip: 1 },
  260. { opcode: 0x0F3B, skip: 1 },
  261. { opcode: 0x0F3C, skip: 1 },
  262. { opcode: 0x0F3D, skip: 1 },
  263. { opcode: 0x0F3E, skip: 1 },
  264. { opcode: 0x0F3F, skip: 1 },
  265. { opcode: 0x0F40, nonfaulting: 1, e: 1, os: 1, },
  266. { opcode: 0x0F41, nonfaulting: 1, e: 1, os: 1, },
  267. { opcode: 0x0F42, nonfaulting: 1, e: 1, os: 1, },
  268. { opcode: 0x0F43, nonfaulting: 1, e: 1, os: 1, },
  269. { opcode: 0x0F44, nonfaulting: 1, e: 1, os: 1, },
  270. { opcode: 0x0F45, nonfaulting: 1, e: 1, os: 1, },
  271. { opcode: 0x0F46, nonfaulting: 1, e: 1, os: 1, },
  272. { opcode: 0x0F47, nonfaulting: 1, e: 1, os: 1, },
  273. { opcode: 0x0F48, nonfaulting: 1, e: 1, os: 1, },
  274. { opcode: 0x0F49, nonfaulting: 1, e: 1, os: 1, },
  275. { opcode: 0x0F4A, nonfaulting: 1, e: 1, os: 1, },
  276. { opcode: 0x0F4B, nonfaulting: 1, e: 1, os: 1, },
  277. { opcode: 0x0F4C, nonfaulting: 1, e: 1, os: 1, },
  278. { opcode: 0x0F4D, nonfaulting: 1, e: 1, os: 1, },
  279. { opcode: 0x0F4E, nonfaulting: 1, e: 1, os: 1, },
  280. { opcode: 0x0F4F, nonfaulting: 1, e: 1, os: 1, },
  281. { opcode: 0x0F80, block_boundary: 1, jump_offset_imm: 1, conditional_jump: 1, imm1632: 1, os: 1, custom: 1, skip: 1, },
  282. { opcode: 0x0F81, block_boundary: 1, jump_offset_imm: 1, conditional_jump: 1, imm1632: 1, os: 1, custom: 1, skip: 1, },
  283. { opcode: 0x0F82, block_boundary: 1, jump_offset_imm: 1, conditional_jump: 1, imm1632: 1, os: 1, custom: 1, skip: 1, },
  284. { opcode: 0x0F83, block_boundary: 1, jump_offset_imm: 1, conditional_jump: 1, imm1632: 1, os: 1, custom: 1, skip: 1, },
  285. { opcode: 0x0F84, block_boundary: 1, jump_offset_imm: 1, conditional_jump: 1, imm1632: 1, os: 1, custom: 1, skip: 1, },
  286. { opcode: 0x0F85, block_boundary: 1, jump_offset_imm: 1, conditional_jump: 1, imm1632: 1, os: 1, custom: 1, skip: 1, },
  287. { opcode: 0x0F86, block_boundary: 1, jump_offset_imm: 1, conditional_jump: 1, imm1632: 1, os: 1, custom: 1, skip: 1, },
  288. { opcode: 0x0F87, block_boundary: 1, jump_offset_imm: 1, conditional_jump: 1, imm1632: 1, os: 1, custom: 1, skip: 1, },
  289. { opcode: 0x0F88, block_boundary: 1, jump_offset_imm: 1, conditional_jump: 1, imm1632: 1, os: 1, custom: 1, skip: 1, },
  290. { opcode: 0x0F89, block_boundary: 1, jump_offset_imm: 1, conditional_jump: 1, imm1632: 1, os: 1, custom: 1, skip: 1, },
  291. { opcode: 0x0F8A, block_boundary: 1, jump_offset_imm: 1, conditional_jump: 1, imm1632: 1, os: 1, custom: 1, skip: 1, },
  292. { opcode: 0x0F8B, block_boundary: 1, jump_offset_imm: 1, conditional_jump: 1, imm1632: 1, os: 1, custom: 1, skip: 1, },
  293. { opcode: 0x0F8C, block_boundary: 1, jump_offset_imm: 1, conditional_jump: 1, imm1632: 1, os: 1, custom: 1, skip: 1, },
  294. { opcode: 0x0F8D, block_boundary: 1, jump_offset_imm: 1, conditional_jump: 1, imm1632: 1, os: 1, custom: 1, skip: 1, },
  295. { opcode: 0x0F8E, block_boundary: 1, jump_offset_imm: 1, conditional_jump: 1, imm1632: 1, os: 1, custom: 1, skip: 1, },
  296. { opcode: 0x0F8F, block_boundary: 1, jump_offset_imm: 1, conditional_jump: 1, imm1632: 1, os: 1, custom: 1, skip: 1, },
  297. { opcode: 0x0F90, nonfaulting: 1, e: 1, },
  298. { opcode: 0x0F91, nonfaulting: 1, e: 1, },
  299. { opcode: 0x0F92, nonfaulting: 1, e: 1, },
  300. { opcode: 0x0F93, nonfaulting: 1, e: 1, },
  301. { opcode: 0x0F94, nonfaulting: 1, e: 1, },
  302. { opcode: 0x0F95, nonfaulting: 1, e: 1, },
  303. { opcode: 0x0F96, nonfaulting: 1, e: 1, },
  304. { opcode: 0x0F97, nonfaulting: 1, e: 1, },
  305. { opcode: 0x0F98, nonfaulting: 1, e: 1, },
  306. { opcode: 0x0F99, nonfaulting: 1, e: 1, },
  307. { opcode: 0x0F9A, nonfaulting: 1, e: 1, },
  308. { opcode: 0x0F9B, nonfaulting: 1, e: 1, },
  309. { opcode: 0x0F9C, nonfaulting: 1, e: 1, },
  310. { opcode: 0x0F9D, nonfaulting: 1, e: 1, },
  311. { opcode: 0x0F9E, nonfaulting: 1, e: 1, },
  312. { opcode: 0x0F9F, nonfaulting: 1, e: 1, },
  313. { opcode: 0x0FA0, os: 1, skip: 1, },
  314. { opcode: 0x0FA1, os: 1, skip: 1, },
  315. { opcode: 0x0FA2, skip: 1, },
  316. { opcode: 0x0FA8, os: 1, skip: 1, },
  317. { opcode: 0x0FA9, os: 1, skip: 1, },
  318. { opcode: 0x0FA3, os: 1, e: 1, only_reg: 1, }, // bt (can also index memory, but not supported by test right now)
  319. { opcode: 0x0FAB, os: 1, e: 1, only_reg: 1, },
  320. { opcode: 0x0FB3, os: 1, e: 1, only_reg: 1, },
  321. { opcode: 0x0FBB, os: 1, e: 1, only_reg: 1, },
  322. { opcode: 0x0FBA, os: 1, e: 1, fixed_g: 4, imm8: 1, only_reg: 1, }, // bt
  323. { opcode: 0x0FBA, os: 1, e: 1, fixed_g: 5, imm8: 1, only_reg: 1, },
  324. { opcode: 0x0FBA, os: 1, e: 1, fixed_g: 6, imm8: 1, only_reg: 1, },
  325. { opcode: 0x0FBA, os: 1, e: 1, fixed_g: 7, imm8: 1, only_reg: 1, },
  326. { opcode: 0x0FBC, os: 1, e: 1, mask_flags: af, }, // bsf
  327. { opcode: 0x0FBD, os: 1, e: 1, mask_flags: af, },
  328. // note: overflow flag only undefined if shift is > 1
  329. { opcode: 0x0FA4, nonfaulting: 1, os: 1, e: 1, imm8: 1, mask_flags: af | of, }, // shld
  330. { opcode: 0x0FA5, nonfaulting: 1, os: 1, e: 1, mask_flags: af | of, },
  331. { opcode: 0x0FAC, nonfaulting: 1, os: 1, e: 1, imm8: 1, mask_flags: af | of, },
  332. { opcode: 0x0FAD, nonfaulting: 1, os: 1, e: 1, mask_flags: af | of, },
  333. { opcode: 0x0FA6, skip: 1 },
  334. { opcode: 0x0FA7, skip: 1 },
  335. { opcode: 0x0FAA, skip: 1 },
  336. { opcode: 0x0FAE, e: 1, fixed_g: 0, only_mem: 1, skip: 1, }, // fxsave, ...
  337. { opcode: 0x0FAE, e: 1, fixed_g: 1, only_mem: 1, skip: 1, },
  338. { opcode: 0x0FAE, e: 1, fixed_g: 2, only_mem: 1, skip: 1, },
  339. { opcode: 0x0FAE, e: 1, fixed_g: 3, only_mem: 1, skip: 1, },
  340. { opcode: 0x0FAE, e: 1, fixed_g: 4, only_mem: 1, skip: 1, },
  341. { opcode: 0x0FAE, e: 1, fixed_g: 5, only_reg: 1, skip: 1, }, // lfence (reg, only 0), xrstor (mem)
  342. { opcode: 0x0FAE, e: 1, fixed_g: 6, only_reg: 1, skip: 1, }, // mfence (reg, only 0)
  343. { opcode: 0x0FAE, e: 1, fixed_g: 7, only_reg: 1, skip: 1, }, // sfence (reg, only 0), clflush (mem)
  344. { opcode: 0x0FAF, nonfaulting: 1, os: 1, e: 1, mask_flags: af | zf }, // imul
  345. { opcode: 0x0FB0, nonfaulting: 1, e: 1 }, // cmxchg
  346. { opcode: 0x0FB1, nonfaulting: 1, os: 1, e: 1 },
  347. { opcode: 0x0FC7, e: 1, fixed_g: 1, only_mem: 1, }, // cmpxchg8b (memory)
  348. { opcode: 0x0FC7, e: 1, fixed_g: 6, only_reg: 1, skip: 1, }, // rdrand
  349. { opcode: 0x0FB2, block_boundary: 1, os: 1, e: 1, skip: 1, }, // lss, lfs, lgs
  350. { opcode: 0x0FB4, os: 1, e: 1, skip: 1, },
  351. { opcode: 0x0FB5, os: 1, e: 1, skip: 1, },
  352. { opcode: 0x0FB6, nonfaulting: 1, os: 1, e: 1, }, // movzx
  353. { opcode: 0x0FB7, nonfaulting: 1, os: 1, e: 1, },
  354. { opcode: 0xF30FB8, os: 1, e: 1 }, // popcnt
  355. { opcode: 0x0FB9, }, // ud2
  356. { opcode: 0x0FBE, nonfaulting: 1, os: 1, e: 1, }, // movsx
  357. { opcode: 0x0FBF, nonfaulting: 1, os: 1, e: 1, },
  358. { opcode: 0x0FC0, nonfaulting: 1, e: 1, }, // xadd
  359. { opcode: 0x0FC1, nonfaulting: 1, os: 1, e: 1, },
  360. { opcode: 0x0FC8, nonfaulting: 1, }, // bswap
  361. { opcode: 0x0FC9, nonfaulting: 1, },
  362. { opcode: 0x0FCA, nonfaulting: 1, },
  363. { opcode: 0x0FCB, nonfaulting: 1, },
  364. { opcode: 0x0FCC, nonfaulting: 1, },
  365. { opcode: 0x0FCD, nonfaulting: 1, },
  366. { opcode: 0x0FCE, nonfaulting: 1, },
  367. { opcode: 0x0FCF, nonfaulting: 1, },
  368. // mmx, sse
  369. // - Skipped are not implemented
  370. // - Missing are sse3+, and floating point
  371. { opcode: 0x0F10, e: 1 },
  372. { opcode: 0xF30F10, e: 1 },
  373. { opcode: 0x660F10, e: 1 },
  374. { opcode: 0xF20F10, e: 1 },
  375. { opcode: 0x0F11, e: 1 },
  376. { opcode: 0xF30F11, e: 1 },
  377. { opcode: 0x660F11, e: 1 },
  378. { opcode: 0xF20F11, e: 1 },
  379. { opcode: 0x0F12, e: 1 },
  380. { opcode: 0x660F12, only_mem: 1, e: 1 },
  381. { opcode: 0xF20F12, e: 1, skip: 1, },
  382. { opcode: 0xF30F12, e: 1, skip: 1, },
  383. { opcode: 0x0F13, only_mem: 1, e: 1 },
  384. { opcode: 0x660F13, only_mem: 1, e: 1 },
  385. { opcode: 0x0F14, e: 1 },
  386. { opcode: 0x660F14, e: 1 },
  387. { opcode: 0x0F15, e: 1 },
  388. { opcode: 0x660F15, e: 1 },
  389. { opcode: 0x0F16, e: 1 },
  390. { opcode: 0x660F16, only_mem: 1, e: 1 },
  391. { opcode: 0x0F17, only_mem: 1, e: 1 },
  392. { opcode: 0x660F17, only_mem: 1, e: 1 },
  393. { opcode: 0x0F28, e: 1 },
  394. { opcode: 0x660F28, e: 1 },
  395. { opcode: 0x0F29, e: 1 },
  396. { opcode: 0x660F29, e: 1 },
  397. { opcode: 0x0F2A, skip: 1 },
  398. { opcode: 0x0F2B, only_mem: 1, e: 1 },
  399. { opcode: 0x660F2B, only_mem: 1, e: 1 },
  400. { opcode: 0xF20F2C, e: 1, },
  401. { opcode: 0x0F2C, e: 1, skip: 1, },
  402. { opcode: 0xF30F2C, e: 1, skip: 1, },
  403. { opcode: 0x660F2C, e: 1, skip: 1, },
  404. { opcode: 0x0F2D, skip: 1 },
  405. { opcode: 0x0F2E, skip: 1 },
  406. { opcode: 0x0F2F, skip: 1 },
  407. { opcode: 0x0F50, only_reg: 1, e: 1 },
  408. { opcode: 0x660F50, only_reg: 1, e: 1 },
  409. { opcode: 0x0F51, skip: 1 },
  410. { opcode: 0x0F52, skip: 1 },
  411. { opcode: 0x0F53, skip: 1 },
  412. { opcode: 0x0F54, e: 1 },
  413. { opcode: 0x660F54, e: 1 },
  414. { opcode: 0x0F55, e: 1 },
  415. { opcode: 0x660F55, e: 1 },
  416. { opcode: 0x0F56, e: 1 },
  417. { opcode: 0x660F56, e: 1 },
  418. { opcode: 0x0F57, e: 1 },
  419. { opcode: 0x660F57, e: 1 },
  420. { opcode: 0x0F58, skip: 1 },
  421. { opcode: 0x0F59, skip: 1 },
  422. { opcode: 0x0F5A, skip: 1 },
  423. { opcode: 0x0F5B, skip: 1 },
  424. { opcode: 0x0F5C, skip: 1 },
  425. { opcode: 0x0F5D, skip: 1 },
  426. { opcode: 0x0F5E, skip: 1 },
  427. { opcode: 0x0F5F, skip: 1 },
  428. { opcode: 0x660F60, e: 1 },
  429. { opcode: 0x0F60, e: 1 },
  430. { opcode: 0x660F61, e: 1 },
  431. { opcode: 0x0F61, e: 1 },
  432. { opcode: 0x660F62, e: 1 },
  433. { opcode: 0x0F62, e: 1 },
  434. { opcode: 0x660F63, e: 1 },
  435. { opcode: 0x0F63, e: 1 },
  436. { opcode: 0x660F64, e: 1 },
  437. { opcode: 0x0F64, e: 1 },
  438. { opcode: 0x660F65, e: 1 },
  439. { opcode: 0x0F65, e: 1 },
  440. { opcode: 0x660F66, e: 1 },
  441. { opcode: 0x0F66, e: 1 },
  442. { opcode: 0x660F67, e: 1 },
  443. { opcode: 0x0F67, e: 1 },
  444. { opcode: 0x660F68, e: 1 },
  445. { opcode: 0x0F68, e: 1 },
  446. { opcode: 0x660F69, e: 1 },
  447. { opcode: 0x0F69, e: 1 },
  448. { opcode: 0x660F6A, e: 1 },
  449. { opcode: 0x0F6A, e: 1 },
  450. { opcode: 0x660F6B, e: 1 },
  451. { opcode: 0x0F6B, e: 1 },
  452. { opcode: 0x660F6C, e: 1 },
  453. { opcode: 0x660F6D, e: 1 },
  454. { opcode: 0x660F6E, e: 1 },
  455. { opcode: 0x0F6E, e: 1 },
  456. { opcode: 0xF30F6F, e: 1 },
  457. { opcode: 0x660F6F, e: 1 },
  458. { opcode: 0x0F6F, e: 1 },
  459. { opcode: 0x0F70, e: 1, imm8: 1, },
  460. { opcode: 0x660F70, e: 1, imm8: 1, },
  461. { opcode: 0xF20F70, e: 1, imm8: 1, },
  462. { opcode: 0xF30F70, e: 1, imm8: 1, },
  463. { opcode: 0x0F71, e: 1, fixed_g: 2, imm8: 1, only_reg: 1, },
  464. { opcode: 0x660F71, e: 1, fixed_g: 2, imm8: 1, only_reg: 1 },
  465. { opcode: 0x0F71, e: 1, fixed_g: 4, imm8: 1, only_reg: 1, },
  466. { opcode: 0x660F71, e: 1, fixed_g: 4, imm8: 1, only_reg: 1 },
  467. { opcode: 0x0F71, e: 1, fixed_g: 6, imm8: 1, only_reg: 1, },
  468. { opcode: 0x660F71, e: 1, fixed_g: 6, imm8: 1, only_reg: 1 },
  469. { opcode: 0x0F72, e: 1, fixed_g: 2, imm8: 1, only_reg: 1, },
  470. { opcode: 0x660F72, e: 1, fixed_g: 2, imm8: 1, only_reg: 1 },
  471. { opcode: 0x0F72, e: 1, fixed_g: 4, imm8: 1, only_reg: 1, },
  472. { opcode: 0x660F72, e: 1, fixed_g: 4, imm8: 1, only_reg: 1 },
  473. { opcode: 0x0F72, e: 1, fixed_g: 6, imm8: 1, only_reg: 1, },
  474. { opcode: 0x660F72, e: 1, fixed_g: 6, imm8: 1, only_reg: 1 },
  475. { opcode: 0x0F73, e: 1, fixed_g: 2, imm8: 1, only_reg: 1, },
  476. { opcode: 0x660F73, e: 1, fixed_g: 2, imm8: 1, only_reg: 1, },
  477. { opcode: 0x660F73, e: 1, fixed_g: 3, imm8: 1, only_reg: 1 },
  478. { opcode: 0x0F73, e: 1, fixed_g: 6, imm8: 1, only_reg: 1, },
  479. { opcode: 0x660F73, e: 1, fixed_g: 6, imm8: 1, only_reg: 1 },
  480. { opcode: 0x660F73, e: 1, fixed_g: 7, imm8: 1, only_reg: 1 },
  481. { opcode: 0x0F74, e: 1, },
  482. { opcode: 0x660F74, e: 1, },
  483. { opcode: 0x0F75, e: 1, },
  484. { opcode: 0x660F75, e: 1, },
  485. { opcode: 0x0F76, e: 1, },
  486. { opcode: 0x660F76, e: 1, },
  487. { opcode: 0x0F77 },
  488. { opcode: 0x0F78, skip: 1 },
  489. { opcode: 0x0F79, skip: 1 },
  490. { opcode: 0x0F7A, skip: 1 },
  491. { opcode: 0x0F7B, skip: 1 },
  492. { opcode: 0x0F7C, skip: 1 },
  493. { opcode: 0x0F7D, skip: 1 },
  494. { opcode: 0x0F7E, e: 1 },
  495. { opcode: 0x660F7E, e: 1 },
  496. { opcode: 0xF30F7E, e: 1 },
  497. { opcode: 0x0F7F, e: 1 },
  498. { opcode: 0x660F7F, e: 1 },
  499. { opcode: 0xF30F7F, e: 1 },
  500. { opcode: 0x0FC2, skip: 1, },
  501. { opcode: 0x0FC3, e: 1, only_mem: 1, },
  502. { opcode: 0x0FC4, e: 1, imm8: 1 },
  503. { opcode: 0x660FC4, e: 1, imm8: 1 },
  504. { opcode: 0x0FC5, e: 1, only_reg: 1, imm8: 1 },
  505. { opcode: 0x660FC5, e: 1, only_reg: 1, imm8: 1, },
  506. { opcode: 0x0FC6, skip: 1, },
  507. { opcode: 0x0FD0, skip: 1, },
  508. { opcode: 0x0FD1, e: 1 },
  509. { opcode: 0x660FD1, e: 1 },
  510. { opcode: 0x0FD2, e: 1 },
  511. { opcode: 0x660FD2, e: 1 },
  512. { opcode: 0x0FD3, e: 1 },
  513. { opcode: 0x660FD3, e: 1 },
  514. { opcode: 0x0FD4, e: 1 },
  515. { opcode: 0x660FD4, e: 1 },
  516. { opcode: 0x0FD5, e: 1 },
  517. { opcode: 0x660FD5, e: 1 },
  518. { opcode: 0x660FD6, e: 1 },
  519. { opcode: 0xF20FD6, only_reg: 1, e: 1 },
  520. { opcode: 0xF30FD6, only_reg: 1, e: 1 },
  521. { opcode: 0x0FD7, e: 1, only_reg: 1 },
  522. { opcode: 0x660FD7, e: 1, only_reg: 1, },
  523. { opcode: 0x0FD8, e: 1 },
  524. { opcode: 0x660FD8, e: 1 },
  525. { opcode: 0x0FD9, e: 1 },
  526. { opcode: 0x660FD9, e: 1 },
  527. { opcode: 0x0FDA, e: 1 },
  528. { opcode: 0x660FDA, e: 1 },
  529. { opcode: 0x0FDB, e: 1 },
  530. { opcode: 0x660FDB, e: 1 },
  531. { opcode: 0x0FDC, e: 1 },
  532. { opcode: 0x660FDC, e: 1 },
  533. { opcode: 0x0FDD, e: 1 },
  534. { opcode: 0x660FDD, e: 1 },
  535. { opcode: 0x0FDE, e: 1 },
  536. { opcode: 0x660FDE, e: 1 },
  537. { opcode: 0x0FDF, e: 1 },
  538. { opcode: 0x660FDF, e: 1 },
  539. { opcode: 0x0FE0, e: 1 },
  540. { opcode: 0x660FE0, e: 1 },
  541. { opcode: 0x0FE1, e: 1 },
  542. { opcode: 0x660FE1, e: 1 },
  543. { opcode: 0x0FE2, e: 1 },
  544. { opcode: 0x660FE2, e: 1 },
  545. { opcode: 0x0FE3, e: 1 },
  546. { opcode: 0x660FE3, e: 1 },
  547. { opcode: 0x0FE4, e: 1 },
  548. { opcode: 0x660FE4, e: 1 },
  549. { opcode: 0x0FE5, e: 1 },
  550. { opcode: 0x660FE5, e: 1 },
  551. { opcode: 0x660FE6, e: 1, skip: 1, },
  552. { opcode: 0xF20FE6, e: 1, skip: 1, },
  553. { opcode: 0xF30FE6, e: 1, skip: 1, },
  554. { opcode: 0x0FE7, e: 1, only_mem: 1 },
  555. { opcode: 0x660FE7, e: 1, only_mem: 1, },
  556. { opcode: 0x0FE8, e: 1 },
  557. { opcode: 0x660FE8, e: 1 },
  558. { opcode: 0x0FE9, e: 1 },
  559. { opcode: 0x660FE9, e: 1 },
  560. { opcode: 0x0FEA, e: 1 },
  561. { opcode: 0x660FEA, e: 1 },
  562. { opcode: 0x0FEB, e: 1 },
  563. { opcode: 0x660FEB, e: 1 },
  564. { opcode: 0x0FEC, e: 1 },
  565. { opcode: 0x660FEC, e: 1 },
  566. { opcode: 0x0FED, e: 1 },
  567. { opcode: 0x660FED, e: 1 },
  568. { opcode: 0x0FEE, e: 1 },
  569. { opcode: 0x660FEE, e: 1 },
  570. { opcode: 0x0FEF, e: 1 },
  571. { opcode: 0x660FEF, e: 1 },
  572. { opcode: 0x0FF0, skip: 1, },
  573. { opcode: 0x0FF1, e: 1 },
  574. { opcode: 0x660FF1, e: 1 },
  575. { opcode: 0x0FF2, e: 1 },
  576. { opcode: 0x660FF2, e: 1 },
  577. { opcode: 0x0FF3, e: 1 },
  578. { opcode: 0x660FF3, e: 1, },
  579. { opcode: 0x0FF4, e: 1 },
  580. { opcode: 0x660FF4, e: 1 },
  581. { opcode: 0x0FF5, e: 1 },
  582. { opcode: 0x660FF5, e: 1 },
  583. { opcode: 0x0FF6, e: 1 },
  584. { opcode: 0x660FF6, e: 1 },
  585. // maskmovq (0FF7), maskmovdqu (660FF7) tested manually
  586. // Generated tests don't setup EDI as required (yet)
  587. { opcode: 0x0FF7, only_reg: 1, e: 1, skip: 1, },
  588. { opcode: 0x660FF7, only_reg: 1, e: 1, skip: 1, },
  589. { opcode: 0x0FF8, e: 1 },
  590. { opcode: 0x660FF8, e: 1 },
  591. { opcode: 0x0FF9, e: 1 },
  592. { opcode: 0x660FF9, e: 1 },
  593. { opcode: 0x0FFA, e: 1 },
  594. { opcode: 0x660FFA, e: 1 },
  595. { opcode: 0x0FFB, e: 1 },
  596. { opcode: 0x660FFB, e: 1 },
  597. { opcode: 0x0FFC, e: 1 },
  598. { opcode: 0x660FFC, e: 1 },
  599. { opcode: 0x0FFD, e: 1 },
  600. { opcode: 0x660FFD, e: 1 },
  601. { opcode: 0x0FFE, e: 1 },
  602. { opcode: 0x660FFE, e: 1 },
  603. { opcode: 0x0FFF, },
  604. ];
  605. for(let i = 0; i < 8; i++)
  606. {
  607. encodings.push.apply(encodings, [
  608. { opcode: 0x00 | i << 3, nonfaulting: 1, e: 1, },
  609. { opcode: 0x01 | i << 3, nonfaulting: 1, os: 1, e: 1, },
  610. { opcode: 0x02 | i << 3, nonfaulting: 1, e: 1, },
  611. { opcode: 0x03 | i << 3, nonfaulting: 1, os: 1, e: 1, },
  612. { opcode: 0x04 | i << 3, nonfaulting: 1, eax: 1, imm8: 1, },
  613. { opcode: 0x05 | i << 3, nonfaulting: 1, os: 1, eax: 1, imm1632: 1, },
  614. { opcode: 0x70 | i, block_boundary: 1, jump_offset_imm: 1, conditional_jump: 1, imm8s: 1, custom: 1, skip: 1, },
  615. { opcode: 0x78 | i, block_boundary: 1, jump_offset_imm: 1, conditional_jump: 1, imm8s: 1, custom: 1, skip: 1, },
  616. { opcode: 0x80, nonfaulting: 1, e: 1, fixed_g: i, imm8: 1, },
  617. { opcode: 0x81, nonfaulting: 1, os: 1, e: 1, fixed_g: i, imm1632: 1, },
  618. { opcode: 0x82, nonfaulting: 1, e: 1, fixed_g: i, imm8: 1, },
  619. { opcode: 0x83, nonfaulting: 1, os: 1, e: 1, fixed_g: i, imm8s: 1, },
  620. { opcode: 0xB0 | i, nonfaulting: 1, imm8: 1, },
  621. { opcode: 0xB8 | i, nonfaulting: 1, os: 1, imm1632: 1, },
  622. // note: overflow flag only undefined if shift is > 1
  623. // note: the adjust flag is undefined for shifts > 0 and unaffected by rotates
  624. { opcode: 0xC0, nonfaulting: 1, e: 1, fixed_g: i, imm8: 1, mask_flags: of | af, },
  625. { opcode: 0xC1, nonfaulting: 1, os: 1, e: 1, fixed_g: i, imm8: 1, mask_flags: of | af, },
  626. { opcode: 0xD0, nonfaulting: 1, e: 1, fixed_g: i, mask_flags: af, },
  627. { opcode: 0xD1, nonfaulting: 1, os: 1, e: 1, fixed_g: i, mask_flags: af, },
  628. { opcode: 0xD2, nonfaulting: 1, e: 1, fixed_g: i, mask_flags: of | af, },
  629. { opcode: 0xD3, nonfaulting: 1, os: 1, e: 1, fixed_g: i, mask_flags: of | af, },
  630. { opcode: 0xD8, e: 1, fixed_g: i, skip: 1, },
  631. { opcode: 0xD9, e: 1, fixed_g: i, skip: 1, },
  632. { opcode: 0xDA, e: 1, fixed_g: i, skip: 1, },
  633. { opcode: 0xDB, e: 1, fixed_g: i, skip: 1, },
  634. { opcode: 0xDC, e: 1, fixed_g: i, skip: 1, },
  635. { opcode: 0xDD, e: 1, fixed_g: i, skip: 1, },
  636. { opcode: 0xDE, e: 1, fixed_g: i, skip: 1, },
  637. { opcode: 0xDF, e: 1, fixed_g: i, skip: 1, },
  638. ]);
  639. }
  640. encodings.sort((e1, e2) => {
  641. let o1 = (e1.opcode & 0xFF00) === 0x0F00 ? e1.opcode & 0xFFFF : e1.opcode & 0xFF;
  642. let o2 = (e2.opcode & 0xFF00) === 0x0F00 ? e2.opcode & 0xFFFF : e2.opcode & 0xFF;
  643. return o1 - o2 || e1.fixed_g - e2.fixed_g;
  644. });
  645. function test_encodings()
  646. {
  647. const invalid = encodings.find(e => e.nonfaulting && e.block_boundary);
  648. if(invalid)
  649. {
  650. console.assert(
  651. false,
  652. "Unsupported: instruction cannot be both a block boundary and nonfaulting. Opcode: " + hex(invalid.opcode)
  653. );
  654. }
  655. }
  656. test_encodings();
  657. module.exports = Object.freeze(encodings.map(entry => Object.freeze(entry)));