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,49 @@
1
+ /* ----------------------------------------------------------------------- *
2
+ *
3
+ * Copyright 1996-2009 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
+ * eval.h header file for eval.c
36
+ */
37
+
38
+ #ifndef NASM_EVAL_H
39
+ #define NASM_EVAL_H
40
+
41
+ /*
42
+ * The evaluator itself.
43
+ */
44
+ expr *evaluate(scanner sc, void *scprivate, struct tokenval *tv,
45
+ int *fwref, int critical, struct eval_hints *hints);
46
+
47
+ void eval_cleanup(void);
48
+
49
+ #endif
@@ -0,0 +1,79 @@
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
+ * exprdump.c
36
+ *
37
+ * Debugging code to dump the contents of an expression vector to stdout
38
+ */
39
+
40
+ #include "nasm.h"
41
+
42
+ static const char *expr_type(int32_t type)
43
+ {
44
+ static char seg_str[64];
45
+
46
+ switch (type) {
47
+ case 0:
48
+ return "null";
49
+ case EXPR_UNKNOWN:
50
+ return "unknown";
51
+ case EXPR_SIMPLE:
52
+ return "simple";
53
+ case EXPR_WRT:
54
+ return "wrt";
55
+ case EXPR_RDSAE:
56
+ return "sae";
57
+ default:
58
+ break;
59
+ }
60
+
61
+ if (type >= EXPR_REG_START && type <= EXPR_REG_END) {
62
+ return nasm_reg_names[type - EXPR_REG_START];
63
+ } else if (type >= EXPR_SEGBASE) {
64
+ snprintf(seg_str, sizeof seg_str, "%sseg %d",
65
+ (type - EXPR_SEGBASE) == location.segment ? "this " : "",
66
+ type - EXPR_SEGBASE);
67
+ return seg_str;
68
+ } else {
69
+ return "ERR";
70
+ }
71
+ }
72
+
73
+ void dump_expr(const expr *e)
74
+ {
75
+ printf("[");
76
+ for (; e->type; e++)
77
+ printf("<%s(%d),%"PRId64">", expr_type(e->type), e->type, e->value);
78
+ printf("]\n");
79
+ }
@@ -0,0 +1,200 @@
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
+ * exprlib.c
36
+ *
37
+ * Library routines to manipulate expression data types.
38
+ */
39
+
40
+ #include "nasm.h"
41
+
42
+ /*
43
+ * Return true if the argument is a simple scalar. (Or a far-
44
+ * absolute, which counts.)
45
+ */
46
+ bool is_simple(const expr *vect)
47
+ {
48
+ while (vect->type && !vect->value)
49
+ vect++;
50
+ if (!vect->type)
51
+ return true;
52
+ if (vect->type != EXPR_SIMPLE)
53
+ return false;
54
+ do {
55
+ vect++;
56
+ } while (vect->type && !vect->value);
57
+ if (vect->type && vect->type < EXPR_SEGBASE + SEG_ABS)
58
+ return false;
59
+ return true;
60
+ }
61
+
62
+ /*
63
+ * Return true if the argument is a simple scalar, _NOT_ a far-
64
+ * absolute.
65
+ */
66
+ bool is_really_simple(const expr *vect)
67
+ {
68
+ while (vect->type && !vect->value)
69
+ vect++;
70
+ if (!vect->type)
71
+ return true;
72
+ if (vect->type != EXPR_SIMPLE)
73
+ return false;
74
+ do {
75
+ vect++;
76
+ } while (vect->type && !vect->value);
77
+ if (vect->type)
78
+ return false;
79
+ return true;
80
+ }
81
+
82
+ /*
83
+ * Return true if the argument is relocatable (i.e. a simple
84
+ * scalar, plus at most one segment-base, possibly a subtraction
85
+ * of the current segment base, plus possibly a WRT).
86
+ */
87
+ bool is_reloc(const expr *vect)
88
+ {
89
+ bool has_rel = false; /* Has a self-segment-subtract */
90
+ bool has_seg = false; /* Has a segment base */
91
+
92
+ for (; vect->type; vect++) {
93
+ if (!vect->value) {
94
+ /* skip value-0 terms */
95
+ continue;
96
+ } else if (vect->type < EXPR_SIMPLE) {
97
+ /* false if a register is present */
98
+ return false;
99
+ } else if (vect->type == EXPR_SIMPLE) {
100
+ /* skip over a pure number term... */
101
+ continue;
102
+ } else if (vect->type == EXPR_WRT) {
103
+ /* skip over a WRT term... */
104
+ continue;
105
+ } else if (vect->type < EXPR_SEGBASE) {
106
+ /* other special type -> problem */
107
+ return false;
108
+ } else if (vect->value == 1) {
109
+ if (has_seg)
110
+ return false; /* only one segbase allowed */
111
+ has_seg = true;
112
+ } else if (vect->value == -1) {
113
+ if (vect->type != location.segment + EXPR_SEGBASE)
114
+ return false; /* can only subtract current segment */
115
+ if (has_rel)
116
+ return false; /* already is relative */
117
+ has_rel = true;
118
+ }
119
+ }
120
+
121
+ return true;
122
+ }
123
+
124
+ /*
125
+ * Return true if the argument contains an `unknown' part.
126
+ */
127
+ bool is_unknown(const expr *vect)
128
+ {
129
+ while (vect->type && vect->type < EXPR_UNKNOWN)
130
+ vect++;
131
+ return (vect->type == EXPR_UNKNOWN);
132
+ }
133
+
134
+ /*
135
+ * Return true if the argument contains nothing but an `unknown'
136
+ * part.
137
+ */
138
+ bool is_just_unknown(const expr *vect)
139
+ {
140
+ while (vect->type && !vect->value)
141
+ vect++;
142
+ return (vect->type == EXPR_UNKNOWN);
143
+ }
144
+
145
+ /*
146
+ * Return the scalar part of a relocatable vector. (Including
147
+ * simple scalar vectors - those qualify as relocatable.)
148
+ */
149
+ int64_t reloc_value(const expr *vect)
150
+ {
151
+ while (vect->type && !vect->value)
152
+ vect++;
153
+ if (!vect->type)
154
+ return 0;
155
+ if (vect->type == EXPR_SIMPLE)
156
+ return vect->value;
157
+ else
158
+ return 0;
159
+ }
160
+
161
+ /*
162
+ * Return the segment number of a relocatable vector, or NO_SEG for
163
+ * simple scalars.
164
+ */
165
+ int32_t reloc_seg(const expr *vect)
166
+ {
167
+ for (; vect->type; vect++) {
168
+ if (vect->type >= EXPR_SEGBASE && vect->value == 1)
169
+ return vect->type - EXPR_SEGBASE;
170
+ }
171
+
172
+ return NO_SEG;
173
+ }
174
+
175
+ /*
176
+ * Return the WRT segment number of a relocatable vector, or NO_SEG
177
+ * if no WRT part is present.
178
+ */
179
+ int32_t reloc_wrt(const expr *vect)
180
+ {
181
+ while (vect->type && vect->type < EXPR_WRT)
182
+ vect++;
183
+ if (vect->type == EXPR_WRT) {
184
+ return vect->value;
185
+ } else
186
+ return NO_SEG;
187
+ }
188
+
189
+ /*
190
+ * Return true if this expression contains a subtraction of the location
191
+ */
192
+ bool is_self_relative(const expr *vect)
193
+ {
194
+ for (; vect->type; vect++) {
195
+ if (vect->type == location.segment + EXPR_SEGBASE && vect->value == -1)
196
+ return true;
197
+ }
198
+
199
+ return false;
200
+ }
@@ -0,0 +1,952 @@
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
+ * float.c floating-point constant support for the Netwide Assembler
36
+ */
37
+
38
+ #include "compiler.h"
39
+
40
+ #include <ctype.h>
41
+ #include <stdio.h>
42
+ #include <stdlib.h>
43
+ #include <string.h>
44
+
45
+ #include "nasm.h"
46
+ #include "float.h"
47
+ #include "error.h"
48
+
49
+ /*
50
+ * -----------------
51
+ * local variables
52
+ * -----------------
53
+ */
54
+ static bool daz = false; /* denormals as zero */
55
+ static enum float_round rc = FLOAT_RC_NEAR; /* rounding control */
56
+
57
+ /*
58
+ * -----------
59
+ * constants
60
+ * -----------
61
+ */
62
+
63
+ /* "A limb is like a digit but bigger */
64
+ typedef uint32_t fp_limb;
65
+ typedef uint64_t fp_2limb;
66
+
67
+ #define LIMB_BITS 32
68
+ #define LIMB_BYTES (LIMB_BITS/8)
69
+ #define LIMB_TOP_BIT ((fp_limb)1 << (LIMB_BITS-1))
70
+ #define LIMB_MASK ((fp_limb)(~0))
71
+ #define LIMB_ALL_BYTES ((fp_limb)0x01010101)
72
+ #define LIMB_BYTE(x) ((x)*LIMB_ALL_BYTES)
73
+
74
+ /* 112 bits + 64 bits for accuracy + 16 bits for rounding */
75
+ #define MANT_LIMBS 6
76
+
77
+ /* 52 digits fit in 176 bits because 10^53 > 2^176 > 10^52 */
78
+ #define MANT_DIGITS 52
79
+
80
+ /* the format and the argument list depend on MANT_LIMBS */
81
+ #define MANT_FMT "%08x_%08x_%08x_%08x_%08x_%08x"
82
+ #define MANT_ARG SOME_ARG(mant, 0)
83
+
84
+ #define SOME_ARG(a,i) (a)[(i)+0], (a)[(i)+1], (a)[(i)+2], \
85
+ (a)[(i)+3], (a)[(i)+4], (a)[(i)+5]
86
+
87
+ /*
88
+ * ---------------------------------------------------------------------------
89
+ * emit a printf()-like debug message... but only if DEBUG_FLOAT was defined
90
+ * ---------------------------------------------------------------------------
91
+ */
92
+
93
+ #ifdef DEBUG_FLOAT
94
+ #define dprintf(x) printf x
95
+ #else
96
+ #define dprintf(x) do { } while (0)
97
+ #endif
98
+
99
+ /*
100
+ * ---------------------------------------------------------------------------
101
+ * multiply
102
+ * ---------------------------------------------------------------------------
103
+ */
104
+ static int float_multiply(fp_limb *to, fp_limb *from)
105
+ {
106
+ fp_2limb temp[MANT_LIMBS * 2];
107
+ int i, j;
108
+
109
+ /*
110
+ * guaranteed that top bit of 'from' is set -- so we only have
111
+ * to worry about _one_ bit shift to the left
112
+ */
113
+ dprintf(("%s=" MANT_FMT "\n", "mul1", SOME_ARG(to, 0)));
114
+ dprintf(("%s=" MANT_FMT "\n", "mul2", SOME_ARG(from, 0)));
115
+
116
+ memset(temp, 0, sizeof temp);
117
+
118
+ for (i = 0; i < MANT_LIMBS; i++) {
119
+ for (j = 0; j < MANT_LIMBS; j++) {
120
+ fp_2limb n;
121
+ n = (fp_2limb) to[i] * (fp_2limb) from[j];
122
+ temp[i + j] += n >> LIMB_BITS;
123
+ temp[i + j + 1] += (fp_limb)n;
124
+ }
125
+ }
126
+
127
+ for (i = MANT_LIMBS * 2; --i;) {
128
+ temp[i - 1] += temp[i] >> LIMB_BITS;
129
+ temp[i] &= LIMB_MASK;
130
+ }
131
+
132
+ dprintf(("%s=" MANT_FMT "_" MANT_FMT "\n", "temp", SOME_ARG(temp, 0),
133
+ SOME_ARG(temp, MANT_LIMBS)));
134
+
135
+ if (temp[0] & LIMB_TOP_BIT) {
136
+ for (i = 0; i < MANT_LIMBS; i++) {
137
+ to[i] = temp[i] & LIMB_MASK;
138
+ }
139
+ dprintf(("%s=" MANT_FMT " (%i)\n", "prod", SOME_ARG(to, 0), 0));
140
+ return 0;
141
+ } else {
142
+ for (i = 0; i < MANT_LIMBS; i++) {
143
+ to[i] = (temp[i] << 1) + !!(temp[i + 1] & LIMB_TOP_BIT);
144
+ }
145
+ dprintf(("%s=" MANT_FMT " (%i)\n", "prod", SOME_ARG(to, 0), -1));
146
+ return -1;
147
+ }
148
+ }
149
+
150
+ /*
151
+ * ---------------------------------------------------------------------------
152
+ * read an exponent; returns INT32_MAX on error
153
+ * ---------------------------------------------------------------------------
154
+ */
155
+ static int32_t read_exponent(const char *string, int32_t max)
156
+ {
157
+ int32_t i = 0;
158
+ bool neg = false;
159
+
160
+ if (*string == '+') {
161
+ string++;
162
+ } else if (*string == '-') {
163
+ neg = true;
164
+ string++;
165
+ }
166
+ while (*string) {
167
+ if (*string >= '0' && *string <= '9') {
168
+ i = (i * 10) + (*string - '0');
169
+
170
+ /*
171
+ * To ensure that underflows and overflows are
172
+ * handled properly we must avoid wraparounds of
173
+ * the signed integer value that is used to hold
174
+ * the exponent. Therefore we cap the exponent at
175
+ * +/-5000, which is slightly more/less than
176
+ * what's required for normal and denormal numbers
177
+ * in single, double, and extended precision, but
178
+ * sufficient to avoid signed integer wraparound.
179
+ */
180
+ if (i > max)
181
+ i = max;
182
+ } else if (*string == '_') {
183
+ /* do nothing */
184
+ } else {
185
+ nasm_error(ERR_NONFATAL|ERR_PASS1,
186
+ "invalid character in floating-point constant %s: '%c'",
187
+ "exponent", *string);
188
+ return INT32_MAX;
189
+ }
190
+ string++;
191
+ }
192
+
193
+ return neg ? -i : i;
194
+ }
195
+
196
+ /*
197
+ * ---------------------------------------------------------------------------
198
+ * convert
199
+ * ---------------------------------------------------------------------------
200
+ */
201
+ static bool ieee_flconvert(const char *string, fp_limb *mant,
202
+ int32_t * exponent)
203
+ {
204
+ char digits[MANT_DIGITS];
205
+ char *p, *q, *r;
206
+ fp_limb mult[MANT_LIMBS], bit;
207
+ fp_limb *m;
208
+ int32_t tenpwr, twopwr;
209
+ int32_t extratwos;
210
+ bool started, seendot, warned;
211
+
212
+ warned = false;
213
+ p = digits;
214
+ tenpwr = 0;
215
+ started = seendot = false;
216
+
217
+ while (*string && *string != 'E' && *string != 'e') {
218
+ if (*string == '.') {
219
+ if (!seendot) {
220
+ seendot = true;
221
+ } else {
222
+ nasm_error(ERR_NONFATAL|ERR_PASS1,
223
+ "too many periods in floating-point constant");
224
+ return false;
225
+ }
226
+ } else if (*string >= '0' && *string <= '9') {
227
+ if (*string == '0' && !started) {
228
+ if (seendot) {
229
+ tenpwr--;
230
+ }
231
+ } else {
232
+ started = true;
233
+ if (p < digits + sizeof(digits)) {
234
+ *p++ = *string - '0';
235
+ } else {
236
+ if (!warned) {
237
+ nasm_error(ERR_WARNING|ERR_WARN_FL_TOOLONG|ERR_PASS1,
238
+ "floating-point constant significand contains "
239
+ "more than %i digits", MANT_DIGITS);
240
+ warned = true;
241
+ }
242
+ }
243
+ if (!seendot) {
244
+ tenpwr++;
245
+ }
246
+ }
247
+ } else if (*string == '_') {
248
+ /* do nothing */
249
+ } else {
250
+ nasm_error(ERR_NONFATAL|ERR_PASS1,
251
+ "invalid character in floating-point constant %s: '%c'",
252
+ "significand", *string);
253
+ return false;
254
+ }
255
+ string++;
256
+ }
257
+
258
+ if (*string) {
259
+ int32_t e;
260
+
261
+ string++; /* eat the E */
262
+ e = read_exponent(string, 5000);
263
+ if (e == INT32_MAX)
264
+ return false;
265
+ tenpwr += e;
266
+ }
267
+
268
+ /*
269
+ * At this point, the memory interval [digits,p) contains a
270
+ * series of decimal digits zzzzzzz, such that our number X
271
+ * satisfies X = 0.zzzzzzz * 10^tenpwr.
272
+ */
273
+ q = digits;
274
+ dprintf(("X = 0."));
275
+ while (q < p) {
276
+ dprintf(("%c", *q + '0'));
277
+ q++;
278
+ }
279
+ dprintf((" * 10^%i\n", tenpwr));
280
+
281
+ /*
282
+ * Now convert [digits,p) to our internal representation.
283
+ */
284
+ bit = LIMB_TOP_BIT;
285
+ for (m = mant; m < mant + MANT_LIMBS; m++) {
286
+ *m = 0;
287
+ }
288
+ m = mant;
289
+ q = digits;
290
+ started = false;
291
+ twopwr = 0;
292
+ while (m < mant + MANT_LIMBS) {
293
+ fp_limb carry = 0;
294
+ while (p > q && !p[-1]) {
295
+ p--;
296
+ }
297
+ if (p <= q) {
298
+ break;
299
+ }
300
+ for (r = p; r-- > q;) {
301
+ int32_t i;
302
+ i = 2 * *r + carry;
303
+ if (i >= 10) {
304
+ carry = 1;
305
+ i -= 10;
306
+ } else {
307
+ carry = 0;
308
+ }
309
+ *r = i;
310
+ }
311
+ if (carry) {
312
+ *m |= bit;
313
+ started = true;
314
+ }
315
+ if (started) {
316
+ if (bit == 1) {
317
+ bit = LIMB_TOP_BIT;
318
+ m++;
319
+ } else {
320
+ bit >>= 1;
321
+ }
322
+ } else {
323
+ twopwr--;
324
+ }
325
+ }
326
+ twopwr += tenpwr;
327
+
328
+ /*
329
+ * At this point, the 'mant' array contains the first frac-
330
+ * tional places of a base-2^16 real number which when mul-
331
+ * tiplied by 2^twopwr and 5^tenpwr gives X.
332
+ */
333
+ dprintf(("X = " MANT_FMT " * 2^%i * 5^%i\n", MANT_ARG, twopwr,
334
+ tenpwr));
335
+
336
+ /*
337
+ * Now multiply 'mant' by 5^tenpwr.
338
+ */
339
+ if (tenpwr < 0) { /* mult = 5^-1 = 0.2 */
340
+ for (m = mult; m < mult + MANT_LIMBS - 1; m++) {
341
+ *m = LIMB_BYTE(0xcc);
342
+ }
343
+ mult[MANT_LIMBS - 1] = LIMB_BYTE(0xcc)+1;
344
+ extratwos = -2;
345
+ tenpwr = -tenpwr;
346
+
347
+ /*
348
+ * If tenpwr was 1000...000b, then it becomes 1000...000b. See
349
+ * the "ANSI C" comment below for more details on that case.
350
+ *
351
+ * Because we already truncated tenpwr to +5000...-5000 inside
352
+ * the exponent parsing code, this shouldn't happen though.
353
+ */
354
+ } else if (tenpwr > 0) { /* mult = 5^+1 = 5.0 */
355
+ mult[0] = (fp_limb)5 << (LIMB_BITS-3); /* 0xA000... */
356
+ for (m = mult + 1; m < mult + MANT_LIMBS; m++) {
357
+ *m = 0;
358
+ }
359
+ extratwos = 3;
360
+ } else {
361
+ extratwos = 0;
362
+ }
363
+ while (tenpwr) {
364
+ dprintf(("loop=" MANT_FMT " * 2^%i * 5^%i (%i)\n", MANT_ARG,
365
+ twopwr, tenpwr, extratwos));
366
+ if (tenpwr & 1) {
367
+ dprintf(("mant*mult\n"));
368
+ twopwr += extratwos + float_multiply(mant, mult);
369
+ }
370
+ dprintf(("mult*mult\n"));
371
+ extratwos = extratwos * 2 + float_multiply(mult, mult);
372
+ tenpwr >>= 1;
373
+
374
+ /*
375
+ * In ANSI C, the result of right-shifting a signed integer is
376
+ * considered implementation-specific. To ensure that the loop
377
+ * terminates even if tenpwr was 1000...000b to begin with, we
378
+ * manually clear the MSB, in case a 1 was shifted in.
379
+ *
380
+ * Because we already truncated tenpwr to +5000...-5000 inside
381
+ * the exponent parsing code, this shouldn't matter; neverthe-
382
+ * less it is the right thing to do here.
383
+ */
384
+ tenpwr &= (uint32_t) - 1 >> 1;
385
+ }
386
+
387
+ /*
388
+ * At this point, the 'mant' array contains the first frac-
389
+ * tional places of a base-2^16 real number in [0.5,1) that
390
+ * when multiplied by 2^twopwr gives X. Or it contains zero
391
+ * of course. We are done.
392
+ */
393
+ *exponent = twopwr;
394
+ return true;
395
+ }
396
+
397
+ /*
398
+ * ---------------------------------------------------------------------------
399
+ * operations of specific bits
400
+ * ---------------------------------------------------------------------------
401
+ */
402
+
403
+ /* Set a bit, using *bigendian* bit numbering (0 = MSB) */
404
+ static void set_bit(fp_limb *mant, int bit)
405
+ {
406
+ mant[bit/LIMB_BITS] |= LIMB_TOP_BIT >> (bit & (LIMB_BITS-1));
407
+ }
408
+
409
+ /* Test a single bit */
410
+ static int test_bit(const fp_limb *mant, int bit)
411
+ {
412
+ return (mant[bit/LIMB_BITS] >> (~bit & (LIMB_BITS-1))) & 1;
413
+ }
414
+
415
+ /* Report if the mantissa value is all zero */
416
+ static bool is_zero(const fp_limb *mant)
417
+ {
418
+ int i;
419
+
420
+ for (i = 0; i < MANT_LIMBS; i++)
421
+ if (mant[i])
422
+ return false;
423
+
424
+ return true;
425
+ }
426
+
427
+ /*
428
+ * ---------------------------------------------------------------------------
429
+ * round a mantissa off after i words
430
+ * ---------------------------------------------------------------------------
431
+ */
432
+
433
+ #define ROUND_COLLECT_BITS \
434
+ do { \
435
+ m = mant[i] & (2*bit-1); \
436
+ for (j = i+1; j < MANT_LIMBS; j++) \
437
+ m = m | mant[j]; \
438
+ } while (0)
439
+
440
+ #define ROUND_ABS_DOWN \
441
+ do { \
442
+ mant[i] &= ~(bit-1); \
443
+ for (j = i+1; j < MANT_LIMBS; j++) \
444
+ mant[j] = 0; \
445
+ return false; \
446
+ } while (0)
447
+
448
+ #define ROUND_ABS_UP \
449
+ do { \
450
+ mant[i] = (mant[i] & ~(bit-1)) + bit; \
451
+ for (j = i+1; j < MANT_LIMBS; j++) \
452
+ mant[j] = 0; \
453
+ while (i > 0 && !mant[i]) \
454
+ ++mant[--i]; \
455
+ return !mant[0]; \
456
+ } while (0)
457
+
458
+ static bool ieee_round(bool minus, fp_limb *mant, int bits)
459
+ {
460
+ fp_limb m = 0;
461
+ int32_t j;
462
+ int i = bits / LIMB_BITS;
463
+ int p = bits % LIMB_BITS;
464
+ fp_limb bit = LIMB_TOP_BIT >> p;
465
+
466
+ if (rc == FLOAT_RC_NEAR) {
467
+ if (mant[i] & bit) {
468
+ mant[i] &= ~bit;
469
+ ROUND_COLLECT_BITS;
470
+ mant[i] |= bit;
471
+ if (m) {
472
+ ROUND_ABS_UP;
473
+ } else {
474
+ if (test_bit(mant, bits-1)) {
475
+ ROUND_ABS_UP;
476
+ } else {
477
+ ROUND_ABS_DOWN;
478
+ }
479
+ }
480
+ } else {
481
+ ROUND_ABS_DOWN;
482
+ }
483
+ } else if (rc == FLOAT_RC_ZERO ||
484
+ rc == (minus ? FLOAT_RC_UP : FLOAT_RC_DOWN)) {
485
+ ROUND_ABS_DOWN;
486
+ } else {
487
+ /* rc == (minus ? FLOAT_RC_DOWN : FLOAT_RC_UP) */
488
+ /* Round toward +/- infinity */
489
+ ROUND_COLLECT_BITS;
490
+ if (m) {
491
+ ROUND_ABS_UP;
492
+ } else {
493
+ ROUND_ABS_DOWN;
494
+ }
495
+ }
496
+ return false;
497
+ }
498
+
499
+ /* Returns a value >= 16 if not a valid hex digit */
500
+ static unsigned int hexval(char c)
501
+ {
502
+ unsigned int v = (unsigned char) c;
503
+
504
+ if (v >= '0' && v <= '9')
505
+ return v - '0';
506
+ else
507
+ return (v|0x20) - 'a' + 10;
508
+ }
509
+
510
+ /* Handle floating-point numbers with radix 2^bits and binary exponent */
511
+ static bool ieee_flconvert_bin(const char *string, int bits,
512
+ fp_limb *mant, int32_t *exponent)
513
+ {
514
+ static const int log2tbl[16] =
515
+ { -1, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3 };
516
+ fp_limb mult[MANT_LIMBS + 1], *mp;
517
+ int ms;
518
+ int32_t twopwr;
519
+ bool seendot, seendigit;
520
+ unsigned char c;
521
+ const int radix = 1 << bits;
522
+ fp_limb v;
523
+
524
+ twopwr = 0;
525
+ seendot = seendigit = false;
526
+ ms = 0;
527
+ mp = NULL;
528
+
529
+ memset(mult, 0, sizeof mult);
530
+
531
+ while ((c = *string++) != '\0') {
532
+ if (c == '.') {
533
+ if (!seendot)
534
+ seendot = true;
535
+ else {
536
+ nasm_error(ERR_NONFATAL|ERR_PASS1,
537
+ "too many periods in floating-point constant");
538
+ return false;
539
+ }
540
+ } else if ((v = hexval(c)) < (unsigned int)radix) {
541
+ if (!seendigit && v) {
542
+ int l = log2tbl[v];
543
+
544
+ seendigit = true;
545
+ mp = mult;
546
+ ms = (LIMB_BITS-1)-l;
547
+
548
+ twopwr += l+1-bits;
549
+ }
550
+
551
+ if (seendigit) {
552
+ if (ms <= 0) {
553
+ *mp |= v >> -ms;
554
+ mp++;
555
+ if (mp > &mult[MANT_LIMBS])
556
+ mp = &mult[MANT_LIMBS]; /* Guard slot */
557
+ ms += LIMB_BITS;
558
+ }
559
+ *mp |= v << ms;
560
+ ms -= bits;
561
+
562
+ if (!seendot)
563
+ twopwr += bits;
564
+ } else {
565
+ if (seendot)
566
+ twopwr -= bits;
567
+ }
568
+ } else if (c == 'p' || c == 'P') {
569
+ int32_t e;
570
+ e = read_exponent(string, 20000);
571
+ if (e == INT32_MAX)
572
+ return false;
573
+ twopwr += e;
574
+ break;
575
+ } else if (c == '_') {
576
+ /* ignore */
577
+ } else {
578
+ nasm_error(ERR_NONFATAL|ERR_PASS1,
579
+ "floating-point constant: `%c' is invalid character", c);
580
+ return false;
581
+ }
582
+ }
583
+
584
+ if (!seendigit) {
585
+ memset(mant, 0, MANT_LIMBS*sizeof(fp_limb)); /* Zero */
586
+ *exponent = 0;
587
+ } else {
588
+ memcpy(mant, mult, MANT_LIMBS*sizeof(fp_limb));
589
+ *exponent = twopwr;
590
+ }
591
+
592
+ return true;
593
+ }
594
+
595
+ /*
596
+ * Shift a mantissa to the right by i bits.
597
+ */
598
+ static void ieee_shr(fp_limb *mant, int i)
599
+ {
600
+ fp_limb n, m;
601
+ int j = 0;
602
+ int sr, sl, offs;
603
+
604
+ sr = i % LIMB_BITS; sl = LIMB_BITS-sr;
605
+ offs = i/LIMB_BITS;
606
+
607
+ if (sr == 0) {
608
+ if (offs)
609
+ for (j = MANT_LIMBS-1; j >= offs; j--)
610
+ mant[j] = mant[j-offs];
611
+ } else {
612
+ n = mant[MANT_LIMBS-1-offs] >> sr;
613
+ for (j = MANT_LIMBS-1; j > offs; j--) {
614
+ m = mant[j-offs-1];
615
+ mant[j] = (m << sl) | n;
616
+ n = m >> sr;
617
+ }
618
+ mant[j--] = n;
619
+ }
620
+ while (j >= 0)
621
+ mant[j--] = 0;
622
+ }
623
+
624
+ /* Produce standard IEEE formats, with implicit or explicit integer
625
+ bit; this makes the following assumptions:
626
+
627
+ - the sign bit is the MSB, followed by the exponent,
628
+ followed by the integer bit if present.
629
+ - the sign bit plus exponent fit in 16 bits.
630
+ - the exponent bias is 2^(n-1)-1 for an n-bit exponent */
631
+
632
+ struct ieee_format {
633
+ int bytes;
634
+ int mantissa; /* Fractional bits in the mantissa */
635
+ int explicit; /* Explicit integer */
636
+ int exponent; /* Bits in the exponent */
637
+ };
638
+
639
+ /*
640
+ * The 16- and 128-bit formats are expected to be in IEEE 754r.
641
+ * AMD SSE5 uses the 16-bit format.
642
+ *
643
+ * The 32- and 64-bit formats are the original IEEE 754 formats.
644
+ *
645
+ * The 80-bit format is x87-specific, but widely used.
646
+ *
647
+ * The 8-bit format appears to be the consensus 8-bit floating-point
648
+ * format. It is apparently used in graphics applications.
649
+ */
650
+ static const struct ieee_format ieee_8 = { 1, 3, 0, 4 };
651
+ static const struct ieee_format ieee_16 = { 2, 10, 0, 5 };
652
+ static const struct ieee_format ieee_32 = { 4, 23, 0, 8 };
653
+ static const struct ieee_format ieee_64 = { 8, 52, 0, 11 };
654
+ static const struct ieee_format ieee_80 = { 10, 63, 1, 15 };
655
+ static const struct ieee_format ieee_128 = { 16, 112, 0, 15 };
656
+
657
+ /* Types of values we can generate */
658
+ enum floats {
659
+ FL_ZERO,
660
+ FL_DENORMAL,
661
+ FL_NORMAL,
662
+ FL_INFINITY,
663
+ FL_QNAN,
664
+ FL_SNAN
665
+ };
666
+
667
+ static int to_packed_bcd(const char *str, const char *p,
668
+ int s, uint8_t *result,
669
+ const struct ieee_format *fmt)
670
+ {
671
+ int n = 0;
672
+ char c;
673
+ int tv = -1;
674
+
675
+ if (fmt != &ieee_80) {
676
+ nasm_error(ERR_NONFATAL|ERR_PASS1,
677
+ "packed BCD requires an 80-bit format");
678
+ return 0;
679
+ }
680
+
681
+ while (p >= str) {
682
+ c = *p--;
683
+ if (c >= '0' && c <= '9') {
684
+ if (tv < 0) {
685
+ if (n == 9) {
686
+ nasm_error(ERR_WARNING|ERR_PASS1,
687
+ "packed BCD truncated to 18 digits");
688
+ }
689
+ tv = c-'0';
690
+ } else {
691
+ if (n < 9)
692
+ *result++ = tv + ((c-'0') << 4);
693
+ n++;
694
+ tv = -1;
695
+ }
696
+ } else if (c == '_') {
697
+ /* do nothing */
698
+ } else {
699
+ nasm_error(ERR_NONFATAL|ERR_PASS1,
700
+ "invalid character `%c' in packed BCD constant", c);
701
+ return 0;
702
+ }
703
+ }
704
+ if (tv >= 0) {
705
+ if (n < 9)
706
+ *result++ = tv;
707
+ n++;
708
+ }
709
+ while (n < 9) {
710
+ *result++ = 0;
711
+ n++;
712
+ }
713
+ *result = (s < 0) ? 0x80 : 0;
714
+
715
+ return 1; /* success */
716
+ }
717
+
718
+ static int to_float(const char *str, int s, uint8_t *result,
719
+ const struct ieee_format *fmt)
720
+ {
721
+ fp_limb mant[MANT_LIMBS];
722
+ int32_t exponent = 0;
723
+ const int32_t expmax = 1 << (fmt->exponent - 1);
724
+ fp_limb one_mask = LIMB_TOP_BIT >>
725
+ ((fmt->exponent+fmt->explicit) % LIMB_BITS);
726
+ const int one_pos = (fmt->exponent+fmt->explicit)/LIMB_BITS;
727
+ int i;
728
+ int shift;
729
+ enum floats type;
730
+ bool ok;
731
+ const bool minus = s < 0;
732
+ const int bits = fmt->bytes * 8;
733
+ const char *strend;
734
+
735
+ if (!str[0]) {
736
+ nasm_panic(0,
737
+ "internal errror: empty string passed to float_const");
738
+ return 0;
739
+ }
740
+
741
+ strend = strchr(str, '\0');
742
+ if (strend[-1] == 'P' || strend[-1] == 'p')
743
+ return to_packed_bcd(str, strend-2, s, result, fmt);
744
+
745
+ if (str[0] == '_') {
746
+ /* Special tokens */
747
+
748
+ switch (str[2]) {
749
+ case 'n': /* __nan__ */
750
+ case 'N':
751
+ case 'q': /* __qnan__ */
752
+ case 'Q':
753
+ type = FL_QNAN;
754
+ break;
755
+ case 's': /* __snan__ */
756
+ case 'S':
757
+ type = FL_SNAN;
758
+ break;
759
+ case 'i': /* __infinity__ */
760
+ case 'I':
761
+ type = FL_INFINITY;
762
+ break;
763
+ default:
764
+ nasm_error(ERR_NONFATAL|ERR_PASS1,
765
+ "internal error: unknown FP constant token `%s'\n", str);
766
+ type = FL_QNAN;
767
+ break;
768
+ }
769
+ } else {
770
+ if (str[0] == '0') {
771
+ switch (str[1]) {
772
+ case 'x': case 'X':
773
+ case 'h': case 'H':
774
+ ok = ieee_flconvert_bin(str+2, 4, mant, &exponent);
775
+ break;
776
+ case 'o': case 'O':
777
+ case 'q': case 'Q':
778
+ ok = ieee_flconvert_bin(str+2, 3, mant, &exponent);
779
+ break;
780
+ case 'b': case 'B':
781
+ case 'y': case 'Y':
782
+ ok = ieee_flconvert_bin(str+2, 1, mant, &exponent);
783
+ break;
784
+ case 'd': case 'D':
785
+ case 't': case 'T':
786
+ ok = ieee_flconvert(str+2, mant, &exponent);
787
+ break;
788
+ case 'p': case 'P':
789
+ return to_packed_bcd(str+2, strend-1, s, result, fmt);
790
+ default:
791
+ /* Leading zero was just a zero? */
792
+ ok = ieee_flconvert(str, mant, &exponent);
793
+ break;
794
+ }
795
+ } else if (str[0] == '$') {
796
+ ok = ieee_flconvert_bin(str+1, 4, mant, &exponent);
797
+ } else {
798
+ ok = ieee_flconvert(str, mant, &exponent);
799
+ }
800
+
801
+ if (!ok) {
802
+ type = FL_QNAN;
803
+ } else if (mant[0] & LIMB_TOP_BIT) {
804
+ /*
805
+ * Non-zero.
806
+ */
807
+ exponent--;
808
+ if (exponent >= 2 - expmax && exponent <= expmax) {
809
+ type = FL_NORMAL;
810
+ } else if (exponent > 0) {
811
+ if (pass0 == 1)
812
+ nasm_error(ERR_WARNING|ERR_WARN_FL_OVERFLOW|ERR_PASS1,
813
+ "overflow in floating-point constant");
814
+ type = FL_INFINITY;
815
+ } else {
816
+ /* underflow or denormal; the denormal code handles
817
+ actual underflow. */
818
+ type = FL_DENORMAL;
819
+ }
820
+ } else {
821
+ /* Zero */
822
+ type = FL_ZERO;
823
+ }
824
+ }
825
+
826
+ switch (type) {
827
+ case FL_ZERO:
828
+ zero:
829
+ memset(mant, 0, sizeof mant);
830
+ break;
831
+
832
+ case FL_DENORMAL:
833
+ {
834
+ shift = -(exponent + expmax - 2 - fmt->exponent)
835
+ + fmt->explicit;
836
+ ieee_shr(mant, shift);
837
+ ieee_round(minus, mant, bits);
838
+ if (mant[one_pos] & one_mask) {
839
+ /* One's position is set, we rounded up into normal range */
840
+ exponent = 1;
841
+ if (!fmt->explicit)
842
+ mant[one_pos] &= ~one_mask; /* remove explicit one */
843
+ mant[0] |= exponent << (LIMB_BITS-1 - fmt->exponent);
844
+ } else {
845
+ if (daz || is_zero(mant)) {
846
+ /* Flush denormals to zero */
847
+ nasm_error(ERR_WARNING|ERR_WARN_FL_UNDERFLOW|ERR_PASS1,
848
+ "underflow in floating-point constant");
849
+ goto zero;
850
+ } else {
851
+ nasm_error(ERR_WARNING|ERR_WARN_FL_DENORM|ERR_PASS1,
852
+ "denormal floating-point constant");
853
+ }
854
+ }
855
+ break;
856
+ }
857
+
858
+ case FL_NORMAL:
859
+ exponent += expmax - 1;
860
+ ieee_shr(mant, fmt->exponent+fmt->explicit);
861
+ ieee_round(minus, mant, bits);
862
+ /* did we scale up by one? */
863
+ if (test_bit(mant, fmt->exponent+fmt->explicit-1)) {
864
+ ieee_shr(mant, 1);
865
+ exponent++;
866
+ if (exponent >= (expmax << 1)-1) {
867
+ nasm_error(ERR_WARNING|ERR_WARN_FL_OVERFLOW|ERR_PASS1,
868
+ "overflow in floating-point constant");
869
+ type = FL_INFINITY;
870
+ goto overflow;
871
+ }
872
+ }
873
+
874
+ if (!fmt->explicit)
875
+ mant[one_pos] &= ~one_mask; /* remove explicit one */
876
+ mant[0] |= exponent << (LIMB_BITS-1 - fmt->exponent);
877
+ break;
878
+
879
+ case FL_INFINITY:
880
+ case FL_QNAN:
881
+ case FL_SNAN:
882
+ overflow:
883
+ memset(mant, 0, sizeof mant);
884
+ mant[0] = (((fp_limb)1 << fmt->exponent)-1)
885
+ << (LIMB_BITS-1 - fmt->exponent);
886
+ if (fmt->explicit)
887
+ mant[one_pos] |= one_mask;
888
+ if (type == FL_QNAN)
889
+ set_bit(mant, fmt->exponent+fmt->explicit+1);
890
+ else if (type == FL_SNAN)
891
+ set_bit(mant, fmt->exponent+fmt->explicit+fmt->mantissa);
892
+ break;
893
+ }
894
+
895
+ mant[0] |= minus ? LIMB_TOP_BIT : 0;
896
+
897
+ for (i = fmt->bytes - 1; i >= 0; i--)
898
+ *result++ = mant[i/LIMB_BYTES] >> (((LIMB_BYTES-1)-(i%LIMB_BYTES))*8);
899
+
900
+ return 1; /* success */
901
+ }
902
+
903
+ int float_const(const char *number, int sign, uint8_t *result, int bytes)
904
+ {
905
+ switch (bytes) {
906
+ case 1:
907
+ return to_float(number, sign, result, &ieee_8);
908
+ case 2:
909
+ return to_float(number, sign, result, &ieee_16);
910
+ case 4:
911
+ return to_float(number, sign, result, &ieee_32);
912
+ case 8:
913
+ return to_float(number, sign, result, &ieee_64);
914
+ case 10:
915
+ return to_float(number, sign, result, &ieee_80);
916
+ case 16:
917
+ return to_float(number, sign, result, &ieee_128);
918
+ default:
919
+ nasm_panic(0, "strange value %d passed to float_const", bytes);
920
+ return 0;
921
+ }
922
+ }
923
+
924
+ /* Set floating-point options */
925
+ int float_option(const char *option)
926
+ {
927
+ if (!nasm_stricmp(option, "daz")) {
928
+ daz = true;
929
+ return 0;
930
+ } else if (!nasm_stricmp(option, "nodaz")) {
931
+ daz = false;
932
+ return 0;
933
+ } else if (!nasm_stricmp(option, "near")) {
934
+ rc = FLOAT_RC_NEAR;
935
+ return 0;
936
+ } else if (!nasm_stricmp(option, "down")) {
937
+ rc = FLOAT_RC_DOWN;
938
+ return 0;
939
+ } else if (!nasm_stricmp(option, "up")) {
940
+ rc = FLOAT_RC_UP;
941
+ return 0;
942
+ } else if (!nasm_stricmp(option, "zero")) {
943
+ rc = FLOAT_RC_ZERO;
944
+ return 0;
945
+ } else if (!nasm_stricmp(option, "default")) {
946
+ rc = FLOAT_RC_NEAR;
947
+ daz = false;
948
+ return 0;
949
+ } else {
950
+ return -1; /* Unknown option */
951
+ }
952
+ }