diff options
Diffstat (limited to 'html/subx/001help.cc.html')
-rw-r--r-- | html/subx/001help.cc.html | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/html/subx/001help.cc.html b/html/subx/001help.cc.html index 665289bb..080b5ae1 100644 --- a/html/subx/001help.cc.html +++ b/html/subx/001help.cc.html @@ -15,6 +15,7 @@ body { font-size:12pt; font-family: monospace; color: #000000; background-color: a { color:inherit; } * { font-size:12pt; font-size: 1em; } .CommentedCode { color: #8a8a8a; } +.PreProc { color: #c000c0; } .LineNr { } .Constant { color: #008787; } .Delimiter { color: #c000c0; } @@ -112,18 +113,18 @@ if ('onhashchange' in window) { <span id="L52" class="LineNr"> 52 </span><span class="Delimiter">:(before "End Globals")</span> <span id="L53" class="LineNr"> 53 </span>map<string<span class="Delimiter">,</span> string> <span class="Special"><a href='001help.cc.html#L53'>Help</a></span><span class="Delimiter">;</span> <span id="L54" class="LineNr"> 54 </span><span class="Delimiter">:(before "End Includes")</span> -<span id="L55" class="LineNr"> 55 </span><span class="Comment">#include <map></span> +<span id="L55" class="LineNr"> 55 </span><span class="PreProc">#include </span><span class="Constant"><map></span> <span id="L56" class="LineNr"> 56 </span><span class="Normal">using</span> std::map<span class="Delimiter">;</span> <span id="L57" class="LineNr"> 57 </span><span class="Delimiter">:(before "End One-time Setup")</span> <span id="L58" class="LineNr"> 58 </span><a href='001help.cc.html#L60'>init_help</a><span class="Delimiter">();</span> <span id="L59" class="LineNr"> 59 </span><span class="Delimiter">:(code)</span> <span id="L60" class="LineNr"> 60 </span><span class="Normal">void</span> <a href='001help.cc.html#L60'>init_help</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L61" class="LineNr"> 61 </span> <a href='001help.cc.html#L252'>put</a><span class="Delimiter">(</span><span class="Special"><a href='001help.cc.html#L53'>Help</a></span><span class="Delimiter">,</span> <span class="Constant">"usage"</span><span class="Delimiter">,</span> -<span id="L62" class="LineNr"> 62 </span> <span class="Constant">"Welcome to SubX, a better way to <a href='011run.cc.html#L95'>program</a> in machine code.\n"</span> +<span id="L62" class="LineNr"> 62 </span> <span class="Constant">"Welcome to SubX, a better way to <a href='011run.cc.html#L102'>program</a> in machine code.\n"</span> <span id="L63" class="LineNr"> 63 </span> <span class="Constant">"SubX uses a subset of the x86 instruction set. SubX programs will run\n"</span> <span id="L64" class="LineNr"> 64 </span> <span class="Constant">"without modification on Linux computers.\n"</span> <span id="L65" class="LineNr"> 65 </span> <span class="Constant">"It provides a better experience and better error messages than\n"</span> -<span id="L66" class="LineNr"> 66 </span> <span class="Constant">"programming directly in machine <a href='031check_operands.cc.html#L11'>code</a>, but you have to stick to the\n"</span> +<span id="L66" class="LineNr"> 66 </span> <span class="Constant">"programming directly in machine code, but you have to stick to the\n"</span> <span id="L67" class="LineNr"> 67 </span> <span class="Constant">"instructions it supports.\n"</span> <span id="L68" class="LineNr"> 68 </span> <span class="Constant">"\n"</span> <span id="L69" class="LineNr"> 69 </span> <span class="Constant">"== Ways to invoke subx\n"</span> @@ -131,24 +132,24 @@ if ('onhashchange' in window) { <span id="L71" class="LineNr"> 71 </span> <span class="Constant">" subx test\n"</span> <span id="L72" class="LineNr"> 72 </span> <span class="Constant">"- See this message:\n"</span> <span id="L73" class="LineNr"> 73 </span> <span class="Constant">" subx --help\n"</span> -<span id="L74" class="LineNr"> 74 </span> <span class="Constant">"- Convert a textual SubX <a href='011run.cc.html#L95'>program</a> into a standard ELF binary that you can\n"</span> -<span id="L75" class="LineNr"> 75 </span> <span class="Constant">" <a href='011run.cc.html#L79'>run</a> on your computer:\n"</span> +<span id="L74" class="LineNr"> 74 </span> <span class="Constant">"- Convert a textual SubX <a href='011run.cc.html#L102'>program</a> into a standard ELF binary that you can\n"</span> +<span id="L75" class="LineNr"> 75 </span> <span class="Constant">" <a href='011run.cc.html#L86'>run</a> on your computer:\n"</span> <span id="L76" class="LineNr"> 76 </span> <span class="Constant">" subx translate input1.subx intput2.subx ... -o <output ELF binary>\n"</span> <span id="L77" class="LineNr"> 77 </span> <span class="Constant">"- Run a SubX binary using SubX itself (for better error messages):\n"</span> -<span id="L78" class="LineNr"> 78 </span> <span class="Constant">" subx <a href='011run.cc.html#L79'>run</a> <ELF binary>\n"</span> +<span id="L78" class="LineNr"> 78 </span> <span class="Constant">" subx <a href='011run.cc.html#L86'>run</a> <ELF binary>\n"</span> <span id="L79" class="LineNr"> 79 </span> <span class="Constant">"\n"</span> <span id="L80" class="LineNr"> 80 </span> <span class="Constant">"== Debugging aids\n"</span> -<span id="L81" class="LineNr"> 81 </span> <span class="Constant">"- Add '--trace' to any of these commands to print a <a href='003trace.cc.html#L98'>trace</a> to stderr\n"</span> +<span id="L81" class="LineNr"> 81 </span> <span class="Constant">"- Add '--trace' to any of these commands to print a <a href='003trace.cc.html#L96'>trace</a> to stderr\n"</span> <span id="L82" class="LineNr"> 82 </span> <span class="Constant">" for debugging purposes.\n"</span> <span id="L83" class="LineNr"> 83 </span> <span class="Constant">"- Add '--map' to add information to traces. 'subx --map translate' will save\n"</span> <span id="L84" class="LineNr"> 84 </span> <span class="Constant">" (to a file called 'map') the mapping from labels to addresses that it computes\n"</span> <span id="L85" class="LineNr"> 85 </span> <span class="Constant">" during translation. This file is then available to 'subx --map --trace run'\n"</span> -<span id="L86" class="LineNr"> 86 </span> <span class="Constant">" which prints out label names in the <a href='003trace.cc.html#L98'>trace</a> as it encounters them.\n"</span> +<span id="L86" class="LineNr"> 86 </span> <span class="Constant">" which prints out label names in the <a href='003trace.cc.html#L96'>trace</a> as it encounters them.\n"</span> <span id="L87" class="LineNr"> 87 </span> <span class="Constant">"\n"</span> <span id="L88" class="LineNr"> 88 </span> <span class="Constant">"Options starting with '--' must always come before any other arguments.\n"</span> <span id="L89" class="LineNr"> 89 </span> <span class="Constant">"\n"</span> <span id="L90" class="LineNr"> 90 </span> <span class="Constant">"To start learning how to write SubX programs, see Readme.md (particularly\n"</span> -<span id="L91" class="LineNr"> 91 </span> <span class="Constant">"the section on the x86 instruction set) and then <a href='011run.cc.html#L79'>run</a>:\n"</span> +<span id="L91" class="LineNr"> 91 </span> <span class="Constant">"the section on the x86 instruction set) and then <a href='011run.cc.html#L86'>run</a>:\n"</span> <span id="L92" class="LineNr"> 92 </span> <span class="Constant">" subx help\n"</span> <span id="L93" class="LineNr"> 93 </span> <span class="Delimiter">);</span> <span id="L94" class="LineNr"> 94 </span> <span class="Comment">// End Help Texts</span> @@ -162,7 +163,7 @@ if ('onhashchange' in window) { <span id="L102" class="LineNr">102 </span><span class="Normal">bool</span> <a href='001help.cc.html#L102'>starts_with</a><span class="Delimiter">(</span><span class="Normal">const</span> string& s<span class="Delimiter">,</span> <span class="Normal">const</span> string& pat<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L103" class="LineNr">103 </span> string::const_iterator a=s<span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> b=pat<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> <span id="L104" class="LineNr">104 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">nada</span><span class="Comment">*/</span><span class="Delimiter">;</span> a!=s<span class="Delimiter">.</span>end<span class="Delimiter">()</span> && b!=pat<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++a<span class="Delimiter">,</span> ++b<span class="Delimiter">)</span> -<span id="L105" class="LineNr">105 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>*a != *b<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Constant"> false</span><span class="Delimiter">;</span> +<span id="L105" class="LineNr">105 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>*a != *b<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span id="L106" class="LineNr">106 </span> <span class="Identifier">return</span> b == pat<span class="Delimiter">.</span>end<span class="Delimiter">();</span> <span id="L107" class="LineNr">107 </span><span class="Delimiter">}</span> <span id="L108" class="LineNr">108 </span> @@ -223,7 +224,7 @@ if ('onhashchange' in window) { <span id="L163" class="LineNr">163 </span><span class="Comment">//: since multiplying two integers seems like a more common situation to end</span> <span id="L164" class="LineNr">164 </span><span class="Comment">//: up in than integer overflow.</span> <span id="L165" class="LineNr">165 </span><span class="Delimiter">:(before "End Includes")</span> -<span id="L166" class="LineNr">166 </span><span class="Comment">#define SIZE(X) (assert((X).size() < (1LL<<(sizeof(int)*8-2))), static_cast<int>((X).size()))</span> +<span id="L166" class="LineNr">166 </span><span class="PreProc">#define SIZE(</span><span class="Special">X</span><span class="PreProc">) (assert((</span><span class="Special">X</span><span class="PreProc">)</span><span class="Delimiter">.</span><span class="PreProc">size() < (</span><span class="Constant">1LL</span><span class="PreProc"><<(</span><span class="Normal">sizeof</span><span class="PreProc">(</span><span class="Normal">int</span><span class="PreProc">)*</span><span class="Constant">8</span><span class="PreProc">-</span><span class="Constant">2</span><span class="PreProc">)))</span><span class="Delimiter">,</span><span class="PreProc"> </span><span class="Normal">static_cast</span><span class="PreProc"><</span><span class="Normal">int</span><span class="PreProc">>((</span><span class="Special">X</span><span class="PreProc">)</span><span class="Delimiter">.</span><span class="PreProc">size()))</span> <span id="L167" class="LineNr">167 </span> <span id="L168" class="LineNr">168 </span><span class="Comment">//: 5. Integer overflow is guarded against at runtime using the -ftrapv flag</span> <span id="L169" class="LineNr">169 </span><span class="Comment">//: to the compiler, supported by Clang (GCC version only works sometimes:</span> @@ -245,23 +246,23 @@ if ('onhashchange' in window) { <span id="L185" class="LineNr">185 </span><span class="Normal">void</span> <a href='001help.cc.html#L185'>dump_and_exit</a><span class="Delimiter">(</span><span class="Normal">int</span> sig<span class="Delimiter">,</span> siginfo_t* <span class="Comment">/*</span><span class="Comment">unused</span><span class="Comment">*/</span><span class="Delimiter">,</span> <span class="Normal">void</span>* <span class="Comment">/*</span><span class="Comment">unused</span><span class="Comment">*/</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L186" class="LineNr">186 </span> <span class="Normal">switch</span> <span class="Delimiter">(</span>sig<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L187" class="LineNr">187 </span> <span class="Normal">case</span> <span class="Constant">SIGABRT</span>: -<span id="L188" class="LineNr">188 </span> <span class="Comment">#ifndef __APPLE__</span> +<span id="L188" class="LineNr">188 </span> <span class="PreProc">#ifndef __APPLE__</span> <span id="L189" class="LineNr">189 </span> cerr << <span class="Constant">"SIGABRT: might be an integer overflow if it wasn't an assert() failure\n"</span><span class="Delimiter">;</span> <span id="L190" class="LineNr">190 </span> _Exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> -<span id="L191" class="LineNr">191 </span> <span class="Comment">#endif</span> +<span id="L191" class="LineNr">191 </span> <span class="PreProc">#endif</span> <span id="L192" class="LineNr">192 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L193" class="LineNr">193 </span> <span class="Normal">case</span> <span class="Constant">SIGILL</span>: -<span id="L194" class="LineNr">194 </span> <span class="Comment">#ifdef __APPLE__</span> +<span id="L194" class="LineNr">194 </span> <span class="PreProc">#ifdef __APPLE__</span> <span id="L195" class="LineNr">195 </span> cerr << <span class="Constant">"SIGILL: most likely caused by integer overflow\n"</span><span class="Delimiter">;</span> <span id="L196" class="LineNr">196 </span> _Exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> -<span id="L197" class="LineNr">197 </span> <span class="Comment">#endif</span> +<span id="L197" class="LineNr">197 </span> <span class="PreProc">#endif</span> <span id="L198" class="LineNr">198 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L199" class="LineNr">199 </span> <span class="Normal">default</span>: <span id="L200" class="LineNr">200 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L201" class="LineNr">201 </span> <span class="Delimiter">}</span> <span id="L202" class="LineNr">202 </span><span class="Delimiter">}</span> <span id="L203" class="LineNr">203 </span><span class="Delimiter">:(before "End Includes")</span> -<span id="L204" class="LineNr">204 </span><span class="Comment">#include <signal.h></span> +<span id="L204" class="LineNr">204 </span><span class="PreProc">#include </span><span class="Constant"><signal.h></span> <span id="L205" class="LineNr">205 </span> <span id="L206" class="LineNr">206 </span><span class="Comment">//: For good measure we'll also enable SIGFPE.</span> <span id="L207" class="LineNr">207 </span><span class="Delimiter">:(before "atexit(reset)")</span> @@ -273,9 +274,9 @@ if ('onhashchange' in window) { <span id="L213" class="LineNr">213 </span><span class="CommentedCode">//? cerr << "ε: " << smallest_subnormal_f << '\n';</span> <span id="L214" class="LineNr">214 </span><span class="CommentedCode">//? cerr << "ε/2: " << smallest_subnormal_f/2 << " (underflow)\n"; // test SIGFPE</span> <span id="L215" class="LineNr">215 </span><span class="Delimiter">:(before "End Includes")</span> -<span id="L216" class="LineNr">216 </span><span class="Comment">#include <fenv.h></span> +<span id="L216" class="LineNr">216 </span><span class="PreProc">#include </span><span class="Constant"><fenv.h></span> <span id="L217" class="LineNr">217 </span><span class="Delimiter">:(code)</span> -<span id="L218" class="LineNr">218 </span><span class="Comment">#ifdef __APPLE__</span> +<span id="L218" class="LineNr">218 </span><span class="PreProc">#ifdef __APPLE__</span> <span id="L219" class="LineNr">219 </span><span class="Comment">// Public domain polyfill for feenableexcept on OS X</span> <span id="L220" class="LineNr">220 </span><span class="Comment">// <a href="http://www-personal.umich.edu/~williams/archive/computation/fe-handling-example.c">http://www-personal.umich.edu/~williams/archive/computation/fe-handling-example.c</a></span> <span id="L221" class="LineNr">221 </span><span class="Normal">int</span> <a href='001help.cc.html#L221'>feenableexcept</a><span class="Delimiter">(</span><span class="Normal">unsigned</span> <span class="Normal">int</span> excepts<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -288,7 +289,7 @@ if ('onhashchange' in window) { <span id="L228" class="LineNr">228 </span> fenv<span class="Delimiter">.</span>__mxcsr &= ~<span class="Delimiter">(</span>new_excepts << <span class="Constant">7</span><span class="Delimiter">);</span> <span id="L229" class="LineNr">229 </span> <span class="Identifier">return</span> fesetenv<span class="Delimiter">(</span>&fenv<span class="Delimiter">)</span> ? -<span class="Constant">1</span> : old_excepts<span class="Delimiter">;</span> <span id="L230" class="LineNr">230 </span><span class="Delimiter">}</span> -<span id="L231" class="LineNr">231 </span><span class="Comment">#endif</span> +<span id="L231" class="LineNr">231 </span><span class="PreProc">#endif</span> <span id="L232" class="LineNr">232 </span> <span id="L233" class="LineNr">233 </span><span class="Comment">//: 6. Map's operator[] being non-const is fucking evil.</span> <span id="L234" class="LineNr">234 </span><span class="Delimiter">:(before "Globals")</span> <span class="Comment">// can't generate prototypes for these</span> @@ -336,22 +337,22 @@ if ('onhashchange' in window) { <span id="L276" class="LineNr">276 </span><span class="Delimiter">}</span> <span id="L277" class="LineNr">277 </span> <span id="L278" class="LineNr">278 </span><span class="Delimiter">:(before "End Includes")</span> -<span id="L279" class="LineNr">279 </span><span class="Comment">#include <assert.h></span> +<span id="L279" class="LineNr">279 </span><span class="PreProc">#include </span><span class="Constant"><assert.h></span> <span id="L280" class="LineNr">280 </span> -<span id="L281" class="LineNr">281 </span><span class="Comment">#include <iostream></span> +<span id="L281" class="LineNr">281 </span><span class="PreProc">#include </span><span class="Constant"><iostream></span> <span id="L282" class="LineNr">282 </span><span class="Normal">using</span> std::istream<span class="Delimiter">;</span> <span id="L283" class="LineNr">283 </span><span class="Normal">using</span> std::ostream<span class="Delimiter">;</span> <span id="L284" class="LineNr">284 </span><span class="Normal">using</span> std::iostream<span class="Delimiter">;</span> <span id="L285" class="LineNr">285 </span><span class="Normal">using</span> std::cin<span class="Delimiter">;</span> <span id="L286" class="LineNr">286 </span><span class="Normal">using</span> std::cout<span class="Delimiter">;</span> <span id="L287" class="LineNr">287 </span><span class="Normal">using</span> std::cerr<span class="Delimiter">;</span> -<span id="L288" class="LineNr">288 </span><span class="Comment">#include <iomanip></span> +<span id="L288" class="LineNr">288 </span><span class="PreProc">#include </span><span class="Constant"><iomanip></span> <span id="L289" class="LineNr">289 </span> -<span id="L290" class="LineNr">290 </span><span class="Comment">#include <string.h></span> -<span id="L291" class="LineNr">291 </span><span class="Comment">#include <string></span> +<span id="L290" class="LineNr">290 </span><span class="PreProc">#include </span><span class="Constant"><string.h></span> +<span id="L291" class="LineNr">291 </span><span class="PreProc">#include </span><span class="Constant"><string></span> <span id="L292" class="LineNr">292 </span><span class="Normal">using</span> std::string<span class="Delimiter">;</span> <span id="L293" class="LineNr">293 </span> -<span id="L294" class="LineNr">294 </span><span class="Comment">#include <algorithm></span> +<span id="L294" class="LineNr">294 </span><span class="PreProc">#include </span><span class="Constant"><algorithm></span> <span id="L295" class="LineNr">295 </span><span class="Normal">using</span> std::min<span class="Delimiter">;</span> <span id="L296" class="LineNr">296 </span><span class="Normal">using</span> std::max<span class="Delimiter">;</span> </pre> |