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,1167 @@
1
+ /* ----------------------------------------------------------------------- *
2
+ *
3
+ * Copyright 1996-2017 The NASM Authors - All Rights Reserved
4
+ * See the file AUTHORS included with the NASM distribution for
5
+ * the specific copyright holders.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following
9
+ * conditions are met:
10
+ *
11
+ * * Redistributions of source code must retain the above copyright
12
+ * notice, this list of conditions and the following disclaimer.
13
+ * * Redistributions in binary form must reproduce the above
14
+ * copyright notice, this list of conditions and the following
15
+ * disclaimer in the documentation and/or other materials provided
16
+ * with the distribution.
17
+ *
18
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ *
32
+ * ----------------------------------------------------------------------- */
33
+
34
+ /*
35
+ * parser.c source line parser for the Netwide Assembler
36
+ */
37
+
38
+ #include "compiler.h"
39
+
40
+ #include <stdio.h>
41
+ #include <stdlib.h>
42
+ #include <stddef.h>
43
+ #include <string.h>
44
+ #include <ctype.h>
45
+
46
+ #include "nasm.h"
47
+ #include "insns.h"
48
+ #include "nasmlib.h"
49
+ #include "error.h"
50
+ #include "stdscan.h"
51
+ #include "eval.h"
52
+ #include "parser.h"
53
+ #include "float.h"
54
+ #include "assemble.h"
55
+ #include "tables.h"
56
+
57
+
58
+ static int is_comma_next(void);
59
+
60
+ static struct tokenval tokval;
61
+
62
+ static int prefix_slot(int prefix)
63
+ {
64
+ switch (prefix) {
65
+ case P_WAIT:
66
+ return PPS_WAIT;
67
+ case R_CS:
68
+ case R_DS:
69
+ case R_SS:
70
+ case R_ES:
71
+ case R_FS:
72
+ case R_GS:
73
+ return PPS_SEG;
74
+ case P_LOCK:
75
+ return PPS_LOCK;
76
+ case P_REP:
77
+ case P_REPE:
78
+ case P_REPZ:
79
+ case P_REPNE:
80
+ case P_REPNZ:
81
+ case P_XACQUIRE:
82
+ case P_XRELEASE:
83
+ case P_BND:
84
+ case P_NOBND:
85
+ return PPS_REP;
86
+ case P_O16:
87
+ case P_O32:
88
+ case P_O64:
89
+ case P_OSP:
90
+ return PPS_OSIZE;
91
+ case P_A16:
92
+ case P_A32:
93
+ case P_A64:
94
+ case P_ASP:
95
+ return PPS_ASIZE;
96
+ case P_EVEX:
97
+ case P_VEX3:
98
+ case P_VEX2:
99
+ return PPS_VEX;
100
+ default:
101
+ nasm_panic(0, "Invalid value %d passed to prefix_slot()", prefix);
102
+ return -1;
103
+ }
104
+ }
105
+
106
+ static void process_size_override(insn *result, operand *op)
107
+ {
108
+ if (tasm_compatible_mode) {
109
+ switch (tokval.t_integer) {
110
+ /* For TASM compatibility a size override inside the
111
+ * brackets changes the size of the operand, not the
112
+ * address type of the operand as it does in standard
113
+ * NASM syntax. Hence:
114
+ *
115
+ * mov eax,[DWORD val]
116
+ *
117
+ * is valid syntax in TASM compatibility mode. Note that
118
+ * you lose the ability to override the default address
119
+ * type for the instruction, but we never use anything
120
+ * but 32-bit flat model addressing in our code.
121
+ */
122
+ case S_BYTE:
123
+ op->type |= BITS8;
124
+ break;
125
+ case S_WORD:
126
+ op->type |= BITS16;
127
+ break;
128
+ case S_DWORD:
129
+ case S_LONG:
130
+ op->type |= BITS32;
131
+ break;
132
+ case S_QWORD:
133
+ op->type |= BITS64;
134
+ break;
135
+ case S_TWORD:
136
+ op->type |= BITS80;
137
+ break;
138
+ case S_OWORD:
139
+ op->type |= BITS128;
140
+ break;
141
+ default:
142
+ nasm_error(ERR_NONFATAL,
143
+ "invalid operand size specification");
144
+ break;
145
+ }
146
+ } else {
147
+ /* Standard NASM compatible syntax */
148
+ switch (tokval.t_integer) {
149
+ case S_NOSPLIT:
150
+ op->eaflags |= EAF_TIMESTWO;
151
+ break;
152
+ case S_REL:
153
+ op->eaflags |= EAF_REL;
154
+ break;
155
+ case S_ABS:
156
+ op->eaflags |= EAF_ABS;
157
+ break;
158
+ case S_BYTE:
159
+ op->disp_size = 8;
160
+ op->eaflags |= EAF_BYTEOFFS;
161
+ break;
162
+ case P_A16:
163
+ case P_A32:
164
+ case P_A64:
165
+ if (result->prefixes[PPS_ASIZE] &&
166
+ result->prefixes[PPS_ASIZE] != tokval.t_integer)
167
+ nasm_error(ERR_NONFATAL,
168
+ "conflicting address size specifications");
169
+ else
170
+ result->prefixes[PPS_ASIZE] = tokval.t_integer;
171
+ break;
172
+ case S_WORD:
173
+ op->disp_size = 16;
174
+ op->eaflags |= EAF_WORDOFFS;
175
+ break;
176
+ case S_DWORD:
177
+ case S_LONG:
178
+ op->disp_size = 32;
179
+ op->eaflags |= EAF_WORDOFFS;
180
+ break;
181
+ case S_QWORD:
182
+ op->disp_size = 64;
183
+ op->eaflags |= EAF_WORDOFFS;
184
+ break;
185
+ default:
186
+ nasm_error(ERR_NONFATAL, "invalid size specification in"
187
+ " effective address");
188
+ break;
189
+ }
190
+ }
191
+ }
192
+
193
+ /*
194
+ * Brace decorators are are parsed here. opmask and zeroing
195
+ * decorators can be placed in any order. e.g. zmm1 {k2}{z} or zmm2
196
+ * {z}{k3} decorator(s) are placed at the end of an operand.
197
+ */
198
+ static bool parse_braces(decoflags_t *decoflags)
199
+ {
200
+ int i, j;
201
+
202
+ i = tokval.t_type;
203
+
204
+ while (true) {
205
+ switch (i) {
206
+ case TOKEN_OPMASK:
207
+ if (*decoflags & OPMASK_MASK) {
208
+ nasm_error(ERR_NONFATAL,
209
+ "opmask k%"PRIu64" is already set",
210
+ *decoflags & OPMASK_MASK);
211
+ *decoflags &= ~OPMASK_MASK;
212
+ }
213
+ *decoflags |= VAL_OPMASK(nasm_regvals[tokval.t_integer]);
214
+ break;
215
+ case TOKEN_DECORATOR:
216
+ j = tokval.t_integer;
217
+ switch (j) {
218
+ case BRC_Z:
219
+ *decoflags |= Z_MASK;
220
+ break;
221
+ case BRC_1TO2:
222
+ case BRC_1TO4:
223
+ case BRC_1TO8:
224
+ case BRC_1TO16:
225
+ *decoflags |= BRDCAST_MASK | VAL_BRNUM(j - BRC_1TO2);
226
+ break;
227
+ default:
228
+ nasm_error(ERR_NONFATAL,
229
+ "{%s} is not an expected decorator",
230
+ tokval.t_charptr);
231
+ break;
232
+ }
233
+ break;
234
+ case ',':
235
+ case TOKEN_EOS:
236
+ return false;
237
+ default:
238
+ nasm_error(ERR_NONFATAL,
239
+ "only a series of valid decorators expected");
240
+ return true;
241
+ }
242
+ i = stdscan(NULL, &tokval);
243
+ }
244
+ }
245
+
246
+ static int parse_mref(operand *op, const expr *e)
247
+ {
248
+ int b, i, s; /* basereg, indexreg, scale */
249
+ int64_t o; /* offset */
250
+
251
+ b = i = -1;
252
+ o = s = 0;
253
+ op->segment = op->wrt = NO_SEG;
254
+
255
+ if (e->type && e->type <= EXPR_REG_END) { /* this bit's a register */
256
+ bool is_gpr = is_class(REG_GPR,nasm_reg_flags[e->type]);
257
+
258
+ if (is_gpr && e->value == 1)
259
+ b = e->type; /* It can be basereg */
260
+ else /* No, it has to be indexreg */
261
+ i = e->type, s = e->value;
262
+ e++;
263
+ }
264
+ if (e->type && e->type <= EXPR_REG_END) { /* it's a 2nd register */
265
+ bool is_gpr = is_class(REG_GPR,nasm_reg_flags[e->type]);
266
+
267
+ if (b != -1) /* If the first was the base, ... */
268
+ i = e->type, s = e->value; /* second has to be indexreg */
269
+
270
+ else if (!is_gpr || e->value != 1) {
271
+ /* If both want to be index */
272
+ nasm_error(ERR_NONFATAL,
273
+ "invalid effective address: two index registers");
274
+ return -1;
275
+ } else
276
+ b = e->type;
277
+ e++;
278
+ }
279
+
280
+ if (e->type) { /* is there an offset? */
281
+ if (e->type <= EXPR_REG_END) { /* in fact, is there an error? */
282
+ nasm_error(ERR_NONFATAL,
283
+ "invalid effective address: impossible register");
284
+ return -1;
285
+ } else {
286
+ if (e->type == EXPR_UNKNOWN) {
287
+ op->opflags |= OPFLAG_UNKNOWN;
288
+ o = 0; /* doesn't matter what */
289
+ while (e->type)
290
+ e++; /* go to the end of the line */
291
+ } else {
292
+ if (e->type == EXPR_SIMPLE) {
293
+ o = e->value;
294
+ e++;
295
+ }
296
+ if (e->type == EXPR_WRT) {
297
+ op->wrt = e->value;
298
+ e++;
299
+ }
300
+ /*
301
+ * Look for a segment base type.
302
+ */
303
+ for (; e->type; e++) {
304
+ if (!e->value)
305
+ continue;
306
+
307
+ if (e->type <= EXPR_REG_END) {
308
+ nasm_error(ERR_NONFATAL,
309
+ "invalid effective address: too many registers");
310
+ return -1;
311
+ } else if (e->type < EXPR_SEGBASE) {
312
+ nasm_error(ERR_NONFATAL,
313
+ "invalid effective address: bad subexpression type");
314
+ return -1;
315
+ } else if (e->value == 1) {
316
+ if (op->segment != NO_SEG) {
317
+ nasm_error(ERR_NONFATAL,
318
+ "invalid effective address: multiple base segments");
319
+ return -1;
320
+ }
321
+ op->segment = e->type - EXPR_SEGBASE;
322
+ } else if (e->value == -1 &&
323
+ e->type == location.segment + EXPR_SEGBASE &&
324
+ !(op->opflags & OPFLAG_RELATIVE)) {
325
+ op->opflags |= OPFLAG_RELATIVE;
326
+ } else {
327
+ nasm_error(ERR_NONFATAL,
328
+ "invalid effective address: impossible segment base multiplier");
329
+ return -1;
330
+ }
331
+ }
332
+ }
333
+ }
334
+ }
335
+
336
+ nasm_assert(!e->type); /* We should be at the end */
337
+
338
+ op->basereg = b;
339
+ op->indexreg = i;
340
+ op->scale = s;
341
+ op->offset = o;
342
+ return 0;
343
+ }
344
+
345
+ static void mref_set_optype(operand *op)
346
+ {
347
+ int b = op->basereg;
348
+ int i = op->indexreg;
349
+ int s = op->scale;
350
+
351
+ /* It is memory, but it can match any r/m operand */
352
+ op->type |= MEMORY_ANY;
353
+
354
+ if (b == -1 && (i == -1 || s == 0)) {
355
+ int is_rel = globalbits == 64 &&
356
+ !(op->eaflags & EAF_ABS) &&
357
+ ((globalrel &&
358
+ !(op->eaflags & EAF_FSGS)) ||
359
+ (op->eaflags & EAF_REL));
360
+
361
+ op->type |= is_rel ? IP_REL : MEM_OFFS;
362
+ }
363
+
364
+ if (i != -1) {
365
+ opflags_t iclass = nasm_reg_flags[i];
366
+
367
+ if (is_class(XMMREG,iclass))
368
+ op->type |= XMEM;
369
+ else if (is_class(YMMREG,iclass))
370
+ op->type |= YMEM;
371
+ else if (is_class(ZMMREG,iclass))
372
+ op->type |= ZMEM;
373
+ }
374
+ }
375
+
376
+ /*
377
+ * Convert an expression vector returned from evaluate() into an
378
+ * extop structure. Return zero on success.
379
+ */
380
+ static int value_to_extop(expr * vect, extop *eop, int32_t myseg)
381
+ {
382
+ eop->type = EOT_DB_NUMBER;
383
+ eop->offset = 0;
384
+ eop->segment = eop->wrt = NO_SEG;
385
+ eop->relative = false;
386
+
387
+ for (; vect->type; vect++) {
388
+ if (!vect->value) /* zero term, safe to ignore */
389
+ continue;
390
+
391
+ if (vect->type <= EXPR_REG_END) /* false if a register is present */
392
+ return -1;
393
+
394
+ if (vect->type == EXPR_UNKNOWN) /* something we can't resolve yet */
395
+ return 0;
396
+
397
+ if (vect->type == EXPR_SIMPLE) {
398
+ /* Simple number expression */
399
+ eop->offset += vect->value;
400
+ continue;
401
+ }
402
+ if (eop->wrt == NO_SEG && !eop->relative && vect->type == EXPR_WRT) {
403
+ /* WRT term */
404
+ eop->wrt = vect->value;
405
+ continue;
406
+ }
407
+
408
+ if (!eop->relative &&
409
+ vect->type == EXPR_SEGBASE + myseg && vect->value == -1) {
410
+ /* Expression of the form: foo - $ */
411
+ eop->relative = true;
412
+ continue;
413
+ }
414
+
415
+ if (eop->segment == NO_SEG && vect->type >= EXPR_SEGBASE &&
416
+ vect->value == 1) {
417
+ eop->segment = vect->type - EXPR_SEGBASE;
418
+ continue;
419
+ }
420
+
421
+ /* Otherwise, badness */
422
+ return -1;
423
+ }
424
+
425
+ /* We got to the end and it was all okay */
426
+ return 0;
427
+ }
428
+
429
+ insn *parse_line(int pass, char *buffer, insn *result, ldfunc ldef)
430
+ {
431
+ bool insn_is_label = false;
432
+ struct eval_hints hints;
433
+ int opnum;
434
+ int critical;
435
+ bool first;
436
+ bool recover;
437
+ int i;
438
+
439
+ restart_parse:
440
+ first = true;
441
+ result->forw_ref = false;
442
+
443
+ stdscan_reset();
444
+ stdscan_set(buffer);
445
+ i = stdscan(NULL, &tokval);
446
+
447
+ nasm_static_assert(P_none == 0);
448
+ memset(result->prefixes, P_none, sizeof(result->prefixes));
449
+ result->times = 1; /* No TIMES either yet */
450
+ result->label = NULL; /* Assume no label */
451
+ result->eops = NULL; /* must do this, whatever happens */
452
+ result->operands = 0; /* must initialize this */
453
+ result->evex_rm = 0; /* Ensure EVEX rounding mode is reset */
454
+ result->evex_brerop = -1; /* Reset EVEX broadcasting/ER op position */
455
+
456
+ /* Ignore blank lines */
457
+ if (i == TOKEN_EOS)
458
+ goto fail;
459
+
460
+ if (i != TOKEN_ID &&
461
+ i != TOKEN_INSN &&
462
+ i != TOKEN_PREFIX &&
463
+ (i != TOKEN_REG || !IS_SREG(tokval.t_integer))) {
464
+ nasm_error(ERR_NONFATAL,
465
+ "label or instruction expected at start of line");
466
+ goto fail;
467
+ }
468
+
469
+ if (i == TOKEN_ID || (insn_is_label && i == TOKEN_INSN)) {
470
+ /* there's a label here */
471
+ first = false;
472
+ result->label = tokval.t_charptr;
473
+ i = stdscan(NULL, &tokval);
474
+ if (i == ':') { /* skip over the optional colon */
475
+ i = stdscan(NULL, &tokval);
476
+ } else if (i == 0) {
477
+ nasm_error(ERR_WARNING | ERR_WARN_OL | ERR_PASS1,
478
+ "label alone on a line without a colon might be in error");
479
+ }
480
+ if (i != TOKEN_INSN || tokval.t_integer != I_EQU) {
481
+ /*
482
+ * FIXME: location.segment could be NO_SEG, in which case
483
+ * it is possible we should be passing 'absolute.segment'. Look into this.
484
+ * Work out whether that is *really* what we should be doing.
485
+ * Generally fix things. I think this is right as it is, but
486
+ * am still not certain.
487
+ */
488
+ ldef(result->label, in_absolute ? absolute.segment : location.segment,
489
+ location.offset, NULL, true, false);
490
+ }
491
+ }
492
+
493
+ /* Just a label here */
494
+ if (i == TOKEN_EOS)
495
+ goto fail;
496
+
497
+ while (i == TOKEN_PREFIX ||
498
+ (i == TOKEN_REG && IS_SREG(tokval.t_integer))) {
499
+ first = false;
500
+
501
+ /*
502
+ * Handle special case: the TIMES prefix.
503
+ */
504
+ if (i == TOKEN_PREFIX && tokval.t_integer == P_TIMES) {
505
+ expr *value;
506
+
507
+ i = stdscan(NULL, &tokval);
508
+ value = evaluate(stdscan, NULL, &tokval, NULL, pass0, NULL);
509
+ i = tokval.t_type;
510
+ if (!value) /* Error in evaluator */
511
+ goto fail;
512
+ if (!is_simple(value)) {
513
+ nasm_error(ERR_NONFATAL,
514
+ "non-constant argument supplied to TIMES");
515
+ result->times = 1L;
516
+ } else {
517
+ result->times = value->value;
518
+ if (value->value < 0) {
519
+ nasm_error(ERR_NONFATAL|ERR_PASS2, "TIMES value %"PRId64" is negative", value->value);
520
+ result->times = 0;
521
+ }
522
+ }
523
+ } else {
524
+ int slot = prefix_slot(tokval.t_integer);
525
+ if (result->prefixes[slot]) {
526
+ if (result->prefixes[slot] == tokval.t_integer)
527
+ nasm_error(ERR_WARNING | ERR_PASS1,
528
+ "instruction has redundant prefixes");
529
+ else
530
+ nasm_error(ERR_NONFATAL,
531
+ "instruction has conflicting prefixes");
532
+ }
533
+ result->prefixes[slot] = tokval.t_integer;
534
+ i = stdscan(NULL, &tokval);
535
+ }
536
+ }
537
+
538
+ if (i != TOKEN_INSN) {
539
+ int j;
540
+ enum prefixes pfx;
541
+
542
+ for (j = 0; j < MAXPREFIX; j++) {
543
+ if ((pfx = result->prefixes[j]) != P_none)
544
+ break;
545
+ }
546
+
547
+ if (i == 0 && pfx != P_none) {
548
+ /*
549
+ * Instruction prefixes are present, but no actual
550
+ * instruction. This is allowed: at this point we
551
+ * invent a notional instruction of RESB 0.
552
+ */
553
+ result->opcode = I_RESB;
554
+ result->operands = 1;
555
+ nasm_zero(result->oprs);
556
+ result->oprs[0].type = IMMEDIATE;
557
+ result->oprs[0].offset = 0L;
558
+ result->oprs[0].segment = result->oprs[0].wrt = NO_SEG;
559
+ return result;
560
+ } else {
561
+ nasm_error(ERR_NONFATAL, "parser: instruction expected");
562
+ goto fail;
563
+ }
564
+ }
565
+
566
+ result->opcode = tokval.t_integer;
567
+ result->condition = tokval.t_inttwo;
568
+
569
+ /*
570
+ * INCBIN cannot be satisfied with incorrectly
571
+ * evaluated operands, since the correct values _must_ be known
572
+ * on the first pass. Hence, even in pass one, we set the
573
+ * `critical' flag on calling evaluate(), so that it will bomb
574
+ * out on undefined symbols.
575
+ */
576
+ if (result->opcode == I_INCBIN) {
577
+ critical = (pass0 < 2 ? 1 : 2);
578
+
579
+ } else
580
+ critical = (pass == 2 ? 2 : 0);
581
+
582
+ if (opcode_is_db(result->opcode) || result->opcode == I_INCBIN) {
583
+ extop *eop, **tail = &result->eops, **fixptr;
584
+ int oper_num = 0;
585
+ int32_t sign;
586
+
587
+ result->eops_float = false;
588
+
589
+ /*
590
+ * Begin to read the DB/DW/DD/DQ/DT/DO/DY/DZ/INCBIN operands.
591
+ */
592
+ while (1) {
593
+ i = stdscan(NULL, &tokval);
594
+ if (i == TOKEN_EOS)
595
+ break;
596
+ else if (first && i == ':') {
597
+ insn_is_label = true;
598
+ goto restart_parse;
599
+ }
600
+ first = false;
601
+ fixptr = tail;
602
+ eop = *tail = nasm_malloc(sizeof(extop));
603
+ tail = &eop->next;
604
+ eop->next = NULL;
605
+ eop->type = EOT_NOTHING;
606
+ oper_num++;
607
+ sign = +1;
608
+
609
+ /*
610
+ * is_comma_next() here is to distinguish this from
611
+ * a string used as part of an expression...
612
+ */
613
+ if (i == TOKEN_STR && is_comma_next()) {
614
+ eop->type = EOT_DB_STRING;
615
+ eop->stringval = tokval.t_charptr;
616
+ eop->stringlen = tokval.t_inttwo;
617
+ i = stdscan(NULL, &tokval); /* eat the comma */
618
+ } else if (i == TOKEN_STRFUNC) {
619
+ bool parens = false;
620
+ const char *funcname = tokval.t_charptr;
621
+ enum strfunc func = tokval.t_integer;
622
+ i = stdscan(NULL, &tokval);
623
+ if (i == '(') {
624
+ parens = true;
625
+ i = stdscan(NULL, &tokval);
626
+ }
627
+ if (i != TOKEN_STR) {
628
+ nasm_error(ERR_NONFATAL,
629
+ "%s must be followed by a string constant",
630
+ funcname);
631
+ eop->type = EOT_NOTHING;
632
+ } else {
633
+ eop->type = EOT_DB_STRING_FREE;
634
+ eop->stringlen =
635
+ string_transform(tokval.t_charptr, tokval.t_inttwo,
636
+ &eop->stringval, func);
637
+ if (eop->stringlen == (size_t)-1) {
638
+ nasm_error(ERR_NONFATAL, "invalid string for transform");
639
+ eop->type = EOT_NOTHING;
640
+ }
641
+ }
642
+ if (parens && i && i != ')') {
643
+ i = stdscan(NULL, &tokval);
644
+ if (i != ')') {
645
+ nasm_error(ERR_NONFATAL, "unterminated %s function",
646
+ funcname);
647
+ }
648
+ }
649
+ if (i && i != ',')
650
+ i = stdscan(NULL, &tokval);
651
+ } else if (i == '-' || i == '+') {
652
+ char *save = stdscan_get();
653
+ int token = i;
654
+ sign = (i == '-') ? -1 : 1;
655
+ i = stdscan(NULL, &tokval);
656
+ if (i != TOKEN_FLOAT) {
657
+ stdscan_set(save);
658
+ i = tokval.t_type = token;
659
+ goto is_expression;
660
+ } else {
661
+ goto is_float;
662
+ }
663
+ } else if (i == TOKEN_FLOAT) {
664
+ is_float:
665
+ eop->type = EOT_DB_STRING;
666
+ result->eops_float = true;
667
+
668
+ eop->stringlen = idata_bytes(result->opcode);
669
+ if (eop->stringlen > 16) {
670
+ nasm_error(ERR_NONFATAL, "floating-point constant"
671
+ " encountered in DY or DZ instruction");
672
+ eop->stringlen = 0;
673
+ } else if (eop->stringlen < 1) {
674
+ nasm_error(ERR_NONFATAL, "floating-point constant"
675
+ " encountered in unknown instruction");
676
+ /*
677
+ * fix suggested by Pedro Gimeno... original line was:
678
+ * eop->type = EOT_NOTHING;
679
+ */
680
+ eop->stringlen = 0;
681
+ }
682
+
683
+ eop = nasm_realloc(eop, sizeof(extop) + eop->stringlen);
684
+ tail = &eop->next;
685
+ *fixptr = eop;
686
+ eop->stringval = (char *)eop + sizeof(extop);
687
+ if (!eop->stringlen ||
688
+ !float_const(tokval.t_charptr, sign,
689
+ (uint8_t *)eop->stringval, eop->stringlen))
690
+ eop->type = EOT_NOTHING;
691
+ i = stdscan(NULL, &tokval); /* eat the comma */
692
+ } else {
693
+ /* anything else, assume it is an expression */
694
+ expr *value;
695
+
696
+ is_expression:
697
+ value = evaluate(stdscan, NULL, &tokval, NULL,
698
+ critical, NULL);
699
+ i = tokval.t_type;
700
+ if (!value) /* Error in evaluator */
701
+ goto fail;
702
+ if (value_to_extop(value, eop, location.segment)) {
703
+ nasm_error(ERR_NONFATAL,
704
+ "operand %d: expression is not simple or relocatable",
705
+ oper_num);
706
+ }
707
+ }
708
+
709
+ /*
710
+ * We're about to call stdscan(), which will eat the
711
+ * comma that we're currently sitting on between
712
+ * arguments. However, we'd better check first that it
713
+ * _is_ a comma.
714
+ */
715
+ if (i == TOKEN_EOS) /* also could be EOL */
716
+ break;
717
+ if (i != ',') {
718
+ nasm_error(ERR_NONFATAL, "comma expected after operand %d",
719
+ oper_num);
720
+ goto fail;
721
+ }
722
+ }
723
+
724
+ if (result->opcode == I_INCBIN) {
725
+ /*
726
+ * Correct syntax for INCBIN is that there should be
727
+ * one string operand, followed by one or two numeric
728
+ * operands.
729
+ */
730
+ if (!result->eops || result->eops->type != EOT_DB_STRING)
731
+ nasm_error(ERR_NONFATAL, "`incbin' expects a file name");
732
+ else if (result->eops->next &&
733
+ result->eops->next->type != EOT_DB_NUMBER)
734
+ nasm_error(ERR_NONFATAL, "`incbin': second parameter is"
735
+ " non-numeric");
736
+ else if (result->eops->next && result->eops->next->next &&
737
+ result->eops->next->next->type != EOT_DB_NUMBER)
738
+ nasm_error(ERR_NONFATAL, "`incbin': third parameter is"
739
+ " non-numeric");
740
+ else if (result->eops->next && result->eops->next->next &&
741
+ result->eops->next->next->next)
742
+ nasm_error(ERR_NONFATAL,
743
+ "`incbin': more than three parameters");
744
+ else
745
+ return result;
746
+ /*
747
+ * If we reach here, one of the above errors happened.
748
+ * Throw the instruction away.
749
+ */
750
+ goto fail;
751
+ } else /* DB ... */ if (oper_num == 0)
752
+ nasm_error(ERR_WARNING | ERR_PASS1,
753
+ "no operand for data declaration");
754
+ else
755
+ result->operands = oper_num;
756
+
757
+ return result;
758
+ }
759
+
760
+ /*
761
+ * Now we begin to parse the operands. There may be up to four
762
+ * of these, separated by commas, and terminated by a zero token.
763
+ */
764
+
765
+ for (opnum = 0; opnum < MAX_OPERANDS; opnum++) {
766
+ operand *op = &result->oprs[opnum];
767
+ expr *value; /* used most of the time */
768
+ bool mref; /* is this going to be a memory ref? */
769
+ bool bracket; /* is it a [] mref, or a & mref? */
770
+ bool mib; /* compound (mib) mref? */
771
+ int setsize = 0;
772
+ decoflags_t brace_flags = 0; /* flags for decorators in braces */
773
+
774
+ op->disp_size = 0; /* have to zero this whatever */
775
+ op->eaflags = 0; /* and this */
776
+ op->opflags = 0;
777
+ op->decoflags = 0;
778
+
779
+ i = stdscan(NULL, &tokval);
780
+ if (i == TOKEN_EOS)
781
+ break; /* end of operands: get out of here */
782
+ else if (first && i == ':') {
783
+ insn_is_label = true;
784
+ goto restart_parse;
785
+ }
786
+ first = false;
787
+ op->type = 0; /* so far, no override */
788
+ while (i == TOKEN_SPECIAL) { /* size specifiers */
789
+ switch (tokval.t_integer) {
790
+ case S_BYTE:
791
+ if (!setsize) /* we want to use only the first */
792
+ op->type |= BITS8;
793
+ setsize = 1;
794
+ break;
795
+ case S_WORD:
796
+ if (!setsize)
797
+ op->type |= BITS16;
798
+ setsize = 1;
799
+ break;
800
+ case S_DWORD:
801
+ case S_LONG:
802
+ if (!setsize)
803
+ op->type |= BITS32;
804
+ setsize = 1;
805
+ break;
806
+ case S_QWORD:
807
+ if (!setsize)
808
+ op->type |= BITS64;
809
+ setsize = 1;
810
+ break;
811
+ case S_TWORD:
812
+ if (!setsize)
813
+ op->type |= BITS80;
814
+ setsize = 1;
815
+ break;
816
+ case S_OWORD:
817
+ if (!setsize)
818
+ op->type |= BITS128;
819
+ setsize = 1;
820
+ break;
821
+ case S_YWORD:
822
+ if (!setsize)
823
+ op->type |= BITS256;
824
+ setsize = 1;
825
+ break;
826
+ case S_ZWORD:
827
+ if (!setsize)
828
+ op->type |= BITS512;
829
+ setsize = 1;
830
+ break;
831
+ case S_TO:
832
+ op->type |= TO;
833
+ break;
834
+ case S_STRICT:
835
+ op->type |= STRICT;
836
+ break;
837
+ case S_FAR:
838
+ op->type |= FAR;
839
+ break;
840
+ case S_NEAR:
841
+ op->type |= NEAR;
842
+ break;
843
+ case S_SHORT:
844
+ op->type |= SHORT;
845
+ break;
846
+ default:
847
+ nasm_error(ERR_NONFATAL, "invalid operand size specification");
848
+ }
849
+ i = stdscan(NULL, &tokval);
850
+ }
851
+
852
+ if (i == '[' || i == '&') { /* memory reference */
853
+ mref = true;
854
+ bracket = (i == '[');
855
+ i = stdscan(NULL, &tokval); /* then skip the colon */
856
+ while (i == TOKEN_SPECIAL || i == TOKEN_PREFIX) {
857
+ process_size_override(result, op);
858
+ i = stdscan(NULL, &tokval);
859
+ }
860
+ /* when a comma follows an opening bracket - [ , eax*4] */
861
+ if (i == ',') {
862
+ /* treat as if there is a zero displacement virtually */
863
+ tokval.t_type = TOKEN_NUM;
864
+ tokval.t_integer = 0;
865
+ stdscan_set(stdscan_get() - 1); /* rewind the comma */
866
+ }
867
+ } else { /* immediate operand, or register */
868
+ mref = false;
869
+ bracket = false; /* placate optimisers */
870
+ }
871
+
872
+ if ((op->type & FAR) && !mref &&
873
+ result->opcode != I_JMP && result->opcode != I_CALL) {
874
+ nasm_error(ERR_NONFATAL, "invalid use of FAR operand specifier");
875
+ }
876
+
877
+ value = evaluate(stdscan, NULL, &tokval,
878
+ &op->opflags, critical, &hints);
879
+ i = tokval.t_type;
880
+ if (op->opflags & OPFLAG_FORWARD) {
881
+ result->forw_ref = true;
882
+ }
883
+ if (!value) /* Error in evaluator */
884
+ goto fail;
885
+ if (i == ':' && mref) { /* it was seg:offset */
886
+ /*
887
+ * Process the segment override.
888
+ */
889
+ if (value[1].type != 0 ||
890
+ value->value != 1 ||
891
+ !IS_SREG(value->type))
892
+ nasm_error(ERR_NONFATAL, "invalid segment override");
893
+ else if (result->prefixes[PPS_SEG])
894
+ nasm_error(ERR_NONFATAL,
895
+ "instruction has conflicting segment overrides");
896
+ else {
897
+ result->prefixes[PPS_SEG] = value->type;
898
+ if (IS_FSGS(value->type))
899
+ op->eaflags |= EAF_FSGS;
900
+ }
901
+
902
+ i = stdscan(NULL, &tokval); /* then skip the colon */
903
+ while (i == TOKEN_SPECIAL || i == TOKEN_PREFIX) {
904
+ process_size_override(result, op);
905
+ i = stdscan(NULL, &tokval);
906
+ }
907
+ value = evaluate(stdscan, NULL, &tokval,
908
+ &op->opflags, critical, &hints);
909
+ i = tokval.t_type;
910
+ if (op->opflags & OPFLAG_FORWARD) {
911
+ result->forw_ref = true;
912
+ }
913
+ /* and get the offset */
914
+ if (!value) /* Error in evaluator */
915
+ goto fail;
916
+ }
917
+
918
+ mib = false;
919
+ if (mref && bracket && i == ',') {
920
+ /* [seg:base+offset,index*scale] syntax (mib) */
921
+
922
+ operand o1, o2; /* Partial operands */
923
+
924
+ if (parse_mref(&o1, value))
925
+ goto fail;
926
+
927
+ i = stdscan(NULL, &tokval); /* Eat comma */
928
+ value = evaluate(stdscan, NULL, &tokval, &op->opflags,
929
+ critical, &hints);
930
+ i = tokval.t_type;
931
+ if (!value)
932
+ goto fail;
933
+
934
+ if (parse_mref(&o2, value))
935
+ goto fail;
936
+
937
+ if (o2.basereg != -1 && o2.indexreg == -1) {
938
+ o2.indexreg = o2.basereg;
939
+ o2.scale = 1;
940
+ o2.basereg = -1;
941
+ }
942
+
943
+ if (o1.indexreg != -1 || o2.basereg != -1 || o2.offset != 0 ||
944
+ o2.segment != NO_SEG || o2.wrt != NO_SEG) {
945
+ nasm_error(ERR_NONFATAL, "invalid mib expression");
946
+ goto fail;
947
+ }
948
+
949
+ op->basereg = o1.basereg;
950
+ op->indexreg = o2.indexreg;
951
+ op->scale = o2.scale;
952
+ op->offset = o1.offset;
953
+ op->segment = o1.segment;
954
+ op->wrt = o1.wrt;
955
+
956
+ if (op->basereg != -1) {
957
+ op->hintbase = op->basereg;
958
+ op->hinttype = EAH_MAKEBASE;
959
+ } else if (op->indexreg != -1) {
960
+ op->hintbase = op->indexreg;
961
+ op->hinttype = EAH_NOTBASE;
962
+ } else {
963
+ op->hintbase = -1;
964
+ op->hinttype = EAH_NOHINT;
965
+ }
966
+
967
+ mib = true;
968
+ }
969
+
970
+ recover = false;
971
+ if (mref && bracket) { /* find ] at the end */
972
+ if (i != ']') {
973
+ nasm_error(ERR_NONFATAL, "parser: expecting ]");
974
+ recover = true;
975
+ } else { /* we got the required ] */
976
+ i = stdscan(NULL, &tokval);
977
+ if (i == TOKEN_DECORATOR || i == TOKEN_OPMASK) {
978
+ /* parse opmask (and zeroing) after an operand */
979
+ recover = parse_braces(&brace_flags);
980
+ i = tokval.t_type;
981
+ }
982
+ if (i != 0 && i != ',') {
983
+ nasm_error(ERR_NONFATAL, "comma or end of line expected");
984
+ recover = true;
985
+ }
986
+ }
987
+ } else { /* immediate operand */
988
+ if (i != 0 && i != ',' && i != ':' &&
989
+ i != TOKEN_DECORATOR && i != TOKEN_OPMASK) {
990
+ nasm_error(ERR_NONFATAL, "comma, colon, decorator or end of "
991
+ "line expected after operand");
992
+ recover = true;
993
+ } else if (i == ':') {
994
+ op->type |= COLON;
995
+ } else if (i == TOKEN_DECORATOR || i == TOKEN_OPMASK) {
996
+ /* parse opmask (and zeroing) after an operand */
997
+ recover = parse_braces(&brace_flags);
998
+ }
999
+ }
1000
+ if (recover) {
1001
+ do { /* error recovery */
1002
+ i = stdscan(NULL, &tokval);
1003
+ } while (i != 0 && i != ',');
1004
+ }
1005
+
1006
+ /*
1007
+ * now convert the exprs returned from evaluate()
1008
+ * into operand descriptions...
1009
+ */
1010
+ op->decoflags |= brace_flags;
1011
+
1012
+ if (mref) { /* it's a memory reference */
1013
+ /* A mib reference was fully parsed already */
1014
+ if (!mib) {
1015
+ if (parse_mref(op, value))
1016
+ goto fail;
1017
+ op->hintbase = hints.base;
1018
+ op->hinttype = hints.type;
1019
+ }
1020
+ mref_set_optype(op);
1021
+ } else { /* it's not a memory reference */
1022
+ if (is_just_unknown(value)) { /* it's immediate but unknown */
1023
+ op->type |= IMMEDIATE;
1024
+ op->opflags |= OPFLAG_UNKNOWN;
1025
+ op->offset = 0; /* don't care */
1026
+ op->segment = NO_SEG; /* don't care again */
1027
+ op->wrt = NO_SEG; /* still don't care */
1028
+
1029
+ if(optimizing >= 0 && !(op->type & STRICT)) {
1030
+ /* Be optimistic */
1031
+ op->type |=
1032
+ UNITY | SBYTEWORD | SBYTEDWORD | UDWORD | SDWORD;
1033
+ }
1034
+ } else if (is_reloc(value)) { /* it's immediate */
1035
+ uint64_t n = reloc_value(value);
1036
+
1037
+ op->type |= IMMEDIATE;
1038
+ op->offset = n;
1039
+ op->segment = reloc_seg(value);
1040
+ op->wrt = reloc_wrt(value);
1041
+ op->opflags |= is_self_relative(value) ? OPFLAG_RELATIVE : 0;
1042
+
1043
+ if (is_simple(value)) {
1044
+ if (n == 1)
1045
+ op->type |= UNITY;
1046
+ if (optimizing >= 0 && !(op->type & STRICT)) {
1047
+ if ((uint32_t) (n + 128) <= 255)
1048
+ op->type |= SBYTEDWORD;
1049
+ if ((uint16_t) (n + 128) <= 255)
1050
+ op->type |= SBYTEWORD;
1051
+ if (n <= UINT64_C(0xFFFFFFFF))
1052
+ op->type |= UDWORD;
1053
+ if (n + UINT64_C(0x80000000) <= UINT64_C(0xFFFFFFFF))
1054
+ op->type |= SDWORD;
1055
+ }
1056
+ }
1057
+ } else if (value->type == EXPR_RDSAE) {
1058
+ /*
1059
+ * it's not an operand but a rounding or SAE decorator.
1060
+ * put the decorator information in the (opflag_t) type field
1061
+ * of previous operand.
1062
+ */
1063
+ opnum--; op--;
1064
+ switch (value->value) {
1065
+ case BRC_RN:
1066
+ case BRC_RU:
1067
+ case BRC_RD:
1068
+ case BRC_RZ:
1069
+ case BRC_SAE:
1070
+ op->decoflags |= (value->value == BRC_SAE ? SAE : ER);
1071
+ result->evex_rm = value->value;
1072
+ break;
1073
+ default:
1074
+ nasm_error(ERR_NONFATAL, "invalid decorator");
1075
+ break;
1076
+ }
1077
+ } else { /* it's a register */
1078
+ opflags_t rs;
1079
+
1080
+ if (value->type >= EXPR_SIMPLE || value->value != 1) {
1081
+ nasm_error(ERR_NONFATAL, "invalid operand type");
1082
+ goto fail;
1083
+ }
1084
+
1085
+ /*
1086
+ * check that its only 1 register, not an expression...
1087
+ */
1088
+ for (i = 1; value[i].type; i++)
1089
+ if (value[i].value) {
1090
+ nasm_error(ERR_NONFATAL, "invalid operand type");
1091
+ goto fail;
1092
+ }
1093
+
1094
+ /* clear overrides, except TO which applies to FPU regs */
1095
+ if (op->type & ~TO) {
1096
+ /*
1097
+ * we want to produce a warning iff the specified size
1098
+ * is different from the register size
1099
+ */
1100
+ rs = op->type & SIZE_MASK;
1101
+ } else
1102
+ rs = 0;
1103
+
1104
+ op->type &= TO;
1105
+ op->type |= REGISTER;
1106
+ op->type |= nasm_reg_flags[value->type];
1107
+ op->decoflags |= brace_flags;
1108
+ op->basereg = value->type;
1109
+
1110
+ if (rs && (op->type & SIZE_MASK) != rs)
1111
+ nasm_error(ERR_WARNING | ERR_PASS1,
1112
+ "register size specification ignored");
1113
+ }
1114
+ }
1115
+
1116
+ /* remember the position of operand having broadcasting/ER mode */
1117
+ if (op->decoflags & (BRDCAST_MASK | ER | SAE))
1118
+ result->evex_brerop = opnum;
1119
+ }
1120
+
1121
+ result->operands = opnum; /* set operand count */
1122
+
1123
+ /* clear remaining operands */
1124
+ while (opnum < MAX_OPERANDS)
1125
+ result->oprs[opnum++].type = 0;
1126
+
1127
+ /*
1128
+ * Transform RESW, RESD, RESQ, REST, RESO, RESY, RESZ into RESB.
1129
+ */
1130
+ if (opcode_is_resb(result->opcode)) {
1131
+ result->oprs[0].offset *= resv_bytes(result->opcode);
1132
+ result->oprs[0].offset *= result->times;
1133
+ result->times = 1;
1134
+ result->opcode = I_RESB;
1135
+ }
1136
+
1137
+ return result;
1138
+
1139
+ fail:
1140
+ result->opcode = I_none;
1141
+ return result;
1142
+ }
1143
+
1144
+ static int is_comma_next(void)
1145
+ {
1146
+ struct tokenval tv;
1147
+ char *p;
1148
+ int i;
1149
+
1150
+ p = stdscan_get();
1151
+ i = stdscan(NULL, &tv);
1152
+ stdscan_set(p);
1153
+
1154
+ return (i == ',' || i == ';' || !i);
1155
+ }
1156
+
1157
+ void cleanup_insn(insn * i)
1158
+ {
1159
+ extop *e;
1160
+
1161
+ while ((e = i->eops)) {
1162
+ i->eops = e->next;
1163
+ if (e->type == EOT_DB_STRING_FREE)
1164
+ nasm_free(e->stringval);
1165
+ nasm_free(e);
1166
+ }
1167
+ }