laag-nasm 2.13.03.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (455) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +57 -0
  3. data/LICENSE.txt +29 -0
  4. data/README.org +34 -0
  5. data/ext/laag/nasm/extconf.rb +16 -0
  6. data/laag-nasm.gemspec +20 -0
  7. data/lib/laag/nasm.rb +29 -0
  8. data/patches/Makefile.in.patch +13 -0
  9. data/vendor/repo.or.cz/nasm/.gitignore +102 -0
  10. data/vendor/repo.or.cz/nasm/AUTHORS +137 -0
  11. data/vendor/repo.or.cz/nasm/CHANGES +2 -0
  12. data/vendor/repo.or.cz/nasm/ChangeLog +2905 -0
  13. data/vendor/repo.or.cz/nasm/INSTALL +102 -0
  14. data/vendor/repo.or.cz/nasm/LICENSE +29 -0
  15. data/vendor/repo.or.cz/nasm/Makefile.in +855 -0
  16. data/vendor/repo.or.cz/nasm/Mkfiles/README +46 -0
  17. data/vendor/repo.or.cz/nasm/Mkfiles/msvc.mak +732 -0
  18. data/vendor/repo.or.cz/nasm/Mkfiles/openwcom.mak +706 -0
  19. data/vendor/repo.or.cz/nasm/README +23 -0
  20. data/vendor/repo.or.cz/nasm/SubmittingPatches +116 -0
  21. data/vendor/repo.or.cz/nasm/TODO +376 -0
  22. data/vendor/repo.or.cz/nasm/aclocal.m4 +139 -0
  23. data/vendor/repo.or.cz/nasm/asm/assemble.c +2957 -0
  24. data/vendor/repo.or.cz/nasm/asm/assemble.h +54 -0
  25. data/vendor/repo.or.cz/nasm/asm/directiv.c +566 -0
  26. data/vendor/repo.or.cz/nasm/asm/directiv.dat +92 -0
  27. data/vendor/repo.or.cz/nasm/asm/error.c +202 -0
  28. data/vendor/repo.or.cz/nasm/asm/eval.c +1014 -0
  29. data/vendor/repo.or.cz/nasm/asm/eval.h +49 -0
  30. data/vendor/repo.or.cz/nasm/asm/exprdump.c +79 -0
  31. data/vendor/repo.or.cz/nasm/asm/exprlib.c +200 -0
  32. data/vendor/repo.or.cz/nasm/asm/float.c +952 -0
  33. data/vendor/repo.or.cz/nasm/asm/float.h +54 -0
  34. data/vendor/repo.or.cz/nasm/asm/labels.c +540 -0
  35. data/vendor/repo.or.cz/nasm/asm/listing.c +346 -0
  36. data/vendor/repo.or.cz/nasm/asm/listing.h +113 -0
  37. data/vendor/repo.or.cz/nasm/asm/nasm.c +1855 -0
  38. data/vendor/repo.or.cz/nasm/asm/parser.c +1167 -0
  39. data/vendor/repo.or.cz/nasm/asm/parser.h +45 -0
  40. data/vendor/repo.or.cz/nasm/asm/phash.pl +109 -0
  41. data/vendor/repo.or.cz/nasm/asm/pptok.dat +96 -0
  42. data/vendor/repo.or.cz/nasm/asm/pptok.pl +271 -0
  43. data/vendor/repo.or.cz/nasm/asm/pragma.c +218 -0
  44. data/vendor/repo.or.cz/nasm/asm/preproc-nop.c +188 -0
  45. data/vendor/repo.or.cz/nasm/asm/preproc.c +5459 -0
  46. data/vendor/repo.or.cz/nasm/asm/preproc.h +55 -0
  47. data/vendor/repo.or.cz/nasm/asm/quote.c +479 -0
  48. data/vendor/repo.or.cz/nasm/asm/quote.h +44 -0
  49. data/vendor/repo.or.cz/nasm/asm/rdstrnum.c +68 -0
  50. data/vendor/repo.or.cz/nasm/asm/segalloc.c +51 -0
  51. data/vendor/repo.or.cz/nasm/asm/stdscan.c +345 -0
  52. data/vendor/repo.or.cz/nasm/asm/stdscan.h +49 -0
  53. data/vendor/repo.or.cz/nasm/asm/strfunc.c +359 -0
  54. data/vendor/repo.or.cz/nasm/asm/tokens.dat +135 -0
  55. data/vendor/repo.or.cz/nasm/asm/tokhash.pl +284 -0
  56. data/vendor/repo.or.cz/nasm/autogen.sh +9 -0
  57. data/vendor/repo.or.cz/nasm/common/common.c +122 -0
  58. data/vendor/repo.or.cz/nasm/config/msvc.h +192 -0
  59. data/vendor/repo.or.cz/nasm/config/unknown.h +51 -0
  60. data/vendor/repo.or.cz/nasm/config/watcom.h +74 -0
  61. data/vendor/repo.or.cz/nasm/configure.ac +253 -0
  62. data/vendor/repo.or.cz/nasm/contrib/MSVC6.txt +25 -0
  63. data/vendor/repo.or.cz/nasm/contrib/VSrules/nasm.README +16 -0
  64. data/vendor/repo.or.cz/nasm/contrib/VSrules/nasm.rules +79 -0
  65. data/vendor/repo.or.cz/nasm/disasm/disasm.c +1735 -0
  66. data/vendor/repo.or.cz/nasm/disasm/disasm.h +49 -0
  67. data/vendor/repo.or.cz/nasm/disasm/ndisasm.c +397 -0
  68. data/vendor/repo.or.cz/nasm/disasm/sync.c +132 -0
  69. data/vendor/repo.or.cz/nasm/disasm/sync.h +45 -0
  70. data/vendor/repo.or.cz/nasm/doc/Makefile.in +86 -0
  71. data/vendor/repo.or.cz/nasm/doc/README +20 -0
  72. data/vendor/repo.or.cz/nasm/doc/afmmetrics.ph +102 -0
  73. data/vendor/repo.or.cz/nasm/doc/changes.src +2588 -0
  74. data/vendor/repo.or.cz/nasm/doc/findfont.ph +180 -0
  75. data/vendor/repo.or.cz/nasm/doc/genps.pl +1294 -0
  76. data/vendor/repo.or.cz/nasm/doc/inslist.pl +108 -0
  77. data/vendor/repo.or.cz/nasm/doc/internal.doc +290 -0
  78. data/vendor/repo.or.cz/nasm/doc/local.css +1 -0
  79. data/vendor/repo.or.cz/nasm/doc/nasmdoc.css +150 -0
  80. data/vendor/repo.or.cz/nasm/doc/nasmdoc.src +8309 -0
  81. data/vendor/repo.or.cz/nasm/doc/nasmlogo.eps +212 -0
  82. data/vendor/repo.or.cz/nasm/doc/nasmlogw.png +0 -0
  83. data/vendor/repo.or.cz/nasm/doc/psfonts.ph +53 -0
  84. data/vendor/repo.or.cz/nasm/doc/pspdf.pl +98 -0
  85. data/vendor/repo.or.cz/nasm/doc/pswidth.ph +25 -0
  86. data/vendor/repo.or.cz/nasm/doc/rdsrc.pl +1111 -0
  87. data/vendor/repo.or.cz/nasm/doc/ttfmetrics.ph +63 -0
  88. data/vendor/repo.or.cz/nasm/headers/c +33 -0
  89. data/vendor/repo.or.cz/nasm/headers/doc +33 -0
  90. data/vendor/repo.or.cz/nasm/headers/mac +33 -0
  91. data/vendor/repo.or.cz/nasm/headers/perl +33 -0
  92. data/vendor/repo.or.cz/nasm/include/compiler.h +277 -0
  93. data/vendor/repo.or.cz/nasm/include/disp8.h +45 -0
  94. data/vendor/repo.or.cz/nasm/include/error.h +135 -0
  95. data/vendor/repo.or.cz/nasm/include/hashtbl.h +85 -0
  96. data/vendor/repo.or.cz/nasm/include/iflag.h +173 -0
  97. data/vendor/repo.or.cz/nasm/include/insns.h +76 -0
  98. data/vendor/repo.or.cz/nasm/include/labels.h +60 -0
  99. data/vendor/repo.or.cz/nasm/include/md5.h +21 -0
  100. data/vendor/repo.or.cz/nasm/include/nasm.h +1246 -0
  101. data/vendor/repo.or.cz/nasm/include/nasmint.h +219 -0
  102. data/vendor/repo.or.cz/nasm/include/nasmlib.h +524 -0
  103. data/vendor/repo.or.cz/nasm/include/opflags.h +271 -0
  104. data/vendor/repo.or.cz/nasm/include/perfhash.h +52 -0
  105. data/vendor/repo.or.cz/nasm/include/raa.h +46 -0
  106. data/vendor/repo.or.cz/nasm/include/rbtree.h +51 -0
  107. data/vendor/repo.or.cz/nasm/include/rdoff.h +169 -0
  108. data/vendor/repo.or.cz/nasm/include/saa.h +94 -0
  109. data/vendor/repo.or.cz/nasm/include/strlist.h +55 -0
  110. data/vendor/repo.or.cz/nasm/include/tables.h +70 -0
  111. data/vendor/repo.or.cz/nasm/include/ver.h +47 -0
  112. data/vendor/repo.or.cz/nasm/install-sh +250 -0
  113. data/vendor/repo.or.cz/nasm/macros/altreg.mac +107 -0
  114. data/vendor/repo.or.cz/nasm/macros/fp.mac +54 -0
  115. data/vendor/repo.or.cz/nasm/macros/ifunc.mac +48 -0
  116. data/vendor/repo.or.cz/nasm/macros/macros.pl +294 -0
  117. data/vendor/repo.or.cz/nasm/macros/smartalign.mac +189 -0
  118. data/vendor/repo.or.cz/nasm/macros/standard.mac +226 -0
  119. data/vendor/repo.or.cz/nasm/misc/Doxyfile +752 -0
  120. data/vendor/repo.or.cz/nasm/misc/Nindent +18 -0
  121. data/vendor/repo.or.cz/nasm/misc/README +2 -0
  122. data/vendor/repo.or.cz/nasm/misc/c16.mac +82 -0
  123. data/vendor/repo.or.cz/nasm/misc/c32.mac +52 -0
  124. data/vendor/repo.or.cz/nasm/misc/crcgen.c +44 -0
  125. data/vendor/repo.or.cz/nasm/misc/exebin.mac +57 -0
  126. data/vendor/repo.or.cz/nasm/misc/exebin2.mac +114 -0
  127. data/vendor/repo.or.cz/nasm/misc/fmtinsns.pl +40 -0
  128. data/vendor/repo.or.cz/nasm/misc/genfma.pl +63 -0
  129. data/vendor/repo.or.cz/nasm/misc/hints.txt +26 -0
  130. data/vendor/repo.or.cz/nasm/misc/magic +6 -0
  131. data/vendor/repo.or.cz/nasm/misc/myC32.mac +121 -0
  132. data/vendor/repo.or.cz/nasm/misc/nasm.sl +320 -0
  133. data/vendor/repo.or.cz/nasm/misc/nasmstab +296 -0
  134. data/vendor/repo.or.cz/nasm/misc/omfdump.c +517 -0
  135. data/vendor/repo.or.cz/nasm/misc/pmw.bat +9 -0
  136. data/vendor/repo.or.cz/nasm/misc/proc32.ash +441 -0
  137. data/vendor/repo.or.cz/nasm/misc/scitech.mac +1223 -0
  138. data/vendor/repo.or.cz/nasm/misc/xcrcgen.c +80 -0
  139. data/vendor/repo.or.cz/nasm/nasm.spec.in +83 -0
  140. data/vendor/repo.or.cz/nasm/nasm.spec.sed +3 -0
  141. data/vendor/repo.or.cz/nasm/nasm.txt +306 -0
  142. data/vendor/repo.or.cz/nasm/nasmlib/badenum.c +43 -0
  143. data/vendor/repo.or.cz/nasm/nasmlib/bsi.c +77 -0
  144. data/vendor/repo.or.cz/nasm/nasmlib/crc64.c +189 -0
  145. data/vendor/repo.or.cz/nasm/nasmlib/file.c +259 -0
  146. data/vendor/repo.or.cz/nasm/nasmlib/file.h +128 -0
  147. data/vendor/repo.or.cz/nasm/nasmlib/filename.c +69 -0
  148. data/vendor/repo.or.cz/nasm/nasmlib/hashtbl.c +232 -0
  149. data/vendor/repo.or.cz/nasm/nasmlib/ilog2.c +168 -0
  150. data/vendor/repo.or.cz/nasm/nasmlib/malloc.c +108 -0
  151. data/vendor/repo.or.cz/nasm/nasmlib/md5c.c +247 -0
  152. data/vendor/repo.or.cz/nasm/nasmlib/mmap.c +139 -0
  153. data/vendor/repo.or.cz/nasm/nasmlib/path.c +186 -0
  154. data/vendor/repo.or.cz/nasm/nasmlib/perfhash.c +55 -0
  155. data/vendor/repo.or.cz/nasm/nasmlib/perfhash.pl +362 -0
  156. data/vendor/repo.or.cz/nasm/nasmlib/raa.c +173 -0
  157. data/vendor/repo.or.cz/nasm/nasmlib/rbtree.c +119 -0
  158. data/vendor/repo.or.cz/nasm/nasmlib/readnum.c +172 -0
  159. data/vendor/repo.or.cz/nasm/nasmlib/realpath.c +135 -0
  160. data/vendor/repo.or.cz/nasm/nasmlib/saa.c +431 -0
  161. data/vendor/repo.or.cz/nasm/nasmlib/srcfile.c +128 -0
  162. data/vendor/repo.or.cz/nasm/nasmlib/string.c +242 -0
  163. data/vendor/repo.or.cz/nasm/nasmlib/strlist.c +100 -0
  164. data/vendor/repo.or.cz/nasm/nasmlib/ver.c +51 -0
  165. data/vendor/repo.or.cz/nasm/nasmlib/zerobuf.c +42 -0
  166. data/vendor/repo.or.cz/nasm/ndisasm.txt +94 -0
  167. data/vendor/repo.or.cz/nasm/nsis/NASMMultiUser.nsh +478 -0
  168. data/vendor/repo.or.cz/nasm/nsis/getpearch.pl +76 -0
  169. data/vendor/repo.or.cz/nasm/nsis/nasm-un.ico +0 -0
  170. data/vendor/repo.or.cz/nasm/nsis/nasm.ico +0 -0
  171. data/vendor/repo.or.cz/nasm/nsis/nasm.nsi +241 -0
  172. data/vendor/repo.or.cz/nasm/output/codeview.c +814 -0
  173. data/vendor/repo.or.cz/nasm/output/dwarf.h +566 -0
  174. data/vendor/repo.or.cz/nasm/output/elf.h +537 -0
  175. data/vendor/repo.or.cz/nasm/output/legacy.c +112 -0
  176. data/vendor/repo.or.cz/nasm/output/nulldbg.c +93 -0
  177. data/vendor/repo.or.cz/nasm/output/nullout.c +51 -0
  178. data/vendor/repo.or.cz/nasm/output/outaout.c +954 -0
  179. data/vendor/repo.or.cz/nasm/output/outaout.mac +37 -0
  180. data/vendor/repo.or.cz/nasm/output/outas86.c +650 -0
  181. data/vendor/repo.or.cz/nasm/output/outas86.mac +37 -0
  182. data/vendor/repo.or.cz/nasm/output/outbin.c +1713 -0
  183. data/vendor/repo.or.cz/nasm/output/outbin.mac +40 -0
  184. data/vendor/repo.or.cz/nasm/output/outcoff.c +1242 -0
  185. data/vendor/repo.or.cz/nasm/output/outcoff.mac +43 -0
  186. data/vendor/repo.or.cz/nasm/output/outdbg.c +425 -0
  187. data/vendor/repo.or.cz/nasm/output/outelf.c +3370 -0
  188. data/vendor/repo.or.cz/nasm/output/outelf.h +156 -0
  189. data/vendor/repo.or.cz/nasm/output/outelf.mac +41 -0
  190. data/vendor/repo.or.cz/nasm/output/outform.c +120 -0
  191. data/vendor/repo.or.cz/nasm/output/outform.h +379 -0
  192. data/vendor/repo.or.cz/nasm/output/outieee.c +1528 -0
  193. data/vendor/repo.or.cz/nasm/output/outlib.c +58 -0
  194. data/vendor/repo.or.cz/nasm/output/outlib.h +63 -0
  195. data/vendor/repo.or.cz/nasm/output/outmacho.c +2387 -0
  196. data/vendor/repo.or.cz/nasm/output/outmacho.mac +49 -0
  197. data/vendor/repo.or.cz/nasm/output/outobj.c +2725 -0
  198. data/vendor/repo.or.cz/nasm/output/outobj.mac +49 -0
  199. data/vendor/repo.or.cz/nasm/output/outrdf.mac +40 -0
  200. data/vendor/repo.or.cz/nasm/output/outrdf2.c +791 -0
  201. data/vendor/repo.or.cz/nasm/output/outrdf2.mac +43 -0
  202. data/vendor/repo.or.cz/nasm/output/pecoff.h +532 -0
  203. data/vendor/repo.or.cz/nasm/output/stabs.h +144 -0
  204. data/vendor/repo.or.cz/nasm/perllib/crc64.ph +158 -0
  205. data/vendor/repo.or.cz/nasm/perllib/gensv.pl +34 -0
  206. data/vendor/repo.or.cz/nasm/perllib/phash.ph +200 -0
  207. data/vendor/repo.or.cz/nasm/perllib/random_sv_vectors.ph +67 -0
  208. data/vendor/repo.or.cz/nasm/rdoff/README +185 -0
  209. data/vendor/repo.or.cz/nasm/rdoff/collectn.c +44 -0
  210. data/vendor/repo.or.cz/nasm/rdoff/collectn.h +22 -0
  211. data/vendor/repo.or.cz/nasm/rdoff/doc/Makefile +37 -0
  212. data/vendor/repo.or.cz/nasm/rdoff/doc/rdoff.texi +137 -0
  213. data/vendor/repo.or.cz/nasm/rdoff/doc/v1-v2.txt +62 -0
  214. data/vendor/repo.or.cz/nasm/rdoff/hash.c +122 -0
  215. data/vendor/repo.or.cz/nasm/rdoff/hash.h +17 -0
  216. data/vendor/repo.or.cz/nasm/rdoff/ldrdf.1 +41 -0
  217. data/vendor/repo.or.cz/nasm/rdoff/ldrdf.c +1395 -0
  218. data/vendor/repo.or.cz/nasm/rdoff/ldsegs.h +59 -0
  219. data/vendor/repo.or.cz/nasm/rdoff/rdf2bin.1 +65 -0
  220. data/vendor/repo.or.cz/nasm/rdoff/rdf2bin.c +431 -0
  221. data/vendor/repo.or.cz/nasm/rdoff/rdf2com.1 +1 -0
  222. data/vendor/repo.or.cz/nasm/rdoff/rdf2ihx.1 +1 -0
  223. data/vendor/repo.or.cz/nasm/rdoff/rdf2ith.1 +1 -0
  224. data/vendor/repo.or.cz/nasm/rdoff/rdf2srec.1 +1 -0
  225. data/vendor/repo.or.cz/nasm/rdoff/rdfdump.1 +24 -0
  226. data/vendor/repo.or.cz/nasm/rdoff/rdfdump.c +347 -0
  227. data/vendor/repo.or.cz/nasm/rdoff/rdflib.1 +39 -0
  228. data/vendor/repo.or.cz/nasm/rdoff/rdflib.c +434 -0
  229. data/vendor/repo.or.cz/nasm/rdoff/rdfload.c +213 -0
  230. data/vendor/repo.or.cz/nasm/rdoff/rdfload.h +29 -0
  231. data/vendor/repo.or.cz/nasm/rdoff/rdfutils.h +165 -0
  232. data/vendor/repo.or.cz/nasm/rdoff/rdlar.c +492 -0
  233. data/vendor/repo.or.cz/nasm/rdoff/rdlar.h +34 -0
  234. data/vendor/repo.or.cz/nasm/rdoff/rdlib.c +290 -0
  235. data/vendor/repo.or.cz/nasm/rdoff/rdlib.h +62 -0
  236. data/vendor/repo.or.cz/nasm/rdoff/rdoff.c +621 -0
  237. data/vendor/repo.or.cz/nasm/rdoff/rdx.1 +21 -0
  238. data/vendor/repo.or.cz/nasm/rdoff/rdx.c +90 -0
  239. data/vendor/repo.or.cz/nasm/rdoff/segtab.c +172 -0
  240. data/vendor/repo.or.cz/nasm/rdoff/segtab.h +45 -0
  241. data/vendor/repo.or.cz/nasm/rdoff/symtab.c +159 -0
  242. data/vendor/repo.or.cz/nasm/rdoff/symtab.h +55 -0
  243. data/vendor/repo.or.cz/nasm/rdoff/test/Makefile +10 -0
  244. data/vendor/repo.or.cz/nasm/rdoff/test/makelib.sh +14 -0
  245. data/vendor/repo.or.cz/nasm/rdoff/test/rdfseg.asm +20 -0
  246. data/vendor/repo.or.cz/nasm/rdoff/test/rdfseg2.asm +12 -0
  247. data/vendor/repo.or.cz/nasm/rdoff/test/rdftest1.asm +54 -0
  248. data/vendor/repo.or.cz/nasm/rdoff/test/rdftest2.asm +33 -0
  249. data/vendor/repo.or.cz/nasm/rdoff/test/rdtlib.asm +48 -0
  250. data/vendor/repo.or.cz/nasm/rdoff/test/rdtmain.asm +47 -0
  251. data/vendor/repo.or.cz/nasm/rdoff/test/testlib.asm +18 -0
  252. data/vendor/repo.or.cz/nasm/stdlib/snprintf.c +29 -0
  253. data/vendor/repo.or.cz/nasm/stdlib/strlcpy.c +51 -0
  254. data/vendor/repo.or.cz/nasm/stdlib/strnlen.c +46 -0
  255. data/vendor/repo.or.cz/nasm/stdlib/vsnprintf.c +51 -0
  256. data/vendor/repo.or.cz/nasm/test/Makefile +106 -0
  257. data/vendor/repo.or.cz/nasm/test/_file_.asm +5 -0
  258. data/vendor/repo.or.cz/nasm/test/_version.asm +2 -0
  259. data/vendor/repo.or.cz/nasm/test/a32offs.asm +9 -0
  260. data/vendor/repo.or.cz/nasm/test/absolute.asm +40 -0
  261. data/vendor/repo.or.cz/nasm/test/addr64x.asm +18 -0
  262. data/vendor/repo.or.cz/nasm/test/align13.asm +19 -0
  263. data/vendor/repo.or.cz/nasm/test/align13s.asm +20 -0
  264. data/vendor/repo.or.cz/nasm/test/alonesym-obj.asm +166 -0
  265. data/vendor/repo.or.cz/nasm/test/andbyte.asm +15 -0
  266. data/vendor/repo.or.cz/nasm/test/aoutso.asm +99 -0
  267. data/vendor/repo.or.cz/nasm/test/aouttest.asm +86 -0
  268. data/vendor/repo.or.cz/nasm/test/aouttest.c +36 -0
  269. data/vendor/repo.or.cz/nasm/test/avx.asm +46 -0
  270. data/vendor/repo.or.cz/nasm/test/avx005.asm +529 -0
  271. data/vendor/repo.or.cz/nasm/test/avx2.asm +1608 -0
  272. data/vendor/repo.or.cz/nasm/test/avx512cd.asm +106 -0
  273. data/vendor/repo.or.cz/nasm/test/avx512er.asm +144 -0
  274. data/vendor/repo.or.cz/nasm/test/avx512f.asm +7000 -0
  275. data/vendor/repo.or.cz/nasm/test/avx512pf.asm +88 -0
  276. data/vendor/repo.or.cz/nasm/test/bcd.asm +23 -0
  277. data/vendor/repo.or.cz/nasm/test/binexe.asm +35 -0
  278. data/vendor/repo.or.cz/nasm/test/bintest.asm +59 -0
  279. data/vendor/repo.or.cz/nasm/test/bisect.sh +22 -0
  280. data/vendor/repo.or.cz/nasm/test/br1879590.asm +25 -0
  281. data/vendor/repo.or.cz/nasm/test/br2003451.asm +17 -0
  282. data/vendor/repo.or.cz/nasm/test/br2030823.asm +7 -0
  283. data/vendor/repo.or.cz/nasm/test/br2148476.asm +221 -0
  284. data/vendor/repo.or.cz/nasm/test/br2222615.asm +19 -0
  285. data/vendor/repo.or.cz/nasm/test/br2496848.asm +42 -0
  286. data/vendor/repo.or.cz/nasm/test/br3005117.asm +26 -0
  287. data/vendor/repo.or.cz/nasm/test/br3026808.asm +20 -0
  288. data/vendor/repo.or.cz/nasm/test/br3028880.asm +8 -0
  289. data/vendor/repo.or.cz/nasm/test/br3041451.asm +59 -0
  290. data/vendor/repo.or.cz/nasm/test/br3058845.asm +14 -0
  291. data/vendor/repo.or.cz/nasm/test/br3066383.asm +70 -0
  292. data/vendor/repo.or.cz/nasm/test/br3074517.asm +12 -0
  293. data/vendor/repo.or.cz/nasm/test/br3092924.asm +25 -0
  294. data/vendor/repo.or.cz/nasm/test/br3104312.asm +11 -0
  295. data/vendor/repo.or.cz/nasm/test/br3109604.asm +9 -0
  296. data/vendor/repo.or.cz/nasm/test/br3174983.asm +9 -0
  297. data/vendor/repo.or.cz/nasm/test/br3187743.asm +7 -0
  298. data/vendor/repo.or.cz/nasm/test/br3189064.asm +7 -0
  299. data/vendor/repo.or.cz/nasm/test/br3200749.asm +9 -0
  300. data/vendor/repo.or.cz/nasm/test/br3385573.asm +11 -0
  301. data/vendor/repo.or.cz/nasm/test/br3392252.asm +43 -0
  302. data/vendor/repo.or.cz/nasm/test/br3392259.asm +8 -0
  303. data/vendor/repo.or.cz/nasm/test/br3392363.asm +4 -0
  304. data/vendor/repo.or.cz/nasm/test/br3392392.asm +16 -0
  305. data/vendor/repo.or.cz/nasm/test/br3392396.asm +5 -0
  306. data/vendor/repo.or.cz/nasm/test/br3392411.asm +22 -0
  307. data/vendor/repo.or.cz/nasm/test/br3392418.asm +3 -0
  308. data/vendor/repo.or.cz/nasm/test/br3392439.asm +25 -0
  309. data/vendor/repo.or.cz/nasm/test/br3392442.asm +6 -0
  310. data/vendor/repo.or.cz/nasm/test/br560575.asm +17 -0
  311. data/vendor/repo.or.cz/nasm/test/br560873.asm +27 -0
  312. data/vendor/repo.or.cz/nasm/test/br890790.asm +7 -0
  313. data/vendor/repo.or.cz/nasm/test/br890790_i.asm +1 -0
  314. data/vendor/repo.or.cz/nasm/test/br978756.asm +7 -0
  315. data/vendor/repo.or.cz/nasm/test/changed.asm +383 -0
  316. data/vendor/repo.or.cz/nasm/test/cofftest.asm +85 -0
  317. data/vendor/repo.or.cz/nasm/test/cofftest.c +35 -0
  318. data/vendor/repo.or.cz/nasm/test/crc32.asm +37 -0
  319. data/vendor/repo.or.cz/nasm/test/cv8struc.asm +14 -0
  320. data/vendor/repo.or.cz/nasm/test/dtbcd.asm +72 -0
  321. data/vendor/repo.or.cz/nasm/test/elf64so.asm +118 -0
  322. data/vendor/repo.or.cz/nasm/test/elfso.asm +100 -0
  323. data/vendor/repo.or.cz/nasm/test/elftest.asm +87 -0
  324. data/vendor/repo.or.cz/nasm/test/elftest.c +38 -0
  325. data/vendor/repo.or.cz/nasm/test/elftest64.c +43 -0
  326. data/vendor/repo.or.cz/nasm/test/elif.asm +39 -0
  327. data/vendor/repo.or.cz/nasm/test/expimp.asm +90 -0
  328. data/vendor/repo.or.cz/nasm/test/far64.asm +10 -0
  329. data/vendor/repo.or.cz/nasm/test/float.asm +186 -0
  330. data/vendor/repo.or.cz/nasm/test/float8.asm +135 -0
  331. data/vendor/repo.or.cz/nasm/test/floatb.asm +35 -0
  332. data/vendor/repo.or.cz/nasm/test/floatexp.asm +382 -0
  333. data/vendor/repo.or.cz/nasm/test/floatize.asm +19 -0
  334. data/vendor/repo.or.cz/nasm/test/floattest.asm +28 -0
  335. data/vendor/repo.or.cz/nasm/test/floatx.asm +525 -0
  336. data/vendor/repo.or.cz/nasm/test/fpu.asm +127 -0
  337. data/vendor/repo.or.cz/nasm/test/fwdopt.asm +133 -0
  338. data/vendor/repo.or.cz/nasm/test/fwdoptpp.asm +150 -0
  339. data/vendor/repo.or.cz/nasm/test/gas2nasm.py +104 -0
  340. data/vendor/repo.or.cz/nasm/test/gather.asm +11 -0
  341. data/vendor/repo.or.cz/nasm/test/gotoff64.asm +25 -0
  342. data/vendor/repo.or.cz/nasm/test/hexfp.asm +25 -0
  343. data/vendor/repo.or.cz/nasm/test/hle.asm +19 -0
  344. data/vendor/repo.or.cz/nasm/test/ifelse.asm +46 -0
  345. data/vendor/repo.or.cz/nasm/test/ifenv.asm +31 -0
  346. data/vendor/repo.or.cz/nasm/test/ifmacro.asm +413 -0
  347. data/vendor/repo.or.cz/nasm/test/iftoken.asm +317 -0
  348. data/vendor/repo.or.cz/nasm/test/iftoken.pl +32 -0
  349. data/vendor/repo.or.cz/nasm/test/ilog2.asm +271 -0
  350. data/vendor/repo.or.cz/nasm/test/imacro.asm +8 -0
  351. data/vendor/repo.or.cz/nasm/test/imm.asm +23 -0
  352. data/vendor/repo.or.cz/nasm/test/imm64.asm +61 -0
  353. data/vendor/repo.or.cz/nasm/test/immwarn.asm +91 -0
  354. data/vendor/repo.or.cz/nasm/test/imul.asm +117 -0
  355. data/vendor/repo.or.cz/nasm/test/inc1.asm +6 -0
  356. data/vendor/repo.or.cz/nasm/test/inc2.asm +8 -0
  357. data/vendor/repo.or.cz/nasm/test/incbin.asm +7 -0
  358. data/vendor/repo.or.cz/nasm/test/incbin.data +2 -0
  359. data/vendor/repo.or.cz/nasm/test/inctest.asm +15 -0
  360. data/vendor/repo.or.cz/nasm/test/insnlbl.asm +12 -0
  361. data/vendor/repo.or.cz/nasm/test/invlpga.asm +11 -0
  362. data/vendor/repo.or.cz/nasm/test/jmp64.asm +19 -0
  363. data/vendor/repo.or.cz/nasm/test/lar_lsl.asm +124 -0
  364. data/vendor/repo.or.cz/nasm/test/larlsl.asm +23 -0
  365. data/vendor/repo.or.cz/nasm/test/lnxhello.asm +54 -0
  366. data/vendor/repo.or.cz/nasm/test/local.asm +19 -0
  367. data/vendor/repo.or.cz/nasm/test/loopoffs.asm +12 -0
  368. data/vendor/repo.or.cz/nasm/test/lwp.asm +213 -0
  369. data/vendor/repo.or.cz/nasm/test/macro-defaults.asm +64 -0
  370. data/vendor/repo.or.cz/nasm/test/macroerr.asm +12 -0
  371. data/vendor/repo.or.cz/nasm/test/macroerr.inc +3 -0
  372. data/vendor/repo.or.cz/nasm/test/mmxsize.asm +38 -0
  373. data/vendor/repo.or.cz/nasm/test/movd.asm +12 -0
  374. data/vendor/repo.or.cz/nasm/test/movd64.asm +15 -0
  375. data/vendor/repo.or.cz/nasm/test/movimm.asm +28 -0
  376. data/vendor/repo.or.cz/nasm/test/movnti.asm +10 -0
  377. data/vendor/repo.or.cz/nasm/test/mpx-64.asm +120 -0
  378. data/vendor/repo.or.cz/nasm/test/mpx.asm +89 -0
  379. data/vendor/repo.or.cz/nasm/test/multisection.asm +96 -0
  380. data/vendor/repo.or.cz/nasm/test/nasmformat.asm +17 -0
  381. data/vendor/repo.or.cz/nasm/test/new +9 -0
  382. data/vendor/repo.or.cz/nasm/test/newrdwr.asm +24 -0
  383. data/vendor/repo.or.cz/nasm/test/nop.asm +17 -0
  384. data/vendor/repo.or.cz/nasm/test/nullfile.asm +4 -0
  385. data/vendor/repo.or.cz/nasm/test/objexe.asm +30 -0
  386. data/vendor/repo.or.cz/nasm/test/objlink.c +33 -0
  387. data/vendor/repo.or.cz/nasm/test/objtest.asm +85 -0
  388. data/vendor/repo.or.cz/nasm/test/optimization.asm +104 -0
  389. data/vendor/repo.or.cz/nasm/test/org.asm +18 -0
  390. data/vendor/repo.or.cz/nasm/test/paste.asm +12 -0
  391. data/vendor/repo.or.cz/nasm/test/pcrel.asm +52 -0
  392. data/vendor/repo.or.cz/nasm/test/perf/label.pl +18 -0
  393. data/vendor/repo.or.cz/nasm/test/perf/macro.pl +18 -0
  394. data/vendor/repo.or.cz/nasm/test/perf/token.pl +23 -0
  395. data/vendor/repo.or.cz/nasm/test/performtest.pl +192 -0
  396. data/vendor/repo.or.cz/nasm/test/pextrw.asm +3 -0
  397. data/vendor/repo.or.cz/nasm/test/pinsr16.asm +53 -0
  398. data/vendor/repo.or.cz/nasm/test/pinsr32.asm +53 -0
  399. data/vendor/repo.or.cz/nasm/test/pinsr64.asm +68 -0
  400. data/vendor/repo.or.cz/nasm/test/popcnt.asm +32 -0
  401. data/vendor/repo.or.cz/nasm/test/ppindirect.asm +42 -0
  402. data/vendor/repo.or.cz/nasm/test/pragma.asm +12 -0
  403. data/vendor/repo.or.cz/nasm/test/prefix66.asm +28 -0
  404. data/vendor/repo.or.cz/nasm/test/ptr.asm +4 -0
  405. data/vendor/repo.or.cz/nasm/test/pushseg.asm +17 -0
  406. data/vendor/repo.or.cz/nasm/test/r13.asm +15 -0
  407. data/vendor/repo.or.cz/nasm/test/radix.asm +54 -0
  408. data/vendor/repo.or.cz/nasm/test/rdpid.asm +21 -0
  409. data/vendor/repo.or.cz/nasm/test/reldef.asm +57 -0
  410. data/vendor/repo.or.cz/nasm/test/relocs.asm +20 -0
  411. data/vendor/repo.or.cz/nasm/test/riprel.asm +5357 -0
  412. data/vendor/repo.or.cz/nasm/test/riprel.pl +29 -0
  413. data/vendor/repo.or.cz/nasm/test/riprel2.asm +11 -0
  414. data/vendor/repo.or.cz/nasm/test/sha-64.asm +30 -0
  415. data/vendor/repo.or.cz/nasm/test/sha.asm +31 -0
  416. data/vendor/repo.or.cz/nasm/test/smartalign16.asm +36 -0
  417. data/vendor/repo.or.cz/nasm/test/smartalign32.asm +36 -0
  418. data/vendor/repo.or.cz/nasm/test/smartalign64.asm +36 -0
  419. data/vendor/repo.or.cz/nasm/test/splitea.asm +11 -0
  420. data/vendor/repo.or.cz/nasm/test/sreg.asm +65 -0
  421. data/vendor/repo.or.cz/nasm/test/strlen.asm +5 -0
  422. data/vendor/repo.or.cz/nasm/test/struc.asm +33 -0
  423. data/vendor/repo.or.cz/nasm/test/test67.asm +38 -0
  424. data/vendor/repo.or.cz/nasm/test/testdos.asm +13 -0
  425. data/vendor/repo.or.cz/nasm/test/testnos3.asm +973 -0
  426. data/vendor/repo.or.cz/nasm/test/time.asm +11 -0
  427. data/vendor/repo.or.cz/nasm/test/times.asm +21 -0
  428. data/vendor/repo.or.cz/nasm/test/timesneg.asm +3 -0
  429. data/vendor/repo.or.cz/nasm/test/tmap.nas +1447 -0
  430. data/vendor/repo.or.cz/nasm/test/uscore.asm +15 -0
  431. data/vendor/repo.or.cz/nasm/test/utf.asm +82 -0
  432. data/vendor/repo.or.cz/nasm/test/vaesenc.asm +22 -0
  433. data/vendor/repo.or.cz/nasm/test/vex.asm +9 -0
  434. data/vendor/repo.or.cz/nasm/test/vgather.asm +76 -0
  435. data/vendor/repo.or.cz/nasm/test/vmread.asm +26 -0
  436. data/vendor/repo.or.cz/nasm/test/weirdpaste.asm +29 -0
  437. data/vendor/repo.or.cz/nasm/test/xchg.asm +96 -0
  438. data/vendor/repo.or.cz/nasm/test/xcrypt.asm +24 -0
  439. data/vendor/repo.or.cz/nasm/test/xmm0.asm +12 -0
  440. data/vendor/repo.or.cz/nasm/test/zerobyte.asm +22 -0
  441. data/vendor/repo.or.cz/nasm/tools/cleanfile +176 -0
  442. data/vendor/repo.or.cz/nasm/tools/cleanpatch +258 -0
  443. data/vendor/repo.or.cz/nasm/tools/mkdep.pl +261 -0
  444. data/vendor/repo.or.cz/nasm/tools/release +105 -0
  445. data/vendor/repo.or.cz/nasm/tools/syncfiles.pl +137 -0
  446. data/vendor/repo.or.cz/nasm/tools/tag-release +58 -0
  447. data/vendor/repo.or.cz/nasm/version +1 -0
  448. data/vendor/repo.or.cz/nasm/version.pl +189 -0
  449. data/vendor/repo.or.cz/nasm/x86/disp8.c +131 -0
  450. data/vendor/repo.or.cz/nasm/x86/insns-iflags.ph +280 -0
  451. data/vendor/repo.or.cz/nasm/x86/insns.dat +5371 -0
  452. data/vendor/repo.or.cz/nasm/x86/insns.pl +1043 -0
  453. data/vendor/repo.or.cz/nasm/x86/regs.dat +138 -0
  454. data/vendor/repo.or.cz/nasm/x86/regs.pl +204 -0
  455. metadata +520 -0
@@ -0,0 +1,1043 @@
1
+ #!/usr/bin/perl
2
+ ## --------------------------------------------------------------------------
3
+ ##
4
+ ## Copyright 1996-2016 The NASM Authors - All Rights Reserved
5
+ ## See the file AUTHORS included with the NASM distribution for
6
+ ## the specific copyright holders.
7
+ ##
8
+ ## Redistribution and use in source and binary forms, with or without
9
+ ## modification, are permitted provided that the following
10
+ ## conditions are met:
11
+ ##
12
+ ## * Redistributions of source code must retain the above copyright
13
+ ## notice, this list of conditions and the following disclaimer.
14
+ ## * Redistributions in binary form must reproduce the above
15
+ ## copyright notice, this list of conditions and the following
16
+ ## disclaimer in the documentation and/or other materials provided
17
+ ## with the distribution.
18
+ ##
19
+ ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
20
+ ## CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
+ ## INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22
+ ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ ## DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24
+ ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
+ ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26
+ ## NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27
+ ## LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28
+ ## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
+ ## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30
+ ## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
31
+ ## EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+ ##
33
+ ## --------------------------------------------------------------------------
34
+
35
+ #
36
+ # insns.pl
37
+ #
38
+ # Parse insns.dat and produce generated source code files
39
+
40
+ require 'x86/insns-iflags.ph';
41
+
42
+ # Opcode prefixes which need their own opcode tables
43
+ # LONGER PREFIXES FIRST!
44
+ @disasm_prefixes = qw(0F24 0F25 0F38 0F3A 0F7A 0FA6 0FA7 0F);
45
+
46
+ # This should match MAX_OPERANDS from nasm.h
47
+ $MAX_OPERANDS = 5;
48
+
49
+ # Add VEX/XOP prefixes
50
+ @vex_class = ( 'vex', 'xop', 'evex' );
51
+ $vex_classes = scalar(@vex_class);
52
+ @vexlist = ();
53
+ %vexmap = ();
54
+ for ($c = 0; $c < $vex_classes; $c++) {
55
+ $vexmap{$vex_class[$c]} = $c;
56
+ for ($m = 0; $m < 32; $m++) {
57
+ for ($p = 0; $p < 4; $p++) {
58
+ push(@vexlist, sprintf("%s%02X%01X", $vex_class[$c], $m, $p));
59
+ }
60
+ }
61
+ }
62
+ @disasm_prefixes = (@vexlist, @disasm_prefixes);
63
+
64
+ @bytecode_count = (0) x 256;
65
+
66
+ print STDERR "Reading insns.dat...\n";
67
+
68
+ @args = ();
69
+ undef $output;
70
+ foreach $arg ( @ARGV ) {
71
+ if ( $arg =~ /^\-/ ) {
72
+ if ( $arg =~ /^\-([abdin]|f[hc])$/ ) {
73
+ $output = $1;
74
+ } else {
75
+ die "$0: Unknown option: ${arg}\n";
76
+ }
77
+ } else {
78
+ push (@args, $arg);
79
+ }
80
+ }
81
+
82
+ die if (scalar(@args) != 2); # input output
83
+ ($fname, $oname) = @args;
84
+
85
+ open(F, '<', $fname) || die "unable to open $fname";
86
+
87
+ %dinstables = ();
88
+ @bytecode_list = ();
89
+
90
+ $line = 0;
91
+ $insns = 0;
92
+ while (<F>) {
93
+ $line++;
94
+ chomp;
95
+ next if ( /^\s*(\;.*|)$/ ); # comments or blank lines
96
+
97
+ unless (/^\s*(\S+)\s+(\S+)\s+(\S+|\[.*\])\s+(\S+)\s*$/) {
98
+ warn "line $line does not contain four fields\n";
99
+ next;
100
+ }
101
+ @fields = ($1, $2, $3, $4);
102
+ @field_list = ([@fields, 0]);
103
+
104
+ if ($fields[1] =~ /\*/) {
105
+ # This instruction has relaxed form(s)
106
+ if ($fields[2] !~ /^\[/) {
107
+ warn "line $line has an * operand but uses raw bytecodes\n";
108
+ next;
109
+ }
110
+
111
+ $opmask = 0;
112
+ @ops = split(/,/, $fields[1]);
113
+ for ($oi = 0; $oi < scalar @ops; $oi++) {
114
+ if ($ops[$oi] =~ /\*$/) {
115
+ if ($oi == 0) {
116
+ warn "line $line has a first operand with a *\n";
117
+ next;
118
+ }
119
+ $opmask |= 1 << $oi;
120
+ }
121
+ }
122
+
123
+ for ($oi = 1; $oi < (1 << scalar @ops); $oi++) {
124
+ if (($oi & ~$opmask) == 0) {
125
+ my @xops = ();
126
+ my $omask = ~$oi;
127
+ for ($oj = 0; $oj < scalar(@ops); $oj++) {
128
+ if ($omask & 1) {
129
+ push(@xops, $ops[$oj]);
130
+ }
131
+ $omask >>= 1;
132
+ }
133
+ push(@field_list, [$fields[0], join(',', @xops),
134
+ $fields[2], $fields[3], $oi]);
135
+ }
136
+ }
137
+ }
138
+
139
+ foreach $fptr (@field_list) {
140
+ @fields = @$fptr;
141
+ ($formatted, $nd) = format_insn(@fields);
142
+ if ($formatted) {
143
+ $insns++;
144
+ $aname = "aa_$fields[0]";
145
+ push @$aname, $formatted;
146
+ }
147
+ if ( $fields[0] =~ /cc$/ ) {
148
+ # Conditional instruction
149
+ $k_opcodes_cc{$fields[0]}++;
150
+ } else {
151
+ # Unconditional instruction
152
+ $k_opcodes{$fields[0]}++;
153
+ }
154
+ if ($formatted && !$nd) {
155
+ push @big, $formatted;
156
+ my @sseq = startseq($fields[2], $fields[4]);
157
+ foreach $i (@sseq) {
158
+ if (!defined($dinstables{$i})) {
159
+ $dinstables{$i} = [];
160
+ }
161
+ push(@{$dinstables{$i}}, $#big);
162
+ }
163
+ }
164
+ }
165
+ }
166
+
167
+ close F;
168
+
169
+ #
170
+ # Generate the bytecode array. At this point, @bytecode_list contains
171
+ # the full set of bytecodes.
172
+ #
173
+
174
+ # Sort by descending length
175
+ @bytecode_list = sort { scalar(@$b) <=> scalar(@$a) } @bytecode_list;
176
+ @bytecode_array = ();
177
+ %bytecode_pos = ();
178
+ $bytecode_next = 0;
179
+ foreach $bl (@bytecode_list) {
180
+ my $h = hexstr(@$bl);
181
+ next if (defined($bytecode_pos{$h}));
182
+
183
+ push(@bytecode_array, $bl);
184
+ while ($h ne '') {
185
+ $bytecode_pos{$h} = $bytecode_next;
186
+ $h = substr($h, 2);
187
+ $bytecode_next++;
188
+ }
189
+ }
190
+ undef @bytecode_list;
191
+
192
+ @opcodes = sort keys(%k_opcodes);
193
+ @opcodes_cc = sort keys(%k_opcodes_cc);
194
+
195
+ if ( $output eq 'b') {
196
+ print STDERR "Writing $oname...\n";
197
+
198
+ open(B, '>', $oname);
199
+
200
+ print B "/* This file auto-generated from insns.dat by insns.pl" .
201
+ " - don't edit it */\n\n";
202
+
203
+ print B "#include \"nasm.h\"\n";
204
+ print B "#include \"insns.h\"\n\n";
205
+
206
+ print B "const uint8_t nasm_bytecodes[$bytecode_next] = {\n";
207
+
208
+ $p = 0;
209
+ foreach $bl (@bytecode_array) {
210
+ printf B " /* %5d */ ", $p;
211
+ foreach $d (@$bl) {
212
+ printf B "%#o,", $d;
213
+ $p++;
214
+ }
215
+ printf B "\n";
216
+ }
217
+ print B "};\n";
218
+
219
+ print B "\n";
220
+ print B "/*\n";
221
+ print B " * Bytecode frequencies (including reuse):\n";
222
+ print B " *\n";
223
+ for ($i = 0; $i < 32; $i++) {
224
+ print B " *";
225
+ for ($j = 0; $j < 256; $j += 32) {
226
+ print B " |" if ($j);
227
+ printf B " %3o:%4d", $i+$j, $bytecode_count[$i+$j];
228
+ }
229
+ print B "\n";
230
+ }
231
+ print B " */\n";
232
+
233
+ close B;
234
+ }
235
+
236
+ if ( $output eq 'a' ) {
237
+ print STDERR "Writing $oname...\n";
238
+
239
+ open(A, '>', $oname);
240
+
241
+ print A "/* This file auto-generated from insns.dat by insns.pl" .
242
+ " - don't edit it */\n\n";
243
+
244
+ print A "#include \"nasm.h\"\n";
245
+ print A "#include \"insns.h\"\n\n";
246
+
247
+ foreach $i (@opcodes, @opcodes_cc) {
248
+ print A "static const struct itemplate instrux_${i}[] = {\n";
249
+ $aname = "aa_$i";
250
+ foreach $j (@$aname) {
251
+ print A " ", codesubst($j), "\n";
252
+ }
253
+ print A " ITEMPLATE_END\n};\n\n";
254
+ }
255
+ print A "const struct itemplate * const nasm_instructions[] = {\n";
256
+ foreach $i (@opcodes, @opcodes_cc) {
257
+ print A " instrux_${i},\n";
258
+ }
259
+ print A "};\n";
260
+
261
+ close A;
262
+ }
263
+
264
+ if ( $output eq 'd' ) {
265
+ print STDERR "Writing $oname...\n";
266
+
267
+ open(D, '>', $oname);
268
+
269
+ print D "/* This file auto-generated from insns.dat by insns.pl" .
270
+ " - don't edit it */\n\n";
271
+
272
+ print D "#include \"nasm.h\"\n";
273
+ print D "#include \"insns.h\"\n\n";
274
+
275
+ print D "static const struct itemplate instrux[] = {\n";
276
+ $n = 0;
277
+ foreach $j (@big) {
278
+ printf D " /* %4d */ %s\n", $n++, codesubst($j);
279
+ }
280
+ print D "};\n";
281
+
282
+ foreach $h (sort(keys(%dinstables))) {
283
+ next if ($h eq ''); # Skip pseudo-instructions
284
+ print D "\nstatic const struct itemplate * const itable_${h}[] = {\n";
285
+ foreach $j (@{$dinstables{$h}}) {
286
+ print D " instrux + $j,\n";
287
+ }
288
+ print D "};\n";
289
+ }
290
+
291
+ @prefix_list = ();
292
+ foreach $h (@disasm_prefixes, '') {
293
+ for ($c = 0; $c < 256; $c++) {
294
+ $nn = sprintf("%s%02X", $h, $c);
295
+ if ($is_prefix{$nn} || defined($dinstables{$nn})) {
296
+ # At least one entry in this prefix table
297
+ push(@prefix_list, $h);
298
+ $is_prefix{$h} = 1;
299
+ last;
300
+ }
301
+ }
302
+ }
303
+
304
+ foreach $h (@prefix_list) {
305
+ print D "\n";
306
+ print D "static " unless ($h eq '');
307
+ print D "const struct disasm_index ";
308
+ print D ($h eq '') ? 'itable' : "itable_$h";
309
+ print D "[256] = {\n";
310
+ for ($c = 0; $c < 256; $c++) {
311
+ $nn = sprintf("%s%02X", $h, $c);
312
+ if ($is_prefix{$nn}) {
313
+ die "$fname: ambiguous decoding of $nn\n"
314
+ if (defined($dinstables{$nn}));
315
+ printf D " /* 0x%02x */ { itable_%s, -1 },\n", $c, $nn;
316
+ } elsif (defined($dinstables{$nn})) {
317
+ printf D " /* 0x%02x */ { itable_%s, %u },\n", $c,
318
+ $nn, scalar(@{$dinstables{$nn}});
319
+ } else {
320
+ printf D " /* 0x%02x */ { NULL, 0 },\n", $c;
321
+ }
322
+ }
323
+ print D "};\n";
324
+ }
325
+
326
+ printf D "\nconst struct disasm_index * const itable_vex[NASM_VEX_CLASSES][32][4] =\n";
327
+ print D "{\n";
328
+ for ($c = 0; $c < $vex_classes; $c++) {
329
+ print D " {\n";
330
+ for ($m = 0; $m < 32; $m++) {
331
+ print D " { ";
332
+ for ($p = 0; $p < 4; $p++) {
333
+ $vp = sprintf("%s%02X%01X", $vex_class[$c], $m, $p);
334
+ printf D "%-15s",
335
+ ($is_prefix{$vp} ? sprintf("itable_%s,", $vp) : 'NULL,');
336
+ }
337
+ print D "},\n";
338
+ }
339
+ print D " },\n";
340
+ }
341
+ print D "};\n";
342
+
343
+ close D;
344
+ }
345
+
346
+ if ( $output eq 'i' ) {
347
+ print STDERR "Writing $oname...\n";
348
+
349
+ open(I, '>', $oname);
350
+
351
+ print I "/* This file is auto-generated from insns.dat by insns.pl" .
352
+ " - don't edit it */\n\n";
353
+ print I "/* This file in included by nasm.h */\n\n";
354
+
355
+ print I "/* Instruction names */\n\n";
356
+ print I "#ifndef NASM_INSNSI_H\n";
357
+ print I "#define NASM_INSNSI_H 1\n\n";
358
+ print I "enum opcode {\n";
359
+ $maxlen = 0;
360
+ foreach $i (@opcodes, @opcodes_cc) {
361
+ print I "\tI_${i},\n";
362
+ $len = length($i);
363
+ $len++ if ( $i =~ /cc$/ ); # Condition codes can be 3 characters long
364
+ $maxlen = $len if ( $len > $maxlen );
365
+ }
366
+ print I "\tI_none = -1\n";
367
+ print I "};\n\n";
368
+ print I "#define MAX_INSLEN ", $maxlen, "\n";
369
+ print I "#define NASM_VEX_CLASSES ", $vex_classes, "\n";
370
+ print I "#define NO_DECORATOR\t{", join(',',(0) x $MAX_OPERANDS), "}\n";
371
+ print I "#define FIRST_COND_OPCODE I_", $opcodes_cc[0], "\n\n";
372
+ print I "#endif /* NASM_INSNSI_H */\n";
373
+
374
+ close I;
375
+ }
376
+
377
+ if ( $output eq 'n' ) {
378
+ print STDERR "Writing $oname...\n";
379
+
380
+ open(N, '>', $oname);
381
+
382
+ print N "/* This file is auto-generated from insns.dat by insns.pl" .
383
+ " - don't edit it */\n\n";
384
+ print N "#include \"tables.h\"\n\n";
385
+
386
+ print N "const char * const nasm_insn_names[] = {";
387
+ $first = 1;
388
+ foreach $i (@opcodes, @opcodes_cc) {
389
+ print N "," if ( !$first );
390
+ $first = 0;
391
+ $ilower = $i;
392
+ $ilower =~ s/cc$//; # Remove conditional cc suffix
393
+ $ilower =~ tr/A-Z/a-z/; # Change to lower case (Perl 4 compatible)
394
+ print N "\n\t\"${ilower}\"";
395
+ }
396
+ print N "\n};\n";
397
+ close N;
398
+ }
399
+
400
+ if ( $output eq 'fh') {
401
+ write_iflaggen_h();
402
+ }
403
+
404
+ if ( $output eq 'fc') {
405
+ write_iflag_c();
406
+ }
407
+
408
+ printf STDERR "Done: %d instructions\n", $insns;
409
+
410
+ # Count primary bytecodes, for statistics
411
+ sub count_bytecodes(@) {
412
+ my $skip = 0;
413
+ foreach my $bc (@_) {
414
+ if ($skip) {
415
+ $skip--;
416
+ next;
417
+ }
418
+ $bytecode_count[$bc]++;
419
+ if ($bc >= 01 && $bc <= 04) {
420
+ $skip = $bc;
421
+ } elsif (($bc & ~03) == 010) {
422
+ $skip = 1;
423
+ } elsif (($bc & ~013) == 0144) {
424
+ $skip = 1;
425
+ } elsif ($bc == 0172 || $bc == 0173) {
426
+ $skip = 1;
427
+ } elsif (($bc & ~3) == 0260 || $bc == 0270) { # VEX
428
+ $skip = 2;
429
+ } elsif (($bc & ~3) == 0240 || $bc == 0250) { # EVEX
430
+ $skip = 3;
431
+ } elsif ($bc == 0330) {
432
+ $skip = 1;
433
+ }
434
+ }
435
+ }
436
+
437
+ sub format_insn($$$$$) {
438
+ my ($opcode, $operands, $codes, $flags, $relax) = @_;
439
+ my $num, $nd = 0, $rawflags, $flagsindex;
440
+ my @bytecode;
441
+ my $op, @ops, $opp, @opx, @oppx, @decos, @opevex;
442
+
443
+ return (undef, undef) if $operands eq "ignore";
444
+
445
+ # format the operands
446
+ $operands =~ s/\*//g;
447
+ $operands =~ s/:/|colon,/g;
448
+ @ops = ();
449
+ @decos = ();
450
+ if ($operands ne 'void') {
451
+ foreach $op (split(/,/, $operands)) {
452
+ @opx = ();
453
+ @opevex = ();
454
+ foreach $opp (split(/\|/, $op)) {
455
+ @oppx = ();
456
+ if ($opp =~ s/^(b(32|64)|mask|z|er|sae)$//) {
457
+ push(@opevex, $1);
458
+ }
459
+
460
+ if ($opp =~ s/(?<!\d)(8|16|32|64|80|128|256|512)$//) {
461
+ push(@oppx, "bits$1");
462
+ }
463
+ $opp =~ s/^mem$/memory/;
464
+ $opp =~ s/^memory_offs$/mem_offs/;
465
+ $opp =~ s/^imm$/immediate/;
466
+ $opp =~ s/^([a-z]+)rm$/rm_$1/;
467
+ $opp =~ s/^rm$/rm_gpr/;
468
+ $opp =~ s/^reg$/reg_gpr/;
469
+ # only for evex insns, high-16 regs are allowed
470
+ if ($codes !~ /(^|\s)evex\./) {
471
+ $opp =~ s/^(rm_[xyz]mm)$/$1_l16/;
472
+ $opp =~ s/^([xyz]mm)reg$/$1_l16/;
473
+ }
474
+ push(@opx, $opp, @oppx) if $opp;
475
+ }
476
+ $op = join('|', @opx);
477
+ push(@ops, $op);
478
+ push(@decos, (@opevex ? join('|', @opevex) : '0'));
479
+ }
480
+ }
481
+
482
+ $num = scalar(@ops);
483
+ while (scalar(@ops) < $MAX_OPERANDS) {
484
+ push(@ops, '0');
485
+ push(@decos, '0');
486
+ }
487
+ $operands = join(',', @ops);
488
+ $operands =~ tr/a-z/A-Z/;
489
+
490
+ $decorators = "{" . join(',', @decos) . "}";
491
+ if ($decorators =~ /^{(0,)+0}$/) {
492
+ $decorators = "NO_DECORATOR";
493
+ }
494
+ $decorators =~ tr/a-z/A-Z/;
495
+
496
+ # format the flags
497
+ $nd = 1 if $flags =~ /(^|\,)ND($|\,)/;
498
+ $flags =~ s/(^|\,)ND($|\,)/\1/g;
499
+ $flags =~ s/(^|\,)X64($|\,)/\1LONG,X86_64\2/g;
500
+ if ($codes =~ /evex\./) {
501
+ $flags .= ",EVEX";
502
+ } elsif ($codes =~ /(vex|xop)\./) {
503
+ $flags .= ",VEX";
504
+ }
505
+ $rawflags = $flags;
506
+ $flagsindex = insns_flag_index(split(',',$flags));
507
+
508
+ die "Error in flags $rawflags" if not defined($flagsindex);
509
+
510
+ @bytecode = (decodify($codes, $relax), 0);
511
+ push(@bytecode_list, [@bytecode]);
512
+ $codes = hexstr(@bytecode);
513
+ count_bytecodes(@bytecode);
514
+
515
+ ("{I_$opcode, $num, {$operands}, $decorators, \@\@CODES-$codes\@\@, $flagsindex},", $nd);
516
+ }
517
+
518
+ #
519
+ # Look for @@CODES-xxx@@ sequences and replace them with the appropriate
520
+ # offset into nasm_bytecodes
521
+ #
522
+ sub codesubst($) {
523
+ my($s) = @_;
524
+ my $n;
525
+
526
+ while ($s =~ /\@\@CODES-([0-9A-F]+)\@\@/) {
527
+ my $pos = $bytecode_pos{$1};
528
+ if (!defined($pos)) {
529
+ die "$fname: no position assigned to byte code $1\n";
530
+ }
531
+ $s = $` . "nasm_bytecodes+${pos}" . "$'";
532
+ }
533
+ return $s;
534
+ }
535
+
536
+ sub addprefix ($@) {
537
+ my ($prefix, @list) = @_;
538
+ my $x;
539
+ my @l = ();
540
+
541
+ foreach $x (@list) {
542
+ push(@l, sprintf("%s%02X", $prefix, $x));
543
+ }
544
+
545
+ return @l;
546
+ }
547
+
548
+ #
549
+ # Turn a code string into a sequence of bytes
550
+ #
551
+ sub decodify($$) {
552
+ # Although these are C-syntax strings, by convention they should have
553
+ # only octal escapes (for directives) and hexadecimal escapes
554
+ # (for verbatim bytes)
555
+ my($codestr, $relax) = @_;
556
+
557
+ if ($codestr =~ /^\s*\[([^\]]*)\]\s*$/) {
558
+ return byte_code_compile($1, $relax);
559
+ }
560
+
561
+ my $c = $codestr;
562
+ my @codes = ();
563
+
564
+ unless ($codestr eq 'ignore') {
565
+ while ($c ne '') {
566
+ if ($c =~ /^\\x([0-9a-f]+)(.*)$/i) {
567
+ push(@codes, hex $1);
568
+ $c = $2;
569
+ next;
570
+ } elsif ($c =~ /^\\([0-7]{1,3})(.*)$/) {
571
+ push(@codes, oct $1);
572
+ $c = $2;
573
+ next;
574
+ } else {
575
+ die "$fname: unknown code format in \"$codestr\"\n";
576
+ }
577
+ }
578
+ }
579
+
580
+ return @codes;
581
+ }
582
+
583
+ # Turn a numeric list into a hex string
584
+ sub hexstr(@) {
585
+ my $s = '';
586
+ my $c;
587
+
588
+ foreach $c (@_) {
589
+ $s .= sprintf("%02X", $c);
590
+ }
591
+ return $s;
592
+ }
593
+
594
+ # Here we determine the range of possible starting bytes for a given
595
+ # instruction. We need only consider the codes:
596
+ # \[1234] mean literal bytes, of course
597
+ # \1[0123] mean byte plus register value
598
+ # \330 means byte plus condition code
599
+ # \0 or \340 mean give up and return empty set
600
+ # \34[4567] mean PUSH/POP of segment registers: special case
601
+ # \17[234] skip is4 control byte
602
+ # \26x \270 skip VEX control bytes
603
+ # \24x \250 skip EVEX control bytes
604
+ sub startseq($$) {
605
+ my ($codestr, $relax) = @_;
606
+ my $word, @range;
607
+ my @codes = ();
608
+ my $c = $codestr;
609
+ my $c0, $c1, $i;
610
+ my $prefix = '';
611
+
612
+ @codes = decodify($codestr, $relax);
613
+
614
+ while ($c0 = shift(@codes)) {
615
+ $c1 = $codes[0];
616
+ if ($c0 >= 01 && $c0 <= 04) {
617
+ # Fixed byte string
618
+ my $fbs = $prefix;
619
+ while (1) {
620
+ if ($c0 >= 01 && $c0 <= 04) {
621
+ while ($c0--) {
622
+ $fbs .= sprintf("%02X", shift(@codes));
623
+ }
624
+ } else {
625
+ last;
626
+ }
627
+ $c0 = shift(@codes);
628
+ }
629
+
630
+ foreach $pfx (@disasm_prefixes) {
631
+ if (substr($fbs, 0, length($pfx)) eq $pfx) {
632
+ $prefix = $pfx;
633
+ $fbs = substr($fbs, length($pfx));
634
+ last;
635
+ }
636
+ }
637
+
638
+ if ($fbs ne '') {
639
+ return ($prefix.substr($fbs,0,2));
640
+ }
641
+
642
+ unshift(@codes, $c0);
643
+ } elsif ($c0 >= 010 && $c0 <= 013) {
644
+ return addprefix($prefix, $c1..($c1+7));
645
+ } elsif (($c0 & ~013) == 0144) {
646
+ return addprefix($prefix, $c1, $c1|2);
647
+ } elsif ($c0 == 0330) {
648
+ return addprefix($prefix, $c1..($c1+15));
649
+ } elsif ($c0 == 0 || $c0 == 0340) {
650
+ return $prefix;
651
+ } elsif (($c0 & ~3) == 0260 || $c0 == 0270 ||
652
+ ($c0 & ~3) == 0240 || $c0 == 0250) {
653
+ my $c,$m,$wlp;
654
+ $m = shift(@codes);
655
+ $wlp = shift(@codes);
656
+ $c = ($m >> 6);
657
+ $m = $m & 31;
658
+ $prefix .= sprintf('%s%02X%01X', $vex_class[$c], $m, $wlp & 3);
659
+ if ($c0 < 0260) {
660
+ my $tuple = shift(@codes);
661
+ }
662
+ } elsif ($c0 >= 0172 && $c0 <= 173) {
663
+ shift(@codes); # Skip is4 control byte
664
+ } else {
665
+ # We really need to be able to distinguish "forbidden"
666
+ # and "ignorable" codes here
667
+ }
668
+ }
669
+ return $prefix;
670
+ }
671
+
672
+ # EVEX tuple types offset is 0300. e.g. 0301 is for full vector(fv).
673
+ sub tupletype($) {
674
+ my ($tuplestr) = @_;
675
+ my %tuple_codes = (
676
+ '' => 000,
677
+ 'fv' => 001,
678
+ 'hv' => 002,
679
+ 'fvm' => 003,
680
+ 't1s8' => 004,
681
+ 't1s16' => 005,
682
+ 't1s' => 006,
683
+ 't1f32' => 007,
684
+ 't1f64' => 010,
685
+ 't2' => 011,
686
+ 't4' => 012,
687
+ 't8' => 013,
688
+ 'hvm' => 014,
689
+ 'qvm' => 015,
690
+ 'ovm' => 016,
691
+ 'm128' => 017,
692
+ 'dup' => 020,
693
+ );
694
+
695
+ if (defined $tuple_codes{$tuplestr}) {
696
+ return 0300 + $tuple_codes{$tuplestr};
697
+ } else {
698
+ die "Undefined tuple type : $tuplestr\n";
699
+ }
700
+ }
701
+
702
+ #
703
+ # This function takes a series of byte codes in a format which is more
704
+ # typical of the Intel documentation, and encode it.
705
+ #
706
+ # The format looks like:
707
+ #
708
+ # [operands: opcodes]
709
+ #
710
+ # The operands word lists the order of the operands:
711
+ #
712
+ # r = register field in the modr/m
713
+ # m = modr/m
714
+ # v = VEX "v" field
715
+ # i = immediate
716
+ # s = register field of is4/imz2 field
717
+ # - = implicit (unencoded) operand
718
+ # x = indeX register of mib. 014..017 bytecodes are used.
719
+ #
720
+ # For an operand that should be filled into more than one field,
721
+ # enter it as e.g. "r+v".
722
+ #
723
+ sub byte_code_compile($$) {
724
+ my($str, $relax) = @_;
725
+ my $opr;
726
+ my $opc;
727
+ my @codes = ();
728
+ my $litix = undef;
729
+ my %oppos = ();
730
+ my $i;
731
+ my $op, $oq;
732
+ my $opex;
733
+
734
+ my %imm_codes = (
735
+ 'ib' => 020, # imm8
736
+ 'ib,u' => 024, # Unsigned imm8
737
+ 'iw' => 030, # imm16
738
+ 'ib,s' => 0274, # imm8 sign-extended to opsize or bits
739
+ 'iwd' => 034, # imm16 or imm32, depending on opsize
740
+ 'id' => 040, # imm32
741
+ 'id,s' => 0254, # imm32 sign-extended to 64 bits
742
+ 'iwdq' => 044, # imm16/32/64, depending on addrsize
743
+ 'rel8' => 050,
744
+ 'iq' => 054,
745
+ 'rel16' => 060,
746
+ 'rel' => 064, # 16 or 32 bit relative operand
747
+ 'rel32' => 070,
748
+ 'seg' => 074,
749
+ );
750
+ my %plain_codes = (
751
+ 'o16' => 0320, # 16-bit operand size
752
+ 'o32' => 0321, # 32-bit operand size
753
+ 'odf' => 0322, # Operand size is default
754
+ 'o64' => 0324, # 64-bit operand size requiring REX.W
755
+ 'o64nw' => 0323, # Implied 64-bit operand size (no REX.W)
756
+ 'a16' => 0310,
757
+ 'a32' => 0311,
758
+ 'adf' => 0312, # Address size is default
759
+ 'a64' => 0313,
760
+ '!osp' => 0364,
761
+ '!asp' => 0365,
762
+ 'f2i' => 0332, # F2 prefix, but 66 for operand size is OK
763
+ 'f3i' => 0333, # F3 prefix, but 66 for operand size is OK
764
+ 'mustrep' => 0336,
765
+ 'mustrepne' => 0337,
766
+ 'rex.l' => 0334,
767
+ 'norexb' => 0314,
768
+ 'norexx' => 0315,
769
+ 'norexr' => 0316,
770
+ 'norexw' => 0317,
771
+ 'repe' => 0335,
772
+ 'nohi' => 0325, # Use spl/bpl/sil/dil even without REX
773
+ 'nof3' => 0326, # No REP 0xF3 prefix permitted
774
+ 'norep' => 0331, # No REP prefix permitted
775
+ 'wait' => 0341, # Needs a wait prefix
776
+ 'resb' => 0340,
777
+ 'np' => 0360, # No prefix
778
+ 'jcc8' => 0370, # Match only if Jcc possible with single byte
779
+ 'jmp8' => 0371, # Match only if JMP possible with single byte
780
+ 'jlen' => 0373, # Length of jump
781
+ 'hlexr' => 0271,
782
+ 'hlenl' => 0272,
783
+ 'hle' => 0273,
784
+
785
+ # This instruction takes XMM VSIB
786
+ 'vsibx' => 0374,
787
+ 'vm32x' => 0374,
788
+ 'vm64x' => 0374,
789
+
790
+ # This instruction takes YMM VSIB
791
+ 'vsiby' => 0375,
792
+ 'vm32y' => 0375,
793
+ 'vm64y' => 0375,
794
+
795
+ # This instruction takes ZMM VSIB
796
+ 'vsibz' => 0376,
797
+ 'vm32z' => 0376,
798
+ 'vm64z' => 0376,
799
+ );
800
+
801
+ unless ($str =~ /^(([^\s:]*)\:*([^\s:]*)\:|)\s*(.*\S)\s*$/) {
802
+ die "$fname: $line: cannot parse: [$str]\n";
803
+ }
804
+ $opr = "\L$2";
805
+ $tuple = "\L$3"; # Tuple type for AVX512
806
+ $opc = "\L$4";
807
+
808
+ my $op = 0;
809
+ for ($i = 0; $i < length($opr); $i++) {
810
+ my $c = substr($opr,$i,1);
811
+ if ($c eq '+') {
812
+ $op--;
813
+ } else {
814
+ if ($relax & 1) {
815
+ $op--;
816
+ }
817
+ $relax >>= 1;
818
+ $oppos{$c} = $op++;
819
+ }
820
+ }
821
+ $tup = tupletype($tuple);
822
+
823
+ my $last_imm = 'h';
824
+ my $prefix_ok = 1;
825
+ foreach $op (split(/\s*(?:\s|(?=[\/\\]))/, $opc)) {
826
+ my $pc = $plain_codes{$op};
827
+
828
+ if (defined $pc) {
829
+ # Plain code
830
+ push(@codes, $pc);
831
+ } elsif ($prefix_ok && $op =~ /^(66|f2|f3)$/) {
832
+ # 66/F2/F3 prefix used as an opcode extension
833
+ if ($op eq '66') {
834
+ push(@codes, 0361);
835
+ } elsif ($op eq 'f2') {
836
+ push(@codes, 0332);
837
+ } else {
838
+ push(@codes, 0333);
839
+ }
840
+ } elsif ($op =~ /^[0-9a-f]{2}$/) {
841
+ if (defined($litix) && $litix+$codes[$litix]+1 == scalar @codes &&
842
+ $codes[$litix] < 4) {
843
+ $codes[$litix]++;
844
+ push(@codes, hex $op);
845
+ } else {
846
+ $litix = scalar(@codes);
847
+ push(@codes, 01, hex $op);
848
+ }
849
+ $prefix_ok = 0;
850
+ } elsif ($op eq '/r') {
851
+ if (!defined($oppos{'r'}) || !defined($oppos{'m'})) {
852
+ die "$fname: $line: $op requires r and m operands\n";
853
+ }
854
+ $opex = (($oppos{'m'} & 4) ? 06 : 0) |
855
+ (($oppos{'r'} & 4) ? 05 : 0);
856
+ push(@codes, $opex) if ($opex);
857
+ # if mib is composed with two separate operands - ICC style
858
+ push(@codes, 014 + ($oppos{'x'} & 3)) if (defined($oppos{'x'}));
859
+ push(@codes, 0100 + (($oppos{'m'} & 3) << 3) + ($oppos{'r'} & 3));
860
+ $prefix_ok = 0;
861
+ } elsif ($op =~ m:^/([0-7])$:) {
862
+ if (!defined($oppos{'m'})) {
863
+ die "$fname: $line: $op requires m operand\n";
864
+ }
865
+ push(@codes, 06) if ($oppos{'m'} & 4);
866
+ push(@codes, 0200 + (($oppos{'m'} & 3) << 3) + $1);
867
+ $prefix_ok = 0;
868
+ } elsif ($op =~ /^(vex|xop)(|\..*)$/) {
869
+ my $vexname = $1;
870
+ my $c = $vexmap{$vexname};
871
+ my ($m,$w,$l,$p) = (undef,2,undef,0);
872
+ my $has_nds = 0;
873
+ my @subops = split(/\./, $op);
874
+ shift @subops; # Drop prefix
875
+ foreach $oq (@subops) {
876
+ if ($oq eq '128' || $oq eq 'l0' || $oq eq 'lz') {
877
+ $l = 0;
878
+ } elsif ($oq eq '256' || $oq eq 'l1') {
879
+ $l = 1;
880
+ } elsif ($oq eq 'lig') {
881
+ $l = 2;
882
+ } elsif ($oq eq 'w0') {
883
+ $w = 0;
884
+ } elsif ($oq eq 'w1') {
885
+ $w = 1;
886
+ } elsif ($oq eq 'wig') {
887
+ $w = 2;
888
+ } elsif ($oq eq 'ww') {
889
+ $w = 3;
890
+ } elsif ($oq eq 'p0') {
891
+ $p = 0;
892
+ } elsif ($oq eq '66' || $oq eq 'p1') {
893
+ $p = 1;
894
+ } elsif ($oq eq 'f3' || $oq eq 'p2') {
895
+ $p = 2;
896
+ } elsif ($oq eq 'f2' || $oq eq 'p3') {
897
+ $p = 3;
898
+ } elsif ($oq eq '0f') {
899
+ $m = 1;
900
+ } elsif ($oq eq '0f38') {
901
+ $m = 2;
902
+ } elsif ($oq eq '0f3a') {
903
+ $m = 3;
904
+ } elsif ($oq =~ /^m([0-9]+)$/) {
905
+ $m = $1+0;
906
+ } elsif ($oq eq 'nds' || $oq eq 'ndd' || $oq eq 'dds') {
907
+ if (!defined($oppos{'v'})) {
908
+ die "$fname: $line: $vexname.$oq without 'v' operand\n";
909
+ }
910
+ $has_nds = 1;
911
+ } else {
912
+ die "$fname: $line: undefined \U$vexname\E subcode: $oq\n";
913
+ }
914
+ }
915
+ if (!defined($m) || !defined($w) || !defined($l) || !defined($p)) {
916
+ die "$fname: $line: missing fields in \U$vexname\E specification\n";
917
+ }
918
+ if (defined($oppos{'v'}) && !$has_nds) {
919
+ die "$fname: $line: 'v' operand without ${vexname}.nds or ${vexname}.ndd\n";
920
+ }
921
+ my $minmap = ($c == 1) ? 8 : 0; # 0-31 for VEX, 8-31 for XOP
922
+ if ($m < $minmap || $m > 31) {
923
+ die "$fname: $line: Only maps ${minmap}-31 are valid for \U${vexname}\n";
924
+ }
925
+ push(@codes, defined($oppos{'v'}) ? 0260+($oppos{'v'} & 3) : 0270,
926
+ ($c << 6)+$m, ($w << 4)+($l << 2)+$p);
927
+ $prefix_ok = 0;
928
+ } elsif ($op =~ /^(evex)(|\..*)$/) {
929
+ my $c = $vexmap{$1};
930
+ my ($m,$w,$l,$p) = (undef,2,undef,0);
931
+ my $has_nds = 0;
932
+ my @subops = split(/\./, $op);
933
+ shift @subops; # Drop prefix
934
+ foreach $oq (@subops) {
935
+ if ($oq eq '128' || $oq eq 'l0' || $oq eq 'lz' || $oq eq 'lig') {
936
+ $l = 0;
937
+ } elsif ($oq eq '256' || $oq eq 'l1') {
938
+ $l = 1;
939
+ } elsif ($oq eq '512' || $oq eq 'l2') {
940
+ $l = 2;
941
+ } elsif ($oq eq 'w0') {
942
+ $w = 0;
943
+ } elsif ($oq eq 'w1') {
944
+ $w = 1;
945
+ } elsif ($oq eq 'wig') {
946
+ $w = 2;
947
+ } elsif ($oq eq 'ww') {
948
+ $w = 3;
949
+ } elsif ($oq eq 'p0') {
950
+ $p = 0;
951
+ } elsif ($oq eq '66' || $oq eq 'p1') {
952
+ $p = 1;
953
+ } elsif ($oq eq 'f3' || $oq eq 'p2') {
954
+ $p = 2;
955
+ } elsif ($oq eq 'f2' || $oq eq 'p3') {
956
+ $p = 3;
957
+ } elsif ($oq eq '0f') {
958
+ $m = 1;
959
+ } elsif ($oq eq '0f38') {
960
+ $m = 2;
961
+ } elsif ($oq eq '0f3a') {
962
+ $m = 3;
963
+ } elsif ($oq =~ /^m([0-9]+)$/) {
964
+ $m = $1+0;
965
+ } elsif ($oq eq 'nds' || $oq eq 'ndd' || $oq eq 'dds') {
966
+ if (!defined($oppos{'v'})) {
967
+ die "$fname: $line: evex.$oq without 'v' operand\n";
968
+ }
969
+ $has_nds = 1;
970
+ } else {
971
+ die "$fname: $line: undefined EVEX subcode: $oq\n";
972
+ }
973
+ }
974
+ if (!defined($m) || !defined($w) || !defined($l) || !defined($p)) {
975
+ die "$fname: $line: missing fields in EVEX specification\n";
976
+ }
977
+ if (defined($oppos{'v'}) && !$has_nds) {
978
+ die "$fname: $line: 'v' operand without evex.nds or evex.ndd\n";
979
+ }
980
+ if ($m > 15) {
981
+ die "$fname: $line: Only maps 0-15 are valid for EVEX\n";
982
+ }
983
+ push(@codes, defined($oppos{'v'}) ? 0240+($oppos{'v'} & 3) : 0250,
984
+ ($c << 6)+$m, ($w << 4)+($l << 2)+$p, $tup);
985
+ $prefix_ok = 0;
986
+ } elsif (defined $imm_codes{$op}) {
987
+ if ($op eq 'seg') {
988
+ if ($last_imm lt 'i') {
989
+ die "$fname: $line: seg without an immediate operand\n";
990
+ }
991
+ } else {
992
+ $last_imm++;
993
+ if ($last_imm gt 'j') {
994
+ die "$fname: $line: too many immediate operands\n";
995
+ }
996
+ }
997
+ if (!defined($oppos{$last_imm})) {
998
+ die "$fname: $line: $op without '$last_imm' operand\n";
999
+ }
1000
+ push(@codes, 05) if ($oppos{$last_imm} & 4);
1001
+ push(@codes, $imm_codes{$op} + ($oppos{$last_imm} & 3));
1002
+ $prefix_ok = 0;
1003
+ } elsif ($op eq '/is4') {
1004
+ if (!defined($oppos{'s'})) {
1005
+ die "$fname: $line: $op without 's' operand\n";
1006
+ }
1007
+ if (defined($oppos{'i'})) {
1008
+ push(@codes, 0172, ($oppos{'s'} << 3)+$oppos{'i'});
1009
+ } else {
1010
+ push(@codes, 05) if ($oppos{'s'} & 4);
1011
+ push(@codes, 0174+($oppos{'s'} & 3));
1012
+ }
1013
+ $prefix_ok = 0;
1014
+ } elsif ($op =~ /^\/is4\=([0-9]+)$/) {
1015
+ my $imm = $1;
1016
+ if (!defined($oppos{'s'})) {
1017
+ die "$fname: $line: $op without 's' operand\n";
1018
+ }
1019
+ if ($imm < 0 || $imm > 15) {
1020
+ die "$fname: $line: invalid imm4 value for $op: $imm\n";
1021
+ }
1022
+ push(@codes, 0173, ($oppos{'s'} << 4) + $imm);
1023
+ $prefix_ok = 0;
1024
+ } elsif ($op =~ /^([0-9a-f]{2})\+c$/) {
1025
+ push(@codes, 0330, hex $1);
1026
+ $prefix_ok = 0;
1027
+ } elsif ($op =~ /^([0-9a-f]{2})\+r$/) {
1028
+ if (!defined($oppos{'r'})) {
1029
+ die "$fname: $line: $op without 'r' operand\n";
1030
+ }
1031
+ push(@codes, 05) if ($oppos{'r'} & 4);
1032
+ push(@codes, 010 + ($oppos{'r'} & 3), hex $1);
1033
+ $prefix_ok = 0;
1034
+ } elsif ($op =~ /^\\([0-7]+|x[0-9a-f]{2})$/) {
1035
+ # Escape to enter literal bytecodes
1036
+ push(@codes, oct $1);
1037
+ } else {
1038
+ die "$fname: $line: unknown operation: $op\n";
1039
+ }
1040
+ }
1041
+
1042
+ return @codes;
1043
+ }